add a time bar #8

Merged
PlexSheep merged 18 commits from feat/timebar into devel 2024-07-11 16:55:49 +02:00
1 changed files with 6 additions and 7 deletions
Showing only changes of commit d6d9e32c73 - Show all commits

View File

@ -92,11 +92,9 @@ impl UiData {
#[must_use] #[must_use]
#[inline] #[inline]
pub fn changed(&self) -> bool { pub fn changed(&self) -> bool {
let r = // NOTE: the timebar ratio is discarded, so that we only render the ui when the time
self.fdate[0] != self.fdate[1] || self.ftime[0] != self.ftime[1] // (second) changes
//&& self.timebar_ratio[0] == self.timebar_ratio[1] let r = self.fdate[0] != self.fdate[1] || self.ftime[0] != self.ftime[1];
// NOTE: the timebar ratio is discarded, so that we only render the ui when the time (second) changes
;
trace!("changed: {r}"); trace!("changed: {r}");
r r
} }
@ -143,7 +141,8 @@ impl Clock {
let len = self.timebar_len()?; let len = self.timebar_len()?;
let since = (Local::now() let since = (Local::now()
.signed_duration_since(self.last_reset.unwrap()) .signed_duration_since(self.last_reset.unwrap())
.num_seconds()+1) as f64; .num_seconds()
+ 1) as f64;
Some((since / len.as_secs() as f64).min(1.0).max(0.0)) Some((since / len.as_secs() as f64).min(1.0).max(0.0))
} }