Skip to content

Commit

Permalink
Fix node selection not working on graph node text labels (#8394)
Browse files Browse the repository at this point in the history
### What

This fixes a bug where specifically, selecting nodes via text labels was
not working. We encountered this bug during our work on #8390.

### How to test

To test open the `+main` manifest in the web viewer (link in bot message
below), select the graph lattice example and try clicking on nodes.

<!--
Make sure the PR title and labels are set to maximize their usefulness
for the CHANGELOG,
and our `git log`.

If you have noticed any breaking changes, include them in the migration
guide.

We track various metrics at <https://build.rerun.io>.

For maintainers:
* To run all checks from `main`, comment on the PR with `@rerun-bot
full-check`.
* To deploy documentation changes immediately after merging this PR, add
the `deploy docs` label.
-->
  • Loading branch information
grtlr authored Dec 11, 2024
1 parent 4e3e24a commit 867ec9e
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions crates/viewer/re_view_graph/src/ui/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ fn draw_circle_label(
let &CircleLabel { radius, color } = label;
let visuals = &ui.style().visuals.clone();

let (resp, painter) = ui.allocate_painter(Vec2::splat(radius * 2.0), Sense::click());
let (resp, painter) = ui.allocate_painter(Vec2::splat(radius * 2.0), Sense::hover());
painter.circle(
resp.rect.center(),
radius,
Expand Down Expand Up @@ -132,13 +132,9 @@ fn draw_text_label(ui: &mut Ui, label: &TextLabel, highlight: InteractionHighlig
.stroke(stroke)
.fill(bg)
.show(ui, |ui| {
ui.add(
egui::Label::new(galley.clone())
.selectable(false)
.sense(Sense::click()),
)
ui.add(egui::Label::new(galley.clone()).selectable(false))
})
.response
.inner
}

/// Draws a node at the given position.
Expand All @@ -148,15 +144,18 @@ fn draw_node(
node: &DrawableLabel,
highlight: InteractionHighlight,
) -> Response {
let builder = UiBuilder::new().max_rect(Rect::from_center_size(center, node.size()));
let mut node_ui = ui.new_child(builder);
let builder = UiBuilder::new()
.max_rect(Rect::from_center_size(center, node.size()))
.sense(Sense::click());

// TODO(grtlr): handle highlights
let mut node_ui = ui.new_child(builder);

match node {
DrawableLabel::Circle(label) => draw_circle_label(&mut node_ui, label, highlight),
DrawableLabel::Text(label) => draw_text_label(&mut node_ui, label, highlight),
}
};

node_ui.response()
}

/// Draws a bounding box, as well as a basic coordinate system.
Expand Down

0 comments on commit 867ec9e

Please sign in to comment.