Skip to content
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

register TextLayoutInfo and TextFlags type. #9919

Merged
merged 2 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion crates/bevy_text/src/font_atlas_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use bevy_asset::{AssetEvent, AssetId};
use bevy_asset::{Assets, Handle};
use bevy_ecs::prelude::*;
use bevy_math::Vec2;
use bevy_reflect::Reflect;
use bevy_render::texture::Image;
use bevy_sprite::TextureAtlas;
use bevy_utils::FloatOrd;
Expand Down Expand Up @@ -40,7 +41,7 @@ pub struct FontAtlasSet {
font_atlases: HashMap<FontSizeKey, Vec<FontAtlas>>,
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, Reflect)]
pub struct GlyphAtlasInfo {
pub texture_atlas: Handle<TextureAtlas>,
pub glyph_index: usize,
Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_text/src/glyph_brush.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use ab_glyph::{Font as _, FontArc, Glyph, PxScaleFont, ScaleFont as _};
use bevy_asset::{AssetId, Assets};
use bevy_math::{Rect, Vec2};
use bevy_reflect::Reflect;
use bevy_render::texture::Image;
use bevy_sprite::TextureAtlas;
use bevy_utils::tracing::warn;
Expand Down Expand Up @@ -158,7 +159,7 @@ impl GlyphBrush {
}
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, Reflect)]
pub struct PositionedGlyph {
pub position: Vec2,
pub size: Vec2,
Expand Down
6 changes: 5 additions & 1 deletion crates/bevy_text/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ use crate::{
use ab_glyph::PxScale;
use bevy_asset::{AssetId, Assets, Handle};
use bevy_ecs::component::Component;
use bevy_ecs::prelude::ReflectComponent;
use bevy_ecs::system::Resource;
use bevy_math::Vec2;
use bevy_reflect::prelude::ReflectDefault;
use bevy_reflect::Reflect;
use bevy_render::texture::Image;
use bevy_sprite::TextureAtlas;
use bevy_utils::HashMap;
Expand All @@ -22,7 +25,8 @@ pub struct TextPipeline {
/// Render information for a corresponding [`Text`](crate::Text) component.
///
/// 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 glyphs: Vec<PositionedGlyph>,
pub logical_size: Vec2,
Expand Down
4 changes: 4 additions & 0 deletions crates/bevy_ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub mod widget;

use bevy_derive::{Deref, DerefMut};
use bevy_reflect::Reflect;
use bevy_text::TextLayoutInfo;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
use bevy_text::TextLayoutInfo;
#[cfg(feature = "bevy_text")]
use bevy_text::TextLayoutInfo;

#[cfg(feature = "bevy_text")]
mod accessibility;
mod focus;
Expand Down Expand Up @@ -40,6 +41,7 @@ pub mod prelude {
}

use crate::prelude::UiCameraConfig;
use crate::widget::TextFlags;
use bevy_app::prelude::*;
use bevy_asset::Assets;
use bevy_ecs::prelude::*;
Expand Down Expand Up @@ -89,6 +91,8 @@ impl Plugin for UiPlugin {
.register_type::<AlignSelf>()
.register_type::<BackgroundColor>()
.register_type::<CalculatedClip>()
.register_type::<TextLayoutInfo>()
.register_type::<TextFlags>()
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to add those conditionally.

To check your changes, use the cargo check -p bevy_ui --no-default-features command

.register_type::<ContentSize>()
.register_type::<Direction>()
.register_type::<Display>()
Expand Down