tweaks
This commit is contained in:
parent
58319dffff
commit
83eb23f1d3
2 changed files with 15 additions and 16 deletions
|
@ -1,12 +1,11 @@
|
||||||
use crate::util::display_digits;
|
|
||||||
|
|
||||||
use super::state::NextTimerState;
|
|
||||||
|
|
||||||
use std::{sync::mpsc::Sender, time::Duration};
|
use std::{sync::mpsc::Sender, time::Duration};
|
||||||
|
|
||||||
use egui::{Color32, Direction, Layout, RichText, Ui};
|
use egui::{Color32, Direction, Layout, RichText, Ui};
|
||||||
use egui_extras::{Size, StripBuilder};
|
use egui_extras::{Size, StripBuilder};
|
||||||
|
|
||||||
|
use super::state::NextTimerState;
|
||||||
|
use crate::util::display_digits;
|
||||||
|
|
||||||
pub(crate) fn two_button(
|
pub(crate) fn two_button(
|
||||||
ui: &mut Ui,
|
ui: &mut Ui,
|
||||||
button1: RichText,
|
button1: RichText,
|
||||||
|
@ -15,8 +14,8 @@ pub(crate) fn two_button(
|
||||||
signal2: NextTimerState,
|
signal2: NextTimerState,
|
||||||
sender: Sender<NextTimerState>,
|
sender: Sender<NextTimerState>,
|
||||||
remaining: Duration,
|
remaining: Duration,
|
||||||
color: Color32,
|
digit_color: Color32,
|
||||||
size: f32,
|
digit_size: f32,
|
||||||
) {
|
) {
|
||||||
let sender2 = sender.clone();
|
let sender2 = sender.clone();
|
||||||
StripBuilder::new(ui)
|
StripBuilder::new(ui)
|
||||||
|
@ -42,7 +41,7 @@ pub(crate) fn two_button(
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
display_digits(&mut strip, remaining, color, size);
|
display_digits(&mut strip, remaining, digit_color, digit_size);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,8 +51,8 @@ pub(crate) fn one_button(
|
||||||
signal1: NextTimerState,
|
signal1: NextTimerState,
|
||||||
sender: Sender<NextTimerState>,
|
sender: Sender<NextTimerState>,
|
||||||
remaining: Duration,
|
remaining: Duration,
|
||||||
color: Color32,
|
digit_color: Color32,
|
||||||
size: f32,
|
digit_size: f32,
|
||||||
) {
|
) {
|
||||||
StripBuilder::new(ui)
|
StripBuilder::new(ui)
|
||||||
.size(Size::relative(0.33333))
|
.size(Size::relative(0.33333))
|
||||||
|
@ -66,6 +65,6 @@ pub(crate) fn one_button(
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
display_digits(&mut strip, remaining, color, size);
|
display_digits(&mut strip, remaining, digit_color, digit_size);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ use clap::Parser;
|
||||||
use egui::{Color32, FontId, Layout, RichText, Ui};
|
use egui::{Color32, FontId, Layout, RichText, Ui};
|
||||||
use egui_extras::{Size, StripBuilder};
|
use egui_extras::{Size, StripBuilder};
|
||||||
|
|
||||||
use crate::{cli::Cli, util::*, AIRHORN, DIGIT_FACTOR, PREDATOR_FONT, TEXT_FACTOR};
|
use crate::{cli::Cli, util::*, AIRHORN, DIGIT_FACTOR, MAX_REPAINT, PREDATOR_FONT, TEXT_FACTOR};
|
||||||
|
|
||||||
mod state;
|
mod state;
|
||||||
use state::{ChronoState, NextTimerState, TimerState};
|
use state::{ChronoState, NextTimerState, TimerState};
|
||||||
|
@ -44,8 +44,9 @@ impl Timer {
|
||||||
};
|
};
|
||||||
|
|
||||||
let alarm = if let Some(path) = cli.alarm {
|
let alarm = if let Some(path) = cli.alarm {
|
||||||
let buffer = std::fs::read(&path)
|
let buffer = std::fs::read(&path).unwrap_or_else(|_| {
|
||||||
.unwrap_or_else(|_| panic!("Could not open {:?} for reading.", path));
|
panic!("Could not open alarm sound file {:?} for reading.", path)
|
||||||
|
});
|
||||||
Some(buffer)
|
Some(buffer)
|
||||||
} else if cli.airhorn {
|
} else if cli.airhorn {
|
||||||
Some(AIRHORN.to_owned())
|
Some(AIRHORN.to_owned())
|
||||||
|
@ -66,7 +67,7 @@ impl Timer {
|
||||||
.insert(0, "predator".to_owned());
|
.insert(0, "predator".to_owned());
|
||||||
ctx.egui_ctx.set_fonts(fonts);
|
ctx.egui_ctx.set_fonts(fonts);
|
||||||
}
|
}
|
||||||
ctx.egui_ctx.request_repaint_after(Duration::from_secs(1));
|
ctx.egui_ctx.request_repaint_after(MAX_REPAINT);
|
||||||
let mut timer = Timer {
|
let mut timer = Timer {
|
||||||
duration,
|
duration,
|
||||||
direction,
|
direction,
|
||||||
|
@ -132,7 +133,6 @@ impl Timer {
|
||||||
CountDirection::Down => remaining,
|
CountDirection::Down => remaining,
|
||||||
CountDirection::Up => self.duration - remaining,
|
CountDirection::Up => self.duration - remaining,
|
||||||
};
|
};
|
||||||
// now the numbers
|
|
||||||
let color = Color32::DARK_GRAY;
|
let color = Color32::DARK_GRAY;
|
||||||
let tsize = size * DIGIT_FACTOR;
|
let tsize = size * DIGIT_FACTOR;
|
||||||
one_button(
|
one_button(
|
||||||
|
@ -244,7 +244,7 @@ impl Timer {
|
||||||
sender,
|
sender,
|
||||||
remaining,
|
remaining,
|
||||||
color,
|
color,
|
||||||
tsize,
|
vsize * DIGIT_FACTOR,
|
||||||
);
|
);
|
||||||
if rx.recv().is_ok() {
|
if rx.recv().is_ok() {
|
||||||
self.state = TimerState::Unstarted;
|
self.state = TimerState::Unstarted;
|
||||||
|
|
Loading…
Reference in a new issue