You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What problem does this solve or what need does it fill?
The UI Style component is rather monolithic could benefit from being split into multiple components.
This would allow more granular access to the various style elements on the UI.
I think it could improve ergonomics around modifying existing UI like animation, hover effects, showing or hiding UI ++.
I suspect the UX around creating UI would more or less be the same but it could unlock other approaches to improve that problem area
I want to gather some feedback on the validity / usefulness of doing so before we'll mark this as "ready-for-implementation" or close it out if it turns out to not be a good idea.
This is what it looks like today:
pubstructStyle{/// Whether to arrange this node and its children with flexbox layout////// If this is set to [`Display::None`], this node will be collapsed.pubdisplay:Display,/// Whether to arrange this node relative to other nodes, or positioned absolutelypubposition_type:PositionType,/// Which direction the content of this node should gopubdirection:Direction,/// Whether to use column or row layoutpubflex_direction:FlexDirection,/// How to wrap nodespubflex_wrap:FlexWrap,/// How items are aligned according to the cross axispubalign_items:AlignItems,/// Like align_items but for only this itempubalign_self:AlignSelf,/// How to align each line, only applies if flex_wrap is set to/// [`FlexWrap::Wrap`] and there are multiple lines of itemspubalign_content:AlignContent,/// How items align according to the main axispubjustify_content:JustifyContent,/// The position of the node as described by its Rectpubposition:UiRect<Val>,/// The margin of the nodepubmargin:UiRect<Val>,/// The padding of the nodepubpadding:UiRect<Val>,/// The border of the nodepubborder:UiRect<Val>,/// Defines how much a flexbox item should grow if there's space availablepubflex_grow:f32,/// How to shrink if there's not enough space availablepubflex_shrink:f32,/// The initial size of the itempubflex_basis:Val,/// The size of the flexboxpubsize:Size<Val>,/// The minimum size of the flexboxpubmin_size:Size<Val>,/// The maximum size of the flexboxpubmax_size:Size<Val>,/// The aspect ratio of the flexboxpubaspect_ratio:Option<f32>,/// How to handle overflowpuboverflow:Overflow,}
What solution would you like?
Split the Style component into the following:
DisplayComponent
PositionTypeComponent
DirectionComponent
FlexDirectionComponent
FlexWrapComponent
AlignItemsComponent
AlignSelfComponent
AlignContentComponent
JustifyContentComponent
PositionComponent
MarginComponent
PaddingComponent
BorderComponent
FlexGrowComponent
FlexShrinkComponent
FlexBasisComponent
SizeComponent
MinSizeComponent
MaxSizeComponent
AspectRatioComponent
OverflowComponent
Implement a UiStyleQuery that queries for all of these components
Create a UiStyleBundle containing all of these components
Add the UiStyleBundle to the UiNodeBundles
We need some mechanism to ensure all UI nodes always have all style-components present or the node would be invalid and the app should panic or produce error
Not sure what kind of mechanism would be best suited for this, but is directly related to Archetype Invariants #1481
sixfold on discord mentioned that these components should all share the same Style-trait which would be a marker trait to start with but could be extended going forward
Open to suggestions on naming, I'm not sure how useful calling them FooComponent when they also #[derive(Component)]
If some of these components are always used together, it might make sense to merge them instead of having everything be separate.
What alternative(s) have you considered?
Leave Style as is.
We are going to need more ergonomic ways of interacting with UI overall, this addresses a tiny part of it but there could be other designs that makes more sense.
What problem does this solve or what need does it fill?
Stylecomponent is rather monolithic could benefit from being split into multiple components.I want to gather some feedback on the validity / usefulness of doing so before we'll mark this as "ready-for-implementation" or close it out if it turns out to not be a good idea.
This is what it looks like today:
What solution would you like?
Stylecomponent into the following:DisplayComponentPositionTypeComponentDirectionComponentFlexDirectionComponentFlexWrapComponentAlignItemsComponentAlignSelfComponentAlignContentComponentJustifyContentComponentPositionComponentMarginComponentPaddingComponentBorderComponentFlexGrowComponentFlexShrinkComponentFlexBasisComponentSizeComponentMinSizeComponentMaxSizeComponentAspectRatioComponentOverflowComponentUiStyleQuerythat queries for all of these componentsUiStyleBundlecontaining all of these componentsUiStyleBundleto theUiNodeBundlessixfoldon discord mentioned that these components should all share the sameStyle-trait which would be a marker trait to start with but could be extended going forwardOpen to suggestions on naming, I'm not sure how useful calling them
FooComponentwhen they also#[derive(Component)]If some of these components are always used together, it might make sense to merge them instead of having everything be separate.
What alternative(s) have you considered?
Leave
Styleas is.We are going to need more ergonomic ways of interacting with UI overall, this addresses a tiny part of it but there could be other designs that makes more sense.
Additional context
Windowstruct into multiple separate componentsEntities#4947