mirror of
https://github.com/bevyengine/bevy
synced 2024-11-25 06:00:20 +00:00
Remove bevy_ui
's "bevy_text" feature (#15951)
# Objective Remove `bevy-ui`'s non-functional "bevy_text" feature. Fixes #15900 ## Solution Remove all the "bevy_text" cfg gates. I tried to fix it at first but couldn't figure it out. I'll happily withdraw this in favour of another PR that gets the feature gate working.
This commit is contained in:
parent
ab797630c5
commit
396aff906e
8 changed files with 21 additions and 78 deletions
|
@ -32,12 +32,10 @@ bevy_reflect = { path = "../bevy_reflect", version = "0.15.0-dev" }
|
||||||
bevy_render = { path = "../bevy_render", version = "0.15.0-dev" }
|
bevy_render = { path = "../bevy_render", version = "0.15.0-dev" }
|
||||||
bevy_time = { path = "../bevy_time", version = "0.15.0-dev" }
|
bevy_time = { path = "../bevy_time", version = "0.15.0-dev" }
|
||||||
bevy_transform = { path = "../bevy_transform", version = "0.15.0-dev" }
|
bevy_transform = { path = "../bevy_transform", version = "0.15.0-dev" }
|
||||||
bevy_ui = { path = "../bevy_ui", version = "0.15.0-dev", features = [
|
bevy_text = { path = "../bevy_text", version = "0.15.0-dev" }
|
||||||
"bevy_text",
|
bevy_ui = { path = "../bevy_ui", version = "0.15.0-dev" }
|
||||||
] }
|
|
||||||
bevy_utils = { path = "../bevy_utils", version = "0.15.0-dev" }
|
bevy_utils = { path = "../bevy_utils", version = "0.15.0-dev" }
|
||||||
bevy_window = { path = "../bevy_window", version = "0.15.0-dev" }
|
bevy_window = { path = "../bevy_window", version = "0.15.0-dev" }
|
||||||
bevy_text = { path = "../bevy_text", version = "0.15.0-dev" }
|
|
||||||
bevy_state = { path = "../bevy_state", version = "0.15.0-dev" }
|
bevy_state = { path = "../bevy_state", version = "0.15.0-dev" }
|
||||||
|
|
||||||
# other
|
# other
|
||||||
|
|
|
@ -21,9 +21,8 @@ use bevy_window::{PrimaryWindow, Window, WindowScaleFactorChanged};
|
||||||
use derive_more::derive::{Display, Error, From};
|
use derive_more::derive::{Display, Error, From};
|
||||||
use ui_surface::UiSurface;
|
use ui_surface::UiSurface;
|
||||||
|
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
use bevy_text::ComputedTextBlock;
|
use bevy_text::ComputedTextBlock;
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
use bevy_text::CosmicFontSystem;
|
use bevy_text::CosmicFontSystem;
|
||||||
|
|
||||||
mod convert;
|
mod convert;
|
||||||
|
@ -135,8 +134,8 @@ pub fn ui_layout_system(
|
||||||
Option<&Outline>,
|
Option<&Outline>,
|
||||||
Option<&ScrollPosition>,
|
Option<&ScrollPosition>,
|
||||||
)>,
|
)>,
|
||||||
#[cfg(feature = "bevy_text")] mut buffer_query: Query<&mut ComputedTextBlock>,
|
mut buffer_query: Query<&mut ComputedTextBlock>,
|
||||||
#[cfg(feature = "bevy_text")] mut font_system: ResMut<CosmicFontSystem>,
|
mut font_system: ResMut<CosmicFontSystem>,
|
||||||
) {
|
) {
|
||||||
let UiLayoutSystemBuffers {
|
let UiLayoutSystemBuffers {
|
||||||
interned_root_nodes,
|
interned_root_nodes,
|
||||||
|
@ -277,7 +276,6 @@ with UI components as a child of an entity without UI components, your UI layout
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
let text_buffers = &mut buffer_query;
|
let text_buffers = &mut buffer_query;
|
||||||
// clean up removed nodes after syncing children to avoid potential panic (invalid SlotMap key used)
|
// clean up removed nodes after syncing children to avoid potential panic (invalid SlotMap key used)
|
||||||
ui_surface.remove_entities(removed_components.removed_nodes.read());
|
ui_surface.remove_entities(removed_components.removed_nodes.read());
|
||||||
|
@ -292,14 +290,7 @@ with UI components as a child of an entity without UI components, your UI layout
|
||||||
for (camera_id, mut camera) in camera_layout_info.drain() {
|
for (camera_id, mut camera) in camera_layout_info.drain() {
|
||||||
let inverse_target_scale_factor = camera.scale_factor.recip();
|
let inverse_target_scale_factor = camera.scale_factor.recip();
|
||||||
|
|
||||||
ui_surface.compute_camera_layout(
|
ui_surface.compute_camera_layout(camera_id, camera.size, text_buffers, &mut font_system.0);
|
||||||
camera_id,
|
|
||||||
camera.size,
|
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
text_buffers,
|
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
&mut font_system.0,
|
|
||||||
);
|
|
||||||
|
|
||||||
for root in &camera.root_nodes {
|
for root in &camera.root_nodes {
|
||||||
update_uinode_geometry_recursive(
|
update_uinode_geometry_recursive(
|
||||||
|
@ -549,11 +540,11 @@ mod tests {
|
||||||
world.init_resource::<Events<AssetEvent<Image>>>();
|
world.init_resource::<Events<AssetEvent<Image>>>();
|
||||||
world.init_resource::<Assets<Image>>();
|
world.init_resource::<Assets<Image>>();
|
||||||
world.init_resource::<ManualTextureViews>();
|
world.init_resource::<ManualTextureViews>();
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
world.init_resource::<bevy_text::TextPipeline>();
|
world.init_resource::<bevy_text::TextPipeline>();
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
world.init_resource::<bevy_text::CosmicFontSystem>();
|
world.init_resource::<bevy_text::CosmicFontSystem>();
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
world.init_resource::<bevy_text::SwashCache>();
|
world.init_resource::<bevy_text::SwashCache>();
|
||||||
|
|
||||||
// spawn a dummy primary window and camera
|
// spawn a dummy primary window and camera
|
||||||
|
@ -1190,11 +1181,11 @@ mod tests {
|
||||||
world.init_resource::<Events<AssetEvent<Image>>>();
|
world.init_resource::<Events<AssetEvent<Image>>>();
|
||||||
world.init_resource::<Assets<Image>>();
|
world.init_resource::<Assets<Image>>();
|
||||||
world.init_resource::<ManualTextureViews>();
|
world.init_resource::<ManualTextureViews>();
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
world.init_resource::<bevy_text::TextPipeline>();
|
world.init_resource::<bevy_text::TextPipeline>();
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
world.init_resource::<bevy_text::CosmicFontSystem>();
|
world.init_resource::<bevy_text::CosmicFontSystem>();
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
world.init_resource::<bevy_text::SwashCache>();
|
world.init_resource::<bevy_text::SwashCache>();
|
||||||
|
|
||||||
// spawn a dummy primary window and camera
|
// spawn a dummy primary window and camera
|
||||||
|
@ -1262,10 +1253,8 @@ mod tests {
|
||||||
fn test_system(
|
fn test_system(
|
||||||
params: In<TestSystemParam>,
|
params: In<TestSystemParam>,
|
||||||
mut ui_surface: ResMut<UiSurface>,
|
mut ui_surface: ResMut<UiSurface>,
|
||||||
#[cfg(feature = "bevy_text")] mut computed_text_block_query: Query<
|
mut computed_text_block_query: Query<&mut bevy_text::ComputedTextBlock>,
|
||||||
&mut bevy_text::ComputedTextBlock,
|
mut font_system: ResMut<bevy_text::CosmicFontSystem>,
|
||||||
>,
|
|
||||||
#[cfg(feature = "bevy_text")] mut font_system: ResMut<bevy_text::CosmicFontSystem>,
|
|
||||||
) {
|
) {
|
||||||
ui_surface.upsert_node(
|
ui_surface.upsert_node(
|
||||||
&LayoutContext::TEST_CONTEXT,
|
&LayoutContext::TEST_CONTEXT,
|
||||||
|
@ -1277,9 +1266,7 @@ mod tests {
|
||||||
ui_surface.compute_camera_layout(
|
ui_surface.compute_camera_layout(
|
||||||
params.camera_entity,
|
params.camera_entity,
|
||||||
UVec2::new(800, 600),
|
UVec2::new(800, 600),
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
&mut computed_text_block_query,
|
&mut computed_text_block_query,
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
&mut font_system.0,
|
&mut font_system.0,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -203,10 +203,8 @@ impl UiSurface {
|
||||||
&mut self,
|
&mut self,
|
||||||
camera: Entity,
|
camera: Entity,
|
||||||
render_target_resolution: UVec2,
|
render_target_resolution: UVec2,
|
||||||
#[cfg(feature = "bevy_text")] buffer_query: &'a mut bevy_ecs::prelude::Query<
|
buffer_query: &'a mut bevy_ecs::prelude::Query<&mut bevy_text::ComputedTextBlock>,
|
||||||
&mut bevy_text::ComputedTextBlock,
|
font_system: &'a mut bevy_text::cosmic_text::FontSystem,
|
||||||
>,
|
|
||||||
#[cfg(feature = "bevy_text")] font_system: &'a mut bevy_text::cosmic_text::FontSystem,
|
|
||||||
) {
|
) {
|
||||||
let Some(camera_root_nodes) = self.camera_roots.get(&camera) else {
|
let Some(camera_root_nodes) = self.camera_roots.get(&camera) else {
|
||||||
return;
|
return;
|
||||||
|
@ -229,7 +227,6 @@ impl UiSurface {
|
||||||
-> taffy::Size<f32> {
|
-> taffy::Size<f32> {
|
||||||
context
|
context
|
||||||
.map(|ctx| {
|
.map(|ctx| {
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
let buffer = get_text_buffer(
|
let buffer = get_text_buffer(
|
||||||
crate::widget::TextMeasure::needs_buffer(
|
crate::widget::TextMeasure::needs_buffer(
|
||||||
known_dimensions.height,
|
known_dimensions.height,
|
||||||
|
@ -244,12 +241,8 @@ impl UiSurface {
|
||||||
height: known_dimensions.height,
|
height: known_dimensions.height,
|
||||||
available_width: available_space.width,
|
available_width: available_space.width,
|
||||||
available_height: available_space.height,
|
available_height: available_space.height,
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
font_system,
|
font_system,
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
buffer,
|
buffer,
|
||||||
#[cfg(not(feature = "bevy_text"))]
|
|
||||||
font_system: core::marker::PhantomData,
|
|
||||||
},
|
},
|
||||||
style,
|
style,
|
||||||
);
|
);
|
||||||
|
@ -298,7 +291,6 @@ impl UiSurface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
fn get_text_buffer<'a>(
|
fn get_text_buffer<'a>(
|
||||||
needs_buffer: bool,
|
needs_buffer: bool,
|
||||||
ctx: &mut NodeMeasure,
|
ctx: &mut NodeMeasure,
|
||||||
|
@ -705,20 +697,4 @@ mod tests {
|
||||||
"expected root node child count to be 1"
|
"expected root node child count to be 1"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
#[cfg(not(feature = "bevy_text"))]
|
|
||||||
fn test_compute_camera_layout() {
|
|
||||||
let mut ui_surface = UiSurface::default();
|
|
||||||
let camera_entity = Entity::from_raw(0);
|
|
||||||
let root_node_entity = Entity::from_raw(1);
|
|
||||||
let style = Style::default();
|
|
||||||
|
|
||||||
ui_surface.upsert_node(&LayoutContext::TEST_CONTEXT, root_node_entity, &style, None);
|
|
||||||
|
|
||||||
ui_surface.compute_camera_layout(camera_entity, UVec2::new(800, 600));
|
|
||||||
|
|
||||||
let taffy_node = ui_surface.entity_to_taffy.get(&root_node_entity).unwrap();
|
|
||||||
assert!(ui_surface.taffy.layout(*taffy_node).is_ok());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ pub mod picking_backend;
|
||||||
|
|
||||||
use bevy_derive::{Deref, DerefMut};
|
use bevy_derive::{Deref, DerefMut};
|
||||||
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
|
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
mod accessibility;
|
mod accessibility;
|
||||||
mod focus;
|
mod focus;
|
||||||
mod geometry;
|
mod geometry;
|
||||||
|
@ -46,11 +45,9 @@ use widget::UiImageSize;
|
||||||
///
|
///
|
||||||
/// This includes the most common types in this crate, re-exported for your convenience.
|
/// This includes the most common types in this crate, re-exported for your convenience.
|
||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub use crate::widget::TextBundle;
|
pub use crate::widget::TextBundle;
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub use crate::widget::{Text, TextUiReader, TextUiWriter};
|
pub use crate::widget::{Text, TextUiReader, TextUiWriter};
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
|
@ -183,7 +180,6 @@ impl Plugin for UiPlugin {
|
||||||
.in_set(UiSystem::Layout)
|
.in_set(UiSystem::Layout)
|
||||||
.before(TransformSystem::TransformPropagate);
|
.before(TransformSystem::TransformPropagate);
|
||||||
|
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
let ui_layout_system_config = ui_layout_system_config
|
let ui_layout_system_config = ui_layout_system_config
|
||||||
// Text and Text2D operate on disjoint sets of entities
|
// Text and Text2D operate on disjoint sets of entities
|
||||||
.ambiguous_with(bevy_text::update_text2d_layout)
|
.ambiguous_with(bevy_text::update_text2d_layout)
|
||||||
|
@ -213,7 +209,6 @@ impl Plugin for UiPlugin {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
build_text_interop(app);
|
build_text_interop(app);
|
||||||
|
|
||||||
build_ui_render(app);
|
build_ui_render(app);
|
||||||
|
@ -231,8 +226,6 @@ impl Plugin for UiPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A function that should be called from [`UiPlugin::build`] when [`bevy_text`] is enabled.
|
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
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;
|
||||||
|
|
|
@ -6,7 +6,6 @@ pub use taffy::style::AvailableSpace;
|
||||||
|
|
||||||
use crate::widget::ImageMeasure;
|
use crate::widget::ImageMeasure;
|
||||||
|
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
use crate::widget::TextMeasure;
|
use crate::widget::TextMeasure;
|
||||||
|
|
||||||
impl core::fmt::Debug for ContentSize {
|
impl core::fmt::Debug for ContentSize {
|
||||||
|
@ -20,13 +19,8 @@ pub struct MeasureArgs<'a> {
|
||||||
pub height: Option<f32>,
|
pub height: Option<f32>,
|
||||||
pub available_width: AvailableSpace,
|
pub available_width: AvailableSpace,
|
||||||
pub available_height: AvailableSpace,
|
pub available_height: AvailableSpace,
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
pub font_system: &'a mut bevy_text::cosmic_text::FontSystem,
|
pub font_system: &'a mut bevy_text::cosmic_text::FontSystem,
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
pub buffer: Option<&'a mut bevy_text::ComputedTextBlock>,
|
pub buffer: Option<&'a mut bevy_text::ComputedTextBlock>,
|
||||||
// When `bevy_text` is disabled, use `PhantomData` in order to keep lifetime in type signature.
|
|
||||||
#[cfg(not(feature = "bevy_text"))]
|
|
||||||
pub font_system: core::marker::PhantomData<&'a mut ()>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A `Measure` is used to compute the size of a ui node
|
/// A `Measure` is used to compute the size of a ui node
|
||||||
|
@ -42,7 +36,7 @@ pub trait Measure: Send + Sync + 'static {
|
||||||
/// by wrapping them in a closure and a Custom variant that allows arbitrary measurement closures if required.
|
/// by wrapping them in a closure and a Custom variant that allows arbitrary measurement closures if required.
|
||||||
pub enum NodeMeasure {
|
pub enum NodeMeasure {
|
||||||
Fixed(FixedMeasure),
|
Fixed(FixedMeasure),
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
Text(TextMeasure),
|
Text(TextMeasure),
|
||||||
Image(ImageMeasure),
|
Image(ImageMeasure),
|
||||||
Custom(Box<dyn Measure>),
|
Custom(Box<dyn Measure>),
|
||||||
|
@ -52,7 +46,7 @@ impl Measure for NodeMeasure {
|
||||||
fn measure(&mut self, measure_args: MeasureArgs, style: &taffy::Style) -> Vec2 {
|
fn measure(&mut self, measure_args: MeasureArgs, style: &taffy::Style) -> Vec2 {
|
||||||
match self {
|
match self {
|
||||||
NodeMeasure::Fixed(fixed) => fixed.measure(measure_args, style),
|
NodeMeasure::Fixed(fixed) => fixed.measure(measure_args, style),
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
NodeMeasure::Text(text) => text.measure(measure_args, style),
|
NodeMeasure::Text(text) => text.measure(measure_args, style),
|
||||||
NodeMeasure::Image(image) => image.measure(measure_args, style),
|
NodeMeasure::Image(image) => image.measure(measure_args, style),
|
||||||
NodeMeasure::Custom(custom) => custom.measure(measure_args, style),
|
NodeMeasure::Custom(custom) => custom.measure(measure_args, style),
|
||||||
|
|
|
@ -40,7 +40,7 @@ use bevy_render::{
|
||||||
};
|
};
|
||||||
use bevy_sprite::TextureAtlasLayout;
|
use bevy_sprite::TextureAtlasLayout;
|
||||||
use bevy_sprite::{BorderRect, ImageScaleMode, SpriteAssetEvents, TextureAtlas};
|
use bevy_sprite::{BorderRect, ImageScaleMode, SpriteAssetEvents, TextureAtlas};
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
use bevy_text::{ComputedTextBlock, PositionedGlyph, TextColor, TextLayoutInfo};
|
use bevy_text::{ComputedTextBlock, PositionedGlyph, TextColor, TextLayoutInfo};
|
||||||
use bevy_transform::components::GlobalTransform;
|
use bevy_transform::components::GlobalTransform;
|
||||||
use bevy_utils::HashMap;
|
use bevy_utils::HashMap;
|
||||||
|
@ -112,7 +112,6 @@ pub fn build_ui_render(app: &mut App) {
|
||||||
extract_uinode_background_colors.in_set(RenderUiSystem::ExtractBackgrounds),
|
extract_uinode_background_colors.in_set(RenderUiSystem::ExtractBackgrounds),
|
||||||
extract_uinode_images.in_set(RenderUiSystem::ExtractImages),
|
extract_uinode_images.in_set(RenderUiSystem::ExtractImages),
|
||||||
extract_uinode_borders.in_set(RenderUiSystem::ExtractBorders),
|
extract_uinode_borders.in_set(RenderUiSystem::ExtractBorders),
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
extract_text_sections.in_set(RenderUiSystem::ExtractText),
|
extract_text_sections.in_set(RenderUiSystem::ExtractText),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -584,7 +583,6 @@ pub fn extract_default_ui_camera_view(
|
||||||
transparent_render_phases.retain(|entity, _| live_entities.contains(entity));
|
transparent_render_phases.retain(|entity, _| live_entities.contains(entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn extract_text_sections(
|
pub fn extract_text_sections(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
|
|
|
@ -87,10 +87,7 @@ impl Measure for ImageMeasure {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
type UpdateImageFilter = (With<Node>, Without<crate::prelude::Text>);
|
type UpdateImageFilter = (With<Node>, Without<crate::prelude::Text>);
|
||||||
#[cfg(not(feature = "bevy_text"))]
|
|
||||||
type UpdateImageFilter = With<Node>;
|
|
||||||
|
|
||||||
/// Updates content size of the node based on the image provided
|
/// Updates content size of the node based on the image provided
|
||||||
pub fn update_image_content_size_system(
|
pub fn update_image_content_size_system(
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
mod button;
|
mod button;
|
||||||
mod image;
|
mod image;
|
||||||
mod label;
|
mod label;
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
mod text;
|
mod text;
|
||||||
|
|
||||||
pub use button::*;
|
pub use button::*;
|
||||||
pub use image::*;
|
pub use image::*;
|
||||||
pub use label::*;
|
pub use label::*;
|
||||||
#[cfg(feature = "bevy_text")]
|
|
||||||
pub use text::*;
|
pub use text::*;
|
||||||
|
|
Loading…
Reference in a new issue