@@ -36,15 +36,12 @@ use std::rc::Rc;
3636use std:: sync:: { Arc , mpsc} ;
3737use std:: time:: { Duration , Instant } ;
3838use windowing:: {
39- APP_ID , BarResizeState , PopoutWindow , layershell_available, main_window_size, open_main_window,
39+ APP_ID , BarResizeState , PopoutWindow , layershell_available, main_window_size,
40+ open_config_base_window, open_main_window,
4041} ;
4142
4243const TOAST_DISPLAY_DURATION : Duration = Duration :: from_secs ( 2 ) ;
43- const DEFAULT_DRAWER_RATIO : f32 = 0.20 ;
44- const MIN_DRAWER_RATIO : f32 = 0.10 ;
45- const MAX_DRAWER_RATIO : f32 = 0.50 ;
4644const BAR_RESIZE_HANDLE_THICKNESS : f32 = 6.0 ;
47- const DRAWER_RESIZE_HANDLE_WIDTH : f32 = 6.0 ;
4845
4946#[ derive( Clone ) ]
5047pub ( crate ) struct UiConfig {
@@ -96,10 +93,7 @@ struct UiApp {
9693 visual_manager : VisualManagerHandle ,
9794 settings_handle : SettingsHandle ,
9895 audio_frames : Arc < AsyncReceiver < AudioBatch > > ,
99- drawer_open : bool ,
100- drawer_width_ratio : f32 ,
101- drawer_resizing : bool ,
102- drawer_resize_offset : Option < f32 > ,
96+ config_window : Option < window:: Id > ,
10397 bar_resize_state : Option < BarResizeState > ,
10498 rendering_paused : bool ,
10599 toast_until : Option < Instant > ,
@@ -156,10 +150,7 @@ impl UiApp {
156150 visual_manager,
157151 settings_handle,
158152 audio_frames,
159- drawer_open : false ,
160- drawer_width_ratio : DEFAULT_DRAWER_RATIO ,
161- drawer_resizing : false ,
162- drawer_resize_offset : None ,
153+ config_window : None ,
163154 bar_resize_state : None ,
164155 rendering_paused : false ,
165156 toast_until : None ,
@@ -194,38 +185,20 @@ impl UiApp {
194185 } ) ,
195186 ] ;
196187 subs. push ( channel_subscription ( Arc :: clone ( & self . audio_frames ) ) . map ( Message :: AudioFrame ) ) ;
197- if self . drawer_resizing && self . drawer_open {
198- subs. push ( event:: listen_with ( message:: drawer_drag_events) ) ;
199- }
200188 if self . bar_resize_state . is_some ( ) {
201189 subs. push ( event:: listen_with ( message:: bar_drag_events) ) ;
202190 }
203191 Subscription :: batch ( subs)
204192 }
205193
206- fn toggle_drawer ( & mut self ) {
207- self . drawer_open = !self . drawer_open ;
208- self . end_drawer_resize ( ) ;
209- self . toast_until = self
210- . drawer_open
211- . then ( || Instant :: now ( ) + TOAST_DISPLAY_DURATION ) ;
212- }
213-
214- fn end_drawer_resize ( & mut self ) {
215- self . drawer_resizing = false ;
216- self . drawer_resize_offset = None ;
217- }
218-
219- fn handle_drawer_resize ( & mut self , position : iced:: Point ) {
220- if self . drawer_resizing && self . drawer_width_ratio > 0.0 {
221- let estimated_width = self . drawer_resize_offset . get_or_insert_with ( || {
222- ( position. x - DRAWER_RESIZE_HANDLE_WIDTH ) / self . drawer_width_ratio
223- } ) ;
224- if * estimated_width > 0.0 {
225- self . drawer_width_ratio =
226- ( position. x / * estimated_width) . clamp ( MIN_DRAWER_RATIO , MAX_DRAWER_RATIO ) ;
227- }
194+ fn toggle_config_window ( & mut self ) -> Task < Message > {
195+ if let Some ( id) = self . config_window . take ( ) {
196+ return window:: close ( id) ;
228197 }
198+ let ( id, task) = open_config_base_window ( self . use_layershell ) ;
199+ self . config_window = Some ( id) ;
200+ self . toast_until = Some ( Instant :: now ( ) + TOAST_DISPLAY_DURATION ) ;
201+ task
229202 }
230203
231204 fn begin_bar_resize ( & mut self ) {
@@ -288,22 +261,19 @@ impl UiApp {
288261 } ;
289262
290263 let content = self . visuals_with_toasts ( ) ;
291- let content = self . wrap_drawer ( content) ;
292264 let content = self . wrap_bar_resize ( content, & bar) ;
293265 Self :: wrap_window_resize ( content, use_decorations, & bar)
294266 }
295267
296268 fn visuals_with_toasts ( & self ) -> Element < ' _ , Message > {
297- let visuals_view = self
298- . visuals_page
299- . view ( self . drawer_open )
300- . map ( Message :: Visuals ) ;
269+ let config_open = self . config_window . is_some ( ) ;
270+ let visuals_view = self . visuals_page . view ( config_open) . map ( Message :: Visuals ) ;
301271
302272 let now = Instant :: now ( ) ;
303273 let is_active = |deadline : Option < Instant > | deadline. is_some_and ( |expires| now < expires) ;
304274 let toast_msgs: Vec < & str > = [
305- ( self . drawer_open && is_active ( self . toast_until ) )
306- . then_some ( "ctrl+shift+h to close drawer " ) ,
275+ ( config_open && is_active ( self . toast_until ) )
276+ . then_some ( "drag visuals to rearrange | ctrl+shift+h to close config " ) ,
307277 self . rendering_paused . then_some ( "paused (p to resume)" ) ,
308278 is_active ( self . exit_warning_until ) . then_some ( "q again to exit" ) ,
309279 ]
@@ -329,36 +299,6 @@ impl UiApp {
329299 layer. into ( )
330300 }
331301
332- fn wrap_drawer < ' a > ( & ' a self , visuals : Element < ' a , Message > ) -> Element < ' a , Message > {
333- if !self . drawer_open {
334- return visuals;
335- }
336- let drawer_portion = ( self . drawer_width_ratio * 1000.0 ) . round ( ) as u16 ;
337- let visuals_portion = 1000 - drawer_portion;
338- let drawer: Element < ' _ , Message > = fill ! ( self . config_page. view( ) . map( Message :: Config ) )
339- . width ( Length :: FillPortion ( drawer_portion) )
340- . style ( theme:: opaque_container)
341- . into ( ) ;
342- let handle: Element < ' _ , Message > = mouse_area (
343- container ( text ( ":" ) . size ( 12 ) . align_x ( Horizontal :: Center ) )
344- . width ( 12 )
345- . height ( Length :: Fill )
346- . align_x ( Horizontal :: Center )
347- . align_y ( Vertical :: Center )
348- . style ( theme:: resize_handle_container) ,
349- )
350- . on_press ( Message :: DrawerResizeStart )
351- . interaction ( iced:: mouse:: Interaction :: ResizingHorizontally )
352- . into ( ) ;
353- let visuals: Element < ' _ , Message > = fill ! ( visuals)
354- . width ( Length :: FillPortion ( visuals_portion) )
355- . into ( ) ;
356- row ! [ drawer, handle, visuals]
357- . width ( Length :: Fill )
358- . height ( Length :: Fill )
359- . into ( )
360- }
361-
362302 fn wrap_bar_resize < ' a > (
363303 & ' a self ,
364304 content : Element < ' a , Message > ,
0 commit comments