From 40338bd3c0cbf294f26bb62e557bd2782dfdb19d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Mon, 16 Dec 2024 14:35:57 +0100 Subject: [PATCH] Fix single-click and double-click in the graph view (#8474) ### Related * Closes #8437 * Closes #8442 ### What This implements: * Single-click on empty space to select view. * Double-click on node to select entire entity. Merging @emilk's recent changes (#8469 and #8457) seems to have fixed the flickering on selection too. --- crates/viewer/re_view_graph/src/ui/draw.rs | 20 +++++++++++++++----- crates/viewer/re_view_graph/src/view.rs | 8 +++++++- 2 files changed, 22 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 2b226f4041ca..70d3e03b9f17 100644 --- a/crates/viewer/re_view_graph/src/ui/draw.rs +++ b/crates/viewer/re_view_graph/src/ui/draw.rs @@ -362,11 +362,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| { @@ -383,6 +378,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 b2dfdc54d7db..b3227406cd51 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, }; @@ -206,6 +206,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);