From 02fa833be151903bb28a6ecbbb77849539ac791a Mon Sep 17 00:00:00 2001 From: ickshonpe Date: Mon, 9 Jun 2025 20:59:48 +0100 Subject: [PATCH] Rename `JustifyText` to `Justify` (#19522) # Objective Rename `JustifyText`: * The name `JustifyText` is just ugly. * It's inconsistent since no other `bevy_text` types have a `Text-` suffix, only prefix. * It's inconsistent with the other text layout enum `Linebreak` which doesn't have a prefix or suffix. Fixes #19521. ## Solution Rename `JustifyText` to `Justify`. Without other context, it's natural to assume the name `Justify` refers to text justification. --------- Co-authored-by: Alice Cecile --- crates/bevy_text/src/bounds.rs | 2 +- crates/bevy_text/src/lib.rs | 2 +- crates/bevy_text/src/pipeline.rs | 8 +++--- crates/bevy_text/src/text.rs | 26 +++++++++---------- crates/bevy_text/src/text2d.rs | 4 +-- crates/bevy_ui/src/widget/text.rs | 4 +-- examples/2d/sprite_scale.rs | 4 +-- examples/2d/sprite_slice.rs | 2 +- examples/2d/text2d.rs | 10 +++---- examples/2d/texture_atlas.rs | 2 +- examples/3d/tonemapping.rs | 2 +- examples/animation/animated_ui.rs | 2 +- examples/animation/animation_graph.rs | 2 +- examples/animation/animation_masks.rs | 2 +- .../external_source_external_thread.rs | 2 +- examples/ecs/one_shot_systems.rs | 2 +- examples/math/render_primitives.rs | 2 +- examples/mobile/src/lib.rs | 2 +- examples/stress_tests/many_glyphs.rs | 2 +- examples/stress_tests/many_text2d.rs | 6 ++--- examples/stress_tests/text_pipeline.rs | 2 +- examples/testbed/2d.rs | 10 +++---- examples/testbed/ui.rs | 2 +- examples/time/virtual_time.rs | 4 +-- examples/ui/directional_navigation.rs | 2 +- examples/ui/display_and_visibility.rs | 8 +++--- examples/ui/size_constraints.rs | 2 +- examples/ui/text.rs | 2 +- examples/ui/text_background_colors.rs | 2 +- examples/ui/text_debug.rs | 10 +++---- examples/ui/text_wrap_debug.rs | 2 +- .../migration-guides/rename-justifytext.md | 8 ++++++ 32 files changed, 75 insertions(+), 67 deletions(-) create mode 100644 release-content/migration-guides/rename-justifytext.md diff --git a/crates/bevy_text/src/bounds.rs b/crates/bevy_text/src/bounds.rs index db2ceb0b28..1c0833b443 100644 --- a/crates/bevy_text/src/bounds.rs +++ b/crates/bevy_text/src/bounds.rs @@ -5,7 +5,7 @@ use bevy_reflect::{std_traits::ReflectDefault, Reflect}; /// The maximum width and height of text. The text will wrap according to the specified size. /// /// Characters out of the bounds after wrapping will be truncated. Text is aligned according to the -/// specified [`JustifyText`](crate::text::JustifyText). +/// specified [`Justify`](crate::text::Justify). /// /// Note: only characters that are completely out of the bounds will be truncated, so this is not a /// reliable limit if it is necessary to contain the text strictly in the bounds. Currently this diff --git a/crates/bevy_text/src/lib.rs b/crates/bevy_text/src/lib.rs index 2bc74a1aa7..b36f5fa2bb 100644 --- a/crates/bevy_text/src/lib.rs +++ b/crates/bevy_text/src/lib.rs @@ -61,7 +61,7 @@ pub use text_access::*; pub mod prelude { #[doc(hidden)] pub use crate::{ - Font, JustifyText, LineBreak, Text2d, Text2dReader, Text2dWriter, TextColor, TextError, + Font, Justify, LineBreak, Text2d, Text2dReader, Text2dWriter, TextColor, TextError, TextFont, TextLayout, TextSpan, }; } diff --git a/crates/bevy_text/src/pipeline.rs b/crates/bevy_text/src/pipeline.rs index 50b983f929..dd6ca77246 100644 --- a/crates/bevy_text/src/pipeline.rs +++ b/crates/bevy_text/src/pipeline.rs @@ -16,8 +16,8 @@ use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use cosmic_text::{Attrs, Buffer, Family, Metrics, Shaping, Wrap}; use crate::{ - error::TextError, ComputedTextBlock, Font, FontAtlasSets, FontSmoothing, JustifyText, - LineBreak, PositionedGlyph, TextBounds, TextEntity, TextFont, TextLayout, + error::TextError, ComputedTextBlock, Font, FontAtlasSets, FontSmoothing, Justify, LineBreak, + PositionedGlyph, TextBounds, TextEntity, TextFont, TextLayout, }; /// A wrapper resource around a [`cosmic_text::FontSystem`] @@ -88,7 +88,7 @@ impl TextPipeline { fonts: &Assets, text_spans: impl Iterator, linebreak: LineBreak, - justify: JustifyText, + justify: Justify, bounds: TextBounds, scale_factor: f64, computed: &mut ComputedTextBlock, @@ -201,7 +201,7 @@ impl TextPipeline { // Workaround for alignment not working for unbounded text. // See https://github.com/pop-os/cosmic-text/issues/343 - if bounds.width.is_none() && justify != JustifyText::Left { + if bounds.width.is_none() && justify != Justify::Left { let dimensions = buffer_dimensions(buffer); // `set_size` causes a re-layout to occur. buffer.set_size(font_system, Some(dimensions.x), bounds.height); diff --git a/crates/bevy_text/src/text.rs b/crates/bevy_text/src/text.rs index debf9cc375..ecaa8ffd2f 100644 --- a/crates/bevy_text/src/text.rs +++ b/crates/bevy_text/src/text.rs @@ -116,19 +116,19 @@ impl Default for ComputedTextBlock { pub struct TextLayout { /// The text's internal alignment. /// Should not affect its position within a container. - pub justify: JustifyText, + pub justify: Justify, /// How the text should linebreak when running out of the bounds determined by `max_size`. pub linebreak: LineBreak, } impl TextLayout { /// Makes a new [`TextLayout`]. - pub const fn new(justify: JustifyText, linebreak: LineBreak) -> Self { + pub const fn new(justify: Justify, linebreak: LineBreak) -> Self { Self { justify, linebreak } } - /// Makes a new [`TextLayout`] with the specified [`JustifyText`]. - pub fn new_with_justify(justify: JustifyText) -> Self { + /// Makes a new [`TextLayout`] with the specified [`Justify`]. + pub fn new_with_justify(justify: Justify) -> Self { Self::default().with_justify(justify) } @@ -143,8 +143,8 @@ impl TextLayout { Self::default().with_no_wrap() } - /// Returns this [`TextLayout`] with the specified [`JustifyText`]. - pub const fn with_justify(mut self, justify: JustifyText) -> Self { + /// Returns this [`TextLayout`] with the specified [`Justify`]. + pub const fn with_justify(mut self, justify: Justify) -> Self { self.justify = justify; self } @@ -246,7 +246,7 @@ impl From for TextSpan { /// [`TextBounds`](super::bounds::TextBounds) component with an explicit `width` value. #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash, Reflect, Serialize, Deserialize)] #[reflect(Serialize, Deserialize, Clone, PartialEq, Hash)] -pub enum JustifyText { +pub enum Justify { /// Leftmost character is immediately to the right of the render position. /// Bounds start from the render position and advance rightwards. #[default] @@ -263,13 +263,13 @@ pub enum JustifyText { Justified, } -impl From for cosmic_text::Align { - fn from(justify: JustifyText) -> Self { +impl From for cosmic_text::Align { + fn from(justify: Justify) -> Self { match justify { - JustifyText::Left => cosmic_text::Align::Left, - JustifyText::Center => cosmic_text::Align::Center, - JustifyText::Right => cosmic_text::Align::Right, - JustifyText::Justified => cosmic_text::Align::Justified, + Justify::Left => cosmic_text::Align::Left, + Justify::Center => cosmic_text::Align::Center, + Justify::Right => cosmic_text::Align::Right, + Justify::Justified => cosmic_text::Align::Justified, } } } diff --git a/crates/bevy_text/src/text2d.rs b/crates/bevy_text/src/text2d.rs index 5069804df8..8d4a926e1b 100644 --- a/crates/bevy_text/src/text2d.rs +++ b/crates/bevy_text/src/text2d.rs @@ -51,7 +51,7 @@ use bevy_window::{PrimaryWindow, Window}; /// # use bevy_color::Color; /// # use bevy_color::palettes::basic::BLUE; /// # use bevy_ecs::world::World; -/// # use bevy_text::{Font, JustifyText, Text2d, TextLayout, TextFont, TextColor, TextSpan}; +/// # use bevy_text::{Font, Justify, Text2d, TextLayout, TextFont, TextColor, TextSpan}; /// # /// # let font_handle: Handle = Default::default(); /// # let mut world = World::default(); @@ -73,7 +73,7 @@ use bevy_window::{PrimaryWindow, Window}; /// // With text justification. /// world.spawn(( /// Text2d::new("hello world\nand bevy!"), -/// TextLayout::new_with_justify(JustifyText::Center) +/// TextLayout::new_with_justify(Justify::Center) /// )); /// /// // With spans diff --git a/crates/bevy_ui/src/widget/text.rs b/crates/bevy_ui/src/widget/text.rs index 785040c1e9..d7f8e243a4 100644 --- a/crates/bevy_ui/src/widget/text.rs +++ b/crates/bevy_ui/src/widget/text.rs @@ -61,7 +61,7 @@ impl Default for TextNodeFlags { /// # use bevy_color::Color; /// # use bevy_color::palettes::basic::BLUE; /// # use bevy_ecs::world::World; -/// # use bevy_text::{Font, JustifyText, TextLayout, TextFont, TextColor, TextSpan}; +/// # use bevy_text::{Font, Justify, TextLayout, TextFont, TextColor, TextSpan}; /// # use bevy_ui::prelude::Text; /// # /// # let font_handle: Handle = Default::default(); @@ -84,7 +84,7 @@ impl Default for TextNodeFlags { /// // With text justification. /// world.spawn(( /// Text::new("hello world\nand bevy!"), -/// TextLayout::new_with_justify(JustifyText::Center) +/// TextLayout::new_with_justify(Justify::Center) /// )); /// /// // With spans diff --git a/examples/2d/sprite_scale.rs b/examples/2d/sprite_scale.rs index c549134419..9cffb8e00c 100644 --- a/examples/2d/sprite_scale.rs +++ b/examples/2d/sprite_scale.rs @@ -129,7 +129,7 @@ fn setup_sprites(mut commands: Commands, asset_server: Res) { cmd.with_children(|builder| { builder.spawn(( Text2d::new(rect.text), - TextLayout::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(Justify::Center), TextFont::from_font_size(15.), Transform::from_xyz(0., -0.5 * rect.size.y - 10., 0.), bevy::sprite::Anchor::TOP_CENTER, @@ -275,7 +275,7 @@ fn setup_texture_atlas( cmd.with_children(|builder| { builder.spawn(( Text2d::new(sprite_sheet.text), - TextLayout::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(Justify::Center), TextFont::from_font_size(15.), Transform::from_xyz(0., -0.5 * sprite_sheet.size.y - 10., 0.), bevy::sprite::Anchor::TOP_CENTER, diff --git a/examples/2d/sprite_slice.rs b/examples/2d/sprite_slice.rs index 94f4fe809f..91918b1d66 100644 --- a/examples/2d/sprite_slice.rs +++ b/examples/2d/sprite_slice.rs @@ -94,7 +94,7 @@ fn spawn_sprites( children![( Text2d::new(label), text_style, - TextLayout::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(Justify::Center), Transform::from_xyz(0., -0.5 * size.y - 10., 0.0), bevy::sprite::Anchor::TOP_CENTER, )], diff --git a/examples/2d/text2d.rs b/examples/2d/text2d.rs index 7b1abfd8da..3123e8d891 100644 --- a/examples/2d/text2d.rs +++ b/examples/2d/text2d.rs @@ -40,7 +40,7 @@ fn setup(mut commands: Commands, asset_server: Res) { font_size: 50.0, ..default() }; - let text_justification = JustifyText::Center; + let text_justification = Justify::Center; commands.spawn(Camera2d); // Demonstrate changing translation commands.spawn(( @@ -78,7 +78,7 @@ fn setup(mut commands: Commands, asset_server: Res) { children![( Text2d::new("this text wraps in the box\n(Unicode linebreaks)"), slightly_smaller_text_font.clone(), - TextLayout::new(JustifyText::Left, LineBreak::WordBoundary), + TextLayout::new(Justify::Left, LineBreak::WordBoundary), // Wrap text in the rectangle TextBounds::from(box_size), // Ensure the text is drawn on top of the box @@ -94,7 +94,7 @@ fn setup(mut commands: Commands, asset_server: Res) { children![( Text2d::new("this text wraps in the box\n(AnyCharacter linebreaks)"), slightly_smaller_text_font.clone(), - TextLayout::new(JustifyText::Left, LineBreak::AnyCharacter), + TextLayout::new(Justify::Left, LineBreak::AnyCharacter), // Wrap text in the rectangle TextBounds::from(other_box_size), // Ensure the text is drawn on top of the box @@ -104,11 +104,11 @@ fn setup(mut commands: Commands, asset_server: Res) { // Demonstrate font smoothing off commands.spawn(( - Text2d::new("This text has\nFontSmoothing::None\nAnd JustifyText::Center"), + Text2d::new("This text has\nFontSmoothing::None\nAnd Justify::Center"), slightly_smaller_text_font .clone() .with_font_smoothing(FontSmoothing::None), - TextLayout::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(Justify::Center), Transform::from_translation(Vec3::new(-400.0, -250.0, 0.0)), )); diff --git a/examples/2d/texture_atlas.rs b/examples/2d/texture_atlas.rs index 7510afbcee..25106adcfb 100644 --- a/examples/2d/texture_atlas.rs +++ b/examples/2d/texture_atlas.rs @@ -279,7 +279,7 @@ fn create_label( commands.spawn(( Text2d::new(text), text_style, - TextLayout::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(Justify::Center), Transform { translation: Vec3::new(translation.0, translation.1, translation.2), ..default() diff --git a/examples/3d/tonemapping.rs b/examples/3d/tonemapping.rs index 0808776e2b..987ceda70d 100644 --- a/examples/3d/tonemapping.rs +++ b/examples/3d/tonemapping.rs @@ -180,7 +180,7 @@ fn setup_image_viewer_scene( ..default() }, TextColor(Color::BLACK), - TextLayout::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(Justify::Center), Node { align_self: AlignSelf::Center, margin: UiRect::all(Val::Auto), diff --git a/examples/animation/animated_ui.rs b/examples/animation/animated_ui.rs index f31b2ccd5e..68b0eb7a8f 100644 --- a/examples/animation/animated_ui.rs +++ b/examples/animation/animated_ui.rs @@ -151,7 +151,7 @@ fn setup( ..default() }, TextColor(Color::Srgba(Srgba::RED)), - TextLayout::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(Justify::Center), )) // Mark as an animation target. .insert(AnimationTarget { diff --git a/examples/animation/animation_graph.rs b/examples/animation/animation_graph.rs index 610074744f..884ec1a2af 100644 --- a/examples/animation/animation_graph.rs +++ b/examples/animation/animation_graph.rs @@ -277,7 +277,7 @@ fn setup_node_rects(commands: &mut Commands) { ..default() }, TextColor(ANTIQUE_WHITE.into()), - TextLayout::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(Justify::Center), )) .id(); diff --git a/examples/animation/animation_masks.rs b/examples/animation/animation_masks.rs index 07261b40df..05b50711fe 100644 --- a/examples/animation/animation_masks.rs +++ b/examples/animation/animation_masks.rs @@ -334,7 +334,7 @@ fn add_mask_group_control( } else { selected_button_text_style.clone() }, - TextLayout::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(Justify::Center), Node { flex_grow: 1.0, margin: UiRect::vertical(Val::Px(3.0)), diff --git a/examples/async_tasks/external_source_external_thread.rs b/examples/async_tasks/external_source_external_thread.rs index 1b7bb27b16..1b437ed76c 100644 --- a/examples/async_tasks/external_source_external_thread.rs +++ b/examples/async_tasks/external_source_external_thread.rs @@ -54,7 +54,7 @@ fn spawn_text(mut commands: Commands, mut reader: EventReader) { for (per_frame, event) in reader.read().enumerate() { commands.spawn(( Text2d::new(event.0.to_string()), - TextLayout::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(Justify::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 8dfb90f175..faa40b6184 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(), - TextLayout::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(Justify::Center), Node { align_self: AlignSelf::Center, justify_self: JustifySelf::Center, diff --git a/examples/math/render_primitives.rs b/examples/math/render_primitives.rs index 7d1e3aca97..26be0445ba 100644 --- a/examples/math/render_primitives.rs +++ b/examples/math/render_primitives.rs @@ -379,7 +379,7 @@ fn setup_text(mut commands: Commands, cameras: Query<(Entity, &Camera)>) { children![( Text::default(), HeaderText, - TextLayout::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(Justify::Center), children![ TextSpan::new("Primitive: "), TextSpan(format!("{text}", text = PrimitiveSelected::default())), diff --git a/examples/mobile/src/lib.rs b/examples/mobile/src/lib.rs index ba93268e86..de83152552 100644 --- a/examples/mobile/src/lib.rs +++ b/examples/mobile/src/lib.rs @@ -158,7 +158,7 @@ fn setup_scene( ..default() }, TextColor::BLACK, - TextLayout::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(Justify::Center), )); } diff --git a/examples/stress_tests/many_glyphs.rs b/examples/stress_tests/many_glyphs.rs index d6629fa80c..dc94e65ca8 100644 --- a/examples/stress_tests/many_glyphs.rs +++ b/examples/stress_tests/many_glyphs.rs @@ -74,7 +74,7 @@ fn setup(mut commands: Commands, args: Res) { ..Default::default() }; let text_block = TextLayout { - justify: JustifyText::Left, + justify: Justify::Left, linebreak: LineBreak::AnyCharacter, }; diff --git a/examples/stress_tests/many_text2d.rs b/examples/stress_tests/many_text2d.rs index c05ce00a47..cc1247e13f 100644 --- a/examples/stress_tests/many_text2d.rs +++ b/examples/stress_tests/many_text2d.rs @@ -47,7 +47,7 @@ struct Args { #[argh(switch)] no_frustum_culling: bool, - /// whether the text should use `JustifyText::Center`. + /// whether the text should use `Justify::Center`. #[argh(switch)] center: bool, } @@ -132,9 +132,9 @@ fn setup(mut commands: Commands, font: Res, args: Res) { random_text_font(&mut rng, &args, font.0.clone()), TextColor(color.into()), TextLayout::new_with_justify(if args.center { - JustifyText::Center + Justify::Center } else { - JustifyText::Left + Justify::Left }), Transform { translation, diff --git a/examples/stress_tests/text_pipeline.rs b/examples/stress_tests/text_pipeline.rs index acb0b0e804..5f9fdca8e0 100644 --- a/examples/stress_tests/text_pipeline.rs +++ b/examples/stress_tests/text_pipeline.rs @@ -69,7 +69,7 @@ fn spawn(mut commands: Commands, asset_server: Res) { .spawn(( Text2d::default(), TextLayout { - justify: JustifyText::Center, + justify: Justify::Center, linebreak: LineBreak::AnyCharacter, }, TextBounds::default(), diff --git a/examples/testbed/2d.rs b/examples/testbed/2d.rs index c812157899..4d53daf507 100644 --- a/examples/testbed/2d.rs +++ b/examples/testbed/2d.rs @@ -151,10 +151,10 @@ mod text { commands.spawn((Camera2d, DespawnOnExitState(super::Scene::Text))); for (i, justify) in [ - JustifyText::Left, - JustifyText::Right, - JustifyText::Center, - JustifyText::Justified, + Justify::Left, + Justify::Right, + Justify::Center, + Justify::Justified, ] .into_iter() .enumerate() @@ -196,7 +196,7 @@ mod text { fn spawn_anchored_text( commands: &mut Commands, dest: Vec3, - justify: JustifyText, + justify: Justify, bounds: Option, ) { commands.spawn(( diff --git a/examples/testbed/ui.rs b/examples/testbed/ui.rs index eba2afb409..6538840575 100644 --- a/examples/testbed/ui.rs +++ b/examples/testbed/ui.rs @@ -372,7 +372,7 @@ mod text_wrap { for (j, message) in messages.into_iter().enumerate() { commands.entity(root).with_child(( Text(message.clone()), - TextLayout::new(JustifyText::Left, linebreak), + TextLayout::new(Justify::Left, linebreak), BackgroundColor(Color::srgb(0.8 - j as f32 * 0.3, 0., 0.)), )); } diff --git a/examples/time/virtual_time.rs b/examples/time/virtual_time.rs index 09923da7b7..4b6aec436e 100644 --- a/examples/time/virtual_time.rs +++ b/examples/time/virtual_time.rs @@ -102,7 +102,7 @@ fn setup(mut commands: Commands, asset_server: Res, mut time: ResMu ..default() }, TextColor(Color::srgb(0.85, 0.85, 0.85)), - TextLayout::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(Justify::Center), ), ( Text::default(), @@ -111,7 +111,7 @@ fn setup(mut commands: Commands, asset_server: Res, mut time: ResMu ..default() }, TextColor(virtual_color), - TextLayout::new_with_justify(JustifyText::Right), + TextLayout::new_with_justify(Justify::Right), VirtualTime, ), ], diff --git a/examples/ui/directional_navigation.rs b/examples/ui/directional_navigation.rs index a570846fa7..05b3effbc3 100644 --- a/examples/ui/directional_navigation.rs +++ b/examples/ui/directional_navigation.rs @@ -186,7 +186,7 @@ fn setup_ui( Text::new(button_name), // And center the text if it flows onto multiple lines TextLayout { - justify: JustifyText::Center, + justify: Justify::Center, ..default() }, )) diff --git a/examples/ui/display_and_visibility.rs b/examples/ui/display_and_visibility.rs index 239b9814db..3513c94321 100644 --- a/examples/ui/display_and_visibility.rs +++ b/examples/ui/display_and_visibility.rs @@ -99,7 +99,7 @@ fn setup(mut commands: Commands, asset_server: Res) { 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_font.clone(), - TextLayout::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(Justify::Center), Node { margin: UiRect::bottom(Val::Px(10.)), ..Default::default() @@ -153,13 +153,13 @@ fn setup(mut commands: Commands, asset_server: Res) { Text::new("Display::None\nVisibility::Hidden\nVisibility::Inherited"), text_font.clone(), TextColor(HIDDEN_COLOR), - TextLayout::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(Justify::Center), )); builder.spawn(( Text::new("-\n-\n-"), text_font.clone(), TextColor(DARK_GRAY.into()), - TextLayout::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(Justify::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_font)); }); @@ -396,7 +396,7 @@ where builder.spawn(( Text(format!("{}::{:?}", Target::::NAME, T::default())), text_font, - TextLayout::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(Justify::Center), )); }); } diff --git a/examples/ui/size_constraints.rs b/examples/ui/size_constraints.rs index 72a072d788..e69ec911fa 100644 --- a/examples/ui/size_constraints.rs +++ b/examples/ui/size_constraints.rs @@ -251,7 +251,7 @@ fn spawn_button( } else { UNHOVERED_TEXT_COLOR }), - TextLayout::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(Justify::Center), )); }); } diff --git a/examples/ui/text.rs b/examples/ui/text.rs index 8bf34cc96e..12ed5c53ae 100644 --- a/examples/ui/text.rs +++ b/examples/ui/text.rs @@ -40,7 +40,7 @@ fn setup(mut commands: Commands, asset_server: Res) { }, TextShadow::default(), // Set the justification of the Text - TextLayout::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(Justify::Center), // Set the style of the Node itself. Node { position_type: PositionType::Absolute, diff --git a/examples/ui/text_background_colors.rs b/examples/ui/text_background_colors.rs index caf0b60e85..3f82190f74 100644 --- a/examples/ui/text_background_colors.rs +++ b/examples/ui/text_background_colors.rs @@ -43,7 +43,7 @@ fn setup(mut commands: Commands) { .spawn(( Text::default(), TextLayout { - justify: JustifyText::Center, + justify: Justify::Center, ..Default::default() }, )) diff --git a/examples/ui/text_debug.rs b/examples/ui/text_debug.rs index 10ba7040b7..948cf0a534 100644 --- a/examples/ui/text_debug.rs +++ b/examples/ui/text_debug.rs @@ -64,7 +64,7 @@ fn infotext_system(mut commands: Commands, asset_server: Res) { )); builder.spawn(( Text::new( - "This text is right-justified. The `JustifyText` component controls the horizontal alignment of the lines of multi-line text relative to each other, and does not affect the text node's position in the UI layout.", + "This text is right-justified. The `Justify` component controls the horizontal alignment of the lines of multi-line text relative to each other, and does not affect the text node's position in the UI layout.", ), TextFont { font: font.clone(), @@ -72,7 +72,7 @@ fn infotext_system(mut commands: Commands, asset_server: Res) { ..default() }, TextColor(YELLOW.into()), - TextLayout::new_with_justify(JustifyText::Right), + TextLayout::new_with_justify(Justify::Right), Node { max_width: Val::Px(300.), ..default() @@ -114,7 +114,7 @@ fn infotext_system(mut commands: Commands, asset_server: Res) { ..default() }, TextColor(Color::srgb(0.8, 0.2, 0.7)), - TextLayout::new_with_justify(JustifyText::Center), + TextLayout::new_with_justify(Justify::Center), Node { max_width: Val::Px(400.), ..default() @@ -130,7 +130,7 @@ fn infotext_system(mut commands: Commands, asset_server: Res) { ..default() }, TextColor(YELLOW.into()), - TextLayout::new_with_justify(JustifyText::Left), + TextLayout::new_with_justify(Justify::Left), Node { max_width: Val::Px(300.), ..default() @@ -145,7 +145,7 @@ fn infotext_system(mut commands: Commands, asset_server: Res) { font_size: 29.0, ..default() }, - TextLayout::new_with_justify(JustifyText::Justified), + TextLayout::new_with_justify(Justify::Justified), TextColor(GREEN_YELLOW.into()), Node { max_width: Val::Px(300.), diff --git a/examples/ui/text_wrap_debug.rs b/examples/ui/text_wrap_debug.rs index 227fb15116..986d9c79ff 100644 --- a/examples/ui/text_wrap_debug.rs +++ b/examples/ui/text_wrap_debug.rs @@ -117,7 +117,7 @@ fn spawn(mut commands: Commands, asset_server: Res) { commands.entity(column_id).with_child(( Text(message.clone()), text_font.clone(), - TextLayout::new(JustifyText::Left, linebreak), + TextLayout::new(Justify::Left, linebreak), BackgroundColor(Color::srgb(0.8 - j as f32 * 0.2, 0., 0.)), )); } diff --git a/release-content/migration-guides/rename-justifytext.md b/release-content/migration-guides/rename-justifytext.md new file mode 100644 index 0000000000..04b351a21f --- /dev/null +++ b/release-content/migration-guides/rename-justifytext.md @@ -0,0 +1,8 @@ +--- +title: Renamed `JustifyText` to `Justify` +pull_requests: [19522] +--- + +`JustifyText` has been renamed to `Justify`. + +The `-Text` suffix was inconsistent with the names of other `bevy_text` types and unnecessary since it's natural to assume `Justify` refers to text justification.