From f8e6d80fd46b3d00c6fcadf02b55509f07ee5318 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Mon, 16 Dec 2024 10:15:04 +0100 Subject: [PATCH 1/2] Implement double-click to select entity and single-click for view. --- crates/viewer/re_view_graph/src/ui/draw.rs | 21 ++++++++++++++++----- crates/viewer/re_view_graph/src/view.rs | 8 +++++++- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/crates/viewer/re_view_graph/src/ui/draw.rs b/crates/viewer/re_view_graph/src/ui/draw.rs index 0916e1026372..e5558e80f871 100644 --- a/crates/viewer/re_view_graph/src/ui/draw.rs +++ b/crates/viewer/re_view_graph/src/ui/draw.rs @@ -7,6 +7,7 @@ use egui::{ use re_chunk::EntityPath; use re_data_ui::{item_ui, DataUi as _}; use re_entity_db::InstancePath; +use re_log_types::Instance; use re_types::ArrowString; use re_ui::list_item; use re_viewer_context::{ @@ -298,11 +299,6 @@ pub fn draw_graph( let instance_path = InstancePath::instance(entity_path.clone(), instance.instance_index); - ctx.handle_select_hover_drag_interactions( - &response, - Item::DataResult(query.view_id, instance_path.clone()), - false, - ); response = response.on_hover_ui_at_pointer(|ui| { list_item::list_item_scope(ui, "graph_node_hover", |ui| { @@ -319,6 +315,21 @@ pub fn draw_graph( }); }); + ctx.handle_select_hover_drag_interactions( + &response, + Item::DataResult(query.view_id, instance_path.clone()), + false, + ); + + // double click selects the entire entity + if response.double_clicked() { + // Select the entire entity + ctx.selection_state().set_selection(Item::DataResult( + query.view_id, + instance_path.entity_path.clone().into(), + )); + } + response } Node::Implicit { graph_node, .. } => { diff --git a/crates/viewer/re_view_graph/src/view.rs b/crates/viewer/re_view_graph/src/view.rs index 581dd8bdcec9..55b503054bdd 100644 --- a/crates/viewer/re_view_graph/src/view.rs +++ b/crates/viewer/re_view_graph/src/view.rs @@ -19,7 +19,7 @@ use re_view::{ view_property_ui, }; use re_viewer_context::{ - IdentifiedViewSystem as _, RecommendedView, SystemExecutionOutput, ViewClass, + IdentifiedViewSystem as _, Item, RecommendedView, SystemExecutionOutput, ViewClass, ViewClassLayoutPriority, ViewClassRegistryError, ViewId, ViewQuery, ViewSpawnHeuristics, ViewState, ViewStateExt as _, ViewSystemExecutionError, ViewSystemRegistrator, ViewerContext, }; @@ -204,6 +204,12 @@ Display a graph of nodes and edges. } }); + if resp.clicked() { + // clicked elsewhere, select the view + ctx.selection_state() + .set_selection(Item::View(query.view_id)); + } + // Update blueprint if changed let updated_rect_in_scene = blueprint::components::VisualBounds2D::from(ui_from_world.inverse() * rect_in_ui); From 37d19d99cb6fcdf5073490ac4092435febd770dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Mon, 16 Dec 2024 12:33:45 +0100 Subject: [PATCH 2/2] Lint --- crates/viewer/re_view_graph/src/ui/draw.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/viewer/re_view_graph/src/ui/draw.rs b/crates/viewer/re_view_graph/src/ui/draw.rs index 55ccd84a0407..70d3e03b9f17 100644 --- a/crates/viewer/re_view_graph/src/ui/draw.rs +++ b/crates/viewer/re_view_graph/src/ui/draw.rs @@ -7,7 +7,6 @@ use egui::{ use re_chunk::EntityPath; use re_data_ui::{item_ui, DataUi as _}; use re_entity_db::InstancePath; -use re_log_types::Instance; use re_types::ArrowString; use re_ui::list_item; use re_viewer_context::{