Skip to content

Commit fbec79f

Browse files
committed
Move ResetBlueprint to a SystemCommand
1 parent 6932da5 commit fbec79f

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

crates/re_viewer/src/app.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,11 @@ impl App {
356356
}
357357

358358
SystemCommand::ResetViewer => self.reset(store_hub, egui_ctx),
359+
SystemCommand::ResetBlueprint => {
360+
// By clearing the blueprint it will be re-populated with the defaults
361+
// at the beginning of the next frame.
362+
store_hub.clear_blueprint();
363+
}
359364
SystemCommand::UpdateBlueprint(blueprint_id, updates) => {
360365
let blueprint_db = store_hub.store_db_mut(&blueprint_id);
361366
for row in updates {

crates/re_viewer/src/ui/blueprint_panel.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use re_viewer_context::ViewerContext;
1+
use re_viewer_context::{SystemCommandSender as _, ViewerContext};
22
use re_viewport::{SpaceInfoCollection, ViewportBlueprint};
33

44
/// Show the Blueprint section of the left panel based on the current [`ViewportBlueprint`]
@@ -15,7 +15,7 @@ pub fn blueprint_panel_ui(
1515
Some("The Blueprint is where you can configure the Rerun Viewer"),
1616
|ui| {
1717
blueprint.add_new_spaceview_button_ui(ctx, ui, spaces_info);
18-
reset_button_ui(blueprint, ctx, ui, spaces_info);
18+
reset_blueprint_button_ui(ctx, ui);
1919
},
2020
);
2121
});
@@ -25,18 +25,14 @@ pub fn blueprint_panel_ui(
2525
blueprint.tree_ui(ctx, ui);
2626
}
2727

28-
fn reset_button_ui(
29-
blueprint: &mut ViewportBlueprint<'_>,
30-
ctx: &ViewerContext<'_>,
31-
ui: &mut egui::Ui,
32-
spaces_info: &SpaceInfoCollection,
33-
) {
28+
fn reset_blueprint_button_ui(ctx: &ViewerContext<'_>, ui: &mut egui::Ui) {
3429
if ctx
3530
.re_ui
3631
.small_icon_button(ui, &re_ui::icons::RESET)
3732
.on_hover_text("Re-populate Viewport with automatically chosen Space Views")
3833
.clicked()
3934
{
40-
blueprint.reset(ctx, spaces_info);
35+
ctx.command_sender
36+
.send_system(re_viewer_context::SystemCommand::ResetBlueprint);
4137
}
4238
}

crates/re_viewer_context/src/command_sender.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ pub enum SystemCommand {
1717
/// Reset the `Viewer` to the default state
1818
ResetViewer,
1919

20+
/// Reset the `Blueprint` to the default state
21+
ResetBlueprint,
22+
2023
/// Change the active recording-id in the `StoreHub`
2124
SetRecordingId(StoreId),
2225

0 commit comments

Comments
 (0)