diff options
Diffstat (limited to '')
| -rw-r--r-- | style/src/lib.rs | 1 | ||||
| -rw-r--r-- | style/src/rule.rs | 89 | ||||
| -rw-r--r-- | style/src/theme.rs | 43 | 
3 files changed, 0 insertions, 133 deletions
diff --git a/style/src/lib.rs b/style/src/lib.rs index c8fb9ffe..09a943aa 100644 --- a/style/src/lib.rs +++ b/style/src/lib.rs @@ -20,7 +20,6 @@ pub mod application;  pub mod menu;  pub mod pane_grid;  pub mod pick_list; -pub mod rule;  pub mod svg;  pub mod text_editor;  pub mod theme; diff --git a/style/src/rule.rs b/style/src/rule.rs deleted file mode 100644 index 12980da7..00000000 --- a/style/src/rule.rs +++ /dev/null @@ -1,89 +0,0 @@ -//! Change the appearance of a rule. -use crate::core::border; -use crate::core::Color; - -/// The appearance of a rule. -#[derive(Debug, Clone, Copy)] -pub struct Appearance { -    /// The color of the rule. -    pub color: Color, -    /// The width (thickness) of the rule line. -    pub width: u16, -    /// The radius of the line corners. -    pub radius: border::Radius, -    /// The [`FillMode`] of the rule. -    pub fill_mode: FillMode, -} - -/// A set of rules that dictate the style of a rule. -pub trait StyleSheet { -    /// The supported style of the [`StyleSheet`]. -    type Style: Default; - -    /// Produces the style of a rule. -    fn appearance(&self, style: &Self::Style) -> Appearance; -} - -/// The fill mode of a rule. -#[derive(Debug, Clone, Copy)] -pub enum FillMode { -    /// Fill the whole length of the container. -    Full, -    /// Fill a percent of the length of the container. The rule -    /// will be centered in that container. -    /// -    /// The range is `[0.0, 100.0]`. -    Percent(f32), -    /// Uniform offset from each end, length units. -    Padded(u16), -    /// Different offset on each end of the rule, length units. -    /// First = top or left. -    AsymmetricPadding(u16, u16), -} - -impl FillMode { -    /// Return the starting offset and length of the rule. -    /// -    /// * `space` - The space to fill. -    /// -    /// # Returns -    /// -    /// * (`starting_offset`, `length`) -    pub fn fill(&self, space: f32) -> (f32, f32) { -        match *self { -            FillMode::Full => (0.0, space), -            FillMode::Percent(percent) => { -                if percent >= 100.0 { -                    (0.0, space) -                } else { -                    let percent_width = (space * percent / 100.0).round(); - -                    (((space - percent_width) / 2.0).round(), percent_width) -                } -            } -            FillMode::Padded(padding) => { -                if padding == 0 { -                    (0.0, space) -                } else { -                    let padding = padding as f32; -                    let mut line_width = space - (padding * 2.0); -                    if line_width < 0.0 { -                        line_width = 0.0; -                    } - -                    (padding, line_width) -                } -            } -            FillMode::AsymmetricPadding(first_pad, second_pad) => { -                let first_pad = first_pad as f32; -                let second_pad = second_pad as f32; -                let mut line_width = space - first_pad - second_pad; -                if line_width < 0.0 { -                    line_width = 0.0; -                } - -                (first_pad, line_width) -            } -        } -    } -} diff --git a/style/src/theme.rs b/style/src/theme.rs index 8ed15408..a7a95ab0 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -8,7 +8,6 @@ use crate::core::widget::text;  use crate::menu;  use crate::pane_grid;  use crate::pick_list; -use crate::rule;  use crate::svg;  use crate::text_editor;  use crate::toggler; @@ -511,48 +510,6 @@ impl pane_grid::StyleSheet for Theme {      }  } -/// The style of a rule. -#[derive(Default)] -pub enum Rule { -    /// The default style. -    #[default] -    Default, -    /// A custom style. -    Custom(Box<dyn rule::StyleSheet<Style = Theme>>), -} - -impl<T: Fn(&Theme) -> rule::Appearance + 'static> From<T> for Rule { -    fn from(f: T) -> Self { -        Self::Custom(Box::new(f)) -    } -} - -impl rule::StyleSheet for Theme { -    type Style = Rule; - -    fn appearance(&self, style: &Self::Style) -> rule::Appearance { -        let palette = self.extended_palette(); - -        match style { -            Rule::Default => rule::Appearance { -                color: palette.background.strong.color, -                width: 1, -                radius: 0.0.into(), -                fill_mode: rule::FillMode::Full, -            }, -            Rule::Custom(custom) => custom.appearance(self), -        } -    } -} - -impl<T: Fn(&Theme) -> rule::Appearance> rule::StyleSheet for T { -    type Style = Theme; - -    fn appearance(&self, style: &Self::Style) -> rule::Appearance { -        (self)(style) -    } -} -  /**   * Svg   */  | 
