use crate::{CalculatedSize, Node, Style, Val}; use bevy_asset::{Assets, Handle}; use bevy_ecs::{Changed, Entity, Local, Or, Query, QuerySet, Res, ResMut}; use bevy_math::Size; use bevy_render::{ draw::{Draw, DrawContext, Drawable}, mesh::Mesh, prelude::Msaa, renderer::{AssetRenderResourceBindings, RenderResourceBindings}, texture::Texture, }; use bevy_sprite::{TextureAtlas, QUAD_HANDLE}; use bevy_text::{DefaultTextPipeline, DrawableText, Font, FontAtlasSet, TextError, TextStyle}; use bevy_transform::prelude::GlobalTransform; #[derive(Debug, Default)] pub struct QueuedText { entities: Vec, } #[derive(Debug, Default, Clone)] pub struct Text { pub value: String, pub font: Handle, pub style: TextStyle, } /// Defines how min_size, size, and max_size affects the bounds of a text /// block. pub fn text_constraint(min_size: Val, size: Val, max_size: Val) -> f32 { // Needs support for percentages match (min_size, size, max_size) { (_, _, Val::Px(max)) => max, (Val::Px(min), _, _) => min, (Val::Undefined, Val::Px(size), Val::Undefined) => size, (Val::Auto, Val::Px(size), Val::Auto) => size, _ => f32::MAX, } } /// Computes the size of a text block and updates the TextGlyphs with the /// new computed glyphs from the layout pub fn text_system( mut queued_text: Local, mut textures: ResMut>, fonts: Res>, mut texture_atlases: ResMut>, mut font_atlas_set_storage: ResMut>, mut text_pipeline: ResMut, mut text_queries: QuerySet<( Query, Changed