Skip to content

Commit

Permalink
Show Welcome Screen after closing recording even with `--skip-welcome…
Browse files Browse the repository at this point in the history
…-screen` (#3035)

### What

Fixes #3018 


https://github.com/rerun-io/rerun/assets/49431240/af2d69e0-921d-4f11-8ca0-b6f6957f7599

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/3035) (if
applicable)

- [PR Build Summary](https://build.rerun.io/pr/3035)
- [Docs
preview](https://rerun.io/preview/pr%3Aantoine%2Foverride-skip-welcome-screen/docs)
- [Examples
preview](https://rerun.io/preview/pr%3Aantoine%2Foverride-skip-welcome-screen/examples)
  • Loading branch information
abey79 authored Aug 22, 2023
1 parent 1ffe697 commit e210793
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
26 changes: 15 additions & 11 deletions crates/re_viewer/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -868,17 +868,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;
}

// 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 @@ -894,10 +900,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 @@ -1014,7 +1016,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

0 comments on commit e210793

Please sign in to comment.