-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Add builder methods to bevy_ui
's Style
struct
#7881
base: main
Are you sure you want to change the base?
Conversation
b031b38
to
dd799a5
Compare
I think the builder methods would be more useful on the node bundles probably, or they could be implemented for both the bundles and Style. |
Perhaps we can use a trait here with default impls to reduce boilerplate in the engine? |
Hmm... I suppose you could probably set it up so that the only method each implementor of the trait needed to implement was something like: fn apply_style(mut self, applicator: FnMut(&mut Style)) -> Self {
applicator(&mut self.style);
self
} It would leak the implementation detail through to the docs though (the methods for layout would all be grouped together on the trait separately from other methods) |
Leaking that through to the docs seems net good to me? Being able to see that structure is good, and as a user I'd really like to be able to easily use whatever ergonomics solution we end up on with my own bundle types. |
Objective
Make it more ergonomic to create UI nodes
Solution
From
impls have been added toVal
(f32 and i32 both map to Val::Px)Notes
I've added the methods to Style, but I'm they might be better on
NodeBundle
? Advantage of that is that it cuts out an extra level of nesting. Disadvantage is that we'd presumably have to add them for every bundle.Changelog
bevy_ui::Style