allow CLAY_SIZING_PERCENT to be used for the opposite axis
say you have a parent container in which you wanna have a series of squares where the size is the height of the parent container like so:
the way this would have to be done with the current API (unless im missing something) is like so
CLAY( Clay_ElementDeclaration{
.id = CLAY_ID( "ExampleContainer" ),
.layout = { .sizing = { CLAY_SIZING_FIXED( 800 ), CLAY_SIZING_PERCENT( 0.2 ) }, .childGap = 8 },
.backgroundColor = { 50, 50, 50, 255 }
} )
{
auto element = Clay_GetElementData( CLAY_ID( "ExampleContainer" ) );
CLAY( Clay_ElementDeclaration{
.layout = { .sizing = { CLAY_SIZING_FIXED( element.boundingBox.height ), CLAY_SIZING_PERCENT( 1.f ) } },
.backgroundColor = { 255, 0, 0, 100 }
} );
CLAY( Clay_ElementDeclaration{
.layout = { .sizing = { CLAY_SIZING_FIXED( element.boundingBox.height ), CLAY_SIZING_PERCENT( 1.f ) } },
.backgroundColor = { 255, 0, 0, 100 }
} );
CLAY( Clay_ElementDeclaration{
.layout = { .sizing = { CLAY_SIZING_FIXED( element.boundingBox.height ), CLAY_SIZING_PERCENT( 1.f ) } },
.backgroundColor = { 255, 0, 0, 100 }
} );
}
(note that this would break with any sort of padding in the parent container)
however, i think an api like
.layout = { .sizing = { CLAY_SIZING_PERCENT_Y( 1.f ), CLAY_SIZING_PERCENT( 1.f ) } },
would be nicer.
is this something that would be considered for a merge or is it out of scope?
i suppose https://github.com/nicbarker/clay/issues/147 would also address this and might be a cleaner implementation than what i suggested
Aspect ratio boxes will be implemented soon, apologies for the delay 🙂
Since https://github.com/nicbarker/clay/issues/147 is now closed, shouldn't this be closed as well?