diff --git a/Calendr.xcodeproj/project.pbxproj b/Calendr.xcodeproj/project.pbxproj index 007fec2..b898482 100644 --- a/Calendr.xcodeproj/project.pbxproj +++ b/Calendr.xcodeproj/project.pbxproj @@ -1487,7 +1487,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); - MARKETING_VERSION = 1.14.2; + MARKETING_VERSION = 1.14.3; PRODUCT_BUNDLE_IDENTIFIER = br.paker.Calendr; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Calendr/Config/Calendr-Bridging-Header.h"; @@ -1515,7 +1515,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); - MARKETING_VERSION = 1.14.2; + MARKETING_VERSION = 1.14.3; PRODUCT_BUNDLE_IDENTIFIER = br.paker.Calendr; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Calendr/Config/Calendr-Bridging-Header.h"; diff --git a/Calendr/MenuBar/StatusItemIconFactory.swift b/Calendr/MenuBar/StatusItemIconFactory.swift index 62884a0..291c4a7 100644 --- a/Calendr/MenuBar/StatusItemIconFactory.swift +++ b/Calendr/MenuBar/StatusItemIconFactory.swift @@ -10,13 +10,19 @@ import AppKit enum StatusItemIconFactory { static func icon(size: CGFloat, style: StatusItemIconStyle, textScaling: Double, dateProvider: DateProviding) -> NSImage { - let headerHeight: CGFloat = 3.5 + let headerHeight: CGFloat = 3 * textScaling let borderWidth: CGFloat = 2 let radius: CGFloat = 2.5 - let ratio: CGFloat = 1.15 - let rect = CGRect(x: 0, y: 0, width: size * ratio, height: size) + let rect = CGRect(x: 0, y: 0, width: size + borderWidth, height: size) - let image = NSImage(size: rect.size, flipped: true) { _ in + let size = switch style { + case .calendar, .date: + rect.size + case .dayOfWeek: + rect.insetBy(dx: -2, dy: -1).size + } + + let image = NSImage(size: size, flipped: true) { _ in /// can be any opaque color, but red is good for debugging let color = NSColor.red color.setStroke() @@ -89,7 +95,7 @@ enum StatusItemIconFactory { let date = formatter.string(from: dateProvider.now) let paragraph = NSMutableParagraphStyle() paragraph.alignment = .center - let fontSize = 0.5 * rect.height * textScaling + let fontSize = 0.6 * rect.height NSAttributedString(string: date, attributes: [ .font: NSFont.systemFont(ofSize: fontSize, weight: .medium), .foregroundColor: NSColor.red, @@ -105,29 +111,31 @@ enum StatusItemIconFactory { let paragraph = NSMutableParagraphStyle() paragraph.alignment = .center - let headerFontSize = round(6.5 * textScaling) - let dateFontSize = round(7.5 * textScaling) + let fontSize = 0.6 * rect.height + let middleY = rect.height / 2 - fontSize / 2 + 1 + let middleYSpread = fontSize / 2.5 + 1 + let insetX = 2.5 run { formatter.dateFormat = "E" let date = formatter.string(from: dateProvider.now).uppercased().trimmingCharacters(in: ["."]) NSAttributedString(string: date, attributes: [ - .font: NSFont.systemFont(ofSize: headerFontSize, weight: .bold), + .font: NSFont.systemFont(ofSize: fontSize, weight: .bold), .foregroundColor: NSColor.red, .paragraphStyle: paragraph ]) - .draw(in: rect.offsetBy(dx: 0, dy: -2).insetBy(dx: -0.5, dy: 0)) + .draw(in: rect.offsetBy(dx: insetX, dy: middleY - middleYSpread).insetBy(dx: -insetX, dy: 0)) } run { formatter.dateFormat = "d" let date = formatter.string(from: dateProvider.now) NSAttributedString(string: date, attributes: [ - .font: NSFont.systemFont(ofSize: dateFontSize, weight: .medium), + .font: NSFont.systemFont(ofSize: fontSize, weight: .bold), .foregroundColor: NSColor.red, .paragraphStyle: paragraph ]) - .draw(in: rect.offsetBy(dx: 0, dy: rect.height / 3)) + .draw(in: rect.offsetBy(dx: insetX, dy: middleY + middleYSpread).insetBy(dx: 0, dy: -1)) } } } diff --git a/Calendr/MenuBar/StatusItemViewModel.swift b/Calendr/MenuBar/StatusItemViewModel.swift index 730f02d..928ba6e 100644 --- a/Calendr/MenuBar/StatusItemViewModel.swift +++ b/Calendr/MenuBar/StatusItemViewModel.swift @@ -171,7 +171,7 @@ class StatusItemViewModel { let padding: NSPoint = text.isEmpty ? .init(x: border, y: border) : .init(x: 4, y: 2) let spacing: CGFloat = 4 var iconsWidth = icons.map(\.size.width).reduce(0) { $0 + $1 + spacing } - let height = max(icons.map(\.size.height).reduce(0, max), 15) + let height = icons.map(\.size.height).reduce(0, max) if text.isEmpty { iconsWidth -= spacing }