mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 12:43:34 +00:00
register TextLayoutInfo
and TextFlags
type. (#9919)
derive `Reflect` to `GlyphAtlasInfo`,`PositionedGlyph` and `TextLayoutInfo`. # Objective - I need reflection gets all components of the `TextBundle` and `clone_value` it ## Solution - registry it
This commit is contained in:
parent
db1e3d36bc
commit
35de5e608e
4 changed files with 17 additions and 3 deletions
|
@ -4,6 +4,7 @@ use bevy_asset::{AssetEvent, AssetId};
|
||||||
use bevy_asset::{Assets, Handle};
|
use bevy_asset::{Assets, Handle};
|
||||||
use bevy_ecs::prelude::*;
|
use bevy_ecs::prelude::*;
|
||||||
use bevy_math::Vec2;
|
use bevy_math::Vec2;
|
||||||
|
use bevy_reflect::Reflect;
|
||||||
use bevy_render::texture::Image;
|
use bevy_render::texture::Image;
|
||||||
use bevy_sprite::TextureAtlas;
|
use bevy_sprite::TextureAtlas;
|
||||||
use bevy_utils::FloatOrd;
|
use bevy_utils::FloatOrd;
|
||||||
|
@ -40,7 +41,7 @@ pub struct FontAtlasSet {
|
||||||
font_atlases: HashMap<FontSizeKey, Vec<FontAtlas>>,
|
font_atlases: HashMap<FontSizeKey, Vec<FontAtlas>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, Reflect)]
|
||||||
pub struct GlyphAtlasInfo {
|
pub struct GlyphAtlasInfo {
|
||||||
pub texture_atlas: Handle<TextureAtlas>,
|
pub texture_atlas: Handle<TextureAtlas>,
|
||||||
pub glyph_index: usize,
|
pub glyph_index: usize,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use ab_glyph::{Font as _, FontArc, Glyph, PxScaleFont, ScaleFont as _};
|
use ab_glyph::{Font as _, FontArc, Glyph, PxScaleFont, ScaleFont as _};
|
||||||
use bevy_asset::{AssetId, Assets};
|
use bevy_asset::{AssetId, Assets};
|
||||||
use bevy_math::{Rect, Vec2};
|
use bevy_math::{Rect, Vec2};
|
||||||
|
use bevy_reflect::Reflect;
|
||||||
use bevy_render::texture::Image;
|
use bevy_render::texture::Image;
|
||||||
use bevy_sprite::TextureAtlas;
|
use bevy_sprite::TextureAtlas;
|
||||||
use bevy_utils::tracing::warn;
|
use bevy_utils::tracing::warn;
|
||||||
|
@ -158,7 +159,7 @@ impl GlyphBrush {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, Reflect)]
|
||||||
pub struct PositionedGlyph {
|
pub struct PositionedGlyph {
|
||||||
pub position: Vec2,
|
pub position: Vec2,
|
||||||
pub size: Vec2,
|
pub size: Vec2,
|
||||||
|
|
|
@ -6,8 +6,11 @@ use crate::{
|
||||||
use ab_glyph::PxScale;
|
use ab_glyph::PxScale;
|
||||||
use bevy_asset::{AssetId, Assets, Handle};
|
use bevy_asset::{AssetId, Assets, Handle};
|
||||||
use bevy_ecs::component::Component;
|
use bevy_ecs::component::Component;
|
||||||
|
use bevy_ecs::prelude::ReflectComponent;
|
||||||
use bevy_ecs::system::Resource;
|
use bevy_ecs::system::Resource;
|
||||||
use bevy_math::Vec2;
|
use bevy_math::Vec2;
|
||||||
|
use bevy_reflect::prelude::ReflectDefault;
|
||||||
|
use bevy_reflect::Reflect;
|
||||||
use bevy_render::texture::Image;
|
use bevy_render::texture::Image;
|
||||||
use bevy_sprite::TextureAtlas;
|
use bevy_sprite::TextureAtlas;
|
||||||
use bevy_utils::HashMap;
|
use bevy_utils::HashMap;
|
||||||
|
@ -22,7 +25,8 @@ pub struct TextPipeline {
|
||||||
/// Render information for a corresponding [`Text`](crate::Text) component.
|
/// Render information for a corresponding [`Text`](crate::Text) component.
|
||||||
///
|
///
|
||||||
/// Contains scaled glyphs and their size. Generated via [`TextPipeline::queue_text`].
|
/// Contains scaled glyphs and their size. Generated via [`TextPipeline::queue_text`].
|
||||||
#[derive(Component, Clone, Default, Debug)]
|
#[derive(Component, Clone, Default, Debug, Reflect)]
|
||||||
|
#[reflect(Component, Default)]
|
||||||
pub struct TextLayoutInfo {
|
pub struct TextLayoutInfo {
|
||||||
pub glyphs: Vec<PositionedGlyph>,
|
pub glyphs: Vec<PositionedGlyph>,
|
||||||
pub logical_size: Vec2,
|
pub logical_size: Vec2,
|
||||||
|
|
|
@ -14,6 +14,8 @@ pub mod widget;
|
||||||
use bevy_derive::{Deref, DerefMut};
|
use bevy_derive::{Deref, DerefMut};
|
||||||
use bevy_reflect::Reflect;
|
use bevy_reflect::Reflect;
|
||||||
#[cfg(feature = "bevy_text")]
|
#[cfg(feature = "bevy_text")]
|
||||||
|
use bevy_text::TextLayoutInfo;
|
||||||
|
#[cfg(feature = "bevy_text")]
|
||||||
mod accessibility;
|
mod accessibility;
|
||||||
mod focus;
|
mod focus;
|
||||||
mod geometry;
|
mod geometry;
|
||||||
|
@ -40,6 +42,8 @@ pub mod prelude {
|
||||||
}
|
}
|
||||||
|
|
||||||
use crate::prelude::UiCameraConfig;
|
use crate::prelude::UiCameraConfig;
|
||||||
|
#[cfg(feature = "bevy_text")]
|
||||||
|
use crate::widget::TextFlags;
|
||||||
use bevy_app::prelude::*;
|
use bevy_app::prelude::*;
|
||||||
use bevy_asset::Assets;
|
use bevy_asset::Assets;
|
||||||
use bevy_ecs::prelude::*;
|
use bevy_ecs::prelude::*;
|
||||||
|
@ -126,6 +130,10 @@ impl Plugin for UiPlugin {
|
||||||
PreUpdate,
|
PreUpdate,
|
||||||
ui_focus_system.in_set(UiSystem::Focus).after(InputSystem),
|
ui_focus_system.in_set(UiSystem::Focus).after(InputSystem),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#[cfg(feature = "bevy_text")]
|
||||||
|
app.register_type::<TextLayoutInfo>()
|
||||||
|
.register_type::<TextFlags>();
|
||||||
// add these systems to front because these must run before transform update systems
|
// add these systems to front because these must run before transform update systems
|
||||||
#[cfg(feature = "bevy_text")]
|
#[cfg(feature = "bevy_text")]
|
||||||
app.add_systems(
|
app.add_systems(
|
||||||
|
|
Loading…
Reference in a new issue