diff --git a/crates/re_viewer/src/app.rs b/crates/re_viewer/src/app.rs index dd3a897859db..f161ee4a0982 100644 --- a/crates/re_viewer/src/app.rs +++ b/crates/re_viewer/src/app.rs @@ -356,6 +356,11 @@ impl App { } SystemCommand::ResetViewer => self.reset(store_hub, egui_ctx), + SystemCommand::ResetBlueprint => { + // By clearing the blueprint it will be re-populated with the defaults + // at the beginning of the next frame. + store_hub.clear_blueprint(); + } SystemCommand::UpdateBlueprint(blueprint_id, updates) => { let blueprint_db = store_hub.store_db_mut(&blueprint_id); for row in updates { diff --git a/crates/re_viewer/src/ui/blueprint_panel.rs b/crates/re_viewer/src/ui/blueprint_panel.rs index 8401a8e6641b..7f7579c9477e 100644 --- a/crates/re_viewer/src/ui/blueprint_panel.rs +++ b/crates/re_viewer/src/ui/blueprint_panel.rs @@ -1,4 +1,4 @@ -use re_viewer_context::ViewerContext; +use re_viewer_context::{SystemCommandSender as _, ViewerContext}; use re_viewport::{SpaceInfoCollection, ViewportBlueprint}; /// Show the Blueprint section of the left panel based on the current [`ViewportBlueprint`] @@ -15,7 +15,7 @@ pub fn blueprint_panel_ui( Some("The Blueprint is where you can configure the Rerun Viewer"), |ui| { blueprint.add_new_spaceview_button_ui(ctx, ui, spaces_info); - reset_button_ui(blueprint, ctx, ui, spaces_info); + reset_blueprint_button_ui(ctx, ui); }, ); }); @@ -25,18 +25,14 @@ pub fn blueprint_panel_ui( blueprint.tree_ui(ctx, ui); } -fn reset_button_ui( - blueprint: &mut ViewportBlueprint<'_>, - ctx: &ViewerContext<'_>, - ui: &mut egui::Ui, - spaces_info: &SpaceInfoCollection, -) { +fn reset_blueprint_button_ui(ctx: &ViewerContext<'_>, ui: &mut egui::Ui) { if ctx .re_ui .small_icon_button(ui, &re_ui::icons::RESET) .on_hover_text("Re-populate Viewport with automatically chosen Space Views") .clicked() { - blueprint.reset(ctx, spaces_info); + ctx.command_sender + .send_system(re_viewer_context::SystemCommand::ResetBlueprint); } } diff --git a/crates/re_viewer_context/src/command_sender.rs b/crates/re_viewer_context/src/command_sender.rs index 4de6ac5ed72a..b05631f6e05f 100644 --- a/crates/re_viewer_context/src/command_sender.rs +++ b/crates/re_viewer_context/src/command_sender.rs @@ -17,6 +17,9 @@ pub enum SystemCommand { /// Reset the `Viewer` to the default state ResetViewer, + /// Reset the `Blueprint` to the default state + ResetBlueprint, + /// Change the active recording-id in the `StoreHub` SetRecordingId(StoreId),