wip: example applet
This commit is contained in:
parent
45ccc8c3d2
commit
b1c3a52589
18 changed files with 525 additions and 103 deletions
|
|
@ -174,11 +174,7 @@ impl Default for Checkbox {
|
|||
impl checkbox::StyleSheet for Theme {
|
||||
type Style = Checkbox;
|
||||
|
||||
fn active(
|
||||
&self,
|
||||
style: &Self::Style,
|
||||
is_checked: bool,
|
||||
) -> checkbox::Appearance {
|
||||
fn active(&self, style: &Self::Style, is_checked: bool) -> checkbox::Appearance {
|
||||
let palette = self.extended_palette();
|
||||
|
||||
match style {
|
||||
|
|
@ -209,11 +205,7 @@ impl checkbox::StyleSheet for Theme {
|
|||
}
|
||||
}
|
||||
|
||||
fn hovered(
|
||||
&self,
|
||||
style: &Self::Style,
|
||||
is_checked: bool,
|
||||
) -> checkbox::Appearance {
|
||||
fn hovered(&self, style: &Self::Style, is_checked: bool) -> checkbox::Appearance {
|
||||
let palette = self.extended_palette();
|
||||
|
||||
match style {
|
||||
|
|
@ -252,11 +244,7 @@ fn checkbox_appearance(
|
|||
is_checked: bool,
|
||||
) -> checkbox::Appearance {
|
||||
checkbox::Appearance {
|
||||
background: Background::Color(if is_checked {
|
||||
accent.color
|
||||
} else {
|
||||
base.color
|
||||
}),
|
||||
background: Background::Color(if is_checked { accent.color } else { base.color }),
|
||||
checkmark_color,
|
||||
border_radius: 4.0,
|
||||
border_width: if is_checked { 0.0 } else { 1.0 },
|
||||
|
|
@ -355,21 +343,17 @@ impl slider::StyleSheet for Theme {
|
|||
Color::TRANSPARENT,
|
||||
),
|
||||
handle: slider::Handle {
|
||||
shape: slider::HandleShape::Circle {
|
||||
radius: 10.0,
|
||||
},
|
||||
shape: slider::HandleShape::Circle { radius: 10.0 },
|
||||
color: cosmic.accent.base.into(),
|
||||
border_color: Color::TRANSPARENT,
|
||||
border_width: 0.0,
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn hovered(&self, style: &Self::Style) -> slider::Appearance {
|
||||
let mut style = self.active(&style);
|
||||
style.handle.shape = slider::HandleShape::Circle {
|
||||
radius: 16.0
|
||||
};
|
||||
style.handle.shape = slider::HandleShape::Circle { radius: 16.0 };
|
||||
style.handle.border_width = 6.0;
|
||||
style.handle.border_color = match self {
|
||||
Theme::Dark => Color::from_rgba8(0xFF, 0xFF, 0xFF, 0.1),
|
||||
|
|
@ -475,11 +459,7 @@ impl radio::StyleSheet for Theme {
|
|||
impl toggler::StyleSheet for Theme {
|
||||
type Style = ();
|
||||
|
||||
fn active(
|
||||
&self,
|
||||
_style: &Self::Style,
|
||||
is_active: bool,
|
||||
) -> toggler::Appearance {
|
||||
fn active(&self, _style: &Self::Style, is_active: bool) -> toggler::Appearance {
|
||||
let palette = self.palette();
|
||||
|
||||
toggler::Appearance {
|
||||
|
|
@ -502,14 +482,10 @@ impl toggler::StyleSheet for Theme {
|
|||
}
|
||||
}
|
||||
|
||||
fn hovered(
|
||||
&self,
|
||||
style: &Self::Style,
|
||||
is_active: bool,
|
||||
) -> toggler::Appearance {
|
||||
fn hovered(&self, style: &Self::Style, is_active: bool) -> toggler::Appearance {
|
||||
//TODO: grab colors from palette
|
||||
match self {
|
||||
Theme::Dark => toggler::Appearance {
|
||||
Theme::Dark => toggler::Appearance {
|
||||
background: if is_active {
|
||||
Color::from_rgb8(0x9f, 0xed, 0xed)
|
||||
} else {
|
||||
|
|
@ -517,14 +493,14 @@ impl toggler::StyleSheet for Theme {
|
|||
},
|
||||
..self.active(&style, is_active)
|
||||
},
|
||||
Theme::Light => toggler::Appearance {
|
||||
Theme::Light => toggler::Appearance {
|
||||
background: if is_active {
|
||||
Color::from_rgb8(0x00, 0x42, 0x62)
|
||||
} else {
|
||||
Color::from_rgb8(0x54, 0x54, 0x54)
|
||||
},
|
||||
..self.active(&style, is_active)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -666,7 +642,6 @@ impl scrollable::StyleSheet for Theme {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Default, Clone, Copy)]
|
||||
pub enum Svg {
|
||||
Custom(fn(&Theme) -> svg::Appearance),
|
||||
|
|
@ -715,7 +690,7 @@ impl text::StyleSheet for Theme {
|
|||
fn appearance(&self, style: Self::Style) -> text::Appearance {
|
||||
match style {
|
||||
Text::Accent => text::Appearance {
|
||||
color: Some(self.cosmic().accent.base.into())
|
||||
color: Some(self.cosmic().accent.base.into()),
|
||||
},
|
||||
Text::Default => Default::default(),
|
||||
Text::Color(c) => text::Appearance { color: Some(c) },
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ impl Palette {
|
|||
background: Color::from_rgb(
|
||||
0x1e as f32 / 255.0,
|
||||
0x1e as f32 / 255.0,
|
||||
0x1e as f32 / 255.0
|
||||
0x1e as f32 / 255.0,
|
||||
),
|
||||
text: Color::from_rgb(
|
||||
0xe4 as f32 / 255.0,
|
||||
|
|
@ -80,8 +80,7 @@ pub struct Extended {
|
|||
}
|
||||
|
||||
lazy_static! {
|
||||
pub static ref EXTENDED_LIGHT: Extended =
|
||||
Extended::generate(Palette::LIGHT);
|
||||
pub static ref EXTENDED_LIGHT: Extended = Extended::generate(Palette::LIGHT);
|
||||
pub static ref EXTENDED_DARK: Extended = Extended::generate(Palette::DARK);
|
||||
}
|
||||
|
||||
|
|
@ -89,22 +88,10 @@ impl Extended {
|
|||
pub fn generate(palette: Palette) -> Self {
|
||||
Self {
|
||||
background: Background::new(palette.background, palette.text),
|
||||
primary: Primary::generate(
|
||||
palette.primary,
|
||||
palette.background,
|
||||
palette.text,
|
||||
),
|
||||
primary: Primary::generate(palette.primary, palette.background, palette.text),
|
||||
secondary: Secondary::generate(palette.background, palette.text),
|
||||
success: Success::generate(
|
||||
palette.success,
|
||||
palette.background,
|
||||
palette.text,
|
||||
),
|
||||
danger: Danger::generate(
|
||||
palette.danger,
|
||||
palette.background,
|
||||
palette.text,
|
||||
),
|
||||
success: Success::generate(palette.success, palette.background, palette.text),
|
||||
danger: Danger::generate(palette.danger, palette.background, palette.text),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue