Skip to content

Commit e52af83

Browse files
ickshonpemockersf
andauthored
Improved text widget doc comments (#9344)
# 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]>
1 parent 60c6ca7 commit e52af83

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

crates/bevy_ui/src/widget/text.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,15 @@ fn create_text_measure(
113113
};
114114
}
115115

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
117118
/// 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.
118125
pub fn measure_text_system(
119126
mut last_scale_factor: Local<f64>,
120127
fonts: Res<Assets<Font>>,
@@ -217,8 +224,9 @@ fn queue_text(
217224
}
218225
}
219226

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`].
222230
///
223231
/// ## World Resources
224232
///

0 commit comments

Comments
 (0)