Skip to content

Commit

Permalink
Display Visible History on timeline when the mouse hovers the UI (#4259)
Browse files Browse the repository at this point in the history
### What

- Fixes #4141

<img width="1791" alt="image"
src="https://github.com/rerun-io/rerun/assets/49431240/049217b0-2a2b-4204-9394-465045c484e4">
<img width="1835" alt="image"
src="https://github.com/rerun-io/rerun/assets/49431240/4faf657a-4497-46b4-bad8-dbac4660bc09">


### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/4259) (if
applicable)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG

- [PR Build Summary](https://build.rerun.io/pr/4259)
- [Docs
preview](https://rerun.io/preview/8134b6de51524b7df3556157a202f607c3f3ed63/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/8134b6de51524b7df3556157a202f607c3f3ed63/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)
  • Loading branch information
abey79 authored Nov 20, 2023
1 parent c2b3ae0 commit a239748
Show file tree
Hide file tree
Showing 4 changed files with 219 additions and 140 deletions.
29 changes: 29 additions & 0 deletions crates/re_time_panel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ impl TimePanel {
let time_bg_area_painter = ui.painter().with_clip_rect(time_bg_area_rect);
let time_area_painter = ui.painter().with_clip_rect(time_fg_area_rect);

paint_visible_history_range(&self.time_ranges_ui, ctx, ui.painter(), time_fg_area_rect);

ui.painter().hline(
0.0..=ui.max_rect().right(),
timeline_rect.bottom(),
Expand Down Expand Up @@ -742,6 +744,9 @@ fn collapsed_time_marker_and_time(ui: &mut egui::Ui, ctx: &mut ViewerContext<'_>
time_ranges_ui.snap_time_control(ctx);

let painter = ui.painter_at(time_range_rect.expand(4.0));

paint_visible_history_range(&time_ranges_ui, ctx, &painter, time_range_rect);

painter.hline(
time_range_rect.x_range(),
time_range_rect.center().y,
Expand All @@ -763,6 +768,30 @@ fn collapsed_time_marker_and_time(ui: &mut egui::Ui, ctx: &mut ViewerContext<'_>
current_time_ui(ctx, ui);
}

fn paint_visible_history_range(
time_ranges_ui: &TimeRangesUi,
ctx: &mut ViewerContext<'_>,
painter: &egui::Painter,
rect: Rect,
) {
if let Some(time_range) = ctx.rec_cfg.visible_history_highlight {
let x_from = time_ranges_ui.x_from_time_f32(time_range.min.into());
let x_to = time_ranges_ui.x_from_time_f32(time_range.max.into());

if let (Some(x_from), Some(x_to)) = (x_from, x_to) {
let visible_history_area_rect =
Rect::from_x_y_ranges(x_from..=x_to, rect.y_range()).intersect(rect);

painter.rect(
visible_history_area_rect,
0.0,
egui::Color32::WHITE.gamma_multiply(0.1),
egui::Stroke::NONE,
);
}
}
}

fn help_button(ui: &mut egui::Ui) {
// TODO(andreas): Nicer help text like on space views.
re_ui::help_hover_button(ui).on_hover_text(
Expand Down
3 changes: 3 additions & 0 deletions crates/re_viewer/src/ui/selection_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ impl SelectionPanel {
..Default::default()
});

// Always reset the VH highlight, and let the UI re-set it if needed.
ctx.rec_cfg.visible_history_highlight = None;

panel.show_animated_inside(ui, expanded, |ui: &mut egui::Ui| {
// Set the clip rectangle to the panel for the benefit of nested, "full span" widgets
// like large collapsing headers. Here, no need to extend `ui.max_rect()` as the
Expand Down
Loading

0 comments on commit a239748

Please sign in to comment.