Skip to content

Commit

Permalink
Generalize refresh-every as refresh-rate
Browse files Browse the repository at this point in the history
Since white text on black background can produce much more ghosting that
the opposite, we need to generalize the `refresh-every` setting in order
to be able to specify a separate refresh rate for each context.
  • Loading branch information
Aszarsha authored and baskerville committed Mar 3, 2020
1 parent 14eafe4 commit 29c2c9d
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 64 deletions.
20 changes: 18 additions & 2 deletions src/settings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,17 +214,24 @@ pub struct HomeSettings {
pub hooks: Vec<Hook>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(default, rename_all = "kebab-case")]
pub struct RefreshRateSettings {
pub regular: u8,
pub inverted: u8,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(default, rename_all = "kebab-case")]
pub struct ReaderSettings {
pub refresh_every: u8,
pub finished: FinishedAction,
pub font_path: String,
pub font_family: String,
pub font_size: f32,
pub text_align: TextAlign,
pub margin_width: i32,
pub line_height: f32,
pub refresh_rate: RefreshRateSettings,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand All @@ -251,10 +258,19 @@ impl Default for HomeSettings {
}
}

impl Default for RefreshRateSettings {
fn default() -> Self {
RefreshRateSettings {
regular: 8,
inverted: 2,
}
}
}

impl Default for ReaderSettings {
fn default() -> Self {
ReaderSettings {
refresh_every: 8,
refresh_rate: RefreshRateSettings::default(),
finished: FinishedAction::Notify,
font_path: DEFAULT_FONT_PATH.to_string(),
font_family: DEFAULT_FONT_FAMILY.to_string(),
Expand Down
Loading

0 comments on commit 29c2c9d

Please sign in to comment.