Introduce Custom style variant for Rule

This commit is contained in:
Héctor Ramón Jiménez 2022-06-01 02:04:23 +02:00
parent c275fde67a
commit e4ca779e43
No known key found for this signature in database
GPG key ID: 140CC052C94F138E

View file

@ -284,17 +284,32 @@ impl pane_grid::StyleSheet for Theme {
/*
* Rule
*/
impl rule::StyleSheet for Theme {
type Style = ();
#[derive(Clone, Copy)]
pub enum Rule {
Default,
Custom(fn(&Theme) -> rule::Appearance),
}
fn style(&self, _style: Self::Style) -> rule::Appearance {
impl Default for Rule {
fn default() -> Self {
Self::Default
}
}
impl rule::StyleSheet for Theme {
type Style = Rule;
fn style(&self, style: Self::Style) -> rule::Appearance {
let palette = self.extended_palette();
rule::Appearance {
color: palette.background.strong.color,
width: 1,
radius: 0.0,
fill_mode: rule::FillMode::Full,
match style {
Rule::Default => rule::Appearance {
color: palette.background.strong.color,
width: 1,
radius: 0.0,
fill_mode: rule::FillMode::Full,
},
Rule::Custom(f) => f(self),
}
}
}