Skip to content

Commit a66cc7a

Browse files
committed
keep hover cursor where the timeline was right-clicked
1 parent fc7e5de commit a66cc7a

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

crates/viewer/re_time_panel/src/time_panel.rs

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1884,19 +1884,38 @@ fn time_marker_ui(
18841884
let is_pointer_in_timeline_rect =
18851885
ui.ui_contains_pointer() && timeline_rect.contains(pointer_pos);
18861886

1887-
// Show preview?
1888-
if !is_hovering_time_cursor
1887+
let hovered_ctx_id = egui::Id::new("hovered timestamp context");
1888+
1889+
let on_timeline = !is_hovering_time_cursor
18891890
&& !time_area_double_clicked
18901891
&& is_pointer_in_time_area_rect
18911892
&& !is_anything_being_dragged
1892-
&& !is_hovering_the_loop_selection
1893+
&& !is_hovering_the_loop_selection;
1894+
1895+
if on_timeline {
1896+
ui.ctx().set_cursor_icon(timeline_cursor_icon);
1897+
}
1898+
1899+
// Show a preview bar at this position, if we have right-clicked
1900+
// on the time panel we want to still draw the line at the
1901+
// original position.
1902+
let hovered_x_pos = if let Some(hovered_time) =
1903+
ui.ctx().memory(|mem| mem.data.get_temp(hovered_ctx_id))
1904+
&& let Some(x) = time_ranges_ui.x_from_time_f32(hovered_time)
18931905
{
1906+
Some(x)
1907+
} else if on_timeline {
1908+
Some(pointer_pos.x)
1909+
} else {
1910+
None
1911+
};
1912+
1913+
if let Some(x) = hovered_x_pos {
18941914
time_area_painter.vline(
1895-
pointer_pos.x,
1915+
x,
18961916
timeline_rect.top()..=ui.max_rect().bottom(),
18971917
ui.visuals().widgets.noninteractive.fg_stroke,
18981918
);
1899-
ui.ctx().set_cursor_icon(timeline_cursor_icon); // preview!
19001919
}
19011920

19021921
// Click to move time here:
@@ -1935,7 +1954,6 @@ fn time_marker_ui(
19351954
}
19361955
}
19371956

1938-
let hovered_ctx_id = egui::Id::new("hovered timestamp context");
19391957
if let Some(hovered_time) = ui
19401958
.ctx()
19411959
.memory(|mem| mem.data.get_temp(hovered_ctx_id))

0 commit comments

Comments
 (0)