From 732965da40aefc4c82c4ca0bb6b494f37366b5a4 Mon Sep 17 00:00:00 2001 From: ickshonpe Date: Wed, 11 Jun 2025 10:32:25 +0100 Subject: [PATCH 1/7] Moved the `TextShadow` component to the `bevy_ui::widget::text` module. --- crates/bevy_ui/src/widget/text.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/crates/bevy_ui/src/widget/text.rs b/crates/bevy_ui/src/widget/text.rs index 785040c1e9057..714943a2eadfc 100644 --- a/crates/bevy_ui/src/widget/text.rs +++ b/crates/bevy_ui/src/widget/text.rs @@ -128,6 +128,26 @@ impl From for Text { } } +/// Adds a shadow behind text +#[derive(Component, Copy, Clone, Debug, Reflect)] +#[reflect(Component, Default, Debug, Clone)] +pub struct TextShadow { + /// Shadow displacement in logical pixels + /// With a value of zero the shadow will be hidden directly behind the text + pub offset: Vec2, + /// Color of the shadow + pub color: Color, +} + +impl Default for TextShadow { + fn default() -> Self { + Self { + offset: Vec2::splat(4.), + color: Color::linear_rgba(0., 0., 0., 0.75), + } + } +} + /// UI alias for [`TextReader`]. pub type TextUiReader<'w, 's> = TextReader<'w, 's, Text>; From 72347762047eac14eec36d86a20567af9d4a8c72 Mon Sep 17 00:00:00 2001 From: ickshonpe Date: Wed, 11 Jun 2025 10:43:28 +0100 Subject: [PATCH 2/7] Moved the `TextShadow` component to the `bevy_ui::widget::text` module. --- crates/bevy_ui/src/widget/text.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/crates/bevy_ui/src/widget/text.rs b/crates/bevy_ui/src/widget/text.rs index 785040c1e9057..714943a2eadfc 100644 --- a/crates/bevy_ui/src/widget/text.rs +++ b/crates/bevy_ui/src/widget/text.rs @@ -128,6 +128,26 @@ impl From for Text { } } +/// Adds a shadow behind text +#[derive(Component, Copy, Clone, Debug, Reflect)] +#[reflect(Component, Default, Debug, Clone)] +pub struct TextShadow { + /// Shadow displacement in logical pixels + /// With a value of zero the shadow will be hidden directly behind the text + pub offset: Vec2, + /// Color of the shadow + pub color: Color, +} + +impl Default for TextShadow { + fn default() -> Self { + Self { + offset: Vec2::splat(4.), + color: Color::linear_rgba(0., 0., 0., 0.75), + } + } +} + /// UI alias for [`TextReader`]. pub type TextUiReader<'w, 's> = TextReader<'w, 's, Text>; From 8b57185f5699919eba0ee64f2818cd19105c2d02 Mon Sep 17 00:00:00 2001 From: ickshonpe Date: Wed, 11 Jun 2025 10:46:35 +0100 Subject: [PATCH 3/7] Moved `TextShadow` type registration to `build_text_interop`. Fixed imports and prelude. --- crates/bevy_ui/src/lib.rs | 8 ++++---- crates/bevy_ui/src/render/mod.rs | 4 ++-- crates/bevy_ui/src/ui_node.rs | 20 -------------------- 3 files changed, 6 insertions(+), 26 deletions(-) diff --git a/crates/bevy_ui/src/lib.rs b/crates/bevy_ui/src/lib.rs index 4ce635920652c..470a0f5533130 100644 --- a/crates/bevy_ui/src/lib.rs +++ b/crates/bevy_ui/src/lib.rs @@ -56,7 +56,7 @@ pub mod prelude { #[cfg(feature = "bevy_ui_debug")] pub use crate::render::UiDebugOptions; #[doc(hidden)] - pub use crate::widget::{Text, TextUiReader, TextUiWriter}; + pub use crate::widget::{Text, TextShadow, TextUiReader, TextUiWriter}; #[doc(hidden)] pub use { crate::{ @@ -179,7 +179,6 @@ impl Plugin for UiPlugin { .register_type::() .register_type::() .register_type::() - .register_type::() .register_type::() .register_type::() .register_type::() @@ -279,11 +278,12 @@ impl Plugin for UiPlugin { fn build_text_interop(app: &mut App) { use crate::widget::TextNodeFlags; use bevy_text::TextLayoutInfo; - use widget::Text; + use widget::{Text, TextShadow}; app.register_type::() .register_type::() - .register_type::(); + .register_type::() + .register_type::(); app.add_systems( PostUpdate, diff --git a/crates/bevy_ui/src/render/mod.rs b/crates/bevy_ui/src/render/mod.rs index 83140d0f3b9cb..e506818a00521 100644 --- a/crates/bevy_ui/src/render/mod.rs +++ b/crates/bevy_ui/src/render/mod.rs @@ -8,10 +8,10 @@ pub mod ui_texture_slice_pipeline; mod debug_overlay; mod gradient; -use crate::widget::{ImageNode, ViewportNode}; +use crate::widget::{ImageNode, TextShadow, ViewportNode}; use crate::{ BackgroundColor, BorderColor, BoxShadowSamples, CalculatedClip, ComputedNode, - ComputedNodeTarget, Outline, ResolvedBorderRadius, TextShadow, UiAntiAlias, + ComputedNodeTarget, Outline, ResolvedBorderRadius, UiAntiAlias, }; use bevy_app::prelude::*; use bevy_asset::{AssetEvent, AssetId, Assets}; diff --git a/crates/bevy_ui/src/ui_node.rs b/crates/bevy_ui/src/ui_node.rs index f5f914bdc01f6..9b066ff543608 100644 --- a/crates/bevy_ui/src/ui_node.rs +++ b/crates/bevy_ui/src/ui_node.rs @@ -2795,26 +2795,6 @@ impl ComputedNodeTarget { } } -/// Adds a shadow behind text -#[derive(Component, Copy, Clone, Debug, Reflect)] -#[reflect(Component, Default, Debug, Clone)] -pub struct TextShadow { - /// Shadow displacement in logical pixels - /// With a value of zero the shadow will be hidden directly behind the text - pub offset: Vec2, - /// Color of the shadow - pub color: Color, -} - -impl Default for TextShadow { - fn default() -> Self { - Self { - offset: Vec2::splat(4.), - color: Color::linear_rgba(0., 0., 0., 0.75), - } - } -} - #[cfg(test)] mod tests { use crate::GridPlacement; From 9c3372a9da5beea9841a2af9d1b3b9f329cfa2f2 Mon Sep 17 00:00:00 2001 From: ickshonpe Date: Wed, 11 Jun 2025 10:50:44 +0100 Subject: [PATCH 4/7] Added migration guide --- .../textshadow_is_moved_to_widget_text_module.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 release-content/migration-guides/textshadow_is_moved_to_widget_text_module.md diff --git a/release-content/migration-guides/textshadow_is_moved_to_widget_text_module.md b/release-content/migration-guides/textshadow_is_moved_to_widget_text_module.md new file mode 100644 index 0000000000000..ee610612d0d2e --- /dev/null +++ b/release-content/migration-guides/textshadow_is_moved_to_widget_text_module.md @@ -0,0 +1,12 @@ +--- +title: `TextShadow` has been moved to `bevy::ui::widget::text` +pull_requests: [] +--- + +`TextShadow` has been moved to `bevy::ui::widget::text`. + + + + + + From 307b5829bb26de5db9db082f9a198b1bcba7eda6 Mon Sep 17 00:00:00 2001 From: ickshonpe Date: Tue, 24 Jun 2025 00:29:55 +0100 Subject: [PATCH 5/7] Replaced comment --- crates/bevy_ui/src/widget/text.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/bevy_ui/src/widget/text.rs b/crates/bevy_ui/src/widget/text.rs index b28f9fa6f52f4..1544a5ff7a976 100644 --- a/crates/bevy_ui/src/widget/text.rs +++ b/crates/bevy_ui/src/widget/text.rs @@ -129,8 +129,10 @@ impl From for Text { } /// Adds a shadow behind text -#[derive(Component, Copy, Clone, Debug, Reflect)] -#[reflect(Component, Default, Debug, Clone)] +/// +/// Not supported by `Text2d` +#[derive(Component, Copy, Clone, Debug, PartialEq, Reflect)] +#[reflect(Component, Default, Debug, Clone, PartialEq)] pub struct TextShadow { /// Shadow displacement in logical pixels /// With a value of zero the shadow will be hidden directly behind the text From 3bec49dd3993e04c6c59a113f780d35193254e15 Mon Sep 17 00:00:00 2001 From: ickshonpe Date: Tue, 24 Jun 2025 00:35:52 +0100 Subject: [PATCH 6/7] Removed blank lines --- .../textshadow_is_moved_to_widget_text_module.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/release-content/migration-guides/textshadow_is_moved_to_widget_text_module.md b/release-content/migration-guides/textshadow_is_moved_to_widget_text_module.md index ee610612d0d2e..6166f6ea75d2a 100644 --- a/release-content/migration-guides/textshadow_is_moved_to_widget_text_module.md +++ b/release-content/migration-guides/textshadow_is_moved_to_widget_text_module.md @@ -5,8 +5,3 @@ pull_requests: [] `TextShadow` has been moved to `bevy::ui::widget::text`. - - - - - From 49d6200296c2a3d402911f1b68299b0c8bdd1820 Mon Sep 17 00:00:00 2001 From: ickshonpe Date: Tue, 24 Jun 2025 01:09:16 +0100 Subject: [PATCH 7/7] Removed another blank line --- .../textshadow_is_moved_to_widget_text_module.md | 1 - 1 file changed, 1 deletion(-) diff --git a/release-content/migration-guides/textshadow_is_moved_to_widget_text_module.md b/release-content/migration-guides/textshadow_is_moved_to_widget_text_module.md index 6166f6ea75d2a..4e23abc36b13b 100644 --- a/release-content/migration-guides/textshadow_is_moved_to_widget_text_module.md +++ b/release-content/migration-guides/textshadow_is_moved_to_widget_text_module.md @@ -4,4 +4,3 @@ pull_requests: [] --- `TextShadow` has been moved to `bevy::ui::widget::text`. -