Skip to content

Commit

Permalink
Add simultaneous swipe sequence: diamond
Browse files Browse the repository at this point in the history
  • Loading branch information
baskerville committed Dec 6, 2020
1 parent 4187a21 commit f8ff53e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion doc/MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ The following swipe sequences are recognized:
- Bottom left corner: guess the frontlight if there's more than two frontlight presets defined, toggle the frontlight otherwise.
- Bottom right corner: toggle the bitonal mode.

Simultaneously performing an east arrow with the left hand and a west arrow with the right hand will lead you back to the home screen.
Simultaneous swipe sequences:

- Cross (east arrow with the left hand, west arrow with the right hand): go back to the home screen.
- Diamond (west arrow with the left hand, east arrow with the right hand): toggle the top and bottom bars.

### Text Selection

Expand Down
6 changes: 6 additions & 0 deletions src/gesture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ pub enum GestureEvent {
angle: f32,
},
Cross(Point),
Diamond(Point),
HoldFingerShort(Point, i32),
HoldFingerLong(Point, i32),
HoldButtonShort(ButtonCode),
Expand All @@ -89,6 +90,7 @@ impl fmt::Display for GestureEvent {
GestureEvent::Spread { axis, strength, .. } => write!(f, "Spread {} {}", axis, strength),
GestureEvent::Rotate { center, quarter_turns, .. } => write!(f, "Rotate {} {}", center, quarter_turns * 90),
GestureEvent::Cross(pt) => write!(f, "Cross {}", pt),
GestureEvent::Diamond(pt) => write!(f, "Diamond {}", pt),
GestureEvent::HoldFingerShort(pt, id) => write!(f, "Short-held finger {} {}", id, pt),
GestureEvent::HoldFingerLong(pt, id) => write!(f, "Long-held finger {} {}", id, pt),
GestureEvent::HoldButtonShort(code) => write!(f, "Short-held button {:?}", code),
Expand Down Expand Up @@ -226,6 +228,10 @@ pub fn parse_gesture_events(rx: &Receiver<DeviceEvent>, ty: &Sender<Event>) {
(GestureEvent::Arrow { dir: Dir::West, start: s2, end: e2 }, GestureEvent::Arrow { dir: Dir::East, start: s1, end: e1 }) if s1.x < s2.x => {
ty.send(Event::Gesture(GestureEvent::Cross((s1+e1+s2+e2)/4))).ok();
},
(GestureEvent::Arrow { dir: Dir::West, start: s1, end: e1 }, GestureEvent::Arrow { dir: Dir::East, start: s2, end: e2 }) |
(GestureEvent::Arrow { dir: Dir::East, start: s2, end: e2 }, GestureEvent::Arrow { dir: Dir::West, start: s1, end: e1 }) if s1.x < s2.x => {
ty.send(Event::Gesture(GestureEvent::Diamond((s1+e1+s2+e2)/4))).ok();
},
(GestureEvent::Arrow { dir: d1, start: s1, end: e1 }, GestureEvent::Arrow { dir: d2, start: s2, end: e2 }) if d1 == d2 => {
ty.send(Event::Gesture(GestureEvent::MultiArrow {
dir: d1,
Expand Down
4 changes: 4 additions & 0 deletions src/view/reader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2571,6 +2571,10 @@ impl View for Reader {
hub.send(Event::Back).ok();
true
},
Event::Gesture(GestureEvent::Diamond(_)) => {
self.toggle_bars(None, hub, rq, context);
true
},
Event::Gesture(GestureEvent::HoldButtonShort(code, ..)) => {
match code {
ButtonCode::Backward => self.go_to_chapter(CycleDir::Previous, hub, rq, context),
Expand Down

0 comments on commit f8ff53e

Please sign in to comment.