-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
NoWrap
Text
feature
#8947
NoWrap
Text
feature
#8947
Conversation
The `size` field is changed to public. It shouldn't have been private, this was an error. `TextWrapOverride` Enum that describes alternative text wrapping behaviours. `TextOptions` Component with extra options for Bevy UI's `TextBundle` that aren't needed for `Text2dBundle`. `Text2dBundle` Added `TextOptions` component to this bundle.
Instead a variant `NeverBreak` has been added to the `BreakLineOn` enum.
Added `Text2d` support for the `NoWrap` variant by setting the width bound to infinity if `NoWrap` is set. `BreakLineOn::NeverBreak` renamed to `BreakLineOn::NoWrap` to match the name of the CSS text property `no_wrap`. `text_wrap_debug` Set `Oveflow::clip_x()` on each of the panels, to clip the unwrapped text.
Removed a line intializing the style to default for a `TextBundle` that did nothing.
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.
Minor style/documentation changes requested, but the meat of the implementation looks good to me.
Corrected a mistake in the description for `NoWrap`. Added more detailed comments explaining that `NoWrap` only disables soft wrapping and that hard wrapping will still occur.
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.
My nits have now been addressed, so I think this is good to go :)
Objective
In Bevy 10.1 and before, the only way to enable text wrapping was to set a local
Val::Px
width constraint on the text node itself.Val::Percent
constraints and constraints on the text node's ancestors did nothing.#7779 fixed those problems. But perversely displaying unwrapped text is really difficult now, and requires users to nest each
TextBundle
in aNodeBundle
and applymin_width
andmax_width
constraints. Some constructions may even need more than one layer of nesting. I've seen several people already who have really struggled with this when porting their projects to main in advance of 0.11.Solution
Add a
NoWrap
variant to theBreakLineOn
enum.If
NoWrap
is set, ignore any constraints on the width for the text and callTextPipeline::queue_text
with a width bound off32::INFINITY
.Changelog
NoWrap
variant to theBreakLineOn
enum.NoWrap
is set, any constraints on the width for the text are ignored andTextPipeline::queue_text
is called with a width bound off32::INFINITY
.size
field ofFixedMeasure
topub
. This shouldn't have been private, it was always intended to havepub
visibility.with_no_wrap
method toTextBundle
.Migration Guide
bevy_text::text::BreakLineOn
has a new variantNoWrap
that disables text wrapping for theText
.Text wrapping can also be disabled using the
with_no_wrap
method ofTextBundle
.