diff --git a/crates/bevy_text/src/lib.rs b/crates/bevy_text/src/lib.rs index 25b29d26ad872..f367b130feac9 100644 --- a/crates/bevy_text/src/lib.rs +++ b/crates/bevy_text/src/lib.rs @@ -65,7 +65,7 @@ pub use text_access::*; pub mod prelude { #[doc(hidden)] pub use crate::{ - Font, JustifyText, LineBreak, Text2d, TextBlock, TextError, TextReader2d, TextSpan, + Font, JustifyText, LineBreak, Text2d, TextError, TextLayout, TextReader2d, TextSpan, TextStyle, TextWriter2d, }; } diff --git a/crates/bevy_text/src/pipeline.rs b/crates/bevy_text/src/pipeline.rs index de96661b52c87..57ced919b1ae9 100644 --- a/crates/bevy_text/src/pipeline.rs +++ b/crates/bevy_text/src/pipeline.rs @@ -17,7 +17,7 @@ use cosmic_text::{Attrs, Buffer, Family, Metrics, Shaping, Wrap}; use crate::{ error::TextError, ComputedTextBlock, Font, FontAtlasSets, FontSmoothing, JustifyText, - LineBreak, PositionedGlyph, TextBlock, TextBounds, TextEntity, TextStyle, YAxisOrientation, + LineBreak, PositionedGlyph, TextBounds, TextEntity, TextLayout, TextStyle, YAxisOrientation, }; /// A wrapper resource around a [`cosmic_text::FontSystem`] @@ -203,7 +203,7 @@ impl TextPipeline { fonts: &Assets, text_spans: impl Iterator, scale_factor: f64, - block: &TextBlock, + layout: &TextLayout, bounds: TextBounds, font_atlas_sets: &mut FontAtlasSets, texture_atlases: &mut Assets, @@ -229,8 +229,8 @@ impl TextPipeline { let update_result = self.update_buffer( fonts, text_spans, - block.linebreak, - block.justify, + layout.linebreak, + layout.justify, bounds, scale_factor, computed, @@ -337,7 +337,7 @@ impl TextPipeline { fonts: &Assets, text_spans: impl Iterator, scale_factor: f64, - block: &TextBlock, + layout: &TextLayout, computed: &mut ComputedTextBlock, font_system: &mut CosmicFontSystem, ) -> Result { @@ -350,8 +350,8 @@ impl TextPipeline { self.update_buffer( fonts, text_spans, - block.linebreak, - block.justify, + layout.linebreak, + layout.justify, MIN_WIDTH_CONTENT_BOUNDS, scale_factor, computed, @@ -386,7 +386,7 @@ impl TextPipeline { /// Render information for a corresponding text block. /// /// Contains scaled glyphs and their size. Generated via [`TextPipeline::queue_text`] when an entity has -/// [`TextBlock`] and [`ComputedTextBlock`] components. +/// [`TextLayout`] and [`ComputedTextBlock`] components. #[derive(Component, Clone, Default, Debug, Reflect)] #[reflect(Component, Default, Debug)] pub struct TextLayoutInfo { diff --git a/crates/bevy_text/src/text.rs b/crates/bevy_text/src/text.rs index 96490ac28deef..97a2cbe5875ad 100644 --- a/crates/bevy_text/src/text.rs +++ b/crates/bevy_text/src/text.rs @@ -25,18 +25,20 @@ impl Default for CosmicBuffer { } } -/// A sub-entity of a [`TextBlock`]. +/// A sub-entity of a [`ComputedTextBlock`]. /// /// Returned by [`ComputedTextBlock::entities`]. #[derive(Debug, Copy, Clone)] pub struct TextEntity { /// The entity. pub entity: Entity, - /// Records the hierarchy depth of the entity within a `TextBlock`. + /// Records the hierarchy depth of the entity within a `TextLayout`. pub depth: usize, } -/// Computed information for a [`TextBlock`]. +/// Computed information for a text block. +/// +/// See [`TextLayout`]. /// /// Automatically updated by 2d and UI text systems. #[derive(Component, Debug, Clone)] @@ -45,7 +47,7 @@ pub struct ComputedTextBlock { /// /// This is private because buffer contents are always refreshed from ECS state when writing glyphs to /// `TextLayoutInfo`. If you want to control the buffer contents manually or use the `cosmic-text` - /// editor, then you need to not use `TextBlock` and instead manually implement the conversion to + /// editor, then you need to not use `TextLayout` and instead manually implement the conversion to /// `TextLayoutInfo`. pub(crate) buffer: CosmicBuffer, /// Entities for all text spans in the block, including the root-level text. @@ -55,12 +57,12 @@ pub struct ComputedTextBlock { /// Flag set when any change has been made to this block that should cause it to be rerendered. /// /// Includes: - /// - [`TextBlock`] changes. + /// - [`TextLayout`] changes. /// - [`TextStyle`] or `Text2d`/`Text`/`TextSpan` changes anywhere in the block's entity hierarchy. // TODO: This encompasses both structural changes like font size or justification and non-structural // changes like text color and font smoothing. This field currently causes UI to 'remeasure' text, even if // the actual changes are non-structural and can be handled by only rerendering and not remeasuring. A full - // solution would probably require splitting TextBlock and TextStyle into structural/non-structural + // solution would probably require splitting TextLayout and TextStyle into structural/non-structural // components for more granular change detection. A cost/benefit analysis is needed. pub(crate) needs_rerender: bool, } @@ -103,7 +105,7 @@ impl Default for ComputedTextBlock { #[derive(Component, Debug, Copy, Clone, Default, Reflect)] #[reflect(Component, Default, Debug)] #[require(ComputedTextBlock, TextLayoutInfo)] -pub struct TextBlock { +pub struct TextLayout { /// The text's internal alignment. /// Should not affect its position within a container. pub justify: JustifyText, @@ -111,41 +113,41 @@ pub struct TextBlock { pub linebreak: LineBreak, } -impl TextBlock { - /// Makes a new [`TextBlock`]. +impl TextLayout { + /// Makes a new [`TextLayout`]. pub const fn new(justify: JustifyText, linebreak: LineBreak) -> Self { Self { justify, linebreak } } - /// Makes a new [`TextBlock`] with the specified [`JustifyText`]. + /// Makes a new [`TextLayout`] with the specified [`JustifyText`]. pub fn new_with_justify(justify: JustifyText) -> Self { Self::default().with_justify(justify) } - /// Makes a new [`TextBlock`] with the specified [`LineBreak`]. + /// Makes a new [`TextLayout`] with the specified [`LineBreak`]. pub fn new_with_linebreak(linebreak: LineBreak) -> Self { Self::default().with_linebreak(linebreak) } - /// Makes a new [`TextBlock`] with soft wrapping disabled. + /// Makes a new [`TextLayout`] with soft wrapping disabled. /// Hard wrapping, where text contains an explicit linebreak such as the escape sequence `\n`, will still occur. pub fn new_with_no_wrap() -> Self { Self::default().with_no_wrap() } - /// Returns this [`TextBlock`] with the specified [`JustifyText`]. + /// Returns this [`TextLayout`] with the specified [`JustifyText`]. pub const fn with_justify(mut self, justify: JustifyText) -> Self { self.justify = justify; self } - /// Returns this [`TextBlock`] with the specified [`LineBreak`]. + /// Returns this [`TextLayout`] with the specified [`LineBreak`]. pub const fn with_linebreak(mut self, linebreak: LineBreak) -> Self { self.linebreak = linebreak; self } - /// Returns this [`TextBlock`] with soft wrapping disabled. + /// Returns this [`TextLayout`] with soft wrapping disabled. /// Hard wrapping, where text contains an explicit linebreak such as the escape sequence `\n`, will still occur. pub const fn with_no_wrap(mut self) -> Self { self.linebreak = LineBreak::NoWrap; @@ -153,7 +155,7 @@ impl TextBlock { } } -/// A span of UI text in a tree of spans under an entity with [`TextBlock`], such as `Text` or `Text2d`. +/// A span of UI text in a tree of spans under an entity with [`TextLayout`] and `Text` or `Text2d`. /// /// Spans are collected in hierarchy traversal order into a [`ComputedTextBlock`] for layout. /// @@ -163,13 +165,13 @@ impl TextBlock { # use bevy_color::Color; # use bevy_color::palettes::basic::{RED, BLUE}; # use bevy_ecs::World; -# use bevy_text::{Font, TextBlock, TextStyle, TextSection}; +# use bevy_text::{Font, TextLayout, TextStyle, TextSection}; # let font_handle: Handle = Default::default(); # let mut world = World::default(); # world.spawn(( - TextBlock::default(), + TextLayout::default(), TextStyle { font: font_handle.clone().into(), font_size: 60.0, @@ -257,7 +259,7 @@ impl From for cosmic_text::Align { } } -/// `TextStyle` determines the style of a text span within a [`TextBlock`], specifically +/// `TextStyle` determines the style of a text span within a [`ComputedTextBlock`], specifically /// the font face, the font size, and the color. #[derive(Component, Clone, Debug, Reflect)] #[reflect(Component, Default, Debug)] @@ -285,7 +287,7 @@ pub struct TextStyle { } impl TextStyle { - /// Returns this [`TextBlock`] with the specified [`FontSmoothing`]. + /// Returns this [`TextStyle`] with the specified [`FontSmoothing`]. pub const fn with_font_smoothing(mut self, font_smoothing: FontSmoothing) -> Self { self.font_smoothing = font_smoothing; self @@ -358,23 +360,23 @@ pub fn detect_text_needs_rerender( Or<( Changed, Changed, - Changed, + Changed, Changed, )>, With, With, - With, + With, ), >, changed_spans: Query< - (Entity, Option<&Parent>, Has), + (Entity, Option<&Parent>, Has), ( Or<( Changed, Changed, Changed, Changed, // Included to detect broken text block hierarchies. - Added, + Added, )>, With, With, @@ -389,7 +391,7 @@ pub fn detect_text_needs_rerender( // Root entity: // - Root component changed. // - TextStyle on root changed. - // - TextBlock changed. + // - TextLayout changed. // - Root children changed (can include additions and removals). for root in changed_roots.iter() { let Ok((_, Some(mut computed), _)) = computed.get_mut(root) else { @@ -406,7 +408,7 @@ pub fn detect_text_needs_rerender( // - Span children changed (can include additions and removals). for (entity, maybe_span_parent, has_text_block) in changed_spans.iter() { if has_text_block { - warn_once!("found entity {:?} with a TextSpan that has a TextBlock, which should only be on root \ + warn_once!("found entity {:?} with a TextSpan that has a TextLayout, which should only be on root \ text entities (that have {}); this warning only prints once", entity, core::any::type_name::()); } diff --git a/crates/bevy_text/src/text2d.rs b/crates/bevy_text/src/text2d.rs index 7047c0aeff4ec..405783bc2153b 100644 --- a/crates/bevy_text/src/text2d.rs +++ b/crates/bevy_text/src/text2d.rs @@ -1,7 +1,7 @@ use crate::pipeline::CosmicFontSystem; use crate::{ - ComputedTextBlock, Font, FontAtlasSets, LineBreak, PositionedGlyph, SwashCache, TextBlock, - TextBounds, TextError, TextLayoutInfo, TextPipeline, TextReader, TextRoot, TextSpanAccess, + ComputedTextBlock, Font, FontAtlasSets, LineBreak, PositionedGlyph, SwashCache, TextBounds, + TextError, TextLayout, TextLayoutInfo, TextPipeline, TextReader, TextRoot, TextSpanAccess, TextStyle, TextWriter, YAxisOrientation, }; use bevy_asset::Assets; @@ -38,9 +38,9 @@ use bevy_window::{PrimaryWindow, Window, WindowScaleFactorChanged}; /// [Example usage.](https://github.com/bevyengine/bevy/blob/latest/examples/2d/text2d.rs) /// /// The string in this component is the first 'text span' in a hierarchy of text spans that are collected into -/// a [`TextBlock`]. See [`TextSpan`](crate::TextSpan) for the component used by children of entities with [`Text2d`]. +/// a [`ComputedTextBlock`]. See [`TextSpan`](crate::TextSpan) for the component used by children of entities with [`Text2d`]. /// -/// With `Text2d` the `justify` field of [`TextBlock`] only affects the internal alignment of a block of text and not its +/// With `Text2d` the `justify` field of [`TextLayout`] only affects the internal alignment of a block of text and not its /// relative position, which is controlled by the [`Anchor`] component. /// This means that for a block of text consisting of only one line that doesn't wrap, the `justify` field will have no effect. /// @@ -50,7 +50,7 @@ use bevy_window::{PrimaryWindow, Window, WindowScaleFactorChanged}; # use bevy_color::Color; # use bevy_color::palettes::basic::BLUE; # use bevy_ecs::World; -# use bevy_text::{Font, JustifyText, Text2d, TextBlock, TextStyle}; +# use bevy_text::{Font, JustifyText, Text2d, TextLayout, TextStyle}; # # let font_handle: Handle = Default::default(); # let mut world = World::default(); @@ -71,14 +71,14 @@ world.spawn(( // With text justification. world.spawn(( Text2d::new("hello world\nand bevy!"), - TextBlock::new_with_justify(JustifyText::Center) + TextLayout::new_with_justify(JustifyText::Center) )); ``` */ #[derive(Component, Clone, Debug, Default, Deref, DerefMut, Reflect)] #[reflect(Component, Default, Debug)] #[require( - TextBlock, + TextLayout, TextStyle, TextBounds, Anchor, @@ -230,7 +230,7 @@ pub fn update_text2d_layout( mut text_pipeline: ResMut, mut text_query: Query<( Entity, - Ref, + Ref, Ref, &mut TextLayoutInfo, &mut ComputedTextBlock, diff --git a/crates/bevy_text/src/text_access.rs b/crates/bevy_text/src/text_access.rs index e8a9a0a0c0587..7ece5533af056 100644 --- a/crates/bevy_text/src/text_access.rs +++ b/crates/bevy_text/src/text_access.rs @@ -42,7 +42,7 @@ impl TextIterScratch { } } -/// System parameter for reading text spans in a [`TextBlock`](crate::TextBlock). +/// System parameter for reading text spans in a text block. /// /// `R` is the root text component, and `S` is the text span component on children. #[derive(SystemParam)] @@ -184,7 +184,7 @@ impl<'a, R: TextRoot> Drop for TextSpanIter<'a, R> { } } -/// System parameter for reading and writing text spans in a [`TextBlock`](crate::TextBlock). +/// System parameter for reading and writing text spans in a text block. /// /// `R` is the root text component, and `S` is the text span component on children. #[derive(SystemParam)] diff --git a/crates/bevy_ui/src/widget/text.rs b/crates/bevy_ui/src/widget/text.rs index 04a511ae0fde1..72b3df30e4484 100644 --- a/crates/bevy_ui/src/widget/text.rs +++ b/crates/bevy_ui/src/widget/text.rs @@ -19,7 +19,7 @@ use bevy_render::{camera::Camera, texture::Image, view::Visibility}; use bevy_sprite::TextureAtlasLayout; use bevy_text::{ scale_value, ComputedTextBlock, CosmicFontSystem, Font, FontAtlasSets, LineBreak, SwashCache, - TextBlock, TextBounds, TextError, TextLayoutInfo, TextMeasureInfo, TextPipeline, TextReader, + TextBounds, TextError, TextLayout, TextLayoutInfo, TextMeasureInfo, TextPipeline, TextReader, TextRoot, TextSpanAccess, TextStyle, TextWriter, YAxisOrientation, }; use bevy_transform::components::Transform; @@ -52,7 +52,7 @@ impl Default for TextNodeFlags { /// Adding [`Text`] to an entity will pull in required components for setting up a UI text node. /// /// The string in this component is the first 'text span' in a hierarchy of text spans that are collected into -/// a [`TextBlock`]. See [`TextSpan`](bevy_text::TextSpan) for the component used by children of entities with [`Text`]. +/// a [`ComputedTextBlock`]. See [`TextSpan`](bevy_text::TextSpan) for the component used by children of entities with [`Text`]. /// /// Note that [`Transform`] on this entity is managed automatically by the UI layout system. /// @@ -62,7 +62,7 @@ impl Default for TextNodeFlags { # use bevy_color::Color; # use bevy_color::palettes::basic::BLUE; # use bevy_ecs::World; -# use bevy_text::{Font, JustifyText, TextBlock, TextStyle}; +# use bevy_text::{Font, JustifyText, TextLayout, TextStyle}; # use bevy_ui::Text; # # let font_handle: Handle = Default::default(); @@ -84,14 +84,14 @@ world.spawn(( // With text justification. world.spawn(( Text::new("hello world\nand bevy!"), - TextBlock::new_with_justify(JustifyText::Center) + TextLayout::new_with_justify(JustifyText::Center) )); ``` */ #[derive(Component, Debug, Default, Clone, Deref, DerefMut, Reflect)] #[reflect(Component, Default, Debug)] #[require( - TextBlock, + TextLayout, TextStyle, TextNodeFlags, Node, @@ -205,7 +205,7 @@ fn create_text_measure<'a>( fonts: &Assets, scale_factor: f64, spans: impl Iterator, - block: Ref, + block: Ref, text_pipeline: &mut TextPipeline, mut content_size: Mut, mut text_flags: Mut, @@ -263,7 +263,7 @@ pub fn measure_text_system( mut text_query: Query< ( Entity, - Ref, + Ref, &mut ContentSize, &mut TextNodeFlags, &mut ComputedTextBlock, @@ -329,7 +329,7 @@ fn queue_text( textures: &mut Assets, scale_factor: f32, inverse_scale_factor: f32, - block: &TextBlock, + block: &TextLayout, node: Ref, mut text_flags: Mut, text_layout_info: Mut, @@ -408,7 +408,7 @@ pub fn text_system( mut text_query: Query<( Entity, Ref, - &TextBlock, + &TextLayout, &mut TextLayoutInfo, &mut TextNodeFlags, &mut ComputedTextBlock, diff --git a/examples/2d/sprite_slice.rs b/examples/2d/sprite_slice.rs index 1e823df9c9a59..7ed097bdb66b8 100644 --- a/examples/2d/sprite_slice.rs +++ b/examples/2d/sprite_slice.rs @@ -88,7 +88,7 @@ fn spawn_sprites( builder.spawn(( Text2d::new(label), text_style, - TextBlock::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(JustifyText::Center), Transform::from_xyz(0., -0.5 * size.y - 10., 0.0), bevy::sprite::Anchor::TopCenter, )); diff --git a/examples/2d/text2d.rs b/examples/2d/text2d.rs index 68a96281f61ac..47a5f16e9beb3 100644 --- a/examples/2d/text2d.rs +++ b/examples/2d/text2d.rs @@ -47,21 +47,21 @@ fn setup(mut commands: Commands, asset_server: Res) { commands.spawn(( Text2d::new("translation"), text_style.clone(), - TextBlock::new_with_justify(text_justification), + TextLayout::new_with_justify(text_justification), AnimateTranslation, )); // Demonstrate changing rotation commands.spawn(( Text2d::new("rotation"), text_style.clone(), - TextBlock::new_with_justify(text_justification), + TextLayout::new_with_justify(text_justification), AnimateRotation, )); // Demonstrate changing scale commands.spawn(( Text2d::new("scale"), text_style, - TextBlock::new_with_justify(text_justification), + TextLayout::new_with_justify(text_justification), Transform::from_translation(Vec3::new(400.0, 0.0, 0.0)), AnimateScale, )); @@ -82,7 +82,7 @@ fn setup(mut commands: Commands, asset_server: Res) { builder.spawn(( Text2d::new("this text wraps in the box\n(Unicode linebreaks)"), slightly_smaller_text_style.clone(), - TextBlock::new(JustifyText::Left, LineBreak::WordBoundary), + TextLayout::new(JustifyText::Left, LineBreak::WordBoundary), // Wrap text in the rectangle TextBounds::from(box_size), // ensure the text is drawn on top of the box @@ -101,7 +101,7 @@ fn setup(mut commands: Commands, asset_server: Res) { builder.spawn(( Text2d::new("this text wraps in the box\n(AnyCharacter linebreaks)"), slightly_smaller_text_style.clone(), - TextBlock::new(JustifyText::Left, LineBreak::AnyCharacter), + TextLayout::new(JustifyText::Left, LineBreak::AnyCharacter), // Wrap text in the rectangle TextBounds::from(other_box_size), // ensure the text is drawn on top of the box diff --git a/examples/2d/texture_atlas.rs b/examples/2d/texture_atlas.rs index 74b73c166553d..d6b391ee6c5f0 100644 --- a/examples/2d/texture_atlas.rs +++ b/examples/2d/texture_atlas.rs @@ -280,7 +280,7 @@ fn create_label( commands.spawn(( Text2d::new(text), text_style, - TextBlock::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(JustifyText::Center), Transform { translation: Vec3::new(translation.0, translation.1, translation.2), ..default() diff --git a/examples/3d/blend_modes.rs b/examples/3d/blend_modes.rs index 6ec0e8c20c91f..6257eec42f830 100644 --- a/examples/3d/blend_modes.rs +++ b/examples/3d/blend_modes.rs @@ -216,7 +216,7 @@ fn setup( bottom: Val::ZERO, ..default() }, - TextBlock::default().with_no_wrap(), + TextLayout::default().with_no_wrap(), )); }); }; diff --git a/examples/3d/tonemapping.rs b/examples/3d/tonemapping.rs index df3a161565b46..b8aef70c2fd34 100644 --- a/examples/3d/tonemapping.rs +++ b/examples/3d/tonemapping.rs @@ -177,7 +177,7 @@ fn setup_image_viewer_scene( color: Color::BLACK, ..default() }, - TextBlock::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(JustifyText::Center), Style { align_self: AlignSelf::Center, margin: UiRect::all(Val::Auto), diff --git a/examples/animation/animated_ui.rs b/examples/animation/animated_ui.rs index 39230bb9a98aa..888ba2c860710 100644 --- a/examples/animation/animated_ui.rs +++ b/examples/animation/animated_ui.rs @@ -178,7 +178,7 @@ fn setup( color: Color::Srgba(Srgba::RED), ..default() }, - TextBlock::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(JustifyText::Center), )) // Mark as an animation target. .insert(AnimationTarget { diff --git a/examples/animation/animation_graph.rs b/examples/animation/animation_graph.rs index dd57fadfc7b98..22d26d412cc93 100644 --- a/examples/animation/animation_graph.rs +++ b/examples/animation/animation_graph.rs @@ -277,7 +277,7 @@ fn setup_node_rects(commands: &mut Commands) { color: ANTIQUE_WHITE.into(), ..default() }, - TextBlock::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(JustifyText::Center), )) .id(); diff --git a/examples/animation/animation_masks.rs b/examples/animation/animation_masks.rs index 2709736c79ad4..0ea939d2eb0d8 100644 --- a/examples/animation/animation_masks.rs +++ b/examples/animation/animation_masks.rs @@ -341,7 +341,7 @@ fn add_mask_group_control(parent: &mut ChildBuilder, label: &str, width: Val, ma } else { selected_button_text_style.clone() }, - TextBlock::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(JustifyText::Center), Style { flex_grow: 1.0, margin: UiRect::vertical(Val::Px(3.0)), diff --git a/examples/asset/multi_asset_sync.rs b/examples/asset/multi_asset_sync.rs index 7a69ab83ea1b8..ed1f8891e5699 100644 --- a/examples/asset/multi_asset_sync.rs +++ b/examples/asset/multi_asset_sync.rs @@ -187,7 +187,7 @@ fn setup_ui(mut commands: Commands) { color: Color::BLACK, ..Default::default() }, - TextBlock::new_with_justify(JustifyText::Right), + TextLayout::new_with_justify(JustifyText::Right), LoadingText, )); }); diff --git a/examples/async_tasks/external_source_external_thread.rs b/examples/async_tasks/external_source_external_thread.rs index 19a0dd0940223..0663b7474fa21 100644 --- a/examples/async_tasks/external_source_external_thread.rs +++ b/examples/async_tasks/external_source_external_thread.rs @@ -60,7 +60,7 @@ fn spawn_text(mut commands: Commands, mut reader: EventReader) { commands.spawn(( Text2d::new(event.0.to_string()), text_style.clone(), - TextBlock::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(JustifyText::Center), Transform::from_xyz(per_frame as f32 * 100.0, 300.0, 0.0), )); } diff --git a/examples/ecs/one_shot_systems.rs b/examples/ecs/one_shot_systems.rs index d092ca407715c..592c7ba314e74 100644 --- a/examples/ecs/one_shot_systems.rs +++ b/examples/ecs/one_shot_systems.rs @@ -94,7 +94,7 @@ fn setup_ui(mut commands: Commands) { commands .spawn(( Text::default(), - TextBlock::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(JustifyText::Center), Style { align_self: AlignSelf::Center, justify_self: JustifySelf::Center, diff --git a/examples/math/render_primitives.rs b/examples/math/render_primitives.rs index ccaabdefcab3f..2be198fb57864 100644 --- a/examples/math/render_primitives.rs +++ b/examples/math/render_primitives.rs @@ -384,7 +384,7 @@ fn setup_text(mut commands: Commands, cameras: Query<(Entity, &Camera)>) { p.spawn(( Text::default(), HeaderText, - TextBlock::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(JustifyText::Center), )) .with_children(|p| { p.spawn(TextSpan::new("Primitive: ")); diff --git a/examples/mobile/src/lib.rs b/examples/mobile/src/lib.rs index cdf8662d48364..505981167b8f6 100644 --- a/examples/mobile/src/lib.rs +++ b/examples/mobile/src/lib.rs @@ -127,7 +127,7 @@ fn setup_scene( color: Color::BLACK, ..default() }, - TextBlock::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(JustifyText::Center), )); } diff --git a/examples/stress_tests/many_glyphs.rs b/examples/stress_tests/many_glyphs.rs index 31376111bcfb2..e593149bc10e8 100644 --- a/examples/stress_tests/many_glyphs.rs +++ b/examples/stress_tests/many_glyphs.rs @@ -50,7 +50,7 @@ fn setup(mut commands: Commands) { font_size: 4., ..Default::default() }; - let text_block = TextBlock { + let text_block = TextLayout { justify: JustifyText::Left, linebreak: LineBreak::AnyCharacter, }; @@ -89,7 +89,7 @@ fn setup(mut commands: Commands) { )); } -fn force_text_recomputation(mut text_query: Query<&mut TextBlock>) { +fn force_text_recomputation(mut text_query: Query<&mut TextLayout>) { for mut block in &mut text_query { block.set_changed(); } diff --git a/examples/stress_tests/text_pipeline.rs b/examples/stress_tests/text_pipeline.rs index ce21f4ac98866..5ac4af8bd13f0 100644 --- a/examples/stress_tests/text_pipeline.rs +++ b/examples/stress_tests/text_pipeline.rs @@ -68,7 +68,7 @@ fn spawn(mut commands: Commands, asset_server: Res) { commands .spawn(( Text2d::default(), - TextBlock { + TextLayout { justify: JustifyText::Center, linebreak: LineBreak::AnyCharacter, }, diff --git a/examples/time/virtual_time.rs b/examples/time/virtual_time.rs index a82f2fbd10553..cae7dbe3fd439 100644 --- a/examples/time/virtual_time.rs +++ b/examples/time/virtual_time.rs @@ -108,7 +108,7 @@ fn setup(mut commands: Commands, asset_server: Res, mut time: ResMu color: Color::srgb(0.85, 0.85, 0.85), ..default() }, - TextBlock::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(JustifyText::Center), )); // virtual time info @@ -119,7 +119,7 @@ fn setup(mut commands: Commands, asset_server: Res, mut time: ResMu color: virtual_color, ..default() }, - TextBlock::new_with_justify(JustifyText::Right), + TextLayout::new_with_justify(JustifyText::Right), VirtualTime, )); }); diff --git a/examples/ui/display_and_visibility.rs b/examples/ui/display_and_visibility.rs index 71247617d8ff0..2dd7dd32262ab 100644 --- a/examples/ui/display_and_visibility.rs +++ b/examples/ui/display_and_visibility.rs @@ -96,7 +96,7 @@ fn setup(mut commands: Commands, asset_server: Res) { }).with_children(|parent| { parent.spawn((Text::new("Use the panel on the right to change the Display and Visibility properties for the respective nodes of the panel on the left"), text_style.clone(), - TextBlock::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(JustifyText::Center), Style { margin: UiRect::bottom(Val::Px(10.)), ..Default::default() @@ -154,11 +154,11 @@ fn setup(mut commands: Commands, asset_server: Res) { builder.spawn((Text::new("Display::None\nVisibility::Hidden\nVisibility::Inherited"), TextStyle { color: HIDDEN_COLOR, ..text_style.clone() }, - TextBlock::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(JustifyText::Center), )); builder.spawn((Text::new("-\n-\n-"), TextStyle { color: DARK_GRAY.into(), ..text_style.clone() }, - TextBlock::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(JustifyText::Center), )); builder.spawn((Text::new("The UI Node and its descendants will not be visible and will not be allotted any space in the UI layout.\nThe UI Node will not be visible but will still occupy space in the UI layout.\nThe UI node will inherit the visibility property of its parent. If it has no parent it will be visible."), text_style @@ -414,7 +414,7 @@ where builder.spawn(( Text(format!("{}::{:?}", Target::::NAME, T::default())), text_style, - TextBlock::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(JustifyText::Center), )); }); } diff --git a/examples/ui/size_constraints.rs b/examples/ui/size_constraints.rs index 27b88668d8606..91fd33cb54794 100644 --- a/examples/ui/size_constraints.rs +++ b/examples/ui/size_constraints.rs @@ -279,7 +279,7 @@ fn spawn_button( }, ..text_style }, - TextBlock::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(JustifyText::Center), )); }); } diff --git a/examples/ui/text.rs b/examples/ui/text.rs index 82225825578e7..90b00bd75b973 100644 --- a/examples/ui/text.rs +++ b/examples/ui/text.rs @@ -39,7 +39,7 @@ fn setup(mut commands: Commands, asset_server: Res) { ..default() }, // Set the justification of the Text - TextBlock::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(JustifyText::Center), // Set the style of the Node itself. Style { position_type: PositionType::Absolute, diff --git a/examples/ui/text_debug.rs b/examples/ui/text_debug.rs index 2d6512e6d6988..1e3a94c4e26dc 100644 --- a/examples/ui/text_debug.rs +++ b/examples/ui/text_debug.rs @@ -77,7 +77,7 @@ fn infotext_system(mut commands: Commands, asset_server: Res) { color: YELLOW.into(), ..default() }, - TextBlock::new_with_justify(JustifyText::Right), + TextLayout::new_with_justify(JustifyText::Right), Style { max_width: Val::Px(300.), ..default() @@ -121,7 +121,7 @@ fn infotext_system(mut commands: Commands, asset_server: Res) { color: Color::srgb(0.8, 0.2, 0.7), ..default() }, - TextBlock::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(JustifyText::Center), Style { max_width: Val::Px(400.), ..default() @@ -136,7 +136,7 @@ fn infotext_system(mut commands: Commands, asset_server: Res) { color: YELLOW.into(), ..default() }, - TextBlock::new_with_justify(JustifyText::Left), + TextLayout::new_with_justify(JustifyText::Left), Style { max_width: Val::Px(300.), ..default() @@ -152,7 +152,7 @@ fn infotext_system(mut commands: Commands, asset_server: Res) { color: GREEN_YELLOW.into(), ..default() }, - TextBlock::new_with_justify(JustifyText::Justified), + TextLayout::new_with_justify(JustifyText::Justified), Style { max_width: Val::Px(300.), ..default() diff --git a/examples/ui/text_wrap_debug.rs b/examples/ui/text_wrap_debug.rs index f130e18d0004b..f2b6b2a96c4a0 100644 --- a/examples/ui/text_wrap_debug.rs +++ b/examples/ui/text_wrap_debug.rs @@ -122,7 +122,7 @@ fn spawn(mut commands: Commands, asset_server: Res) { commands.entity(column_id).with_child(( Text(message.clone()), text_style.clone(), - TextBlock::new(JustifyText::Left, linebreak), + TextLayout::new(JustifyText::Left, linebreak), BackgroundColor(Color::srgb(0.8 - j as f32 * 0.2, 0., 0.)), )); }