UI Building Blocks and Styles
A vision for the basic building blocks, data structures and interaction paradigms for Bevy-native UI. Determining a styling strategy as part of this RFC allows us to make sure the data model works in a more complex use cases.
Previously developed at: https://github.com/alice-i-cecile/bevy-temp-rfc/pull/4
One thing I've found is it's helpful to have Add/RemoveStyle EntityCommands, so that you don't have to pass Res<MyStyles> around to any widget building functions
(Something like commands.entity(my_entity).add_style("my_style").remove_style("default_style") )
While I like the idea of add_style/remove_style, there's a thing I'm concerned about. These methods may be used for any entity even if it doesn't represent a widget.
While I like the idea of add_style/remove_style, there's a thing I'm concerned about. These methods may be used for any entity even if it doesn't represent a widget.
Yes, you see this sort of problem crop up a lot. IMO, kinded entities (https://github.com/bevyengine/bevy/issues/1634) should be up-prioritized and then used aggressively if we end up using this approach to avoid confusing bugs for end users.
I'd like to be able to use this to style things besides UI widgets. For example, if I produce three "texture packs" for all the models in my game, it would be nice if I could use the style system to easily propagate the current texture-pack everywhere I need a texture.
You can almost think of it as a generic way of propagating data through an application. I could imagine a slightly more general system than the one you describe also working for localization, which is a similar problem - you have one value (the current language) which you want to be able to easily change and have that change propagated to lots of components scattered around the application.
Thanks @anchpop; I've made the appropriate changes to ensure that everything Just Works for that, and mentioned the application of styling to other domains in Future Work :)
I'd like to be able to use this to style things besides UI widgets. For example, if I produce three "texture packs" for all the models in my game, it would be nice if I could use the style system to easily propagate the current texture-pack everywhere I need a texture.
You can almost think of it as a generic way of propagating data through an application. I could imagine a slightly more general system than the one you describe also working for localization, which is a similar problem - you have one value (the current language) which you want to be able to easily change and have that change propagated to lots of components scattered around the application.
Wouldn't this fall outside the scope of UI? Is there a clear definition of what Bevy UI means?