Przeglądaj źródła

Improve Quick Start pill button sizing and horizontal padding.

Give action buttons more breathing room while keeping the same text size so the labels look balanced and centered.

Co-authored-by: Cursor <cursoragent@cursor.com>
AhtashamShahzad1 1 miesiąc temu
rodzic
commit
c35f324433
1 zmienionych plików z 17 dodań i 2 usunięć
  1. 17 2
      smart_printer/UIComponents.swift

+ 17 - 2
smart_printer/UIComponents.swift

@@ -144,13 +144,15 @@ final class SidebarNavItem: NSControl {
 // MARK: - Action Button
 // MARK: - Action Button
 
 
 final class PillButton: NSButton {
 final class PillButton: NSButton {
+    private let horizontalPadding: CGFloat = 16
+
     init(title: String, color: NSColor) {
     init(title: String, color: NSColor) {
         super.init(frame: .zero)
         super.init(frame: .zero)
         self.title = title
         self.title = title
         isBordered = false
         isBordered = false
         wantsLayer = true
         wantsLayer = true
         layer?.backgroundColor = color.cgColor
         layer?.backgroundColor = color.cgColor
-        layer?.cornerRadius = 10
+        layer?.cornerRadius = 11
         font = AppTheme.semiboldFont(size: 13)
         font = AppTheme.semiboldFont(size: 13)
         contentTintColor = .white
         contentTintColor = .white
 
 
@@ -161,12 +163,25 @@ final class PillButton: NSButton {
             imageHugsTitle = true
             imageHugsTitle = true
         }
         }
 
 
-        heightAnchor.constraint(equalToConstant: 36).isActive = true
+        heightAnchor.constraint(equalToConstant: 40).isActive = true
     }
     }
 
 
     @available(*, unavailable)
     @available(*, unavailable)
     required init?(coder: NSCoder) { nil }
     required init?(coder: NSCoder) { nil }
 
 
+    override var intrinsicContentSize: NSSize {
+        var size = super.intrinsicContentSize
+        size.width += horizontalPadding * 2
+        return size
+    }
+
+    override func draw(_ dirtyRect: NSRect) {
+        let originalBounds = bounds
+        defer { bounds = originalBounds }
+        bounds = originalBounds.insetBy(dx: horizontalPadding, dy: 0)
+        super.draw(dirtyRect)
+    }
+
     override func resetCursorRects() {
     override func resetCursorRects() {
         addCursorRect(bounds, cursor: .pointingHand)
         addCursorRect(bounds, cursor: .pointingHand)
     }
     }