You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Objective
The doc comment for `text_system` is not quite correct. It implies that
a new `TextLayoutInfo` is generated on changes to `Text` and `Style`.
While changes to those components might indirectly trigger a
regeneration of the text layout, `text_system` itself only queries for
changes to `Node`
Also added details to `measure_text_system`'s doc comments explaining
how it reacts to changes.
---------
Co-authored-by: François <[email protected]>
Copy file name to clipboardExpand all lines: crates/bevy_ui/src/widget/text.rs
+11-3Lines changed: 11 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -113,8 +113,15 @@ fn create_text_measure(
113
113
};
114
114
}
115
115
116
-
/// Creates a `Measure` for text nodes that allows the UI to determine the appropriate amount of space
116
+
/// Generates a new [`Measure`] for a text node on changes to its [`Text`] component.
117
+
/// A `Measure` is used by the UI's layout algorithm to determine the appropriate amount of space
117
118
/// to provide for the text given the fonts, the text itself and the constraints of the layout.
119
+
///
120
+
/// * All measures are regenerated if the primary window's scale factor or [`UiScale`] is changed.
121
+
/// * Changes that only modify the colors of a `Text` do not require a new `Measure`. This system
122
+
/// is only able to detect that a `Text` component has changed and will regenerate the `Measure` on
123
+
/// color changes. This can be expensive, particularly for large blocks of text, and the [`bypass_change_detection`](bevy_ecs::change_detection::DetectChangesMut::bypass_change_detection)
124
+
/// method should be called when only changing the `Text`'s colors.
118
125
pubfnmeasure_text_system(
119
126
mutlast_scale_factor:Local<f64>,
120
127
fonts:Res<Assets<Font>>,
@@ -217,8 +224,9 @@ fn queue_text(
217
224
}
218
225
}
219
226
220
-
/// Updates the layout and size information whenever the text or style is changed.
221
-
/// This information is computed by the `TextPipeline` on insertion, then stored.
227
+
/// Updates the layout and size information for a UI text node on changes to the size value of its [`Node`] component,
228
+
/// or when the `needs_recompute` field of [`TextFlags`] is set to true.
229
+
/// This information is computed by the [`TextPipeline`] and then stored in [`TextLayoutInfo`].
0 commit comments