Add is_selected argument in radio::StyleSheet

This commit is contained in:
MG_REX 2022-05-04 18:56:27 +03:00 committed by Héctor Ramón Jiménez
parent 2278bade55
commit d95c216b2d
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
3 changed files with 15 additions and 7 deletions

View file

@ -230,9 +230,9 @@ where
let mut children = layout.children();
let custom_style = if is_mouse_over {
theme.hovered(self.style)
theme.hovered(self.style, self.is_selected)
} else {
theme.active(self.style)
theme.active(self.style, self.is_selected)
};
{

View file

@ -15,7 +15,7 @@ pub struct Appearance {
pub trait StyleSheet {
type Style: Default + Copy;
fn active(&self, style: Self::Style) -> Appearance;
fn active(&self, style: Self::Style, is_selected: bool) -> Appearance;
fn hovered(&self, style: Self::Style) -> Appearance;
fn hovered(&self, style: Self::Style, is_selected: bool) -> Appearance;
}

View file

@ -415,7 +415,11 @@ impl pick_list::StyleSheet for Theme {
impl radio::StyleSheet for Theme {
type Style = ();
fn active(&self, _style: Self::Style) -> radio::Appearance {
fn active(
&self,
_style: Self::Style,
_is_selected: bool,
) -> radio::Appearance {
let palette = self.extended_palette();
radio::Appearance {
@ -427,8 +431,12 @@ impl radio::StyleSheet for Theme {
}
}
fn hovered(&self, style: Self::Style) -> radio::Appearance {
let active = self.active(style);
fn hovered(
&self,
style: Self::Style,
is_selected: bool,
) -> radio::Appearance {
let active = self.active(style, is_selected);
let palette = self.extended_palette();
radio::Appearance {