gardesk/garfield / 8986f4f

Browse files

ui: fix tooltip opacity, edge cutoff, and help icon

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
8986f4f52e1a063cb6f87e8e19d018569113e2c5
Parents
4685c7a
Tree
058f2c3

1 changed file

StatusFile+-
M garfield/src/ui/toolbar.rs 35 9
garfield/src/ui/toolbar.rsmodified
@@ -240,13 +240,19 @@ impl Toolbar {
240240
         let tooltip_height = text_size.height + padding * 2;
241241
 
242242
         // Position tooltip below the button, centered
243
-        let tooltip_x = button.bounds.x + (button.bounds.width as i32 - tooltip_width as i32) / 2;
243
+        let mut tooltip_x = button.bounds.x + (button.bounds.width as i32 - tooltip_width as i32) / 2;
244244
         let tooltip_y = button.bounds.y + button.bounds.height as i32 + 4;
245245
 
246
+        // Clamp tooltip to stay within toolbar bounds (prevent right edge cutoff)
247
+        let max_x = self.bounds.x + self.bounds.width as i32 - tooltip_width as i32 - 4;
248
+        let min_x = self.bounds.x + 4;
249
+        tooltip_x = tooltip_x.clamp(min_x, max_x);
250
+
246251
         let tooltip_rect = Rect::new(tooltip_x, tooltip_y, tooltip_width, tooltip_height);
247252
 
248
-        // Draw tooltip background with border
249
-        renderer.fill_rounded_rect(tooltip_rect, 4.0, theme.input_background)?;
253
+        // Draw tooltip background with solid color (full opacity)
254
+        let bg_color = gartk_core::Color::from_u8(40, 40, 45, 255);
255
+        renderer.fill_rounded_rect(tooltip_rect, 4.0, bg_color)?;
250256
         renderer.stroke_rounded_rect(tooltip_rect, 4.0, theme.border, 1.0)?;
251257
 
252258
         // Draw tooltip text
@@ -418,12 +424,32 @@ impl Toolbar {
418424
     }
419425
 
420426
     fn draw_help_icon(&self, renderer: &Renderer, cx: f64, cy: f64, color: gartk_core::Color) -> Result<()> {
421
-        // Draw "?" character using text
422
-        let style = TextStyle::new()
423
-            .font_family("monospace")
424
-            .font_size(16.0)
425
-            .color(color);
426
-        renderer.text("?", cx - 4.0, cy - 8.0, &style)?;
427
+        // Draw circle outline
428
+        let r = 9.0;
429
+        let segments = 20;
430
+        for i in 0..segments {
431
+            let a1 = (i as f64 / segments as f64) * std::f64::consts::TAU;
432
+            let a2 = ((i + 1) as f64 / segments as f64) * std::f64::consts::TAU;
433
+            renderer.line(
434
+                cx + r * a1.cos(),
435
+                cy + r * a1.sin(),
436
+                cx + r * a2.cos(),
437
+                cy + r * a2.sin(),
438
+                color,
439
+                1.5,
440
+            )?;
441
+        }
442
+
443
+        // Draw "?" shape inside
444
+        // Top arc of question mark
445
+        renderer.line(cx - 2.5, cy - 3.0, cx - 1.0, cy - 5.0, color, 1.5)?;
446
+        renderer.line(cx - 1.0, cy - 5.0, cx + 2.0, cy - 5.0, color, 1.5)?;
447
+        renderer.line(cx + 2.0, cy - 5.0, cx + 3.0, cy - 3.0, color, 1.5)?;
448
+        // Curve down to stem
449
+        renderer.line(cx + 3.0, cy - 3.0, cx + 1.0, cy - 1.0, color, 1.5)?;
450
+        renderer.line(cx + 1.0, cy - 1.0, cx, cy + 1.0, color, 1.5)?;
451
+        // Dot at bottom
452
+        renderer.fill_rect(Rect::new((cx - 1.0) as i32, (cy + 3.0) as i32, 3, 3), color)?;
427453
         Ok(())
428454
     }
429455
 }