diff options
Diffstat (limited to '')
| -rw-r--r-- | style/src/lib.rs | 1 | ||||
| -rw-r--r-- | style/src/text_editor.rs | 43 | ||||
| -rw-r--r-- | style/src/theme.rs | 121 | 
3 files changed, 0 insertions, 165 deletions
diff --git a/style/src/lib.rs b/style/src/lib.rs index 259ad793..828f5871 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 text_editor;  pub mod theme;  pub use theme::Theme; diff --git a/style/src/text_editor.rs b/style/src/text_editor.rs deleted file mode 100644 index 87f481e3..00000000 --- a/style/src/text_editor.rs +++ /dev/null @@ -1,43 +0,0 @@ -//! Change the appearance of a text editor. -use crate::core::{Background, Border, Color}; - -/// The appearance of a text input. -#[derive(Debug, Clone, Copy)] -pub struct Appearance { -    /// The [`Background`] of the text editor. -    pub background: Background, -    /// The [`Border`] of the text editor. -    pub border: Border, -} - -/// A set of rules that dictate the style of a text input. -pub trait StyleSheet { -    /// The supported style of the [`StyleSheet`]. -    type Style: Default; - -    /// Produces the style of an active text input. -    fn active(&self, style: &Self::Style) -> Appearance; - -    /// Produces the style of a focused text input. -    fn focused(&self, style: &Self::Style) -> Appearance; - -    /// Produces the [`Color`] of the placeholder of a text input. -    fn placeholder_color(&self, style: &Self::Style) -> Color; - -    /// Produces the [`Color`] of the value of a text input. -    fn value_color(&self, style: &Self::Style) -> Color; - -    /// Produces the [`Color`] of the value of a disabled text input. -    fn disabled_color(&self, style: &Self::Style) -> Color; - -    /// Produces the [`Color`] of the selection of a text input. -    fn selection_color(&self, style: &Self::Style) -> Color; - -    /// Produces the style of an hovered text input. -    fn hovered(&self, style: &Self::Style) -> Appearance { -        self.focused(style) -    } - -    /// Produces the style of a disabled text input. -    fn disabled(&self, style: &Self::Style) -> Appearance; -} diff --git a/style/src/theme.rs b/style/src/theme.rs index 27d5b5e0..78995e23 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::text_editor;  use crate::core::{Background, Border, Color}; @@ -440,123 +439,3 @@ impl pane_grid::StyleSheet for Theme {  }  impl text::StyleSheet for Theme {} - -/// The style of a text input. -#[derive(Default)] -pub enum TextEditor { -    /// The default style. -    #[default] -    Default, -    /// A custom style. -    Custom(Box<dyn text_editor::StyleSheet<Style = Theme>>), -} - -impl text_editor::StyleSheet for Theme { -    type Style = TextEditor; - -    fn active(&self, style: &Self::Style) -> text_editor::Appearance { -        if let TextEditor::Custom(custom) = style { -            return custom.active(self); -        } - -        let palette = self.extended_palette(); - -        text_editor::Appearance { -            background: palette.background.base.color.into(), -            border: Border { -                radius: 2.0.into(), -                width: 1.0, -                color: palette.background.strong.color, -            }, -        } -    } - -    fn hovered(&self, style: &Self::Style) -> text_editor::Appearance { -        if let TextEditor::Custom(custom) = style { -            return custom.hovered(self); -        } - -        let palette = self.extended_palette(); - -        text_editor::Appearance { -            background: palette.background.base.color.into(), -            border: Border { -                radius: 2.0.into(), -                width: 1.0, -                color: palette.background.base.text, -            }, -        } -    } - -    fn focused(&self, style: &Self::Style) -> text_editor::Appearance { -        if let TextEditor::Custom(custom) = style { -            return custom.focused(self); -        } - -        let palette = self.extended_palette(); - -        text_editor::Appearance { -            background: palette.background.base.color.into(), -            border: Border { -                radius: 2.0.into(), -                width: 1.0, -                color: palette.primary.strong.color, -            }, -        } -    } - -    fn placeholder_color(&self, style: &Self::Style) -> Color { -        if let TextEditor::Custom(custom) = style { -            return custom.placeholder_color(self); -        } - -        let palette = self.extended_palette(); - -        palette.background.strong.color -    } - -    fn value_color(&self, style: &Self::Style) -> Color { -        if let TextEditor::Custom(custom) = style { -            return custom.value_color(self); -        } - -        let palette = self.extended_palette(); - -        palette.background.base.text -    } - -    fn selection_color(&self, style: &Self::Style) -> Color { -        if let TextEditor::Custom(custom) = style { -            return custom.selection_color(self); -        } - -        let palette = self.extended_palette(); - -        palette.primary.weak.color -    } - -    fn disabled(&self, style: &Self::Style) -> text_editor::Appearance { -        if let TextEditor::Custom(custom) = style { -            return custom.disabled(self); -        } - -        let palette = self.extended_palette(); - -        text_editor::Appearance { -            background: palette.background.weak.color.into(), -            border: Border { -                radius: 2.0.into(), -                width: 1.0, -                color: palette.background.strong.color, -            }, -        } -    } - -    fn disabled_color(&self, style: &Self::Style) -> Color { -        if let TextEditor::Custom(custom) = style { -            return custom.disabled_color(self); -        } - -        self.placeholder_color(style) -    } -}  | 
