diff --git a/examples/stress_tests/many_buttons.rs b/examples/stress_tests/many_buttons.rs index 28846a7f1e..9cd125ac0d 100644 --- a/examples/stress_tests/many_buttons.rs +++ b/examples/stress_tests/many_buttons.rs @@ -3,6 +3,9 @@ //! To start the demo without text run //! `cargo run --example many_buttons --release no-text` //! +//! //! To start the demo without borders run +//! `cargo run --example many_buttons --release no-borders` +//! //| To do a full layout update each frame run //! `cargo run --example many_buttons --release recompute-layout` //! @@ -87,22 +90,40 @@ fn setup(mut commands: Commands) { }) .with_children(|commands| { let spawn_text = std::env::args().all(|arg| arg != "no-text"); + let border = if std::env::args().all(|arg| arg != "no-borders") { + UiRect::all(Val::Percent(10. / count_f)) + } else { + UiRect::DEFAULT + }; for i in 0..count { for j in 0..count { let color = as_rainbow(j % i.max(1)).into(); - spawn_button(commands, color, count_f, i, j, spawn_text); + let border_color = as_rainbow(i % j.max(1)).into(); + spawn_button( + commands, + color, + count_f, + i, + j, + spawn_text, + border, + border_color, + ); } } }); } +#[allow(clippy::too_many_arguments)] fn spawn_button( commands: &mut ChildBuilder, - color: BackgroundColor, + background_color: BackgroundColor, total: f32, i: usize, j: usize, spawn_text: bool, + border: UiRect, + border_color: BorderColor, ) { let width = 90.0 / total; let mut builder = commands.spawn(( @@ -114,12 +135,14 @@ fn spawn_button( left: Val::Percent(100.0 / total * j as f32), align_items: AlignItems::Center, position_type: PositionType::Absolute, + border, ..default() }, - background_color: color, + background_color, + border_color, ..default() }, - IdleColor(color), + IdleColor(background_color), )); if spawn_text {