Skip to content

Commit cf90e1c

Browse files
committed
lints and lingering example migrations
1 parent da42e96 commit cf90e1c

File tree

10 files changed

+46
-63
lines changed

10 files changed

+46
-63
lines changed

crates/bevy_ui/src/widget/text.rs

Lines changed: 0 additions & 5 deletions
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

Lines changed: 9 additions & 12 deletions
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

Lines changed: 6 additions & 9 deletions
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

Lines changed: 20 additions & 20 deletions
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),
@@ -498,8 +498,8 @@ mod ui {
498498
MenuButton::Play,
499499
))
500500
.with_children(|parent| {
501-
parent.spawn(TextBundle::from_section(
502-
"Paused",
501+
parent.spawn((
502+
Text::new("Paused"),
503503
TextStyle {
504504
font_size: 33.0,
505505
color: Color::srgb(0.9, 0.9, 0.9),
@@ -530,8 +530,8 @@ mod ui {
530530
},
531531
))
532532
.with_children(|parent| {
533-
parent.spawn(TextBundle::from_section(
534-
"TURBO MODE",
533+
parent.spawn((
534+
Text::new("TURBO MODE"),
535535
TextStyle {
536536
font_size: 33.0,
537537
color: Color::srgb(0.9, 0.3, 0.1),
@@ -572,34 +572,34 @@ mod ui {
572572
},
573573
))
574574
.with_children(|parent| {
575-
parent.spawn(TextBundle::from_section(
576-
"Move the bevy logo with the arrow keys",
575+
parent.spawn((
576+
Text::new("Move the bevy logo with the arrow keys"),
577577
TextStyle {
578578
font_size: 33.0,
579579
color: Color::srgb(0.3, 0.3, 0.7),
580580
..default()
581581
},
582582
));
583-
parent.spawn(TextBundle::from_section(
584-
"Press T to enter TURBO MODE",
583+
parent.spawn((
584+
Text::new("Press T to enter TURBO MODE"),
585585
TextStyle {
586586
font_size: 33.0,
587587
color: Color::srgb(0.3, 0.3, 0.7),
588588
..default()
589589
},
590590
));
591591

592-
parent.spawn(TextBundle::from_section(
593-
"Press SPACE to pause",
592+
parent.spawn((
593+
Text::new("Press SPACE to pause"),
594594
TextStyle {
595595
font_size: 33.0,
596596
color: Color::srgb(0.3, 0.3, 0.7),
597597
..default()
598598
},
599599
));
600600

601-
parent.spawn(TextBundle::from_section(
602-
"Press ESCAPE to return to the menu",
601+
parent.spawn((
602+
Text::new("Press ESCAPE to return to the menu"),
603603
TextStyle {
604604
font_size: 33.0,
605605
color: Color::srgb(0.3, 0.3, 0.7),
@@ -629,17 +629,17 @@ mod ui {
629629
},
630630
))
631631
.with_children(|parent| {
632-
parent.spawn(TextBundle::from_section(
633-
"Press SPACE to resume",
632+
parent.spawn((
633+
Text::new("Press SPACE to resume"),
634634
TextStyle {
635635
font_size: 33.0,
636636
color: Color::srgb(0.3, 0.3, 0.7),
637637
..default()
638638
},
639639
));
640640

641-
parent.spawn(TextBundle::from_section(
642-
"Press ESCAPE to return to the menu",
641+
parent.spawn((
642+
Text::new("Press ESCAPE to return to the menu"),
643643
TextStyle {
644644
font_size: 33.0,
645645
color: Color::srgb(0.3, 0.3, 0.7),

examples/state/custom_transitions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,8 @@ fn setup_menu(mut commands: Commands) {
270270
..default()
271271
})
272272
.with_children(|parent| {
273-
parent.spawn(TextBundle::from_section(
274-
"Play",
273+
parent.spawn((
274+
Text::new("Play"),
275275
TextStyle {
276276
font_size: 33.0,
277277
color: Color::srgb(0.9, 0.9, 0.9),

examples/state/states.rs

Lines changed: 2 additions & 2 deletions
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

Lines changed: 4 additions & 4 deletions
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),
@@ -235,8 +235,8 @@ mod ui {
235235
..default()
236236
})
237237
.with_children(|parent| {
238-
parent.spawn(TextBundle::from_section(
239-
"Paused",
238+
parent.spawn((
239+
Text::new("Paused"),
240240
TextStyle {
241241
font_size: 33.0,
242242
color: Color::srgb(0.9, 0.9, 0.9),

examples/stress_tests/many_glyphs.rs

Lines changed: 1 addition & 6 deletions
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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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)