Skip to content

Commit a441939

Browse files
committed
Remove QueuedText (#7414)
## Objective Remove `QueuedText`. `QueuedText` isn't useful. It's exposed in the `bevy_ui` public interface but can't be used for anything because its `entities` field is private. ## Solution Remove the `QueuedText` struct and use a `Local<Vec<Entity>` in its place. ## Changelog * Removed `QueuedText`
1 parent 5d514fb commit a441939

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

crates/bevy_ui/src/widget/text.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ use bevy_text::{
1414
};
1515
use bevy_window::{PrimaryWindow, Window};
1616

17-
#[derive(Debug, Default)]
18-
pub struct QueuedText {
19-
entities: Vec<Entity>,
20-
}
21-
2217
fn scale_value(value: f32, factor: f64) -> f32 {
2318
(value as f64 * factor) as f32
2419
}
@@ -47,7 +42,7 @@ pub fn text_constraint(min_size: Val, size: Val, max_size: Val, scale_factor: f6
4742
#[allow(clippy::too_many_arguments)]
4843
pub fn text_system(
4944
mut commands: Commands,
50-
mut queued_text: Local<QueuedText>,
45+
mut queued_text_ids: Local<Vec<Entity>>,
5146
mut last_scale_factor: Local<f64>,
5247
mut textures: ResMut<Assets<Image>>,
5348
fonts: Res<Assets<Font>>,
@@ -81,24 +76,24 @@ pub fn text_system(
8176
if *last_scale_factor == scale_factor {
8277
// Adds all entities where the text or the style has changed to the local queue
8378
for entity in text_queries.p0().iter() {
84-
queued_text.entities.push(entity);
79+
queued_text_ids.push(entity);
8580
}
8681
} else {
8782
// If the scale factor has changed, queue all text
8883
for entity in text_queries.p1().iter() {
89-
queued_text.entities.push(entity);
84+
queued_text_ids.push(entity);
9085
}
9186
*last_scale_factor = scale_factor;
9287
}
9388

94-
if queued_text.entities.is_empty() {
89+
if queued_text_ids.is_empty() {
9590
return;
9691
}
9792

9893
// Computes all text in the local queue
9994
let mut new_queue = Vec::new();
10095
let mut query = text_queries.p2();
101-
for entity in queued_text.entities.drain(..) {
96+
for entity in queued_text_ids.drain(..) {
10297
if let Ok((text, style, mut calculated_size, text_layout_info)) = query.get_mut(entity) {
10398
let node_size = Vec2::new(
10499
text_constraint(
@@ -153,5 +148,5 @@ pub fn text_system(
153148
}
154149
}
155150

156-
queued_text.entities = new_queue;
151+
*queued_text_ids = new_queue;
157152
}

0 commit comments

Comments
 (0)