rfcs icon indicating copy to clipboard operation
rfcs copied to clipboard

UI Building Blocks and Styles

Open alice-i-cecile opened this issue 4 years ago • 6 comments

RENDERED

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

alice-i-cecile avatar Apr 14 '21 19:04 alice-i-cecile

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") )

jihiggins avatar Apr 16 '21 05:04 jihiggins

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.

YohDeadfall avatar Apr 17 '21 17:04 YohDeadfall

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.

alice-i-cecile avatar Apr 17 '21 17:04 alice-i-cecile

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.

anchpop avatar Apr 17 '21 21:04 anchpop

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 :)

alice-i-cecile avatar Apr 21 '21 04:04 alice-i-cecile

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?

mirkoRainer avatar Aug 21 '21 22:08 mirkoRainer