@@ -2,65 +2,92 @@ use super::{
22 HitKind , HitRegion , SideLayoutContext , ToolbarEvent , ToolbarLayoutSpec , delay_secs_from_t,
33 delay_t_from_ms,
44} ;
5+ use crate :: ui:: toolbar:: ToolbarSideSection ;
56
67pub ( super ) fn push_delay_hits (
78 ctx : & SideLayoutContext < ' _ > ,
89 y : f64 ,
910 hits : & mut Vec < HitRegion > ,
1011) -> f64 {
11- if ctx. snapshot . show_step_section
12- && ctx. snapshot . show_delay_sliders
13- && ctx. snapshot . drawer_open
14- && ctx. snapshot . drawer_tab == crate :: input:: ToolbarDrawerTab :: App
12+ if !ctx. snapshot . show_step_section
13+ || !ctx. snapshot . drawer_open
14+ || ctx. snapshot . drawer_tab != crate :: input:: ToolbarDrawerTab :: App
1515 {
16- let undo_t = delay_t_from_ms ( ctx. snapshot . undo_all_delay_ms ) ;
17- let redo_t = delay_t_from_ms ( ctx. snapshot . redo_all_delay_ms ) ;
18- let toggles_h =
19- ToolbarLayoutSpec :: SIDE_TOGGLE_HEIGHT * 2.0 + ToolbarLayoutSpec :: SIDE_TOGGLE_GAP ;
20- let custom_h = if ctx. snapshot . custom_section_enabled {
21- ToolbarLayoutSpec :: SIDE_CUSTOM_SECTION_HEIGHT
22- } else {
23- 0.0
24- } ;
25- let slider_start_y = y
26- + ToolbarLayoutSpec :: SIDE_STEP_HEADER_HEIGHT
27- + toggles_h
28- + custom_h
29- + ToolbarLayoutSpec :: SIDE_STEP_SLIDER_TOP_PADDING ;
30- let slider_hit_h = ToolbarLayoutSpec :: SIDE_DELAY_SLIDER_HEIGHT
31- + ToolbarLayoutSpec :: SIDE_DELAY_SLIDER_HIT_PADDING * 2.0 ;
32- let undo_y = slider_start_y + ToolbarLayoutSpec :: SIDE_DELAY_SLIDER_UNDO_OFFSET_Y ;
33- hits. push ( HitRegion {
34- rect : (
35- ctx. x ,
36- undo_y - ToolbarLayoutSpec :: SIDE_DELAY_SLIDER_HIT_PADDING ,
37- ctx. content_width ,
38- slider_hit_h,
39- ) ,
40- event : ToolbarEvent :: SetUndoDelay ( delay_secs_from_t ( undo_t) ) ,
41- kind : HitKind :: DragUndoDelay ,
42- tooltip : None ,
43- } ) ;
44- let redo_y = slider_start_y + ToolbarLayoutSpec :: SIDE_DELAY_SLIDER_REDO_OFFSET_Y ;
45- hits. push ( HitRegion {
46- rect : (
47- ctx. x ,
48- redo_y - ToolbarLayoutSpec :: SIDE_DELAY_SLIDER_HIT_PADDING ,
49- ctx. content_width ,
50- slider_hit_h,
51- ) ,
52- event : ToolbarEvent :: SetRedoDelay ( delay_secs_from_t ( redo_t) ) ,
53- kind : HitKind :: DragRedoDelay ,
54- tooltip : None ,
55- } ) ;
16+ return y;
5617 }
5718
58- if ctx. snapshot . show_step_section
59- && ctx. snapshot . drawer_open
60- && ctx. snapshot . drawer_tab == crate :: input:: ToolbarDrawerTab :: App
19+ let card_h = ctx. spec . side_step_height ( ctx. snapshot ) ;
20+ super :: section_header:: push_collapsible_header_hit ( ctx, y, ToolbarSideSection :: StepUndo , hits) ;
21+ if ctx
22+ . snapshot
23+ . side_section_collapsed ( ToolbarSideSection :: StepUndo )
6124 {
62- y + ctx. spec . side_step_height ( ctx. snapshot ) + ctx. section_gap
63- } else {
64- y
25+ return y + card_h + ctx. section_gap ;
26+ }
27+
28+ let toggle_h = ToolbarLayoutSpec :: SIDE_TOGGLE_HEIGHT ;
29+ let toggle_gap = ToolbarLayoutSpec :: SIDE_TOGGLE_GAP ;
30+ let custom_toggle_y = y + ToolbarLayoutSpec :: SIDE_SECTION_TOGGLE_OFFSET_Y ;
31+ hits. push ( HitRegion {
32+ rect : ( ctx. x , custom_toggle_y, ctx. content_width , toggle_h) ,
33+ event : ToolbarEvent :: ToggleCustomSection ( !ctx. snapshot . custom_section_enabled ) ,
34+ kind : HitKind :: Click ,
35+ tooltip : Some ( "Step controls: multi-step undo/redo." . to_string ( ) ) ,
36+ } ) ;
37+ let delay_toggle_y = custom_toggle_y + toggle_h + toggle_gap;
38+ hits. push ( HitRegion {
39+ rect : ( ctx. x , delay_toggle_y, ctx. content_width , toggle_h) ,
40+ event : ToolbarEvent :: ToggleDelaySliders ( !ctx. snapshot . show_delay_sliders ) ,
41+ kind : HitKind :: Click ,
42+ tooltip : Some ( "Delay sliders: undo/redo delays." . to_string ( ) ) ,
43+ } ) ;
44+
45+ if ctx. snapshot . show_delay_sliders {
46+ push_delay_slider_hits ( ctx, y, hits) ;
6547 }
48+
49+ y + card_h + ctx. section_gap
50+ }
51+
52+ fn push_delay_slider_hits ( ctx : & SideLayoutContext < ' _ > , y : f64 , hits : & mut Vec < HitRegion > ) {
53+ let undo_t = delay_t_from_ms ( ctx. snapshot . undo_all_delay_ms ) ;
54+ let redo_t = delay_t_from_ms ( ctx. snapshot . redo_all_delay_ms ) ;
55+ let toggles_h =
56+ ToolbarLayoutSpec :: SIDE_TOGGLE_HEIGHT * 2.0 + ToolbarLayoutSpec :: SIDE_TOGGLE_GAP ;
57+ let custom_h = if ctx. snapshot . custom_section_enabled {
58+ ToolbarLayoutSpec :: SIDE_CUSTOM_SECTION_HEIGHT
59+ } else {
60+ 0.0
61+ } ;
62+ let slider_start_y = y
63+ + ToolbarLayoutSpec :: SIDE_STEP_HEADER_HEIGHT
64+ + toggles_h
65+ + custom_h
66+ + ToolbarLayoutSpec :: SIDE_STEP_SLIDER_TOP_PADDING ;
67+ let slider_hit_h = ToolbarLayoutSpec :: SIDE_DELAY_SLIDER_HEIGHT
68+ + ToolbarLayoutSpec :: SIDE_DELAY_SLIDER_HIT_PADDING * 2.0 ;
69+ let undo_y = slider_start_y + ToolbarLayoutSpec :: SIDE_DELAY_SLIDER_UNDO_OFFSET_Y ;
70+ hits. push ( HitRegion {
71+ rect : (
72+ ctx. x ,
73+ undo_y - ToolbarLayoutSpec :: SIDE_DELAY_SLIDER_HIT_PADDING ,
74+ ctx. content_width ,
75+ slider_hit_h,
76+ ) ,
77+ event : ToolbarEvent :: SetUndoDelay ( delay_secs_from_t ( undo_t) ) ,
78+ kind : HitKind :: DragUndoDelay ,
79+ tooltip : None ,
80+ } ) ;
81+ let redo_y = slider_start_y + ToolbarLayoutSpec :: SIDE_DELAY_SLIDER_REDO_OFFSET_Y ;
82+ hits. push ( HitRegion {
83+ rect : (
84+ ctx. x ,
85+ redo_y - ToolbarLayoutSpec :: SIDE_DELAY_SLIDER_HIT_PADDING ,
86+ ctx. content_width ,
87+ slider_hit_h,
88+ ) ,
89+ event : ToolbarEvent :: SetRedoDelay ( delay_secs_from_t ( redo_t) ) ,
90+ kind : HitKind :: DragRedoDelay ,
91+ tooltip : None ,
92+ } ) ;
6693}
0 commit comments