@@ -18,7 +18,7 @@ pub mod slider;
1818pub mod tabs;
1919
2020use floem:: {
21- action:: { add_overlay, set_window_menu, toggle_theme} ,
21+ action:: { add_overlay, set_window_menu, set_window_scale , toggle_theme} ,
2222 event:: { Event , EventListener } ,
2323 keyboard:: { Key , Modifiers , NamedKey } ,
2424 kurbo:: Size ,
@@ -27,7 +27,7 @@ use floem::{
2727 new_window,
2828 prelude:: * ,
2929 style:: { Background , CursorStyle , TextColor , Transition } ,
30- theme:: { self , StyleThemeExt } ,
30+ theme:: StyleThemeExt ,
3131 window:: { WindowConfig , WindowId } ,
3232} ;
3333
@@ -89,8 +89,7 @@ fn app_view(window_id: WindowId) -> impl IntoView {
8989 let side_tab_bar = tabs
9090 . get ( )
9191 . into_iter ( )
92- . enumerate ( )
93- . map ( move |( idx, item) | {
92+ . map ( move |item| {
9493 item. debug_name ( item) . style ( move |s| {
9594 s. flex_row ( )
9695 . font_size ( 18. )
@@ -104,12 +103,6 @@ fn app_view(window_id: WindowId) -> impl IntoView {
104103 } )
105104 } )
106105 . hover ( |s| s. cursor ( CursorStyle :: Pointer ) )
107- . apply_if ( idx != active_tab. get ( ) , |s| {
108- s. apply (
109- theme:: hover_style ( )
110- . with_theme ( |s, t| s. border_radius ( t. border_radius ( ) ) ) ,
111- )
112- } )
113106 } )
114107 } )
115108 . list ( )
@@ -118,7 +111,7 @@ fn app_view(window_id: WindowId) -> impl IntoView {
118111 set_active_tab. set ( idx) ;
119112 }
120113 } )
121- . style ( |s| s. flex_col ( ) . width ( 140.0 ) . flex_grow ( 1. ) )
114+ . style ( |s| s. flex_col ( ) . width_full ( ) . flex_grow ( 1. ) )
122115 . scroll ( )
123116 . debug_name ( "Side Tab Bar" )
124117 . scroll_style ( |s| s. shrink_to_fit ( ) . handle_thickness ( 8. ) )
@@ -309,21 +302,56 @@ fn app_view(window_id: WindowId) -> impl IntoView {
309302 } ) ,
310303 ) ;
311304
312- add_overlay ( svg ( include_str ! ( "../assets/floem.svg" ) ) . style ( |s| {
313- s. set_style_value ( TextColor , floem:: style:: StyleValue :: Unset )
314- . size ( 50 , 50 )
315- . absolute ( )
316- . inset_bottom ( 20. )
317- . inset_right ( 15. )
318- } ) ) ;
319-
320305 add_overlay (
321- button ( "toggle theme" )
322- . action ( toggle_theme)
323- . style ( |s| s. absolute ( ) . inset_top ( 10. ) . inset_right ( 22. ) ) ,
306+ v_stack ( (
307+ svg ( include_str ! ( "../assets/floem.svg" ) ) . style ( |s| {
308+ s. set_style_value ( TextColor , floem:: style:: StyleValue :: Unset )
309+ . size ( 50 , 50 )
310+ } ) ,
311+ button ( "toggle theme" ) . action ( toggle_theme) ,
312+ ) )
313+ . style ( |s| {
314+ s. absolute ( )
315+ . inset_bottom ( 20. )
316+ . inset_right ( 15. )
317+ . items_center ( )
318+ . justify_center ( )
319+ . gap ( 5 )
320+ } ) ,
324321 ) ;
325322
326- view. on_event_stop ( EventListener :: KeyUp , move |e| {
323+ let window_scale = RwSignal :: new ( 1. ) ;
324+ view. on_key_down (
325+ floem:: keyboard:: Key :: Character ( "=" . into ( ) ) ,
326+ |m| m. meta ( ) ,
327+ move |_| {
328+ set_window_scale ( {
329+ window_scale. update ( |s| * s *= 1.1 ) ;
330+ window_scale. get_untracked ( )
331+ } ) ;
332+ } ,
333+ )
334+ . on_key_down (
335+ floem:: keyboard:: Key :: Character ( "-" . into ( ) ) ,
336+ |m| m. meta ( ) ,
337+ move |_| {
338+ set_window_scale ( {
339+ window_scale. update ( |s| * s /= 1.1 ) ;
340+ window_scale. get_untracked ( )
341+ } ) ;
342+ } ,
343+ )
344+ . on_key_down (
345+ floem:: keyboard:: Key :: Character ( "0" . into ( ) ) ,
346+ |m| m. meta ( ) ,
347+ move |_| {
348+ set_window_scale ( {
349+ window_scale. update ( |s| * s = 1. ) ;
350+ window_scale. get_untracked ( )
351+ } ) ;
352+ } ,
353+ )
354+ . on_event_stop ( EventListener :: KeyUp , move |e| {
327355 if let Event :: KeyUp ( e) = e {
328356 if e. key . logical_key == Key :: Named ( NamedKey :: F11 ) {
329357 floem:: action:: inspect ( ) ;
0 commit comments