-
-
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
[Merged by Bors] - Add a BackgroundColor
component to TextBundle
#7596
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the field. Doc comment on it could be clearer (what area, precisely, is colored).
Builder methods on TextBundle
remain controversial. I kind of like it here for consistency, but I'm also not sold on the pattern as a whole.
Yes I'm not bothered about the builder method but it's needed while commands.spawn((
TextBundle::from_section(
"hello",
TextStyle {
font: asset_server.load("fonts/FiraSans-Bold.ttf"),
font_size: 32.0,
color: Color::WHITE
}
),
BackgroundColor(Color::NAVY)
)); gives a duplicate component error. Agree about the comment. It implies that it will only set a background color for the text, when the color will fill the entire containing node. I'll change it. |
Co-authored-by: François <mockersf@gmail.com>
bors r+ |
# Objective `TextBundle` should have a `BackgroundColor` component. Apart from adding emphasis etc to text, adding a background color to text nodes can be extremely useful for understanding how Bevy aligns, sizes and positions text, and identifying and debugging problems. It's easy for users to insert the `BackgroundColor` component themselves but not immediately obvious or discoverable that it's possible. A `BackgroundColor` component allows us to add a `with_background_color` helper function to `TextBundle`. related issue: #5935 ## Solution Add a `BackgroundColor` component to `TextBundle`. --- ## Changelog * Added a `BackgroundColor` component to `TextBundle`. * Added a helper method `with_background_color` to `TextBundle`. ## Migration Guide `TextBundle` now has a `BackgroundColor` component. Use `TextBundle`'s `background_color` field or the `with_background_color` method to set a background color for text when spawning a text node, in place of manual insertion of a `BackgroundColor` component.
BackgroundColor
component to TextBundle
BackgroundColor
component to TextBundle
Objective
TextBundle
should have aBackgroundColor
component.Apart from adding emphasis etc to text, adding a background color to text nodes can be extremely useful for understanding how Bevy aligns, sizes and positions text, and identifying and debugging problems.
It's easy for users to insert the
BackgroundColor
component themselves but not immediately obvious or discoverable that it's possible. ABackgroundColor
component allows us to add awith_background_color
helper function toTextBundle
.related issue: #5935
Solution
Add a
BackgroundColor
component toTextBundle
.Changelog
BackgroundColor
component toTextBundle
.with_background_color
toTextBundle
.Migration Guide
TextBundle
now has aBackgroundColor
component.Use
TextBundle
'sbackground_color
field or thewith_background_color
method to set a background color for text when spawning a text node, in place of manual insertion of aBackgroundColor
component.