refactor events; watch prep work

This commit is contained in:
galister
2025-06-27 04:16:24 +09:00
parent 1215a50324
commit afb4919970
21 changed files with 613 additions and 420 deletions
+26
View File
@@ -0,0 +1,26 @@
use std::time::{Duration, Instant};
pub struct GuiTimer {
interval: Duration,
next_tick: Instant,
signal: usize,
}
impl GuiTimer {
pub fn new(interval: Duration, signal: usize) -> Self {
Self {
interval,
next_tick: Instant::now() + interval,
signal,
}
}
pub fn check_tick(&mut self) -> Option<usize> {
if self.next_tick > Instant::now() {
return None;
}
self.next_tick = Instant::now() + self.interval;
Some(self.signal)
}
}