gardesk/garfield / e23528e

Browse files

app: wire up icon size controls, fix help modal scroll

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
e23528eb515f77391fc8c812e0a25add3e9051d0
Parents
63af87c
Tree
23ea1ae

1 changed file

StatusFile+-
M garfield/src/app.rs 59 3
garfield/src/app.rsmodified
@@ -6,7 +6,7 @@ use garfield::core::{
66
     trash_files, restore_from_trash,
77
 };
88
 use garfield::ui::pane::SplitDirection;
9
-use garfield::ui::{AddressBar, AppPickerDialog, AppPickerResult, Breadcrumb, ConfirmDialog, ConflictAction, ConflictDialog, ContextMenu, ContextMenuAction, ContextType, DialogResult, HelpModal, InputDialog, InputResult, Pane, ProgressDialog, Sidebar, StatusBar, TabBar, TabInfo, Toolbar, ToolbarAction, ViewMode, TAB_BAR_HEIGHT, TOOLBAR_HEIGHT};
9
+use garfield::ui::{AddressBar, AppPickerDialog, AppPickerResult, Breadcrumb, ConfirmDialog, ConflictAction, ConflictDialog, ContextMenu, ContextMenuAction, ContextType, DialogResult, HelpModal, IconSize, InputDialog, InputResult, Pane, ProgressDialog, Sidebar, StatusBar, TabBar, TabInfo, Toolbar, ToolbarAction, ViewMode, TAB_BAR_HEIGHT, TOOLBAR_HEIGHT};
1010
 use anyhow::Result;
1111
 use gartk_core::{InputEvent, Key, MouseButton, Point, Rect, Theme};
1212
 use gartk_render::{Renderer, TextStyle};
@@ -844,6 +844,12 @@ impl App {
844844
 
845845
     /// Handle mouse scroll. Returns true if a redraw is needed.
846846
     fn handle_scroll(&mut self, pos: Point, _delta_x: i32, delta_y: i32) -> bool {
847
+        // Help modal captures all scroll events when visible
848
+        if self.help_modal.is_visible() {
849
+            self.help_modal.on_scroll(delta_y);
850
+            return true;
851
+        }
852
+
847853
         // Check if scroll is over the content area (not sidebar, toolbar, etc.)
848854
         if let Some(pane) = self.focused_pane_mut() {
849855
             if let Some(tab) = pane.active_tab_mut() {
@@ -1052,12 +1058,23 @@ impl App {
10521058
                     return;
10531059
                 }
10541060
                 Key::Char('+') | Key::Char('=') => {
1055
-                    // Cycle icon size in grid view
1061
+                    // Increase icon size in grid view
1062
+                    if let Some(pane) = self.focused_pane_mut() {
1063
+                        if let Some(tab) = pane.active_tab_mut() {
1064
+                            tab.increase_icon_size();
1065
+                        }
1066
+                    }
1067
+                    self.sync_toolbar_icon_size();
1068
+                    return;
1069
+                }
1070
+                Key::Char('-') | Key::Char('_') => {
1071
+                    // Decrease icon size in grid view
10561072
                     if let Some(pane) = self.focused_pane_mut() {
10571073
                         if let Some(tab) = pane.active_tab_mut() {
1058
-                            tab.cycle_icon_size();
1074
+                            tab.decrease_icon_size();
10591075
                         }
10601076
                     }
1077
+                    self.sync_toolbar_icon_size();
10611078
                     return;
10621079
                 }
10631080
                 Key::Char('t') | Key::Char('T') => {
@@ -1313,6 +1330,8 @@ impl App {
13131330
 
13141331
         self.sync_tab_bar();
13151332
         self.sync_breadcrumb();
1333
+        self.sync_toolbar_view();
1334
+        self.sync_toolbar_icon_size();
13161335
         self.update_status_bar();
13171336
     }
13181337
 
@@ -1399,6 +1418,7 @@ impl App {
13991418
             self.sync_tab_bar();
14001419
             self.sync_breadcrumb();
14011420
             self.sync_toolbar_view();
1421
+            self.sync_toolbar_icon_size();
14021422
             self.update_status_bar();
14031423
         }
14041424
     }
@@ -1409,6 +1429,8 @@ impl App {
14091429
             self.focused_pane_id = new_id;
14101430
             self.sync_tab_bar();
14111431
             self.sync_breadcrumb();
1432
+            self.sync_toolbar_view();
1433
+            self.sync_toolbar_icon_size();
14121434
             self.update_status_bar();
14131435
         }
14141436
     }
@@ -1419,6 +1441,8 @@ impl App {
14191441
             self.focused_pane_id = new_id;
14201442
             self.sync_tab_bar();
14211443
             self.sync_breadcrumb();
1444
+            self.sync_toolbar_view();
1445
+            self.sync_toolbar_icon_size();
14221446
             self.update_status_bar();
14231447
         }
14241448
     }
@@ -1429,6 +1453,8 @@ impl App {
14291453
             self.focused_pane_id = new_id;
14301454
             self.sync_tab_bar();
14311455
             self.sync_breadcrumb();
1456
+            self.sync_toolbar_view();
1457
+            self.sync_toolbar_icon_size();
14321458
             self.update_status_bar();
14331459
         }
14341460
     }
@@ -1439,6 +1465,8 @@ impl App {
14391465
             self.focused_pane_id = new_id;
14401466
             self.sync_tab_bar();
14411467
             self.sync_breadcrumb();
1468
+            self.sync_toolbar_view();
1469
+            self.sync_toolbar_icon_size();
14421470
             self.update_status_bar();
14431471
         }
14441472
     }
@@ -2530,6 +2558,7 @@ impl App {
25302558
         }
25312559
         self.status_bar.set_view_mode(mode.name());
25322560
         self.sync_toolbar_view();
2561
+        self.sync_toolbar_icon_size();
25332562
         self.update_status_bar();
25342563
     }
25352564
 
@@ -2551,7 +2580,20 @@ impl App {
25512580
             ToolbarAction::Paste => self.paste(),
25522581
             ToolbarAction::Trash => self.trash_selected(),
25532582
             ToolbarAction::NewFolder => self.create_new_folder(),
2583
+            ToolbarAction::IconSizeSmall => self.set_icon_size(IconSize::Small),
2584
+            ToolbarAction::IconSizeMedium => self.set_icon_size(IconSize::Medium),
2585
+            ToolbarAction::IconSizeLarge => self.set_icon_size(IconSize::Large),
2586
+        }
2587
+    }
2588
+
2589
+    /// Set icon size for the active tab's grid view.
2590
+    fn set_icon_size(&mut self, size: IconSize) {
2591
+        if let Some(pane) = self.focused_pane_mut() {
2592
+            if let Some(tab) = pane.active_tab_mut() {
2593
+                tab.set_icon_size(size);
2594
+            }
25542595
         }
2596
+        self.sync_toolbar_icon_size();
25552597
     }
25562598
 
25572599
     /// Sync toolbar active view with current tab's view mode.
@@ -2568,6 +2610,20 @@ impl App {
25682610
         }
25692611
     }
25702612
 
2613
+    /// Sync toolbar icon size with current tab's grid view icon size.
2614
+    fn sync_toolbar_icon_size(&mut self) {
2615
+        if let Some(pane) = self.focused_pane() {
2616
+            if let Some(tab) = pane.active_tab() {
2617
+                let action = match tab.icon_size() {
2618
+                    IconSize::Small => ToolbarAction::IconSizeSmall,
2619
+                    IconSize::Medium => ToolbarAction::IconSizeMedium,
2620
+                    IconSize::Large => ToolbarAction::IconSizeLarge,
2621
+                };
2622
+                self.toolbar.set_active_icon_size(action);
2623
+            }
2624
+        }
2625
+    }
2626
+
25712627
     // === Sync helpers ===
25722628
 
25732629
     /// Sync tab bar with focused pane's tabs.