Просмотр исходного кода

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 17 часов назад
Родитель
Сommit
c35f324433
1 измененных файлов с 17 добавлено и 2 удалено
  1. 17 2
      smart_printer/UIComponents.swift

+ 17 - 2
smart_printer/UIComponents.swift

@@ -144,13 +144,15 @@ final class SidebarNavItem: NSControl {
144
 // MARK: - Action Button
144
 // MARK: - Action Button
145
 
145
 
146
 final class PillButton: NSButton {
146
 final class PillButton: NSButton {
147
+    private let horizontalPadding: CGFloat = 16
148
+
147
     init(title: String, color: NSColor) {
149
     init(title: String, color: NSColor) {
148
         super.init(frame: .zero)
150
         super.init(frame: .zero)
149
         self.title = title
151
         self.title = title
150
         isBordered = false
152
         isBordered = false
151
         wantsLayer = true
153
         wantsLayer = true
152
         layer?.backgroundColor = color.cgColor
154
         layer?.backgroundColor = color.cgColor
153
-        layer?.cornerRadius = 10
155
+        layer?.cornerRadius = 11
154
         font = AppTheme.semiboldFont(size: 13)
156
         font = AppTheme.semiboldFont(size: 13)
155
         contentTintColor = .white
157
         contentTintColor = .white
156
 
158
 
@@ -161,12 +163,25 @@ final class PillButton: NSButton {
161
             imageHugsTitle = true
163
             imageHugsTitle = true
162
         }
164
         }
163
 
165
 
164
-        heightAnchor.constraint(equalToConstant: 36).isActive = true
166
+        heightAnchor.constraint(equalToConstant: 40).isActive = true
165
     }
167
     }
166
 
168
 
167
     @available(*, unavailable)
169
     @available(*, unavailable)
168
     required init?(coder: NSCoder) { nil }
170
     required init?(coder: NSCoder) { nil }
169
 
171
 
172
+    override var intrinsicContentSize: NSSize {
173
+        var size = super.intrinsicContentSize
174
+        size.width += horizontalPadding * 2
175
+        return size
176
+    }
177
+
178
+    override func draw(_ dirtyRect: NSRect) {
179
+        let originalBounds = bounds
180
+        defer { bounds = originalBounds }
181
+        bounds = originalBounds.insetBy(dx: horizontalPadding, dy: 0)
182
+        super.draw(dirtyRect)
183
+    }
184
+
170
     override func resetCursorRects() {
185
     override func resetCursorRects() {
171
         addCursorRect(bounds, cursor: .pointingHand)
186
         addCursorRect(bounds, cursor: .pointingHand)
172
     }
187
     }