gardesk/gartop / 9d4452b

Browse files

Improve GUI spacing and layout breathing room

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
9d4452b4cb66483a33ae540eabf48478d3470735
Parents
9f6cd44
Tree
351ecb7

2 changed files

StatusFile+-
M gartop/src/gui/app.rs 21 11
M gartop/src/gui/process_list.rs 5 5
gartop/src/gui/app.rsmodified
@@ -23,6 +23,12 @@ const HEADER_HEIGHT: u32 = 40;
2323
 /// Graph height.
2424
 const GRAPH_HEIGHT: u32 = 150;
2525
 
26
+/// Horizontal content padding.
27
+const CONTENT_PADDING: u32 = 16;
28
+
29
+/// Vertical gap between sections.
30
+const SECTION_GAP: u32 = 12;
31
+
2632
 /// Default window dimensions.
2733
 const DEFAULT_WIDTH: u32 = 800;
2834
 const DEFAULT_HEIGHT: u32 = 600;
@@ -87,7 +93,8 @@ impl App {
8793
 
8894
         // Create components
8995
         let header = HeaderBar::new(Rect::new(0, 0, width, HEADER_HEIGHT));
90
-        let tab_bar = TabBar::new(Rect::new(0, HEADER_HEIGHT as i32, width, TAB_BAR_HEIGHT));
96
+        let tab_bar_y = HEADER_HEIGHT + 4; // Small gap below header
97
+        let tab_bar = TabBar::new(Rect::new(0, tab_bar_y as i32, width, TAB_BAR_HEIGHT));
9198
         let process_list = Self::create_process_list(width, height);
9299
 
93100
         // Check if daemon is available
@@ -117,9 +124,12 @@ impl App {
117124
 
118125
     /// Create process list with correct bounds.
119126
     fn create_process_list(width: u32, height: u32) -> ProcessList {
120
-        let content_start = HEADER_HEIGHT + TAB_BAR_HEIGHT + GRAPH_HEIGHT + 24; // 24 for graph label
127
+        // Account for: header + gap + tab bar + section gap + graph label + graph + section gap
128
+        let tab_bar_y = HEADER_HEIGHT + 4;
129
+        let content_start = tab_bar_y + TAB_BAR_HEIGHT + SECTION_GAP + 20 + GRAPH_HEIGHT + SECTION_GAP;
121130
         let list_height = height.saturating_sub(content_start);
122
-        ProcessList::new(Rect::new(0, content_start as i32, width, list_height))
131
+        let list_width = width.saturating_sub(CONTENT_PADDING * 2);
132
+        ProcessList::new(Rect::new(CONTENT_PADDING as i32, content_start as i32, list_width, list_height))
123133
     }
124134
 
125135
     /// Check if daemon is available by attempting a connection.
@@ -271,8 +281,7 @@ impl App {
271281
 
272282
     /// Render the content for the active tab.
273283
     fn render_tab_content(&self, content_y: i32, _content_height: u32) -> Result<()> {
274
-        let padding = 12;
275
-        let graph_width = self.width - (padding * 2) as u32;
284
+        let graph_width = self.width - (CONTENT_PADDING * 2);
276285
 
277286
         // Get Cairo context for graph rendering
278287
         let ctx = self.renderer.context()?;
@@ -281,7 +290,7 @@ impl App {
281290
             ..LineGraph::default()
282291
         };
283292
 
284
-        let mut y = content_y + padding as i32;
293
+        let mut y = content_y + SECTION_GAP as i32;
285294
 
286295
         match self.tab_bar.active() {
287296
             Tab::Cpu => {
@@ -293,7 +302,7 @@ impl App {
293302
                 };
294303
                 self.renderer.text(
295304
                     &cpu_label,
296
-                    padding as f64,
305
+                    CONTENT_PADDING as f64,
297306
                     y as f64 + 14.0,
298307
                     &TextStyle {
299308
                         font_family: "monospace".to_string(),
@@ -322,7 +331,7 @@ impl App {
322331
                 y += 20;
323332
 
324333
                 // CPU Graph
325
-                let graph_rect = Rect::new(padding as i32, y, graph_width, GRAPH_HEIGHT);
334
+                let graph_rect = Rect::new(CONTENT_PADDING as i32, y, graph_width, GRAPH_HEIGHT);
326335
                 let mut cpu_series = DataSeries::new("CPU", self.theme.cpu_color);
327336
                 cpu_series.set_values(self.cpu_history.iter().map(|s| s.usage_percent).collect());
328337
                 graph.render(&ctx, graph_rect, &[cpu_series], &self.theme);
@@ -342,7 +351,7 @@ impl App {
342351
                 };
343352
                 self.renderer.text(
344353
                     &mem_label,
345
-                    padding as f64,
354
+                    CONTENT_PADDING as f64,
346355
                     y as f64 + 14.0,
347356
                     &TextStyle {
348357
                         font_family: "monospace".to_string(),
@@ -375,7 +384,7 @@ impl App {
375384
                 y += 20;
376385
 
377386
                 // Memory Graph
378
-                let graph_rect = Rect::new(padding as i32, y, graph_width, GRAPH_HEIGHT);
387
+                let graph_rect = Rect::new(CONTENT_PADDING as i32, y, graph_width, GRAPH_HEIGHT);
379388
                 let mut mem_series = DataSeries::new("Memory", self.theme.memory_color);
380389
                 let mut swap_series = DataSeries::new("Swap", self.theme.swap_color);
381390
                 mem_series.set_values(self.memory_history.iter().map(|s| s.usage_percent).collect());
@@ -436,7 +445,8 @@ impl App {
436445
 
437446
         // Update component bounds
438447
         self.header = HeaderBar::new(Rect::new(0, 0, width, HEADER_HEIGHT));
439
-        self.tab_bar.set_bounds(Rect::new(0, HEADER_HEIGHT as i32, width, TAB_BAR_HEIGHT));
448
+        let tab_bar_y = HEADER_HEIGHT + 4;
449
+        self.tab_bar.set_bounds(Rect::new(0, tab_bar_y as i32, width, TAB_BAR_HEIGHT));
440450
         self.process_list = Self::create_process_list(width, height);
441451
         self.process_list.set_processes(self.processes.clone());
442452
 
gartop/src/gui/process_list.rsmodified
@@ -133,13 +133,13 @@ impl ProcessList {
133133
             ..text_style.clone()
134134
         };
135135
 
136
-        // Column positions
136
+        // Column positions (PID can be 7 digits, ~56px at 11px monospace)
137137
         let x = self.bounds.x as f64;
138138
         let col_pid = x + 8.0;
139
-        let col_name = x + 70.0;
140
-        let col_cpu = x + 220.0;
141
-        let col_mem = x + 290.0;
142
-        let col_user = x + 380.0;
139
+        let col_name = x + 80.0;
140
+        let col_cpu = x + 230.0;
141
+        let col_mem = x + 300.0;
142
+        let col_user = x + 390.0;
143143
 
144144
         // Header
145145
         let header_y = self.bounds.y as f64 + 16.0;