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 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)
|
||||
};
|
||||
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
use iced_core::Color;
|
||||
|
||||
/// The appearance of a toggler.
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct Appearance {
|
||||
pub background: Color,
|
||||
pub background_border: Option<Color>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue