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

Fix single-click and double-click in the graph view #8474

Merged
merged 3 commits into from
Dec 16, 2024
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
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
Loading