From 3034d55e5f65e481dc15ae267b392cdf11755d9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Wed, 27 Nov 2024 16:01:33 +0100 Subject: [PATCH] Try to handle edge responses (not working) --- crates/viewer/re_space_view_graph/src/canvas.rs | 5 +++-- crates/viewer/re_space_view_graph/src/layout/layout.rs | 1 + crates/viewer/re_space_view_graph/src/view.rs | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/viewer/re_space_view_graph/src/canvas.rs b/crates/viewer/re_space_view_graph/src/canvas.rs index 4c99812a9b12c..dd9084c382b63 100644 --- a/crates/viewer/re_space_view_graph/src/canvas.rs +++ b/crates/viewer/re_space_view_graph/src/canvas.rs @@ -101,7 +101,7 @@ fn draw_arrow(painter: &Painter, tip: Pos2, direction: Vec2, color: Color32) { )); } -pub fn draw_edge(ui: &mut Ui, points: [Pos2; 2], show_arrow: bool) -> Response { +pub fn draw_edge(ui: &mut Ui, world_to_view: &mut TSTransform, points: [Pos2; 2], show_arrow: bool) -> Response { let fg = ui.style().visuals.text_color(); let painter = ui.painter(); @@ -116,7 +116,8 @@ pub fn draw_edge(ui: &mut Ui, points: [Pos2; 2], show_arrow: bool) -> Response { draw_arrow(painter, points[1], direction, fg); } - ui.allocate_rect(Rect::from_points(&points), Sense::hover()) + let resp = ui.allocate_rect(Rect::from_points(&points), Sense::hover()); + register_pan_and_zoom(ui, resp, world_to_view) } pub fn zoom_pan_area( diff --git a/crates/viewer/re_space_view_graph/src/layout/layout.rs b/crates/viewer/re_space_view_graph/src/layout/layout.rs index 77e7b114817b1..71073078906c6 100644 --- a/crates/viewer/re_space_view_graph/src/layout/layout.rs +++ b/crates/viewer/re_space_view_graph/src/layout/layout.rs @@ -11,6 +11,7 @@ pub struct Layout { } impl Layout { + #[deprecated] pub fn bounding_rect(&self) -> Rect { // TODO(grtlr): We mostly use this for debugging, but we should probably // take all elements of the layout into account. diff --git a/crates/viewer/re_space_view_graph/src/view.rs b/crates/viewer/re_space_view_graph/src/view.rs index 4bf11bb30a340..4662be0512859 100644 --- a/crates/viewer/re_space_view_graph/src/view.rs +++ b/crates/viewer/re_space_view_graph/src/view.rs @@ -184,7 +184,8 @@ Display a graph of nodes and edges. for edge in graph.edges() { let points = layout.get_edge(edge.from, edge.to); - let resp = draw_edge(ui, points, edge.arrow); + let resp = draw_edge(ui, world_to_view, points, edge.arrow); + world_bounding_rect = world_bounding_rect.union(resp.rect); } }