Tweak gamepad viewer example style (#11484)

# Objective

Since #10339, the contrast in this example has been very low. While I
was in there, I made a few other tweaks to the style.

Alternative to #10102.

## Solution

- Increase brightness of inactive buttons for higher contrast on the new
clear color
- Combine `DEAD_COLOR` and `EXTENT_COLOR`. These were using the same
value, and combining them might make the intent a little clearer. (This
is the single color for "not the live zone.")
- Make the "stick buttons" slightly smaller, so it's a bit more obvious
that they are sitting inside of the default dead zone.
- Remove explicit text color -- it was the same as the default
- Add top-left margin to the text in the top left, and change the font
size to better match other examples with text in the corner.

## Screenshots

<details>
  <summary>With Bevy's default dead / live zones.</summary>
Before / After


![default](https://github.com/bevyengine/bevy/assets/200550/67bf1f5c-7fc9-4e74-87cf-2a94fcf59a50)
</details>

<details>
<summary>With Bevy's old dead / live zones. (with the upper live zone
boundary != 1.0)</summary>
Before / After


![old](https://github.com/bevyengine/bevy/assets/200550/3aab6a2a-ad57-4749-b2e5-51ed34072b2c)
</details>
This commit is contained in:
Rob Parrett 2024-01-22 23:27:43 -07:00 committed by GitHub
parent f7c498824f
commit 2951ddf3d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -21,12 +21,10 @@ const BUTTONS_Y: f32 = 80.;
const STICKS_X: f32 = 150.;
const STICKS_Y: f32 = -135.;
const NORMAL_BUTTON_COLOR: Color = Color::rgb(0.2, 0.2, 0.2);
const NORMAL_BUTTON_COLOR: Color = Color::rgb(0.3, 0.3, 0.3);
const ACTIVE_BUTTON_COLOR: Color = Color::PURPLE;
const LIVE_COLOR: Color = Color::rgb(0.4, 0.4, 0.4);
const DEAD_COLOR: Color = Color::rgb(0.3, 0.3, 0.3);
const EXTENT_COLOR: Color = Color::rgb(0.3, 0.3, 0.3);
const TEXT_COLOR: Color = Color::WHITE;
const DEAD_COLOR: Color = Color::rgb(0.13, 0.13, 0.13);
#[derive(Component, Deref)]
struct ReactTo(GamepadButtonType);
@ -290,7 +288,7 @@ fn setup_sticks(
parent.spawn(SpriteBundle {
sprite: Sprite {
custom_size: Some(Vec2::splat(STICK_BOUNDS_SIZE * 2.)),
color: EXTENT_COLOR,
color: DEAD_COLOR,
..default()
},
..default()
@ -318,7 +316,6 @@ fn setup_sticks(
// text
let style = TextStyle {
font_size: 16.,
color: TEXT_COLOR,
..default()
};
parent.spawn((
@ -349,7 +346,7 @@ fn setup_sticks(
mesh: meshes.circle.clone(),
material: materials.normal.clone(),
transform: Transform::from_xyz(0., 0., 5.)
.with_scale(Vec2::splat(0.2).extend(1.)),
.with_scale(Vec2::splat(0.15).extend(1.)),
..default()
},
MoveWithAxes {
@ -400,7 +397,6 @@ fn setup_triggers(
format!("{:.3}", 0.),
TextStyle {
font_size: 16.,
color: TEXT_COLOR,
..default()
},
),
@ -424,22 +420,30 @@ fn setup_triggers(
}
fn setup_connected(mut commands: Commands) {
let style = TextStyle {
color: TEXT_COLOR,
font_size: 30.,
let text_style = TextStyle {
font_size: 20.,
..default()
};
commands.spawn((
TextBundle::from_sections([
TextSection {
value: "Connected Gamepads:\n".to_string(),
style: style.clone(),
TextBundle {
text: Text::from_sections([
TextSection {
value: "Connected Gamepads:\n".to_string(),
style: text_style.clone(),
},
TextSection {
value: "None".to_string(),
style: text_style,
},
]),
style: Style {
position_type: PositionType::Absolute,
top: Val::Px(12.),
left: Val::Px(12.),
..default()
},
TextSection {
value: "None".to_string(),
style,
},
]),
..default()
},
ConnectedGamepadsText,
));
}