Skip to content

Commit

Permalink
Add Restart command and keyboard shortcut for moving time to start of…
Browse files Browse the repository at this point in the history
… timeline (#1802)

* Add Restart button to timeline UI. This sets the timeline back to zero.

* Adds Restart Command & Timeline Command

* Adds Ctrl-Shift-Space keyboard modifier

* Remove restart button from timeline UI.

* Use cmd(Key::LeftArrow) as key combo for restart timeline.

* Add TimeControl::restart to restart the current timeline.

* Use this from the kb_shortcut function

* fix some code nits

---------

Co-authored-by: Emil Ernerfeldt <[email protected]>
  • Loading branch information
h3mosphere and emilk authored Apr 15, 2023
1 parent 625d2bd commit c3a13db
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/re_ui/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pub enum Command {
PlaybackTogglePlayPause,
PlaybackStepBack,
PlaybackStepForward,
PlaybackRestart,
}

impl Command {
Expand Down Expand Up @@ -124,6 +125,7 @@ impl Command {
"Step time forward",
"Move the time marker to the next point in time with any data",
),
Command::PlaybackRestart => ("Restart", "Restart from beginning of timeline"),
}
}

Expand Down Expand Up @@ -183,6 +185,7 @@ impl Command {
Command::PlaybackTogglePlayPause => Some(key(Key::Space)),
Command::PlaybackStepBack => Some(key(Key::ArrowLeft)),
Command::PlaybackStepForward => Some(key(Key::ArrowRight)),
Command::PlaybackRestart => Some(cmd(Key::ArrowLeft)),
}
}

Expand Down
7 changes: 7 additions & 0 deletions crates/re_viewer/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ enum TimeControlCommand {
TogglePlayPause,
StepBack,
StepForward,
Restart,
}

// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -341,6 +342,9 @@ impl App {
Command::PlaybackStepForward => {
self.run_time_control_command(TimeControlCommand::StepForward);
}
Command::PlaybackRestart => {
self.run_time_control_command(TimeControlCommand::Restart);
}
}
}

Expand All @@ -362,6 +366,9 @@ impl App {
TimeControlCommand::StepForward => {
time_ctrl.step_time_fwd(times_per_timeline);
}
TimeControlCommand::Restart => {
time_ctrl.restart(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

1 comment on commit c3a13db

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rust Benchmark

Benchmark suite Current: c3a13db Previous: 625d2bd Ratio
datastore/num_rows=1000/num_instances=1000/packed=false/insert/default 2777843 ns/iter (± 34190) 2841265 ns/iter (± 68397) 0.98
datastore/num_rows=1000/num_instances=1000/packed=false/latest_at/default 370 ns/iter (± 2) 373 ns/iter (± 2) 0.99
datastore/num_rows=1000/num_instances=1000/packed=false/latest_at_missing/primary/default 258 ns/iter (± 1) 261 ns/iter (± 0) 0.99
datastore/num_rows=1000/num_instances=1000/packed=false/latest_at_missing/secondaries/default 418 ns/iter (± 4) 422 ns/iter (± 1) 0.99
datastore/num_rows=1000/num_instances=1000/packed=false/range/default 3006126 ns/iter (± 68412) 2952318 ns/iter (± 69866) 1.02
datastore/num_rows=1000/num_instances=1000/gc/default 2359747 ns/iter (± 25006) 2425312 ns/iter (± 9170) 0.97
mono_points_arrow/generate_message_bundles 24776356 ns/iter (± 1223336) 27582815 ns/iter (± 1579541) 0.90
mono_points_arrow/generate_messages 121932972 ns/iter (± 1332933) 126663078 ns/iter (± 1070774) 0.96
mono_points_arrow/encode_log_msg 152864266 ns/iter (± 1874222) 156944200 ns/iter (± 1632807) 0.97
mono_points_arrow/encode_total 303155603 ns/iter (± 2967023) 311922547 ns/iter (± 1802501) 0.97
mono_points_arrow/decode_log_msg 183099600 ns/iter (± 1807818) 190679457 ns/iter (± 1204467) 0.96
mono_points_arrow/decode_message_bundles 62591644 ns/iter (± 2574711) 70722249 ns/iter (± 1096716) 0.89
mono_points_arrow/decode_total 246988373 ns/iter (± 3106392) 259071553 ns/iter (± 1187479) 0.95
mono_points_arrow_batched/generate_message_bundles 18581032 ns/iter (± 935560) 19762814 ns/iter (± 1609945) 0.94
mono_points_arrow_batched/generate_messages 4193096 ns/iter (± 132046) 4262898 ns/iter (± 162891) 0.98
mono_points_arrow_batched/encode_log_msg 1365898 ns/iter (± 14841) 1370225 ns/iter (± 8545) 1.00
mono_points_arrow_batched/encode_total 25483608 ns/iter (± 916679) 27498535 ns/iter (± 1745494) 0.93
mono_points_arrow_batched/decode_log_msg 772343 ns/iter (± 6154) 780578 ns/iter (± 2916) 0.99
mono_points_arrow_batched/decode_message_bundles 7547962 ns/iter (± 128153) 7531005 ns/iter (± 166755) 1.00
mono_points_arrow_batched/decode_total 8179015 ns/iter (± 139904) 8386604 ns/iter (± 365538) 0.98
batch_points_arrow/generate_message_bundles 188429 ns/iter (± 2570) 198706 ns/iter (± 779) 0.95
batch_points_arrow/generate_messages 4940 ns/iter (± 75) 5066 ns/iter (± 28) 0.98
batch_points_arrow/encode_log_msg 256644 ns/iter (± 2597) 261040 ns/iter (± 1831) 0.98
batch_points_arrow/encode_total 476123 ns/iter (± 4742) 488349 ns/iter (± 2757) 0.97
batch_points_arrow/decode_log_msg 205946 ns/iter (± 2682) 211433 ns/iter (± 796) 0.97
batch_points_arrow/decode_message_bundles 1872 ns/iter (± 25) 1893 ns/iter (± 15) 0.99
batch_points_arrow/decode_total 214584 ns/iter (± 2398) 221303 ns/iter (± 1287) 0.97
arrow_mono_points/insert 2491162934 ns/iter (± 13249449) 2529326427 ns/iter (± 5137330) 0.98
arrow_mono_points/query 1174152 ns/iter (± 14730) 1181497 ns/iter (± 9495) 0.99
arrow_batch_points/insert 1135420 ns/iter (± 17803) 1157077 ns/iter (± 6316) 0.98
arrow_batch_points/query 14406 ns/iter (± 223) 14626 ns/iter (± 170) 0.98
arrow_batch_vecs/insert 26353 ns/iter (± 124) 26424 ns/iter (± 144) 1.00
arrow_batch_vecs/query 319861 ns/iter (± 4319) 325239 ns/iter (± 1198) 0.98
tuid/Tuid::random 44 ns/iter (± 5) 34 ns/iter (± 0) 1.29

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.