bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
36.4k stars 3.59k forks source link

Improve the language syntax/format for designing UI #10864

Open 443eb9 opened 11 months ago

443eb9 commented 11 months ago

What problem does this solve or what need does it fill?

The first time I started bevy ui, I found it's logic quite like html and css. But currently the code for building up ui are quite verbose and a hard to read once the ui panel get complicated.

What solution would you like?

Use html and css for ui designing. And parse them to entities and components.

Additional context

The bevy_ecss crate is using css to change the style of ui and it's much elegant and flexible than rust code. But just as its name, it does not support html to define the structure.

Edit: Not just html, seemy comment below.

rlidwka commented 11 months ago

Are you suggesting something like this: https://github.com/jkb0o/belly ?

alice-i-cecile commented 11 months ago

I feel quite strongly that this isn't something we should do. Persistently coupling bevy_ui to HTML and CSS is a bad plan: these are bad specs, designed for different ecosystems, languages and goals.

viridia commented 11 months ago

It's unlikely that Bevy will adopt HTML and CSS formats verbatim. However, what is under (very!) active discussion is whether to adopt certain ideas and principles from these technologies, and how much. I think most of the people who work on UI are very aware of the problems pointed out by the OP. However, it will take some time to forge a consensus out of all the various ideas that people have.

For example, the idea that UIs are can be declarative, rather than imperative, has broad support. This is something that comes directly from HTML.

443eb9 commented 11 months ago

Just checked the What's wrong with belly? issue in belly, and understood why

this isn't something we should do.

But I wonder if bevy can take the wpf in c# as a reference. Not just html. I think the way wpf define ui is not bad, and the goal of bevy ui and the xml in wpf looks familiar. Also the ecosystem of wpf is strong and perhaps this could demonstrate that its design style is excellent. I realize my issue was too narrow. I will change that.

pablo-lua commented 11 months ago

Maybe supporting an API from external files would be nice? The only thing I can think of. Or else using an external crate for supporting the Ui