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

Show Welcome Screen after closing recording even with --skip-welcome-screen #3035

Merged
merged 4 commits into from
Aug 22, 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
26 changes: 15 additions & 11 deletions crates/re_viewer/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -839,17 +839,23 @@ impl App {
/// The welcome screen can be displayed only when a blueprint is available (and no recording is
/// loaded). This function implements the heuristic which determines when the welcome screen
/// should show up.
fn handle_default_blueprint(&mut self, store_hub: &mut StoreHub) {
if store_hub.current_recording().is_some()
|| store_hub.selected_application_id().is_some()
|| self.startup_options.skip_welcome_screen
fn should_show_welcome_screen(&mut self, store_hub: &mut StoreHub) -> bool {
// Don't show the welcome screen if we have actual data to display.
if store_hub.current_recording().is_some() || store_hub.selected_application_id().is_some()
{
return;
return false;
}

// Don't show the welcome screen if the `--skip-welcome-screen` flag was used (e.g. by the
// Python SDK), until some data has been loaded and shown. This way, we *still* show the
// welcome screen when the user closes all recordings after, e.g., running a Python example.
if self.startup_options.skip_welcome_screen && !store_hub.was_recording_active() {
return false;
}

abey79 marked this conversation as resolved.
Show resolved Hide resolved
// Here, we use the type of Receiver as a proxy for which kind of workflow the viewer is
// being used in.
let welcome = match self.rx.source() {
match self.rx.source() {
// These source are typically "finite". We want the loading screen so long as data is
// coming in.
SmartChannelSource::Files { .. } | SmartChannelSource::RrdHttpStream { .. } => {
Expand All @@ -865,10 +871,6 @@ impl App {
// where it's not the case, including Python/C++ SDKs and possibly other, advanced used,
// scenarios. In this cases, `--skip-welcome-screen` should be used.
SmartChannelSource::TcpServer { .. } => true,
};

if welcome {
store_hub.set_app_id(StoreHub::welcome_screen_app_id());
}
}
}
Expand Down Expand Up @@ -974,7 +976,9 @@ impl eframe::App for App {

// Heuristic to set the app_id to the welcome screen blueprint.
// Must be called before `read_context` below.
self.handle_default_blueprint(&mut store_hub);
if self.should_show_welcome_screen(&mut store_hub) {
store_hub.set_app_id(StoreHub::welcome_screen_app_id());
}

let store_context = store_hub.read_context();

Expand Down
13 changes: 13 additions & 0 deletions crates/re_viewer/src/store_hub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ pub struct StoreHub {
blueprint_by_app_id: HashMap<ApplicationId, StoreId>,
store_dbs: StoreBundle,

/// Was a recording ever activated? Used by the heuristic controlling the welcome screen.
was_recording_active: bool,

// The [`StoreGeneration`] from when the [`StoreDb`] was last saved
#[cfg(not(target_arch = "wasm32"))]
blueprint_last_save: HashMap<StoreId, StoreGeneration>,
Expand Down Expand Up @@ -69,6 +72,8 @@ impl StoreHub {
blueprint_by_app_id: blueprints,
store_dbs: Default::default(),

was_recording_active: false,

#[cfg(not(target_arch = "wasm32"))]
blueprint_last_save: Default::default(),
}
Expand Down Expand Up @@ -114,6 +119,13 @@ impl StoreHub {
})
}

/// Keeps track if a recording was every activated.
///
/// This useful for the heuristic controlling the welcome screen.
pub fn was_recording_active(&self) -> bool {
self.was_recording_active
}

/// Change the selected/visible recording id.
/// This will also change the application-id to match the newly selected recording.
pub fn set_recording_id(&mut self, recording_id: StoreId) {
Expand All @@ -128,6 +140,7 @@ impl StoreHub {
}

self.selected_rec_id = Some(recording_id);
self.was_recording_active = true;
}

pub fn remove_recording_id(&mut self, recording_id: &StoreId) {
Expand Down