Skip to content

Commit 140d5cd

Browse files
committed
rebase fixes
1 parent df31682 commit 140d5cd

File tree

2 files changed

+49
-53
lines changed

2 files changed

+49
-53
lines changed

examples/animation/animation_masks.rs

Lines changed: 33 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -157,18 +157,15 @@ fn setup_scene(
157157
// Creates the UI.
158158
fn setup_ui(mut commands: Commands) {
159159
// Add help text.
160-
commands.spawn(
161-
TextBundle::from_section(
162-
"Click on a button to toggle animations for its associated bones",
163-
TextStyle::default(),
164-
)
165-
.with_style(Style {
160+
commands.spawn((
161+
TextNEW::new("Click on a button to toggle animations for its associated bones"),
162+
Style {
166163
position_type: PositionType::Absolute,
167164
left: Val::Px(12.0),
168165
top: Val::Px(12.0),
169166
..default()
170-
}),
171-
);
167+
},
168+
));
172169

173170
// Add the buttons that allow the user to toggle mask groups on and off.
174171
commands
@@ -287,14 +284,14 @@ fn add_mask_group_control(parent: &mut ChildBuilder, label: &str, width: Val, ma
287284
background_color: Color::BLACK.into(),
288285
..default()
289286
})
290-
.with_child(TextBundle {
291-
text: Text::from_section(label, label_text_style.clone()),
292-
style: Style {
287+
.with_child((
288+
TextNEW::new(label),
289+
label_text_style.clone(),
290+
Style {
293291
margin: UiRect::vertical(Val::Px(3.0)),
294292
..default()
295293
},
296-
..default()
297-
});
294+
));
298295

299296
builder
300297
.spawn(NodeBundle {
@@ -338,29 +335,24 @@ fn add_mask_group_control(parent: &mut ChildBuilder, label: &str, width: Val, ma
338335
border_color: BorderColor(Color::WHITE),
339336
..default()
340337
})
341-
.with_child(
342-
TextBundle {
343-
style: Style {
344-
flex_grow: 1.0,
345-
margin: UiRect::vertical(Val::Px(3.0)),
346-
..default()
347-
},
348-
text: Text::from_section(
349-
format!("{:?}", label),
350-
if index > 0 {
351-
button_text_style.clone()
352-
} else {
353-
selected_button_text_style.clone()
354-
},
355-
),
338+
.with_child((
339+
TextNEW(format!("{:?}", label)),
340+
if index > 0 {
341+
button_text_style.clone()
342+
} else {
343+
selected_button_text_style.clone()
344+
},
345+
TextBlock::new_with_justify(JustifyText::Center),
346+
Style {
347+
flex_grow: 1.0,
348+
margin: UiRect::vertical(Val::Px(3.0)),
356349
..default()
357-
}
358-
.with_text_justify(JustifyText::Center),
359-
)
360-
.insert(AnimationControl {
361-
group_id: mask_group_id,
362-
label: *label,
363-
});
350+
},
351+
AnimationControl {
352+
group_id: mask_group_id,
353+
label: *label,
354+
},
355+
));
364356
}
365357
});
366358
});
@@ -481,7 +473,8 @@ fn handle_button_toggles(
481473
// A system that updates the UI based on the current app state.
482474
fn update_ui(
483475
mut animation_controls: Query<(&AnimationControl, &mut BackgroundColor, &Children)>,
484-
mut texts: Query<&mut Text>,
476+
texts: Query<Entity, With<TextNEW>>,
477+
mut writer: UiTextWriter,
485478
app_state: Res<AppState>,
486479
) {
487480
for (animation_control, mut background_color, kids) in animation_controls.iter_mut() {
@@ -495,13 +488,13 @@ fn update_ui(
495488
};
496489

497490
for &kid in kids {
498-
let Ok(mut text) = texts.get_mut(kid) else {
491+
let Ok(text) = texts.get(kid) else {
499492
continue;
500493
};
501494

502-
for section in &mut text.sections {
503-
section.style.color = if enabled { Color::BLACK } else { Color::WHITE };
504-
}
495+
writer.for_each_style(text, |mut style| {
496+
style.color = if enabled { Color::BLACK } else { Color::WHITE };
497+
});
505498
}
506499
}
507500
}

examples/picking/simple_picking.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,15 @@ fn setup(
1818
mut materials: ResMut<Assets<StandardMaterial>>,
1919
) {
2020
commands
21-
.spawn(TextBundle {
22-
text: Text::from_section("Click Me to get a box", TextStyle::default()),
23-
style: Style {
21+
.spawn((
22+
TextNEW::new("Click Me to get a box"),
23+
Style {
2424
position_type: PositionType::Absolute,
2525
top: Val::Percent(12.0),
2626
left: Val::Percent(12.0),
2727
..default()
2828
},
29-
..Default::default()
30-
})
29+
))
3130
.observe(
3231
|_click: Trigger<Pointer<Click>>,
3332
mut commands: Commands,
@@ -42,14 +41,18 @@ fn setup(
4241
*num += 1;
4342
},
4443
)
45-
.observe(|evt: Trigger<Pointer<Out>>, mut texts: Query<&mut Text>| {
46-
let mut text = texts.get_mut(evt.entity()).unwrap();
47-
text.sections[0].style.color = WHITE.into();
48-
})
49-
.observe(|evt: Trigger<Pointer<Over>>, mut texts: Query<&mut Text>| {
50-
let mut text = texts.get_mut(evt.entity()).unwrap();
51-
text.sections[0].style.color = BLUE.into();
52-
});
44+
.observe(
45+
|evt: Trigger<Pointer<Out>>, mut texts: Query<&mut TextStyle>| {
46+
let mut style = texts.get_mut(evt.entity()).unwrap();
47+
style.color = WHITE.into();
48+
},
49+
)
50+
.observe(
51+
|evt: Trigger<Pointer<Over>>, mut texts: Query<&mut TextStyle>| {
52+
let mut style = texts.get_mut(evt.entity()).unwrap();
53+
style.color = BLUE.into();
54+
},
55+
);
5356
// circular base
5457
commands.spawn((
5558
Mesh3d(meshes.add(Circle::new(4.0))),

0 commit comments

Comments
 (0)