Skip to content

Commit

Permalink
Revert "Reader: add frontlight edges interaction"
Browse files Browse the repository at this point in the history
This reverts commit 791c354.
  • Loading branch information
baskerville committed Apr 11, 2018
1 parent 665cfd9 commit 1046fe8
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 74 deletions.
2 changes: 0 additions & 2 deletions doc/MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ Gestures by region:

Swipe west/east to go to the next/previous page.

Swipe along the left/right edges to adjust the frontlight's intensity/warmth (enabled through the `reader.frontlightEdges` setting).

## Bottom bar

Hold the next/previous page icon to go the next/previous chapter.
Expand Down
16 changes: 0 additions & 16 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,11 @@ pub struct Settings {
pub refresh_every: Option<u8>,
pub summary_size: u8,
pub import: ImportSettings,
pub reader: ReaderSettings,
pub frontlight_levels: LightLevels,
pub frontlight: bool,
pub wifi: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct ReaderSettings {
pub frontlight_edges: bool,
}

impl Default for ReaderSettings {
fn default() -> Self {
ReaderSettings {
frontlight_edges: false,
}
}
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct ImportSettings {
Expand All @@ -54,7 +39,6 @@ impl Default for Settings {
library_path: PathBuf::from("/mnt/onboard"),
refresh_every: Some(24),
summary_size: 1,
reader: ReaderSettings::default(),
import: ImportSettings::default(),
frontlight_levels: LightLevels::Standard(0.0),
frontlight: true,
Expand Down
58 changes: 2 additions & 56 deletions src/view/reader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ use std::path::PathBuf;
use std::collections::{BTreeMap, BTreeSet, VecDeque};
use chrono::Local;
use regex::Regex;
use fnv::FnvHashMap;
use input::{DeviceEvent, FingerStatus};
use input::FingerStatus;
use framebuffer::{Framebuffer, UpdateMode, Pixmap};
use view::{View, Event, Hub, ViewId, EntryKind, EntryId, SliderId, Bus, THICKNESS_MEDIUM};
use unit::{scale_by_dpi, pt_to_px, mm_to_in};
Expand All @@ -37,7 +36,7 @@ use gesture::GestureEvent;
use document::{Document, TocEntry, open, toc_as_html, chapter_at, chapter_relative};
use document::pdf::PdfOpener;
use metadata::{Info, FileInfo, ReaderInfo, PageScheme, Margin, CroppingMargins, make_query};
use geom::{Point, Rectangle, CornerSpec, BorderSpec, Dir, CycleDir, LinearDir, halves};
use geom::{Rectangle, CornerSpec, BorderSpec, Dir, CycleDir, LinearDir, halves};
use color::{BLACK, WHITE};
use app::Context;

Expand All @@ -56,7 +55,6 @@ pub struct Reader {
ephemeral: bool,
refresh_every: Option<u8>,
search_direction: LinearDir,
frontlight_interaction: FnvHashMap<i32, Anchor>,
frame: Rectangle,
scale: f32,
focus: Option<ViewId>,
Expand All @@ -72,17 +70,6 @@ struct Search {
results_count: usize,
}

struct Anchor {
position: Point,
channel: FrontlightChannel,
value: f32,
}

enum FrontlightChannel {
Intensity,
Warmth,
}

impl Default for Search {
fn default() -> Self {
Search {
Expand Down Expand Up @@ -157,7 +144,6 @@ impl Reader {
ephemeral: false,
refresh_every: settings.refresh_every,
search_direction: LinearDir::Forward,
frontlight_interaction: FnvHashMap::default(),
frame,
scale,
focus: None,
Expand Down Expand Up @@ -211,7 +197,6 @@ impl Reader {
ephemeral: true,
refresh_every: context.settings.refresh_every,
search_direction: LinearDir::Forward,
frontlight_interaction: FnvHashMap::default(),
frame,
scale,
focus: None,
Expand Down Expand Up @@ -1037,45 +1022,6 @@ impl View for Reader {
};
true
},
Event::Device(DeviceEvent::Finger { status: FingerStatus::Down, ref id, position, .. }) => {
if context.settings.frontlight && context.settings.reader.frontlight_edges {
let dpi = CURRENT_DEVICE.dpi;
let gutter = 3 * dpi as i32 / 4;
let x1 = self.rect.min.x + gutter;
let x2 = self.rect.max.x - gutter;
// Left gutter: intensity.
if position.x < x1 {
self.frontlight_interaction.insert(*id, Anchor {
position,
channel: FrontlightChannel::Intensity,
value: context.frontlight.intensity(),
});
// Right gutter: warmth.
} else if position.x > x2 {
self.frontlight_interaction.insert(*id, Anchor {
position,
channel: FrontlightChannel::Warmth,
value: context.frontlight.warmth(),
});
}
}
true
},
Event::Device(DeviceEvent::Finger { status: FingerStatus::Motion, ref id, position, .. }) => {
if let Some(anchor) = self.frontlight_interaction.get(id) {
let delta = 100.0 * ((anchor.position.y - position.y) as f32 / self.rect.height() as f32);
let value = (anchor.value + delta).max(0.0).min(100.0);
match anchor.channel {
FrontlightChannel::Intensity => context.frontlight.set_intensity(value),
FrontlightChannel::Warmth => context.frontlight.set_warmth(value),
}
}
true
},
Event::Device(DeviceEvent::Finger { status: FingerStatus::Up, ref id, .. }) => {
self.frontlight_interaction.remove(id);
true
},
Event::Gesture(GestureEvent::Tap(ref center)) if self.rect.includes(center) => {
if self.focus.is_some() {
return true;
Expand Down

0 comments on commit 1046fe8

Please sign in to comment.