Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,19 @@ private extension KeyboardVisualizerGroupView {
return AppleKeycapMetrics.itemSpacing
}
}

private var repeatBadgeInset: CGPoint {
switch self.settings.style {
case .minimal:
return MinimalKeycapMetrics.repeatBadgeInset
case .retro:
return RetroKeycapMetrics.repeatBadgeInset
case .apple:
return AppleKeycapMetrics.repeatBadgeInset
case .pbt:
return PBTKeycapMetrics.repeatBadgeInset
}
}
}

// MARK: - Drawing
Expand Down Expand Up @@ -214,9 +227,10 @@ private extension KeyboardVisualizerGroupView {
let labelSize = badgeText.size(withAttributes: attributes)
let badgeHeight = max(26, labelSize.height + 8)
let badgeWidth = max(badgeHeight, labelSize.width + 14)
let inset = self.repeatBadgeInset
let badgeRect = NSRect(
x: self.baseSize.width - badgeWidth - 6,
y: self.baseSize.height - badgeHeight - 6,
x: self.baseSize.width - badgeWidth - inset.x,
y: self.baseSize.height - badgeHeight - inset.y,
width: badgeWidth,
height: badgeHeight
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ enum AppleKeycapMetrics {
static let minWidth: CGFloat = 74
static let itemSpacing: CGFloat = 6
static let groupPadding = NSEdgeInsets(top: 10, left: 10, bottom: 18, right: 10)
static let repeatBadgeInset = CGPoint(x: 6, y: 6)
}

enum MinimalKeycapMetrics {
Expand All @@ -46,6 +47,7 @@ enum MinimalKeycapMetrics {
static let horizontalPadding: CGFloat = 4
static let itemSpacing: CGFloat = -8
static let groupPadding = NSEdgeInsets(top: 8, left: 14, bottom: 8, right: 14)
static let repeatBadgeInset = CGPoint(x: 0, y: 0)
static let labelFont = NSFont.systemFont(ofSize: 26, weight: .medium)
static let symbolFont = NSFont.systemFont(ofSize: 36, weight: .medium)
static let imageMaxHeight: CGFloat = 36
Expand All @@ -64,6 +66,7 @@ enum RetroKeycapMetrics {
static let horizontalPadding: CGFloat = 24
static let itemSpacing: CGFloat = 10
static let groupPadding = NSEdgeInsets(top: 12, left: 12, bottom: 16, right: 12)
static let repeatBadgeInset = CGPoint(x: 6, y: 6)
static let pressedTravel: CGFloat = 3
}

Expand All @@ -77,6 +80,7 @@ enum PBTKeycapMetrics {
static let pressedTravel: CGFloat = 2.5
static let bodyInset: CGFloat = 2
static let groupPadding = NSEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
static let repeatBadgeInset = CGPoint(x: 6, y: 6)
}

extension KeycapStyle {
Expand Down
Loading