diff options
| author | Joe Carstairs <me@joeac.net> | 2026-02-07 11:52:08 +0000 |
|---|---|---|
| committer | Joe Carstairs <me@joeac.net> | 2026-02-07 12:02:27 +0000 |
| commit | 1664e741ad35ce52a01788c34029f0b2ea477e32 (patch) | |
| tree | dd6bd7c83a7e834c75815a786d67b5188cdd1f48 /schist_desktop_gui/src/gui/components/text.rs | |
| parent | 179878d12ba10ac242da2044f4c6dfe4d4829e59 (diff) | |
task-001: can navigate file screen options with keyboard
Diffstat (limited to 'schist_desktop_gui/src/gui/components/text.rs')
| -rw-r--r-- | schist_desktop_gui/src/gui/components/text.rs | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/schist_desktop_gui/src/gui/components/text.rs b/schist_desktop_gui/src/gui/components/text.rs index a3093ac..d171043 100644 --- a/schist_desktop_gui/src/gui/components/text.rs +++ b/schist_desktop_gui/src/gui/components/text.rs @@ -1,6 +1,6 @@ use std::borrow::Borrow; -use crate::style::*; +use crate::{impl_focusable, style::*}; #[derive(Clone, Debug, PartialEq)] pub struct Text { @@ -8,12 +8,14 @@ pub struct Text { colour: Option<Colour>, size: Option<Size>, strength: Option<Strength>, + is_focused: bool, } #[derive(Clone, Debug, PartialEq)] enum Colour { Danger, Primary, + Highlight, } #[derive(Clone, Debug, PartialEq)] @@ -35,6 +37,7 @@ impl Text { colour: Some(Colour::Primary), size: Some(Size::Base), strength: Some(Strength::Base), + is_focused: false, } } @@ -44,6 +47,7 @@ impl Text { colour: None, size: None, strength: None, + is_focused: false, } } @@ -71,6 +75,17 @@ impl Text { ..self.clone() } } + + pub fn highlight_maybe(&self, do_highlight: bool) -> Self { + if do_highlight { + Self { + colour: Some(Colour::Highlight), + ..self.clone() + } + } else { + self.clone() + } + } } impl<'a, Message> From<Text> for iced::Element<'a, Message> { @@ -111,8 +126,16 @@ where (Some(Colour::Primary), Some(Strength::Weak)) => { Some(theme.extended_palette().primary.weak.text) } + (Some(Colour::Highlight), Some(Strength::Base) | None) => { + Some(theme.extended_palette().primary.base.color) + } + (Some(Colour::Highlight), Some(Strength::Weak)) => { + Some(theme.extended_palette().primary.weak.color) + } (None, _) => None, }, }) .into() } + +impl_focusable!(Text); |
