Skip to content

Commit

Permalink
Add a global gesture to take a screenshot
Browse files Browse the repository at this point in the history
  • Loading branch information
baskerville committed Mar 9, 2019
1 parent 8568ebf commit 260b563
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions doc/MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ Hold the next/previous page icon to go the next/previous chapter.

# Home & Reader

Tap two diagonally opposite corners to take a screenshot.

## Menus

You can select a menu entry *without closing the menu* by holding it.
Expand Down
14 changes: 12 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::settings::{Settings, SETTINGS_PATH};
use crate::frontlight::{Frontlight, StandardFrontlight, NaturalFrontlight, PremixedFrontlight};
use crate::lightsensor::{LightSensor, KoboLightSensor};
use crate::battery::{Battery, KoboBattery};
use crate::geom::Rectangle;
use crate::geom::{Rectangle, Edge};
use crate::view::home::Home;
use crate::view::reader::Reader;
use crate::view::confirmation::Confirmation;
Expand Down Expand Up @@ -564,7 +564,17 @@ pub fn run() -> Result<(), Error> {
power_off(&mut history, &mut updating, &mut context);
exit_status = ExitStatus::PowerOff;
break;
}
},
GestureEvent::MultiTap(points) => {
let mut rect = context.fb.rect();
let w = rect.width() as i32;
let h = rect.height() as i32;
let m = w.min(h);
rect.shrink(&Edge::uniform(m / 12));
if (points[0].dist2(points[1]) >= rect.diag2()) {
tx.send(Event::Select(EntryId::TakeScreenshot)).unwrap();
}
},
_ => {
handle_event(view.as_mut(), &evt, &tx, &mut bus, &mut context);
},
Expand Down
4 changes: 4 additions & 0 deletions src/geom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,10 @@ impl Rectangle {
}
}

pub fn diag2(&self) -> u32 {
self.min.dist2(self.max)
}

pub fn includes(&self, pt: Point) -> bool {
self.min.x <= pt.x && pt.x < self.max.x &&
self.min.y <= pt.y && pt.y < self.max.y
Expand Down

0 comments on commit 260b563

Please sign in to comment.