feat: Themable SVGs, applied to window controls

This commit is contained in:
Michael Aaron Murphy 2022-11-01 13:06:00 +01:00
parent 947532413a
commit 4a899189e6
4 changed files with 35 additions and 2 deletions

View file

@ -15,6 +15,7 @@ use iced_style::radio;
use iced_style::rule;
use iced_style::scrollable;
use iced_style::slider;
use iced_style::svg;
use iced_style::text;
use iced_style::text_input;
use iced_style::toggler;
@ -665,6 +666,31 @@ impl scrollable::StyleSheet for Theme {
}
}
#[derive(Default, Clone, Copy)]
pub enum Svg {
Custom(fn(&Theme) -> svg::Appearance),
#[default]
Default,
Accent,
}
impl svg::StyleSheet for Theme {
type Style = Svg;
fn appearance(&self, style: Self::Style) -> svg::Appearance {
let cosmic = self.cosmic();
match style {
Svg::Default => Default::default(),
Svg::Custom(appearance) => appearance(self),
Svg::Accent => svg::Appearance {
fill: Some(cosmic.accent.base.into()),
},
}
}
}
/*
* TODO: Text
*/