summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2020-11-25 21:01:18 +0200
committerManos Pitsidianakis <el13635@mail.ntua.gr>2020-11-25 21:19:22 +0200
commite01275cd93eeb673160273d5a3de12aa22ac91da (patch)
tree151088cf8e375bccc7a734b9b154831212b82a1d /src
parent879af75d887074a36f39c1950f9205eec3bfa18f (diff)
utilities/dialogs: add cursot Unfocused state as default
Diffstat (limited to 'src')
-rw-r--r--src/components/utilities/dialogs.rs47
1 files changed, 46 insertions, 1 deletions
diff --git a/src/components/utilities/dialogs.rs b/src/components/utilities/dialogs.rs
index 8221d069..dcf66df9 100644
--- a/src/components/utilities/dialogs.rs
+++ b/src/components/utilities/dialogs.rs
@@ -29,6 +29,7 @@ const CANCEL_LENGTH: usize = "Cancel".len();
#[derive(Debug, Copy, PartialEq, Clone)]
enum SelectorCursor {
+ Unfocused,
/// Cursor is at an entry
Entry(usize),
/// Cursor is located on the Ok button
@@ -177,6 +178,27 @@ impl<T: 'static + PartialEq + Debug + Clone + Sync + Send> Component for UIDialo
}
return true;
}
+ (UIEvent::Input(Key::Down), SelectorCursor::Unfocused) => {
+ if self.single_only {
+ for c in self.content.row_iter(0..(width - 1), 0) {
+ self.content[c]
+ .set_fg(highlighted_attrs.fg)
+ .set_bg(highlighted_attrs.bg)
+ .set_attrs(highlighted_attrs.attrs);
+ }
+ self.entries[0].1 = true;
+ } else {
+ for c in self.content.row_iter(0..3, 0) {
+ self.content[c]
+ .set_fg(highlighted_attrs.fg)
+ .set_bg(highlighted_attrs.bg)
+ .set_attrs(highlighted_attrs.attrs);
+ }
+ }
+ self.cursor = SelectorCursor::Entry(0);
+ self.dirty = true;
+ return true;
+ }
(UIEvent::Input(Key::Up), SelectorCursor::Entry(c)) if c > 0 => {
if self.single_only {
// Redraw selection
@@ -531,6 +553,29 @@ impl Component for UIConfirmationDialog {
self.dirty = true;
return true;
}
+ (UIEvent::Input(ref key), SelectorCursor::Unfocused)
+ if shortcut!(key == shortcuts["general"]["scroll_down"]) =>
+ {
+ if self.single_only {
+ for c in self.content.row_iter(0..(width - 1), 0) {
+ self.content[c]
+ .set_fg(highlighted_attrs.fg)
+ .set_bg(highlighted_attrs.bg)
+ .set_attrs(highlighted_attrs.attrs);
+ }
+ self.entries[0].1 = true;
+ } else {
+ for c in self.content.row_iter(0..3, 0) {
+ self.content[c]
+ .set_fg(highlighted_attrs.fg)
+ .set_bg(highlighted_attrs.bg)
+ .set_attrs(highlighted_attrs.attrs);
+ }
+ }
+ self.cursor = SelectorCursor::Entry(0);
+ self.dirty = true;
+ return true;
+ }
(UIEvent::Input(ref key), SelectorCursor::Entry(c))
if c < self.entries.len().saturating_sub(1)
&& shortcut!(key == shortcuts["general"]["scroll_down"]) =>
@@ -767,7 +812,7 @@ impl<T: PartialEq + Debug + Clone + Sync + Send, F: 'static + Sync + Send> Selec
single_only,
entries: identifiers,
content,
- cursor: SelectorCursor::Entry(0),
+ cursor: SelectorCursor::Unfocused,
vertical_alignment: Alignment::Center,
horizontal_alignment: Alignment::Center,
title: title.to_string(),