Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add keyboard shortcut for "Follow", and stop following on "Restart" #1986

Merged
merged 3 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions crates/re_ui/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub enum Command {

// Playback:
PlaybackTogglePlayPause,
PlaybackFollow,
PlaybackStepBack,
PlaybackStepForward,
PlaybackRestart,
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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)),
Expand Down
11 changes: 8 additions & 3 deletions crates/re_viewer/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand All @@ -34,6 +34,7 @@ enum TimeControlCommand {
StepBack,
StepForward,
Restart,
Follow,
}

// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -1879,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.
Expand Down
1 change: 1 addition & 0 deletions crates/re_viewer/src/misc/time_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down