Merged
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.
mockersf
approved these changes
Jun 24, 2023
nicoburns
approved these changes
Jun 25, 2023
Contributor
nicoburns
left a comment
There was a problem hiding this comment.
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.
Dimchikkk
approved these changes
Jun 26, 2023
nicoburns
approved these changes
Jun 26, 2023
Contributor
nicoburns
left a comment
There was a problem hiding this comment.
My nits have now been addressed, so I think this is good to go :)
alice-i-cecile
approved these changes
Jun 26, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
In Bevy 10.1 and before, the only way to enable text wrapping was to set a local
Val::Pxwidth constraint on the text node itself.Val::Percentconstraints 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
TextBundlein aNodeBundleand applymin_widthandmax_widthconstraints. 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
NoWrapvariant to theBreakLineOnenum.If
NoWrapis set, ignore any constraints on the width for the text and callTextPipeline::queue_textwith a width bound off32::INFINITY.Changelog
NoWrapvariant to theBreakLineOnenum.NoWrapis set, any constraints on the width for the text are ignored andTextPipeline::queue_textis called with a width bound off32::INFINITY.sizefield ofFixedMeasuretopub. This shouldn't have been private, it was always intended to havepubvisibility.with_no_wrapmethod toTextBundle.Migration Guide
bevy_text::text::BreakLineOnhas a new variantNoWrapthat disables text wrapping for theText.Text wrapping can also be disabled using the
with_no_wrapmethod ofTextBundle.