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 graph view node highlight on hover #8512

Merged
merged 2 commits into from
Dec 17, 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
14 changes: 7 additions & 7 deletions crates/viewer/re_view_graph/src/ui/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ pub fn draw_graph(
layout: &Layout,
query: &ViewQuery<'_>,
lod: LevelOfDetail,
hover_click_item: &mut Option<(Item, Response)>,
) -> Rect {
let entity_path = graph.entity();
let entity_highlights = query.highlights.entity_highlight(entity_path.hash());
Expand Down Expand Up @@ -363,19 +364,18 @@ pub fn draw_graph(
});
});

ctx.handle_select_hover_drag_interactions(
Wumpf marked this conversation as resolved.
Show resolved Hide resolved
&response,
Item::DataResult(query.view_id, instance_path.clone()),
false,
);

// double click selects the entire entity
// Warning! The order is very important here.
if response.double_clicked() {
// Select the entire entity
ctx.selection_state().set_selection(Item::DataResult(
query.view_id,
instance_path.entity_path.clone().into(),
));
} else if response.hovered() || response.clicked() {
*hover_click_item = Some((
Item::DataResult(query.view_id, instance_path.clone()),
response.clone(),
));
}

response
Expand Down
19 changes: 15 additions & 4 deletions crates/viewer/re_view_graph/src/view.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use egui::Response;
use re_log_types::EntityPath;
use re_types::{
blueprint::{
Expand Down Expand Up @@ -191,18 +192,28 @@ Display a graph of nodes and edges.

let level_of_detail = LevelOfDetail::from_scaling(ui_from_world.scaling);

let mut hover_click_item: Option<(Item, Response)> = None;

let resp = zoom_pan_area(ui, &mut ui_from_world, |ui| {
let mut world_bounding_rect = egui::Rect::NOTHING;

for graph in &graphs {
let graph_rect = draw_graph(ui, ctx, graph, layout, query, level_of_detail);
let graph_rect = draw_graph(
ui,
ctx,
graph,
layout,
query,
level_of_detail,
&mut hover_click_item,
);
world_bounding_rect = world_bounding_rect.union(graph_rect);
}
});

// Don't set the view to hovered if something else was already hovered.
// (this can only mean that a graph node/edge was hovered)
if resp.hovered() && ctx.selection_state().hovered_items().is_empty() {
if let Some((item, response)) = hover_click_item {
ctx.handle_select_hover_drag_interactions(&response, item, false);
} else if resp.hovered() {
ctx.selection_state().set_hovered(Item::View(query.view_id));
}

Expand Down
Loading