Move TextShadow
to text
widget module (#19579)
# Objective It's odd that `TextShadow` is accessible by importing `bevy::ui::*` but `Text` isn't. Move the `TextShadow` component to `text` widget module and move its type registration to the `build_text_interop` function.
This commit is contained in:
parent
e6e731017d
commit
e9daac4f11
@ -60,7 +60,7 @@ pub mod prelude {
|
|||||||
#[cfg(feature = "bevy_ui_debug")]
|
#[cfg(feature = "bevy_ui_debug")]
|
||||||
pub use crate::render::UiDebugOptions;
|
pub use crate::render::UiDebugOptions;
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub use crate::widget::{Text, TextUiReader, TextUiWriter};
|
pub use crate::widget::{Text, TextShadow, TextUiReader, TextUiWriter};
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub use {
|
pub use {
|
||||||
crate::{
|
crate::{
|
||||||
@ -184,7 +184,6 @@ impl Plugin for UiPlugin {
|
|||||||
.register_type::<Outline>()
|
.register_type::<Outline>()
|
||||||
.register_type::<BoxShadowSamples>()
|
.register_type::<BoxShadowSamples>()
|
||||||
.register_type::<UiAntiAlias>()
|
.register_type::<UiAntiAlias>()
|
||||||
.register_type::<TextShadow>()
|
|
||||||
.register_type::<ColorStop>()
|
.register_type::<ColorStop>()
|
||||||
.register_type::<AngularColorStop>()
|
.register_type::<AngularColorStop>()
|
||||||
.register_type::<UiPosition>()
|
.register_type::<UiPosition>()
|
||||||
@ -284,11 +283,12 @@ impl Plugin for UiPlugin {
|
|||||||
fn build_text_interop(app: &mut App) {
|
fn build_text_interop(app: &mut App) {
|
||||||
use crate::widget::TextNodeFlags;
|
use crate::widget::TextNodeFlags;
|
||||||
use bevy_text::TextLayoutInfo;
|
use bevy_text::TextLayoutInfo;
|
||||||
use widget::Text;
|
use widget::{Text, TextShadow};
|
||||||
|
|
||||||
app.register_type::<TextLayoutInfo>()
|
app.register_type::<TextLayoutInfo>()
|
||||||
.register_type::<TextNodeFlags>()
|
.register_type::<TextNodeFlags>()
|
||||||
.register_type::<Text>();
|
.register_type::<Text>()
|
||||||
|
.register_type::<TextShadow>();
|
||||||
|
|
||||||
app.add_systems(
|
app.add_systems(
|
||||||
PostUpdate,
|
PostUpdate,
|
||||||
|
@ -9,11 +9,11 @@ mod debug_overlay;
|
|||||||
mod gradient;
|
mod gradient;
|
||||||
|
|
||||||
use crate::prelude::UiGlobalTransform;
|
use crate::prelude::UiGlobalTransform;
|
||||||
use crate::widget::{ImageNode, ViewportNode};
|
use crate::widget::{ImageNode, TextShadow, ViewportNode};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
BackgroundColor, BorderColor, BoxShadowSamples, CalculatedClip, ComputedNode,
|
BackgroundColor, BorderColor, BoxShadowSamples, CalculatedClip, ComputedNode,
|
||||||
ComputedNodeTarget, Outline, ResolvedBorderRadius, TextShadow, UiAntiAlias,
|
ComputedNodeTarget, Outline, ResolvedBorderRadius, UiAntiAlias,
|
||||||
};
|
};
|
||||||
use bevy_app::prelude::*;
|
use bevy_app::prelude::*;
|
||||||
use bevy_asset::{AssetEvent, AssetId, Assets};
|
use bevy_asset::{AssetEvent, AssetId, Assets};
|
||||||
|
@ -2881,28 +2881,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)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::GridPlacement;
|
use crate::GridPlacement;
|
||||||
|
@ -128,6 +128,28 @@ impl From<String> 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`].
|
/// UI alias for [`TextReader`].
|
||||||
pub type TextUiReader<'w, 's> = TextReader<'w, 's, Text>;
|
pub type TextUiReader<'w, 's> = TextReader<'w, 's, Text>;
|
||||||
|
|
||||||
|
@ -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`.
|
Loading…
Reference in New Issue
Block a user