feat(comp/timer): add shifting inital duration
This commit is contained in:
parent
2c76d826c4
commit
fdedff21dd
|
@ -64,9 +64,12 @@ where
|
|||
let full_duration = self.full_duration(env);
|
||||
match event {
|
||||
Event::WindowConnected => {
|
||||
self.start_time = Instant::now();
|
||||
let shift_start_time = Duration::from_secs_f64(
|
||||
env.try_get(env::TIMER_INIT_DURATION).unwrap_or_default(),
|
||||
);
|
||||
self.start_time = Instant::now() - shift_start_time;
|
||||
self.render_timer_id = ctx.request_timer(TIMER_INTERVAL);
|
||||
self.finish_timer_id = ctx.request_timer(duration);
|
||||
self.finish_timer_id = ctx.request_timer(duration - shift_start_time);
|
||||
data.reset(duration);
|
||||
child.event(ctx, event, data, env);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::state;
|
||||
use druid::{Env, Key};
|
||||
|
||||
pub const TIMER_INIT_DURATION: Key<f64> = Key::new("hwt.env.comp.timer.init_duration");
|
||||
pub const TIMER_DURATION: Key<f64> = Key::new("hwt.env.comp.timer.duration");
|
||||
pub const TIMER_POSTPONE_DURATION: Key<f64> = Key::new("hwt.env.comp.timer.postpone_duration");
|
||||
pub const TIMER_WAIT_DURATION: Key<f64> = Key::new("hwt.env.comp.timer.wait_duration");
|
||||
|
|
Loading…
Reference in New Issue