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

Show outline around hovered/selected tiles in viewport #6597

Merged
merged 3 commits into from
Jun 19, 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
2 changes: 1 addition & 1 deletion crates/re_ui/src/design_tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ impl DesignTokens {
egui_style.visuals.widgets.inactive.fg_stroke.color = default; // button text
egui_style.visuals.widgets.active.fg_stroke.color = strong; // strong text and active button text

let wide_stroke_width = 1.5; // Make it a bit more visible, especially important for spatial primitives.
let wide_stroke_width = 2.0; // Make it a bit more visible, especially important for spatial primitives.
egui_style.visuals.widgets.active.fg_stroke.width = wide_stroke_width;
egui_style.visuals.selection.stroke.width = wide_stroke_width;

Expand Down
30 changes: 30 additions & 0 deletions crates/re_viewport/src/viewport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,36 @@ impl<'a> Viewport<'a> {

// TODO(#4687): Be extra careful here. If we mark edited inappropriately we can create an infinite edit loop.
self.tree_edited |= tab_viewer.edited;

// Outline hovered & selected tiles:
for contents in blueprint.contents_iter() {
let tile_id = contents.as_tile_id();
if let Some(rect) = tree.tiles.rect(tile_id) {
let item = contents.as_item();

let mut hovered = ctx.hovered().contains_item(&item);
let selected = ctx.selection().contains_item(&item);

if hovered && ui.rect_contains_pointer(rect) {
// Showing a hover-outline when hovering the same thing somewhere else
// (e.g. in the blueprint panel) is really helpful,
// but showing a hover-outline when just dragging around the camera is
// just annoying.
hovered = false;
}

let stroke = if hovered {
ui.ctx().hover_stroke()
} else if selected {
ui.ctx().selection_stroke()
} else {
continue;
};

ui.painter()
.rect_stroke(rect.shrink(stroke.width / 2.0), 0.0, stroke);
}
}
});

self.blueprint.set_maximized(maximized, ctx);
Expand Down
Loading