-
-
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
Improve ergonomics for single-section Text
s
#14854
Comments
Text
sText
s
Some additional background:
|
Relevant conversation here: https://discord.com/channels/691052431525675048/1248074018612051978/1276270114517418116 |
I see another three options:
|
This is a bit of a departure from the current minimal state of #14572, and #14791 is a prerequisite, though one could possibly imagine doing something similar with bundles. But it seems that this is something we don't want to put off for later, so it is possible that this issue is redundant. // 1. [Hello]
commands.spawn(Text::new("Hello"));
// 2. [Hello, World]
commands
.spawn(Text::default())
.with_children(|parent| {
parent.spawn(Text::new("Hello"));
parent.spawn(Text::new("World"));
});
// 3. [Hello, World]
commands
.spawn((Node, Style { Display::Flow, ..default() }))
.with_children(|parent| {
parent.spawn(Text::new("Hello"));
parent.spawn(Text::new("World"));
});
// 4. [Hello, World]
commands
.spawn(Text::new("Hello"))
.with_child(Text::new("World"));
// 5. [H, ello, W, orld]
commands
.spawn(Text::new("H"))
.with_children(|parent| {
parent.spawn(Text::new("ello"));
parent.spawn(Text::new("W"))
.with_child(Text::new("orld"));
}); |
In that conversation we reached consensus that the last two cases above shouldn't behave that way (implicitly "flattening" the text layout in nested Text hierarchies). Instead, the rule would simply be: by default, treat each Text as a separate / autonomous text section, laid out according to how it / its parent haven chosen. If a parent specifies |
Pulling in @viridia, who was part of this conversation on discord. |
Thanks for pinging me. Here's a more formal specification of what I proposed:
This proposal is explicitly modeled after the behavior of HTML/SGML text blocks, but with significant simplifications (e.g. we don't strip leading and trailing spaces, the "display" property only affects internal, not external, layout behavior, etc. The |
As mentioned in the discord, the goal here is not to regurgitate the web or allow building of a web browser within Bevy; the goal is to permit document-like UIs such as the character bios or quest logs seen in games like Witcher 3 or Jedi: Last Survivor. There is also the issue of styling, which is part of the problem of text-section ergonomics, but might need to be a separate issue. Individual text nodes can have styles, but there's no internal layout, so properties like As some of you know, I am a fan of inherited styles, however there's a number of prominent users on Discord who don't like them / find them confusing. The compromise that I have implemented in Quill is to allow inheritance for only those styles which are text specific, of which there are just 5: font, size, weight, style, decoration. Other kinds of inheritance can be done in other ways, using reactive contexts or whatever. Being able to assign a text style to a parent and have that style apply to all of the individual text sections is very convenient and ergonomic - for example, my |
See discussion #15014 |
building more complex UI structures has been explored deeply by |
Completed in #15591. |
What problem does this solve or what need does it fill?
With the changes introduced in the PR linked below, the common case for
Text
where there is only oneTextSection
gets a bit more annoying. This should be fixed ASAP, in any case, before 0.15.Info
Old API:
Current API that will need improvements:
What solution would you like?
I think the easiest option is to make add a
Commands::spawn_text()
method, this is simply a shorthand for spawning oneTextSection
as a child of aText
.What alternative(s) have you considered?
There are probably alternatives, and we should discuss those
Additional context
This is important once #14572 gets merged.
The text was updated successfully, but these errors were encountered: