Browse Source

ui/pager: add Left/Right movements

Left/Right movements change the horizontal offset by (page width) / 3.
tags/pre-alpha-0.4.0
Manos Pitsidianakis 1 year ago
parent
commit
31a86533c5
Signed by: epilys GPG Key ID: 73627C2F690DF710
1 changed files with 22 additions and 3 deletions
  1. +22
    -3
      ui/src/components/utilities.rs

+ 22
- 3
ui/src/components/utilities.rs View File

@ -474,7 +474,16 @@ impl Component for Pager {
self.cursor.1 += height * multiplier;
}
}
PageMovement::Right(_) | PageMovement::Left(_) => {}
PageMovement::Right(multiplier) => {
let offset = width!(area) / 3;
if self.cursor.0 + offset * multiplier < self.content.size().0 {
self.cursor.0 += offset * multiplier;
}
}
PageMovement::Left(multiplier) => {
let offset = width!(area) / 3;
self.cursor.0 = self.cursor.0.saturating_sub(offset * multiplier);
}
PageMovement::Home => {
self.cursor.1 = 0;
}
@ -525,13 +534,23 @@ impl Component for Pager {
self.dirty = true;
return true;
}
UIEvent::Input(Key::Home) => {
self.movement = Some(PageMovement::Home);
self.dirty = true;
return true;
}
UIEvent::Input(Key::End) => {
self.movement = Some(PageMovement::End);
self.dirty = true;
return true;
}
UIEvent::Input(Key::Left) => {
self.cursor.0 = self.cursor.0.saturating_sub(1);
self.movement = Some(PageMovement::Left(1));
self.dirty = true;
return true;
}
UIEvent::Input(Key::Right) => {
self.cursor.0 = self.cursor.0 + 1;
self.movement = Some(PageMovement::Right(1));
self.dirty = true;
return true;
}

Loading…
Cancel
Save