Skip to content

Commit

Permalink
Fix single-click and double-click in the graph view (#8474)
Browse files Browse the repository at this point in the history
### Related

<!--
Include links to any related issues/PRs in a bulleted list, for example:
* Closes #1234
* Part of #1337
-->

* 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.
  • Loading branch information
grtlr authored Dec 16, 2024
1 parent a8ae6f5 commit 40338bd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
20 changes: 15 additions & 5 deletions crates/viewer/re_view_graph/src/ui/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand All @@ -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, .. } => {
Expand Down
8 changes: 7 additions & 1 deletion crates/viewer/re_view_graph/src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 40338bd

Please sign in to comment.