From 1664e741ad35ce52a01788c34029f0b2ea477e32 Mon Sep 17 00:00:00 2001 From: Joe Carstairs Date: Sat, 7 Feb 2026 11:52:08 +0000 Subject: task-001: can navigate file screen options with keyboard --- schist_desktop_gui/src/gui/components/text.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'schist_desktop_gui/src/gui/components/text.rs') 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, size: Option, strength: Option, + 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 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); -- cgit v1.2.3