Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] Borders draw back to front and don't shrink child elements #171

Open
mikejsavage opened this issue Jan 6, 2025 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@mikejsavage
Copy link
Contributor

CLAY( CLAY_LAYOUT( { .sizing = { .width = CLAY_SIZING_FIT( 1000.0f ), .height = CLAY_SIZING_FIT( 1000.0f ) } } ), CLAY_FLOATING( { { 50, 50 } } ) ) {
    CLAY( CLAY_LAYOUT( { .sizing = { .width = CLAY_SIZING_FIXED( 200.0f ), .height = CLAY_SIZING_FIXED( 200.0f ) } } ), CLAY_BORDER_ALL( { 10, { 255, 0, 0, 255 } } ) ) {
        CLAY( CLAY_LAYOUT( { .sizing = { .width = CLAY_SIZING_PERCENT( 1.0f ), .height = CLAY_SIZING_PERCENT( 1.0f ) } } ), CLAY_BORDER_ALL( { 10, { 0, 255, 0, 255 } } ) ) { }
    }
};

i.e., a box with a green border inside a box with a red border draws the red border only:

image

So the parent element is being drawn on top of the child, and borders don't shrink their children to fit, which you can't generally correct for yourself by adding padding because you can set borders per edge but padding is per axis.

@mikejsavage mikejsavage changed the title [Core] Borders back to front and don't shrink child elements [Core] Borders draw back to front and don't shrink child elements Jan 6, 2025
@nicbarker
Copy link
Owner

Hello, sorry for taking a while to get to this. It's an (unfortunately) undocumented part of Clay's drawing sorting that parent borders are drawn over the top of children, although it would definitely make sense to give the user a bit more control over this (I think perhaps I got the default behaviour wrong, and insetting the children i.e. border + padding is the correct default)

On the second note though, I will merge a PR either today or tomorrow to provide 4 padding values (top, right, bottom, left) rather than just two, so that might give you something to work with in the meantime 🙂

@nicbarker nicbarker added the enhancement New feature or request label Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants