@@ -157,18 +157,15 @@ fn setup_scene(
157
157
// Creates the UI.
158
158
fn setup_ui ( mut commands : Commands ) {
159
159
// 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 {
166
163
position_type : PositionType :: Absolute ,
167
164
left : Val :: Px ( 12.0 ) ,
168
165
top : Val :: Px ( 12.0 ) ,
169
166
..default ( )
170
- } ) ,
171
- ) ;
167
+ } ,
168
+ ) ) ;
172
169
173
170
// Add the buttons that allow the user to toggle mask groups on and off.
174
171
commands
@@ -287,14 +284,14 @@ fn add_mask_group_control(parent: &mut ChildBuilder, label: &str, width: Val, ma
287
284
background_color : Color :: BLACK . into ( ) ,
288
285
..default ( )
289
286
} )
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 {
293
291
margin : UiRect :: vertical ( Val :: Px ( 3.0 ) ) ,
294
292
..default ( )
295
293
} ,
296
- ..default ( )
297
- } ) ;
294
+ ) ) ;
298
295
299
296
builder
300
297
. spawn ( NodeBundle {
@@ -338,29 +335,24 @@ fn add_mask_group_control(parent: &mut ChildBuilder, label: &str, width: Val, ma
338
335
border_color : BorderColor ( Color :: WHITE ) ,
339
336
..default ( )
340
337
} )
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 ) ) ,
356
349
..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
+ ) ) ;
364
356
}
365
357
} ) ;
366
358
} ) ;
@@ -481,7 +473,8 @@ fn handle_button_toggles(
481
473
// A system that updates the UI based on the current app state.
482
474
fn update_ui (
483
475
mut animation_controls : Query < ( & AnimationControl , & mut BackgroundColor , & Children ) > ,
484
- mut texts : Query < & mut Text > ,
476
+ texts : Query < Entity , With < TextNEW > > ,
477
+ mut writer : UiTextWriter ,
485
478
app_state : Res < AppState > ,
486
479
) {
487
480
for ( animation_control, mut background_color, kids) in animation_controls. iter_mut ( ) {
@@ -495,13 +488,13 @@ fn update_ui(
495
488
} ;
496
489
497
490
for & kid in kids {
498
- let Ok ( mut text) = texts. get_mut ( kid) else {
491
+ let Ok ( text) = texts. get ( kid) else {
499
492
continue ;
500
493
} ;
501
494
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
+ } ) ;
505
498
}
506
499
}
507
500
}
0 commit comments