Skip to content

Commit e95bcf4

Browse files
committed
lints and lingering example migrations
1 parent 5b7bb0b commit e95bcf4

File tree

10 files changed

+46
-63
lines changed

10 files changed

+46
-63
lines changed

crates/bevy_ui/src/widget/text.rs

-5
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,6 @@ impl Text {
109109
pub fn new(text: impl Into<String>) -> Self {
110110
Self(text.into())
111111
}
112-
113-
/// Makes an empty UI text component.
114-
pub fn empty() -> Self {
115-
Self::new("")
116-
}
117112
}
118113

119114
impl TextRoot for Text {}

examples/3d/anisotropy.rs

+9-12
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,15 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>, app_status: Res
8181

8282
/// Spawns the help text.
8383
fn spawn_text(commands: &mut Commands, app_status: &AppStatus) {
84-
commands.spawn(
85-
TextBundle {
86-
text: app_status.create_help_text(),
87-
..default()
88-
}
89-
.with_style(Style {
84+
commands.spawn((
85+
app_status.create_help_text(),
86+
Style {
9087
position_type: PositionType::Absolute,
9188
bottom: Val::Px(12.0),
9289
left: Val::Px(12.0),
9390
..default()
94-
}),
95-
);
91+
},
92+
));
9693
}
9794

9895
/// For each material, creates a version with the anisotropy removed.
@@ -287,10 +284,10 @@ impl AppStatus {
287284
};
288285

289286
// Build the `Text` object.
290-
Text::from_section(
291-
format!("{}\n{}", material_variant_help_text, light_help_text),
292-
TextStyle::default(),
293-
)
287+
Text(format!(
288+
"{}\n{}",
289+
material_variant_help_text, light_help_text
290+
))
294291
}
295292
}
296293

examples/3d/clearcoat.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -217,18 +217,15 @@ fn spawn_camera(commands: &mut Commands, asset_server: &AssetServer) {
217217

218218
/// Spawns the help text.
219219
fn spawn_text(commands: &mut Commands, light_mode: &LightMode) {
220-
commands.spawn(
221-
TextBundle {
222-
text: light_mode.create_help_text(),
223-
..default()
224-
}
225-
.with_style(Style {
220+
commands.spawn((
221+
light_mode.create_help_text(),
222+
Style {
226223
position_type: PositionType::Absolute,
227224
bottom: Val::Px(12.0),
228225
left: Val::Px(12.0),
229226
..default()
230-
}),
231-
);
227+
},
228+
));
232229
}
233230

234231
/// Moves the light around.
@@ -320,6 +317,6 @@ impl LightMode {
320317
LightMode::Directional => "Press Space to switch to a point light",
321318
};
322319

323-
Text::from_section(help_text, TextStyle::default())
320+
Text::new(help_text)
324321
}
325322
}

examples/state/computed_states.rs

+20-20
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,8 @@ mod ui {
368368
MenuButton::Play,
369369
))
370370
.with_children(|parent| {
371-
parent.spawn(TextBundle::from_section(
372-
"Play",
371+
parent.spawn((
372+
Text::new("Play"),
373373
TextStyle {
374374
font_size: 33.0,
375375
color: Color::srgb(0.9, 0.9, 0.9),
@@ -400,8 +400,8 @@ mod ui {
400400
MenuButton::Tutorial,
401401
))
402402
.with_children(|parent| {
403-
parent.spawn(TextBundle::from_section(
404-
"Tutorial",
403+
parent.spawn((
404+
Text::new("Tutorial"),
405405
TextStyle {
406406
font_size: 33.0,
407407
color: Color::srgb(0.9, 0.9, 0.9),
@@ -501,8 +501,8 @@ mod ui {
501501
MenuButton::Play,
502502
))
503503
.with_children(|parent| {
504-
parent.spawn(TextBundle::from_section(
505-
"Paused",
504+
parent.spawn((
505+
Text::new("Paused"),
506506
TextStyle {
507507
font_size: 33.0,
508508
color: Color::srgb(0.9, 0.9, 0.9),
@@ -533,8 +533,8 @@ mod ui {
533533
},
534534
))
535535
.with_children(|parent| {
536-
parent.spawn(TextBundle::from_section(
537-
"TURBO MODE",
536+
parent.spawn((
537+
Text::new("TURBO MODE"),
538538
TextStyle {
539539
font_size: 33.0,
540540
color: Color::srgb(0.9, 0.3, 0.1),
@@ -575,34 +575,34 @@ mod ui {
575575
},
576576
))
577577
.with_children(|parent| {
578-
parent.spawn(TextBundle::from_section(
579-
"Move the bevy logo with the arrow keys",
578+
parent.spawn((
579+
Text::new("Move the bevy logo with the arrow keys"),
580580
TextStyle {
581581
font_size: 33.0,
582582
color: Color::srgb(0.3, 0.3, 0.7),
583583
..default()
584584
},
585585
));
586-
parent.spawn(TextBundle::from_section(
587-
"Press T to enter TURBO MODE",
586+
parent.spawn((
587+
Text::new("Press T to enter TURBO MODE"),
588588
TextStyle {
589589
font_size: 33.0,
590590
color: Color::srgb(0.3, 0.3, 0.7),
591591
..default()
592592
},
593593
));
594594

595-
parent.spawn(TextBundle::from_section(
596-
"Press SPACE to pause",
595+
parent.spawn((
596+
Text::new("Press SPACE to pause"),
597597
TextStyle {
598598
font_size: 33.0,
599599
color: Color::srgb(0.3, 0.3, 0.7),
600600
..default()
601601
},
602602
));
603603

604-
parent.spawn(TextBundle::from_section(
605-
"Press ESCAPE to return to the menu",
604+
parent.spawn((
605+
Text::new("Press ESCAPE to return to the menu"),
606606
TextStyle {
607607
font_size: 33.0,
608608
color: Color::srgb(0.3, 0.3, 0.7),
@@ -632,17 +632,17 @@ mod ui {
632632
},
633633
))
634634
.with_children(|parent| {
635-
parent.spawn(TextBundle::from_section(
636-
"Press SPACE to resume",
635+
parent.spawn((
636+
Text::new("Press SPACE to resume"),
637637
TextStyle {
638638
font_size: 33.0,
639639
color: Color::srgb(0.3, 0.3, 0.7),
640640
..default()
641641
},
642642
));
643643

644-
parent.spawn(TextBundle::from_section(
645-
"Press ESCAPE to return to the menu",
644+
parent.spawn((
645+
Text::new("Press ESCAPE to return to the menu"),
646646
TextStyle {
647647
font_size: 33.0,
648648
color: Color::srgb(0.3, 0.3, 0.7),

examples/state/custom_transitions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@ fn setup_menu(mut commands: Commands) {
273273
..default()
274274
})
275275
.with_children(|parent| {
276-
parent.spawn(TextBundle::from_section(
277-
"Play",
276+
parent.spawn((
277+
Text::new("Play"),
278278
TextStyle {
279279
font_size: 33.0,
280280
color: Color::srgb(0.9, 0.9, 0.9),

examples/state/states.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ fn setup_menu(mut commands: Commands) {
7878
..default()
7979
})
8080
.with_children(|parent| {
81-
parent.spawn(TextBundle::from_section(
82-
"Play",
81+
parent.spawn((
82+
Text::new("Play"),
8383
TextStyle {
8484
font_size: 33.0,
8585
color: Color::srgb(0.9, 0.9, 0.9),

examples/state/sub_states.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ mod ui {
183183
..default()
184184
})
185185
.with_children(|parent| {
186-
parent.spawn(TextBundle::from_section(
187-
"Play",
186+
parent.spawn((
187+
Text::new("Play"),
188188
TextStyle {
189189
font_size: 33.0,
190190
color: Color::srgb(0.9, 0.9, 0.9),
@@ -238,8 +238,8 @@ mod ui {
238238
..default()
239239
})
240240
.with_children(|parent| {
241-
parent.spawn(TextBundle::from_section(
242-
"Paused",
241+
parent.spawn((
242+
Text::new("Paused"),
243243
TextStyle {
244244
font_size: 33.0,
245245
color: Color::srgb(0.9, 0.9, 0.9),

examples/stress_tests/many_glyphs.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ fn setup(mut commands: Commands) {
5353
let text_block = TextBlock {
5454
justify: JustifyText::Left,
5555
linebreak: LineBreak::AnyCharacter,
56-
..Default::default()
5756
};
5857

5958
commands
@@ -75,11 +74,7 @@ fn setup(mut commands: Commands) {
7574
},
7675
..Default::default()
7776
})
78-
.with_child((
79-
Text(text_string.clone()),
80-
text_style.clone(),
81-
text_block.clone(),
82-
));
77+
.with_child((Text(text_string.clone()), text_style.clone(), text_block));
8378
});
8479

8580
commands.spawn((

examples/stress_tests/text_pipeline.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,14 @@ fn spawn(mut commands: Commands, asset_server: Res<AssetServer>) {
6363
]
6464
};
6565

66-
let spans = (1..50).into_iter().flat_map(|i| make_spans(i).into_iter());
66+
let spans = (1..50).flat_map(|i| make_spans(i).into_iter());
6767

6868
commands
6969
.spawn((
7070
Text2d::default(),
7171
TextBlock {
7272
justify: JustifyText::Center,
7373
linebreak: LineBreak::AnyCharacter,
74-
..Default::default()
7574
},
7675
TextBounds::default(),
7776
))

examples/ui/text_wrap_debug.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ fn spawn(mut commands: Commands, asset_server: Res<AssetServer>) {
123123
Text(message.clone()),
124124
text_style.clone(),
125125
TextBlock::new(JustifyText::Left, linebreak),
126-
BackgroundColor(Color::srgb(0.8 - j as f32 * 0.2, 0., 0.).into()),
126+
BackgroundColor(Color::srgb(0.8 - j as f32 * 0.2, 0., 0.)),
127127
));
128128
}
129129
commands.entity(row_id).add_child(column_id);

0 commit comments

Comments
 (0)