Skip to content

Commit

Permalink
Add TimeControl::restart to restart the current timeline.
Browse files Browse the repository at this point in the history
* Use this from the kb_shortcut function
  • Loading branch information
h3mosphere committed Apr 12, 2023
1 parent f278523 commit 31143ab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/re_viewer/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,9 @@ impl App {
TimeControlCommand::TogglePlayPause => {
time_ctrl.toggle_play_pause(times_per_timeline);
}
TimeControlCommand::Restart => time_ctrl.set_time(0),
TimeControlCommand::Restart => {
time_ctrl.restart(times_per_timeline);
}
TimeControlCommand::StepBack => {
time_ctrl.step_time_back(times_per_timeline);
}
Expand Down
8 changes: 8 additions & 0 deletions crates/re_viewer/src/misc/time_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,14 @@ impl TimeControl {
}
}

pub fn restart(&mut self, times_per_timeline: &TimesPerTimeline) {
if let Some(time_points) = times_per_timeline.get(&self.timeline) {
if let Some(state) = self.states.get_mut(&self.timeline) {
state.time = min(time_points).into();
}
}
}

pub fn toggle_play_pause(&mut self, times_per_timeline: &TimesPerTimeline) {
#[allow(clippy::collapsible_else_if)]
if self.playing {
Expand Down

0 comments on commit 31143ab

Please sign in to comment.