Skip to content

Move TextShadow to text widget module #19579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crates/bevy_ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -179,7 +179,6 @@ impl Plugin for UiPlugin {
.register_type::<Outline>()
.register_type::<BoxShadowSamples>()
.register_type::<UiAntiAlias>()
.register_type::<TextShadow>()
.register_type::<ColorStop>()
.register_type::<AngularColorStop>()
.register_type::<UiPosition>()
Expand Down Expand Up @@ -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::<TextLayoutInfo>()
.register_type::<TextNodeFlags>()
.register_type::<Text>();
.register_type::<Text>()
.register_type::<TextShadow>();

app.add_systems(
PostUpdate,
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ui/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
20 changes: 0 additions & 20 deletions crates/bevy_ui/src/ui_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 20 additions & 0 deletions crates/bevy_ui/src/widget/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,26 @@ impl From<String> 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>;

Expand Down
Original file line number Diff line number Diff line change
@@ -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`.






Comment on lines +7 to +12
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove all these empty lines (except one).