Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion crates/bevy_feathers/src/controls/radio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ impl FeathersRadio {
RadioOutline
FocusIndicator
ThemeBorderColor(tokens::RADIO_BORDER)
ThemeBackgroundColor(tokens::RADIO_BG)
Children [(
Node {
width: px(8),
Expand Down Expand Up @@ -170,6 +171,7 @@ pub fn radio_bundle<C: SpawnableList<ChildOf> + Send + Sync + 'static, B: Bundle
RadioOutline,
FocusIndicator,
ThemeBorderColor(tokens::RADIO_BORDER),
ThemeBackgroundColor(tokens::RADIO_BG),
children![(
Node {
width: px(8),
Expand Down Expand Up @@ -330,6 +332,28 @@ fn set_radio_styles(
font_color: &InheritableThemeTextColor,
commands: &mut Commands,
) {
let outline_bg_token = if checked {
if disabled {
tokens::RADIO_BG_CHECKED_DISABLED
} else if pressed && !activate_on_press {
tokens::RADIO_BG_CHECKED_PRESSED
} else if hovered {
tokens::RADIO_BG_CHECKED_HOVER
} else {
tokens::RADIO_BG_CHECKED
}
} else {
if disabled {
tokens::RADIO_BG_DISABLED
} else if pressed && !activate_on_press {
tokens::RADIO_BG_PRESSED
} else if hovered {
tokens::RADIO_BG_HOVER
} else {
tokens::RADIO_BG
}
};

let outline_border_token = if checked {
if disabled {
tokens::RADIO_BORDER_CHECKED_DISABLED
Expand Down Expand Up @@ -376,7 +400,8 @@ fn set_radio_styles(
if outline_border.0 != outline_border_token {
commands
.entity(outline_ent)
.insert(ThemeBorderColor(outline_border_token));
.insert(ThemeBorderColor(outline_border_token))
.insert(ThemeBackgroundColor(outline_bg_token));
}

// Change mark color
Expand Down
10 changes: 9 additions & 1 deletion crates/bevy_feathers/src/dark_theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,15 @@ pub fn create_dark_theme() -> ThemeProps {
tokens::CHECKBOX_TEXT_DISABLED,
palette::LIGHT_GRAY_1.with_alpha(0.5),
),
// Radio
// Radio (default look is no background)
(tokens::RADIO_BG, Color::NONE),
(tokens::RADIO_BG_HOVER, Color::NONE),
(tokens::RADIO_BG_PRESSED, Color::NONE),
(tokens::RADIO_BG_DISABLED, Color::NONE),
(tokens::RADIO_BG_CHECKED, Color::NONE),
(tokens::RADIO_BG_CHECKED_HOVER, Color::NONE),
(tokens::RADIO_BG_CHECKED_PRESSED, Color::NONE),
(tokens::RADIO_BG_CHECKED_DISABLED, Color::NONE),
(tokens::RADIO_BORDER, palette::GRAY_3),
(tokens::RADIO_BORDER_HOVER, palette::GRAY_3.lighter(0.05)),
(tokens::RADIO_BORDER_PRESSED, palette::GRAY_3.lighter(0.1)),
Expand Down
19 changes: 19 additions & 0 deletions crates/bevy_feathers/src/tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,25 @@ pub const CHECKBOX_TEXT_DISABLED: ThemeToken =

// Radio button

/// Background of the radio button
pub const RADIO_BG: ThemeToken = ThemeToken::new_static("feathers.radio.bg");
/// Background of the radio button (hovered)
pub const RADIO_BG_HOVER: ThemeToken = ThemeToken::new_static("feathers.radio.bg.hover");
/// Background of the radio button (pressed)
pub const RADIO_BG_PRESSED: ThemeToken = ThemeToken::new_static("feathers.radio.bg.pressed");
/// Background of the radio button (disabled)
pub const RADIO_BG_DISABLED: ThemeToken = ThemeToken::new_static("feathers.radio.bg.disabled");
/// Background of the radio button (checked)
pub const RADIO_BG_CHECKED: ThemeToken = ThemeToken::new_static("feathers.radio.bg.checked");
/// Background of the radio button (checked+hovered)
pub const RADIO_BG_CHECKED_HOVER: ThemeToken =
ThemeToken::new_static("feathers.radio.bg.checked.hover");
/// Background of the radio button (checked+pressed)
pub const RADIO_BG_CHECKED_PRESSED: ThemeToken =
ThemeToken::new_static("feathers.radio.bg.checked.pressed");
/// Background of the radio button (checked+disabled)
pub const RADIO_BG_CHECKED_DISABLED: ThemeToken =
ThemeToken::new_static("feathers.radio.bg.checked.disabled");
/// Border around the radio button
pub const RADIO_BORDER: ThemeToken = ThemeToken::new_static("feathers.radio.border");
/// Border around the radio button (hovered)
Expand Down