From 381ccebca5674c7c78dab5146652fdad506438ab Mon Sep 17 00:00:00 2001 From: Nick Hemsley Date: Thu, 27 Apr 2023 19:15:29 +1000 Subject: [PATCH 1/3] stop following when restarting timeline --- crates/re_viewer/src/misc/time_control.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/re_viewer/src/misc/time_control.rs b/crates/re_viewer/src/misc/time_control.rs index e9839cefec45..bc5a2a6f1cc4 100644 --- a/crates/re_viewer/src/misc/time_control.rs +++ b/crates/re_viewer/src/misc/time_control.rs @@ -297,6 +297,7 @@ impl TimeControl { 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(); + self.following = false; } } } From 48b61df1d7d9f2c0a2436010cb6fb3b256863dbd Mon Sep 17 00:00:00 2001 From: Nick Hemsley Date: Thu, 27 Apr 2023 19:48:33 +1000 Subject: [PATCH 2/3] add PlaybackFollow command bound to cmd-right --- crates/re_ui/src/command.rs | 3 +++ crates/re_viewer/src/app.rs | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/re_ui/src/command.rs b/crates/re_ui/src/command.rs index 55f1aa2a430a..d2f3efba9d79 100644 --- a/crates/re_ui/src/command.rs +++ b/crates/re_ui/src/command.rs @@ -43,6 +43,7 @@ pub enum Command { // Playback: PlaybackTogglePlayPause, + PlaybackFollow, PlaybackStepBack, PlaybackStepForward, PlaybackRestart, @@ -117,6 +118,7 @@ impl Command { Command::PlaybackTogglePlayPause => { ("Toggle play/pause", "Either play or pause the time") } + Command::PlaybackFollow => ("Follow", "Follow on from end of timeline"), Command::PlaybackStepBack => ( "Step time back", "Move the time marker back to the previous point in time with any data", @@ -183,6 +185,7 @@ impl Command { Command::ToggleCommandPalette => Some(cmd(Key::P)), Command::PlaybackTogglePlayPause => Some(key(Key::Space)), + Command::PlaybackFollow => Some(cmd(Key::ArrowRight)), Command::PlaybackStepBack => Some(key(Key::ArrowLeft)), Command::PlaybackStepForward => Some(key(Key::ArrowRight)), Command::PlaybackRestart => Some(cmd(Key::ArrowLeft)), diff --git a/crates/re_viewer/src/app.rs b/crates/re_viewer/src/app.rs index bce99cd35e5f..5907b27d95ed 100644 --- a/crates/re_viewer/src/app.rs +++ b/crates/re_viewer/src/app.rs @@ -16,7 +16,7 @@ use re_smart_channel::Receiver; use re_ui::{toasts, Command}; use crate::{ - misc::{AppOptions, Caches, RecordingConfig, ViewerContext}, + misc::{time_control::PlayState, AppOptions, Caches, RecordingConfig, ViewerContext}, ui::{data_ui::ComponentUiRegistry, Blueprint}, viewer_analytics::ViewerAnalytics, }; @@ -34,6 +34,7 @@ enum TimeControlCommand { StepBack, StepForward, Restart, + Follow, } // ---------------------------------------------------------------------------- @@ -329,6 +330,9 @@ impl App { Command::PlaybackTogglePlayPause => { self.run_time_control_command(TimeControlCommand::TogglePlayPause); } + Command::PlaybackFollow => { + self.run_time_control_command(TimeControlCommand::Follow); + } Command::PlaybackStepBack => { self.run_time_control_command(TimeControlCommand::StepBack); } @@ -353,6 +357,9 @@ impl App { TimeControlCommand::TogglePlayPause => { time_ctrl.toggle_play_pause(times_per_timeline); } + TimeControlCommand::Follow => { + time_ctrl.set_play_state(times_per_timeline, PlayState::Following) + } TimeControlCommand::StepBack => { time_ctrl.step_time_back(times_per_timeline); } From df56c1085baf9f356862faa6cf1c38743bb6fba6 Mon Sep 17 00:00:00 2001 From: Nick Hemsley Date: Thu, 27 Apr 2023 20:02:26 +1000 Subject: [PATCH 3/3] fix lint warning --- crates/re_viewer/src/app.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/re_viewer/src/app.rs b/crates/re_viewer/src/app.rs index 5907b27d95ed..f7d12368d316 100644 --- a/crates/re_viewer/src/app.rs +++ b/crates/re_viewer/src/app.rs @@ -358,7 +358,7 @@ impl App { time_ctrl.toggle_play_pause(times_per_timeline); } TimeControlCommand::Follow => { - time_ctrl.set_play_state(times_per_timeline, PlayState::Following) + time_ctrl.set_play_state(times_per_timeline, PlayState::Following); } TimeControlCommand::StepBack => { time_ctrl.step_time_back(times_per_timeline); @@ -1886,8 +1886,6 @@ fn new_recording_confg( data_source: &'_ re_smart_channel::Source, log_db: &'_ LogDb, ) -> RecordingConfig { - use crate::misc::time_control::PlayState; - let play_state = match data_source { // Play files from the start by default - it feels nice and alive./ // RrdHttpStream downloads the whole file before decoding it, so we treat it the same as a file.