Merge pull request #1331 from ThisIsRex/master
`is_selected` property for `Radio` `StyleSheet`
This commit is contained in:
commit
cd5a5f2ed2
4 changed files with 16 additions and 8 deletions
|
|
@ -230,9 +230,9 @@ where
|
||||||
let mut children = layout.children();
|
let mut children = layout.children();
|
||||||
|
|
||||||
let custom_style = if is_mouse_over {
|
let custom_style = if is_mouse_over {
|
||||||
theme.hovered(self.style)
|
theme.hovered(self.style, self.is_selected)
|
||||||
} else {
|
} else {
|
||||||
theme.active(self.style)
|
theme.active(self.style, self.is_selected)
|
||||||
};
|
};
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ pub struct Appearance {
|
||||||
pub trait StyleSheet {
|
pub trait StyleSheet {
|
||||||
type Style: Default + Copy;
|
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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -415,7 +415,11 @@ impl pick_list::StyleSheet for Theme {
|
||||||
impl radio::StyleSheet for Theme {
|
impl radio::StyleSheet for Theme {
|
||||||
type Style = ();
|
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();
|
let palette = self.extended_palette();
|
||||||
|
|
||||||
radio::Appearance {
|
radio::Appearance {
|
||||||
|
|
@ -427,8 +431,12 @@ impl radio::StyleSheet for Theme {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hovered(&self, style: Self::Style) -> radio::Appearance {
|
fn hovered(
|
||||||
let active = self.active(style);
|
&self,
|
||||||
|
style: Self::Style,
|
||||||
|
is_selected: bool,
|
||||||
|
) -> radio::Appearance {
|
||||||
|
let active = self.active(style, is_selected);
|
||||||
let palette = self.extended_palette();
|
let palette = self.extended_palette();
|
||||||
|
|
||||||
radio::Appearance {
|
radio::Appearance {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
use iced_core::Color;
|
use iced_core::Color;
|
||||||
|
|
||||||
/// The appearance of a toggler.
|
/// The appearance of a toggler.
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub struct Appearance {
|
pub struct Appearance {
|
||||||
pub background: Color,
|
pub background: Color,
|
||||||
pub background_border: Option<Color>,
|
pub background_border: Option<Color>,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue