Introduce Custom style variant for Rule
This commit is contained in:
parent
c275fde67a
commit
e4ca779e43
1 changed files with 23 additions and 8 deletions
|
|
@ -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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue