Skip to content

Commit

Permalink
lints and lingering example migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
UkoeHB committed Oct 9, 2024
1 parent 5b7bb0b commit e95bcf4
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 63 deletions.
5 changes: 0 additions & 5 deletions crates/bevy_ui/src/widget/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,6 @@ impl Text {
pub fn new(text: impl Into<String>) -> Self {
Self(text.into())
}

/// Makes an empty UI text component.
pub fn empty() -> Self {
Self::new("")
}
}

impl TextRoot for Text {}
Expand Down
21 changes: 9 additions & 12 deletions examples/3d/anisotropy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,15 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>, app_status: Res

/// Spawns the help text.
fn spawn_text(commands: &mut Commands, app_status: &AppStatus) {
commands.spawn(
TextBundle {
text: app_status.create_help_text(),
..default()
}
.with_style(Style {
commands.spawn((
app_status.create_help_text(),
Style {
position_type: PositionType::Absolute,
bottom: Val::Px(12.0),
left: Val::Px(12.0),
..default()
}),
);
},
));
}

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

// Build the `Text` object.
Text::from_section(
format!("{}\n{}", material_variant_help_text, light_help_text),
TextStyle::default(),
)
Text(format!(
"{}\n{}",
material_variant_help_text, light_help_text
))
}
}

Expand Down
15 changes: 6 additions & 9 deletions examples/3d/clearcoat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,18 +217,15 @@ fn spawn_camera(commands: &mut Commands, asset_server: &AssetServer) {

/// Spawns the help text.
fn spawn_text(commands: &mut Commands, light_mode: &LightMode) {
commands.spawn(
TextBundle {
text: light_mode.create_help_text(),
..default()
}
.with_style(Style {
commands.spawn((
light_mode.create_help_text(),
Style {
position_type: PositionType::Absolute,
bottom: Val::Px(12.0),
left: Val::Px(12.0),
..default()
}),
);
},
));
}

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

Text::from_section(help_text, TextStyle::default())
Text::new(help_text)
}
}
40 changes: 20 additions & 20 deletions examples/state/computed_states.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ mod ui {
MenuButton::Play,
))
.with_children(|parent| {
parent.spawn(TextBundle::from_section(
"Play",
parent.spawn((
Text::new("Play"),
TextStyle {
font_size: 33.0,
color: Color::srgb(0.9, 0.9, 0.9),
Expand Down Expand Up @@ -400,8 +400,8 @@ mod ui {
MenuButton::Tutorial,
))
.with_children(|parent| {
parent.spawn(TextBundle::from_section(
"Tutorial",
parent.spawn((
Text::new("Tutorial"),
TextStyle {
font_size: 33.0,
color: Color::srgb(0.9, 0.9, 0.9),
Expand Down Expand Up @@ -501,8 +501,8 @@ mod ui {
MenuButton::Play,
))
.with_children(|parent| {
parent.spawn(TextBundle::from_section(
"Paused",
parent.spawn((
Text::new("Paused"),
TextStyle {
font_size: 33.0,
color: Color::srgb(0.9, 0.9, 0.9),
Expand Down Expand Up @@ -533,8 +533,8 @@ mod ui {
},
))
.with_children(|parent| {
parent.spawn(TextBundle::from_section(
"TURBO MODE",
parent.spawn((
Text::new("TURBO MODE"),
TextStyle {
font_size: 33.0,
color: Color::srgb(0.9, 0.3, 0.1),
Expand Down Expand Up @@ -575,34 +575,34 @@ mod ui {
},
))
.with_children(|parent| {
parent.spawn(TextBundle::from_section(
"Move the bevy logo with the arrow keys",
parent.spawn((
Text::new("Move the bevy logo with the arrow keys"),
TextStyle {
font_size: 33.0,
color: Color::srgb(0.3, 0.3, 0.7),
..default()
},
));
parent.spawn(TextBundle::from_section(
"Press T to enter TURBO MODE",
parent.spawn((
Text::new("Press T to enter TURBO MODE"),
TextStyle {
font_size: 33.0,
color: Color::srgb(0.3, 0.3, 0.7),
..default()
},
));

parent.spawn(TextBundle::from_section(
"Press SPACE to pause",
parent.spawn((
Text::new("Press SPACE to pause"),
TextStyle {
font_size: 33.0,
color: Color::srgb(0.3, 0.3, 0.7),
..default()
},
));

parent.spawn(TextBundle::from_section(
"Press ESCAPE to return to the menu",
parent.spawn((
Text::new("Press ESCAPE to return to the menu"),
TextStyle {
font_size: 33.0,
color: Color::srgb(0.3, 0.3, 0.7),
Expand Down Expand Up @@ -632,17 +632,17 @@ mod ui {
},
))
.with_children(|parent| {
parent.spawn(TextBundle::from_section(
"Press SPACE to resume",
parent.spawn((
Text::new("Press SPACE to resume"),
TextStyle {
font_size: 33.0,
color: Color::srgb(0.3, 0.3, 0.7),
..default()
},
));

parent.spawn(TextBundle::from_section(
"Press ESCAPE to return to the menu",
parent.spawn((
Text::new("Press ESCAPE to return to the menu"),
TextStyle {
font_size: 33.0,
color: Color::srgb(0.3, 0.3, 0.7),
Expand Down
4 changes: 2 additions & 2 deletions examples/state/custom_transitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ fn setup_menu(mut commands: Commands) {
..default()
})
.with_children(|parent| {
parent.spawn(TextBundle::from_section(
"Play",
parent.spawn((
Text::new("Play"),
TextStyle {
font_size: 33.0,
color: Color::srgb(0.9, 0.9, 0.9),
Expand Down
4 changes: 2 additions & 2 deletions examples/state/states.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ fn setup_menu(mut commands: Commands) {
..default()
})
.with_children(|parent| {
parent.spawn(TextBundle::from_section(
"Play",
parent.spawn((
Text::new("Play"),
TextStyle {
font_size: 33.0,
color: Color::srgb(0.9, 0.9, 0.9),
Expand Down
8 changes: 4 additions & 4 deletions examples/state/sub_states.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ mod ui {
..default()
})
.with_children(|parent| {
parent.spawn(TextBundle::from_section(
"Play",
parent.spawn((
Text::new("Play"),
TextStyle {
font_size: 33.0,
color: Color::srgb(0.9, 0.9, 0.9),
Expand Down Expand Up @@ -238,8 +238,8 @@ mod ui {
..default()
})
.with_children(|parent| {
parent.spawn(TextBundle::from_section(
"Paused",
parent.spawn((
Text::new("Paused"),
TextStyle {
font_size: 33.0,
color: Color::srgb(0.9, 0.9, 0.9),
Expand Down
7 changes: 1 addition & 6 deletions examples/stress_tests/many_glyphs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ fn setup(mut commands: Commands) {
let text_block = TextBlock {
justify: JustifyText::Left,
linebreak: LineBreak::AnyCharacter,
..Default::default()
};

commands
Expand All @@ -75,11 +74,7 @@ fn setup(mut commands: Commands) {
},
..Default::default()
})
.with_child((
Text(text_string.clone()),
text_style.clone(),
text_block.clone(),
));
.with_child((Text(text_string.clone()), text_style.clone(), text_block));
});

commands.spawn((
Expand Down
3 changes: 1 addition & 2 deletions examples/stress_tests/text_pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,14 @@ fn spawn(mut commands: Commands, asset_server: Res<AssetServer>) {
]
};

let spans = (1..50).into_iter().flat_map(|i| make_spans(i).into_iter());
let spans = (1..50).flat_map(|i| make_spans(i).into_iter());

commands
.spawn((
Text2d::default(),
TextBlock {
justify: JustifyText::Center,
linebreak: LineBreak::AnyCharacter,
..Default::default()
},
TextBounds::default(),
))
Expand Down
2 changes: 1 addition & 1 deletion examples/ui/text_wrap_debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ fn spawn(mut commands: Commands, asset_server: Res<AssetServer>) {
Text(message.clone()),
text_style.clone(),
TextBlock::new(JustifyText::Left, linebreak),
BackgroundColor(Color::srgb(0.8 - j as f32 * 0.2, 0., 0.).into()),
BackgroundColor(Color::srgb(0.8 - j as f32 * 0.2, 0., 0.)),
));
}
commands.entity(row_id).add_child(column_id);
Expand Down

0 comments on commit e95bcf4

Please sign in to comment.