1
- use egui:: { CursorIcon , Id , NumExt as _, Rect } ;
1
+ use egui:: { Color32 , CursorIcon , Id , NumExt as _, Rect } ;
2
2
3
- use re_log_types:: { AbsoluteTimeRangeF , Duration , TimeInt , TimeReal , TimeType } ;
3
+ use re_log_types:: { AbsoluteTimeRange , AbsoluteTimeRangeF , Duration , TimeInt , TimeReal , TimeType } ;
4
4
use re_ui:: UiExt as _;
5
5
use re_viewer_context:: { Looping , TimeControl } ;
6
6
7
7
use super :: time_ranges_ui:: TimeRangesUi ;
8
8
9
+ /// Paints a rect on the timeline given a time range.
10
+ pub fn paint_timeline_range (
11
+ highlighted_range : AbsoluteTimeRange ,
12
+ time_ranges_ui : & TimeRangesUi ,
13
+ painter : & egui:: Painter ,
14
+ rect : Rect ,
15
+ color : Color32 ,
16
+ ) {
17
+ let x_from = time_ranges_ui. x_from_time_f32 ( highlighted_range. min ( ) . into ( ) ) ;
18
+ let x_to = time_ranges_ui. x_from_time_f32 ( highlighted_range. max ( ) . into ( ) ) ;
19
+
20
+ if let ( Some ( x_from) , Some ( x_to) ) = ( x_from, x_to) {
21
+ let visible_history_area_rect =
22
+ Rect :: from_x_y_ranges ( x_from..=x_to, rect. y_range ( ) ) . intersect ( rect) ;
23
+
24
+ painter. rect_filled ( visible_history_area_rect, 0.0 , color) ;
25
+ }
26
+ }
27
+
28
+ fn loop_selection_color ( time_ctrl : & TimeControl , tokens : & re_ui:: DesignTokens ) -> Color32 {
29
+ // Display in a brighter color when active
30
+ if time_ctrl. looping ( ) == Looping :: Selection {
31
+ tokens. loop_selection_color
32
+ } else {
33
+ tokens. loop_selection_color . gamma_multiply ( 0.7 )
34
+ }
35
+ }
36
+
37
+ pub fn collapsed_loop_selection_ui (
38
+ time_ctrl : & TimeControl ,
39
+ painter : & egui:: Painter ,
40
+ time_ranges_ui : & TimeRangesUi ,
41
+ ui : & egui:: Ui ,
42
+ time_range_rect : Rect ,
43
+ ) {
44
+ if let Some ( loop_range) = time_ctrl. loop_selection ( ) {
45
+ paint_timeline_range (
46
+ loop_range. to_int ( ) ,
47
+ time_ranges_ui,
48
+ painter,
49
+ time_range_rect,
50
+ loop_selection_color ( time_ctrl, ui. tokens ( ) ) ,
51
+ ) ;
52
+ }
53
+ }
54
+
9
55
pub fn loop_selection_ui (
10
56
time_ctrl : & mut TimeControl ,
11
57
time_ranges_ui : & TimeRangesUi ,
@@ -28,11 +74,7 @@ pub fn loop_selection_ui(
28
74
29
75
let is_active = time_ctrl. looping ( ) == Looping :: Selection ;
30
76
31
- let selection_color = if is_active {
32
- tokens. loop_selection_color
33
- } else {
34
- tokens. loop_selection_color . gamma_multiply ( 0.7 )
35
- } ;
77
+ let selection_color = loop_selection_color ( time_ctrl, tokens) ;
36
78
37
79
let pointer_pos = ui. input ( |i| i. pointer . hover_pos ( ) ) ;
38
80
let is_pointer_in_timeline =
0 commit comments