-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Refactor Node
fields (previously Style
)
#10497
Comments
I would definitely like a rename here, but this does add a bit of verbosity. This is inherited from CSS, but ultimately something like IMO no type alias: users can just define their own. |
Perhaps |
I have been thinking we could prefix a lot of the bevy_ui types with |
Another alternative might be
|
I've edited the title of the bug to reflect the current discussion. |
I'm in favor of changing this to LayoutConstraints. I ran into the same confusion in bevy_dioxus. |
Imo we should still use the postfix
|
@cart 's latest BSN design doc (#14437) diverges from what has been proposed here. I have no particular preference either way, but I do want to highlight the differences:
My understanding is that the original motivation for bundling all those properties Note that one important ability remains unchanged even under both proposals: the process for getting the logical rect for a UI element, which requires In any case, we should either close or repurpose this issue if we're going to go with Cart's scheme. |
I've changed my mind after some time spent dogfooding this. IMO we should split |
The way in which Taffy's new traitified API split's things up might make sense (separate "container" and "child" variants for each layout mode because a node might (for example) simultaneously be a flexbox child while being grid container. There is a "CoreStyle" trait which contains things like display, width, height, aspect_ratio that apply pretty globally. |
Ah right, that's a great idea. It also makes things even more granular in a natural way, which I like. |
I agree with @nicoburns approach: separate "layout props for child" from "layout props for container". But I'd add one more thing: there should be four types of containers:
This means that the extra overhead of doing text flow layout would be strictly opt-in. For children, I don't think we need to have separate "FlexChild" and "GridChild" components - the "Align" and "Justify" properties can continue to be used regardless of the type of container. |
Align and Justify work for both, but:
Whether that justifies separate components I don't know (but IMO it might be a clearer API) |
OK, then, how about:
|
I think that that model is quite a bit harder to learn than Nico's original idea. |
Well, I was just trying to impose some kind of categorization without creating too much duplication. I don't have strong opinions here. In any case, we should either come up with a concrete proposal, or close this issue. |
I'm strongly in favor of Nico's suggestion. |
I'm confused, I thought what I was proposing was compatible with that suggestion:
That's what my The thing to understand here is that this can't be completely orthogonal: for example,
Again, this is in line with what I described. The question is what to do about child attributes that apply to more than one layout mode but not all? The only other deviation is my proposal for a fourth layout type, to support the "text spans as entities" feature. My reasoning for making this a layout type is that some people might object to the additional computational overhead of running a word-wrap and text measurement computation on every UI node; so I propose that we only run that algorithm when the user explicitly asks for it, by setting the layout type. Thus, if you have an element with a bunch of children that are Text entities, what you get depends on the layout type:
|
Several people have brought up the idea of splitting up |
I'd probably move the alignment styles into the relevant Container and Item components, duplicating where necessary (these are tiny single-byte enum types). That would reduce the number of components, and make it clear which alignment styles apply to which container/item modes. |
Also, |
Q: Would you also duplicate Gap? My first draft had it that way. |
Maybe? I considered suggesting that, but I think it's less clear cut. What's the motivation for the change? Just ergonomics? |
Node
fields (previously Style
)
Just consistency: Since the rationale for putting align/justify inside the Flex and Grid structs is that they only apply to those display modes, the same argument holds true for gaps. Of course, these are larger values than the enums, so that's a counter-argument. |
What problem does this solve or what need does it fill?
Bevy uses the word "Style" to represent a set of styles that can be applied to a NodeBundle. Unfortunately, the name is rather broad, which causes problems for a number of reasons:
What solution would you like?
I propose renaming "Style" to something more specific such as "NodeStyle". We can keep a type alias "Style" for backwards compatibility.
The text was updated successfully, but these errors were encountered: