diff --git a/crates/bevy_ui/src/lib.rs b/crates/bevy_ui/src/lib.rs index 47d396b2010e2..03c7cc523922c 100644 --- a/crates/bevy_ui/src/lib.rs +++ b/crates/bevy_ui/src/lib.rs @@ -60,7 +60,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::{ @@ -184,7 +184,6 @@ impl Plugin for UiPlugin { .register_type::() .register_type::() .register_type::() - .register_type::() .register_type::() .register_type::() .register_type::() @@ -284,11 +283,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 61319eda9baa1..b3d0117801dcc 100644 --- a/crates/bevy_ui/src/render/mod.rs +++ b/crates/bevy_ui/src/render/mod.rs @@ -9,11 +9,11 @@ mod debug_overlay; mod gradient; use crate::prelude::UiGlobalTransform; -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 6418f69ff87f4..d58e2fe6eff54 100644 --- a/crates/bevy_ui/src/ui_node.rs +++ b/crates/bevy_ui/src/ui_node.rs @@ -2876,28 +2876,6 @@ impl ComputedNodeTarget { } } -/// Adds a shadow behind text -/// -/// 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 - 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; diff --git a/crates/bevy_ui/src/widget/text.rs b/crates/bevy_ui/src/widget/text.rs index d7f8e243a4a69..1544a5ff7a976 100644 --- a/crates/bevy_ui/src/widget/text.rs +++ b/crates/bevy_ui/src/widget/text.rs @@ -128,6 +128,28 @@ impl From for Text { } } +/// Adds a shadow behind text +/// +/// 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 + 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>; 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..4e23abc36b13b --- /dev/null +++ b/release-content/migration-guides/textshadow_is_moved_to_widget_text_module.md @@ -0,0 +1,6 @@ +--- +title: `TextShadow` has been moved to `bevy::ui::widget::text` +pull_requests: [] +--- + +`TextShadow` has been moved to `bevy::ui::widget::text`.