generated from PlexSheep/rs-base
add a time bar #8
11
src/clock.rs
11
src/clock.rs
|
@ -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))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue