Skip to content

Commit c51dfab

Browse files
committed
Display remaining time in slideshow
1 parent 3d02bf3 commit c51dfab

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/app/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,12 @@ impl App {
309309
ui.spinner().on_hover_text("Loading");
310310
}
311311

312+
if let SlideshowState::Active { remaining } = self.slideshow {
313+
ui.label(format!("\u{2398} {} s", remaining.ceil_secs()));
314+
ui.ctx()
315+
.request_repaint_after(std::time::Duration::from_secs(1));
316+
}
317+
312318
if let Some(to_delete) = to_delete {
313319
self.delete_file(ui, to_delete);
314320
}

src/duration.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ impl Duration {
9999
az::cast::<_, f32>(self.micros) / SECS_MICROS_F
100100
}
101101

102+
pub fn whole_secs(self) -> u32 {
103+
self.micros / SECS_MICROS
104+
}
105+
106+
pub fn ceil_secs(self) -> u32 {
107+
self.micros.div_ceil(SECS_MICROS)
108+
}
109+
102110
pub fn new_millis_f32(millis: f32) -> Result<Self, OutOfRange> {
103111
az::checked_cast(millis * MILLIS_MICROS_F)
104112
.ok_or(OutOfRange)

0 commit comments

Comments
 (0)