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 hover (proper this time) #8510

Closed
wants to merge 1 commit into from
Closed
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
5 changes: 3 additions & 2 deletions crates/viewer/re_ui/src/zoom_pan_area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ pub fn fit_to_rect_in_scene(rect_in_ui: Rect, rect_in_scene: Rect) -> TSTransfor
/// Provides a zoom-pan area for a given view.
///
/// Will fill the entire `max_rect` of the `parent_ui`.
/// `draw_contents` is called with the response of the pan-and-zoom area and its local ui.
pub fn zoom_pan_area(
parent_ui: &mut Ui,
to_global: &mut TSTransform,
draw_contents: impl FnOnce(&mut Ui),
draw_contents: impl FnOnce(&egui::Response, &mut Ui),
) -> Response {
// Create a new egui paint layer, where we can draw our contents:
let zoom_pan_layer_id = egui::LayerId::new(
Expand Down Expand Up @@ -103,7 +104,7 @@ pub fn zoom_pan_area(
local_ui.set_clip_rect(to_global.inverse() * global_view_bounds);

// Add the actual contents to the area:
draw_contents(&mut local_ui);
draw_contents(&pan_response, &mut local_ui);

// Tell egui to apply the transform on the layer:
local_ui
Expand Down
14 changes: 7 additions & 7 deletions crates/viewer/re_view_graph/src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,13 @@

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

let resp = zoom_pan_area(ui, &mut ui_from_world, |ui| {
let resp = zoom_pan_area(ui, &mut ui_from_world, |response, ui| {
// Set the view to hovered if the mouse is hovering over the area.
// This may be overriden by hovering graph nodes/edges down the line.

Check warning on line 196 in crates/viewer/re_view_graph/src/view.rs

View workflow job for this annotation

GitHub Actions / Checks / Spell Check

"overriden" should be "overridden".
if response.hovered() {
ctx.selection_state().set_hovered(Item::View(query.view_id));
}

let mut world_bounding_rect = egui::Rect::NOTHING;

for graph in &graphs {
Expand All @@ -200,12 +206,6 @@
}
});

// 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() {
ctx.selection_state().set_hovered(Item::View(query.view_id));
}

if resp.clicked() {
// clicked elsewhere, select the view
ctx.selection_state()
Expand Down
Loading