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

Move ResetBlueprint to a SystemCommand #4408

Merged
merged 1 commit into from
Nov 30, 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
5 changes: 5 additions & 0 deletions crates/re_viewer/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 5 additions & 9 deletions crates/re_viewer/src/ui/blueprint_panel.rs
Original file line number Diff line number Diff line change
@@ -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`]
Expand All @@ -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);
},
);
});
Expand All @@ -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);
}
}
3 changes: 3 additions & 0 deletions crates/re_viewer_context/src/command_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),

Expand Down
Loading