diff --git a/Padbury Clock Revived.xcodeproj/project.pbxproj b/Padbury Clock Revived.xcodeproj/project.pbxproj
index f26ba43..df01648 100644
--- a/Padbury Clock Revived.xcodeproj/project.pbxproj
+++ b/Padbury Clock Revived.xcodeproj/project.pbxproj
@@ -276,6 +276,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
+ CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = VW549R3EEQ;
INFOPLIST_FILE = "Padbury Clock Revived/Info.plist";
INSTALL_PATH = "$(HOME)/Library/Screen Savers";
@@ -284,7 +285,8 @@
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
- MARKETING_VERSION = 1.1.0;
+ MACOSX_DEPLOYMENT_TARGET = 10.15;
+ MARKETING_VERSION = 1.1.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.hans.Padbury-Clock-Revived";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@@ -300,6 +302,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
+ CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = VW549R3EEQ;
INFOPLIST_FILE = "Padbury Clock Revived/Info.plist";
INSTALL_PATH = "$(HOME)/Library/Screen Savers";
@@ -308,7 +311,8 @@
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
- MARKETING_VERSION = 1.1.0;
+ MACOSX_DEPLOYMENT_TARGET = 10.15;
+ MARKETING_VERSION = 1.1.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.hans.Padbury-Clock-Revived";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
diff --git a/Padbury Clock Revived.xcodeproj/project.xcworkspace/xcuserdata/hans.xcuserdatad/UserInterfaceState.xcuserstate b/Padbury Clock Revived.xcodeproj/project.xcworkspace/xcuserdata/hans.xcuserdatad/UserInterfaceState.xcuserstate
index 8124721..5f2eaf4 100644
Binary files a/Padbury Clock Revived.xcodeproj/project.xcworkspace/xcuserdata/hans.xcuserdatad/UserInterfaceState.xcuserstate and b/Padbury Clock Revived.xcodeproj/project.xcworkspace/xcuserdata/hans.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/Padbury Clock Revived.xcodeproj/xcshareddata/xcschemes/Padbury Clock Revived.xcscheme b/Padbury Clock Revived.xcodeproj/xcshareddata/xcschemes/Padbury Clock Revived.xcscheme
new file mode 100644
index 0000000..8012428
--- /dev/null
+++ b/Padbury Clock Revived.xcodeproj/xcshareddata/xcschemes/Padbury Clock Revived.xcscheme
@@ -0,0 +1,67 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Padbury Clock Revived.xcodeproj/xcuserdata/hans.xcuserdatad/xcschemes/xcschememanagement.plist b/Padbury Clock Revived.xcodeproj/xcuserdata/hans.xcuserdatad/xcschemes/xcschememanagement.plist
index 2f01122..c489254 100644
--- a/Padbury Clock Revived.xcodeproj/xcuserdata/hans.xcuserdatad/xcschemes/xcschememanagement.plist
+++ b/Padbury Clock Revived.xcodeproj/xcuserdata/hans.xcuserdatad/xcschemes/xcschememanagement.plist
@@ -10,5 +10,13 @@
0
+ SuppressBuildableAutocreation
+
+ 3AA5BF5925C98A31005B39FE
+
+ primary
+
+
+
diff --git a/Padbury Clock Revived/ClockView.swift b/Padbury Clock Revived/ClockView.swift
index 3c671e9..9cdce82 100644
--- a/Padbury Clock Revived/ClockView.swift
+++ b/Padbury Clock Revived/ClockView.swift
@@ -15,13 +15,14 @@ final class ClockView: ScreenSaverView {
static var shared: ClockView? = nil
override init?(frame: NSRect, isPreview: Bool) {
+ // Setup Window
super.init(frame: frame, isPreview: isPreview)
- ClockView.shared = self
+ if isPreview { ClockView.shared = self }
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
- ClockView.shared = self
+// ClockView.shared = self
}
// MARK: - Configuration
@@ -32,85 +33,122 @@ final class ClockView: ScreenSaverView {
var vOffset: CGFloat = 0
var backgroundColor: NSColor = .blue
- var foregroundColor: NSColor = .blue
+ var foregroundColor: NSColor = .green
var dateFormatter: DateFormatter = DateFormatter()
var attributes: [NSAttributedString.Key: Any] = [:]
+ var lastUsedNightTimeMode: Bool = false
+
func setup(force: Bool = false) {
- if force || !hasSetup {
- hasSetup = true
-
- let currentHour = Calendar.current.component(.hour, from: Date())
- let useNightTimeMode = preferences.nightTimeMode && (currentHour >= (10 + 12) || currentHour < 6)
-
- if preferences.darkTheme {
- backgroundColor = .black
- foregroundColor = useNightTimeMode ? NSColor(red: 2.0 / 3.0, green: 0, blue: 0, alpha: 1) : .white
- } else {
- backgroundColor = .white
- foregroundColor = useNightTimeMode ? .red : .black
- }
-
- let separator = preferences.showTimeSeparators ? ":" : " "
-
- let hour = preferences.useAmPm ? "h" : "HH"
- let minute = "\(separator)mm"
- let second = preferences.showSeconds ? "\(separator)ss" : ""
- let suffix = preferences.useAmPm ? " a" : ""
- dateFormatter.locale = Locale(identifier: "en_US_POSIX")
- dateFormatter.dateFormat = "\(hour)\(minute)\(second)\(suffix)"
- dateFormatter.amSymbol = "AM"
- dateFormatter.pmSymbol = "PM"
-
- let fontSizeScaleFactor : CGFloat
- switch preferences.font {
- case .sanFrancisco, .helveticaNeue:
- fontSizeScaleFactor = 0.20
- case .sanFranciscoMono:
- fontSizeScaleFactor = 0.15
- case .newYork:
- fontSizeScaleFactor = 0.17
- }
- fontSize = fontSizeScaleFactor * bounds.width
-
- // TODO: dynamically determine value. I don't know how though
- // 0.5: align center of target rect with center of screen
- // 0.15: offset so font is visually centered
- vOffset = fontSize * 0.5 - 0.15 * fontSize
-
- let font = preferences.nsFont(ofSize: fontSize)
- let paragraphStyle = NSMutableParagraphStyle()
- paragraphStyle.alignment = .center
- attributes = [
- .font : font,
- .foregroundColor: foregroundColor,
- .paragraphStyle: paragraphStyle,
- ]
+ // Get the current hour to determine conditions for night mode
+ let currentHour = Calendar.current.component(.hour, from: Date())
+ let useNightTimeMode = preferences.nightTimeMode && (currentHour >= (10 + 12) || currentHour < 6)
+ let nightTimeModeChanged = lastUsedNightTimeMode != useNightTimeMode
+
+ // Don't run the setup for every frame, only for the first time or when explicitly asked to
+ // or when the night time mode changed
+ if hasSetup && !force && !nightTimeModeChanged { return }
+ hasSetup = true
+
+ // Set the background and foreground color variables to use later
+ if useNightTimeMode {
+ backgroundColor = .black
+ // Red night time mode color, picked from the original
+ foregroundColor = NSColor(red: 255 / 255, green: 59 / 255, blue: 48 / 255, alpha: 1)
+ } else if preferences.darkTheme {
+ backgroundColor = .black
+ foregroundColor = .white
+ } else { // light theme
+ backgroundColor = .white
+ foregroundColor = .black
+ }
+
+ // Use a space or a colon as separator according to the settings
+ let separator = preferences.showTimeSeparators ? ":" : " "
+
+ // Time format setup according to the seconds
+ let hour = preferences.useAmPm ? "h" : "HH"
+ let minute = "\(separator)mm"
+ let second = preferences.showSeconds ? "\(separator)ss" : ""
+ let suffix = preferences.useAmPm ? " a" : ""
+ dateFormatter.locale = Locale(identifier: "en_US_POSIX")
+ dateFormatter.dateFormat = "\(hour)\(minute)\(second)\(suffix)"
+ dateFormatter.amSymbol = "AM"
+ dateFormatter.pmSymbol = "PM"
+
+ // The font gets a font size relative to the screen width as not to clip.
+ // I don't know how to determine this correctly, these are ugly hard coded
+ // numbers and they MIGHT fail for long strings (bold + AM/PM). If you know
+ // of a better system please make a pull request or write me an email!
+ // >>> contact.kamik423@gmail.com <<<
+ let fontSizeScaleFactor : CGFloat
+ switch preferences.font {
+ case .sanFrancisco, .neueHelvetica:
+ fontSizeScaleFactor = 0.20
+ case .sanFranciscoMono:
+ fontSizeScaleFactor = 0.13
+ case .newYork:
+ fontSizeScaleFactor = 0.17
}
+ fontSize = fontSizeScaleFactor * bounds.width
+
+ // Vertical offset of the font. This is manually determined.
+ // The 0.15 is to move it down a bit since the center of the font rect is
+ // lower than the center of the numbers as the rect accounts for lower case
+ // letter that might extend below the baseline.
+ //
+ // 0.5: align center of target rect with center of screen
+ // 0.15: offset so font is visually centered
+ vOffset = fontSize * 0.5 - 0.15 * fontSize
+
+ // Load the correct font
+ let font = preferences.nsFont(ofSize: fontSize)
+ // Set the paragraph style with the correct font, centering and color.
+ let paragraphStyle = NSMutableParagraphStyle()
+ paragraphStyle.alignment = .center
+ attributes = [
+ .font : font,
+ .foregroundColor: foregroundColor,
+ .paragraphStyle: paragraphStyle,
+ ]
}
// MARK: - Drawing
override func animateOneFrame() {
super.animateOneFrame()
+ // Update the screen. This could potentially be improved by only updating
+ // the text bit.
setNeedsDisplay(bounds)
}
override func draw(_ dirtyRect: NSRect) {
super.draw(dirtyRect)
+ // Reload variables if needed
setup()
+ // Fill the screen in with the background color in case it was not painted
+ // yet and to overwrite the last font printed
backgroundColor.setFill()
bounds.fill()
+ // If the setting is set to only draw on the main screen and this is not
+ // the main screen stop here.
+ let isMainScreen = self.window?.screen == .main
+ if preferences.mainScreenOnly && !isMainScreen { return }
+
+ // The font rect. vOffset has been described above
let targetRect = NSRect(x: 0, y: bounds.height * 0.5 - vOffset, width: bounds.width, height: fontSize)
-// NSColor.red.setFill()
-// targetRect.fill()
+ ///// For debugging the font rect can be drawn now.
+ // NSColor.blue.setFill()
+ // targetRect.fill()
+ // Get the time string
let time = NSString(string: dateFormatter.string(from: Date()))
+ // Draw the time
time.draw(in: targetRect, withAttributes: attributes)
}
diff --git a/Padbury Clock Revived/ConfigureSheet.xib b/Padbury Clock Revived/ConfigureSheet.xib
index d073246..9fdfeda 100644
--- a/Padbury Clock Revived/ConfigureSheet.xib
+++ b/Padbury Clock Revived/ConfigureSheet.xib
@@ -11,6 +11,7 @@
+
@@ -25,19 +26,20 @@
-
+
-
+
+
@@ -46,7 +48,7 @@
-
+
@@ -56,7 +58,7 @@
-
+
-
+
@@ -111,7 +113,7 @@
-
+
-
+
@@ -168,7 +170,7 @@
-
+
@@ -209,8 +211,30 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Padbury Clock Revived/ConfigureSheetController.swift b/Padbury Clock Revived/ConfigureSheetController.swift
index 4942de4..5e615bf 100644
--- a/Padbury Clock Revived/ConfigureSheetController.swift
+++ b/Padbury Clock Revived/ConfigureSheetController.swift
@@ -12,6 +12,7 @@ class ConfigureSheetController: NSObject {
@IBOutlet var window: NSWindow?
+ // Outlets for the checkboxes to use
@IBOutlet var versionStringLabel: NSTextField!
@IBOutlet var darkThemeCheckbox: NSButton!
@@ -21,11 +22,12 @@ class ConfigureSheetController: NSObject {
@IBOutlet var showTimeSeparatorsCheckbox: NSButton!
@IBOutlet var fontSelector: NSPopUpButton!
@IBOutlet var fontWeightSelector: NSPopUpButton!
+ @IBOutlet var mainScreenCheckbox: NSButton!
override init() {
super.init()
- let myBundle = Bundle(for: ConfigureSheetController.self)
- myBundle.loadNibNamed("ConfigureSheet", owner: self, topLevelObjects: nil)
+ // Load the UI
+ Bundle(for: ConfigureSheetController.self).loadNibNamed("ConfigureSheet", owner: self, topLevelObjects: nil)
}
override func awakeFromNib() {
@@ -34,54 +36,69 @@ class ConfigureSheetController: NSObject {
}
func setup() {
+ // Display the version number in the corner
let bundle = Bundle(for: ConfigureSheetController.self)
- versionStringLabel.stringValue = "v\(bundle.object(forInfoDictionaryKey: "CFBundleShortVersionString") ?? "???") b\(bundle.object(forInfoDictionaryKey: "CFBundleVersion") ?? "?")"
+ let versionNumber = bundle.object(forInfoDictionaryKey: "CFBundleShortVersionString") ?? "?.?.?"
+ let buildNumber = bundle.object(forInfoDictionaryKey: "CFBundleVersion") ?? "?"
+ versionStringLabel.stringValue = "v\(versionNumber) b\(buildNumber)"
- if let preferences = Preferences.shared {
- darkThemeCheckbox.state = preferences.darkTheme ? .on : .off
- nightTimeModeCheckbox.state = preferences.nightTimeMode ? .on : .off
- twentyfourHoursCheckbox.state = preferences.useAmPm ? .off : .on
- showSecondsCheckbox.state = preferences.showSeconds ? .on : .off
- showTimeSeparatorsCheckbox.state = preferences.showTimeSeparators ? .on : .off
- fontSelector.selectItem(withTitle: preferences.font.name)
-
- fontSelector.removeAllItems()
- let availableFonts: [String] = SupportedFonts.allCases.map { $0.name }
- for font in availableFonts {
- fontSelector.addItem(withTitle: font)
- }
- fontSelector.selectItem(withTitle: preferences.font.name)
-
- fontWeightSelector.removeAllItems()
- for fontWeight in preferences.font.availableWeights {
- fontWeightSelector.addItem(withTitle: fontWeight.name)
- }
- fontWeightSelector.selectItem(at: preferences.font.availableWeights.firstIndex(of: preferences.fontWeight) ?? 0)
- preferences.fontWeight = NSFont.Weight.from(name: fontWeightSelector.selectedItem?.title ?? "")
-
- ClockView.shared?.setup(force: true)
- }
+ // Continue only if the preferences can be loaded
+ guard let preferences = Preferences.shared else { return }
+
+ // Set the checkboxes according to the settings
+ darkThemeCheckbox.state = preferences.darkTheme ? .on : .off
+ nightTimeModeCheckbox.state = preferences.nightTimeMode ? .on : .off
+ twentyfourHoursCheckbox.state = preferences.useAmPm ? .off : .on
+ showSecondsCheckbox.state = preferences.showSeconds ? .on : .off
+ showTimeSeparatorsCheckbox.state = preferences.showTimeSeparators ? .on : .off
+ fontSelector.selectItem(withTitle: preferences.font.name)
+ mainScreenCheckbox.state = preferences.mainScreenOnly ? .on : .off
+
+ // Remove all options from the font selector and add the ones corresponding to the fonts
+ fontSelector.removeAllItems()
+ fontSelector.addItems(withTitles: SupportedFont.allCases.map { $0.name })
+ fontSelector.selectItem(withTitle: preferences.font.name)
+
+ // Remove all the options from the font weight selector
+ // and add the ones corresponding to the current font
+ fontWeightSelector.removeAllItems()
+ fontWeightSelector.addItems(withTitles: preferences.font.availableWeights.map({ $0.name }))
+ // Select the correct item
+ // If the weight is not available for this font select the first option
+ fontWeightSelector.selectItem(at: preferences.font.availableWeights.firstIndex(where: { $0.name == preferences.fontWeight.name }) ?? 0 )
+ // Store said option back to the settings in case it changed
+ preferences.fontWeight = NSFont.Weight.from(name: fontWeightSelector.selectedItem?.title ?? "")
+
+ // Trigger update of the preview window
+ ClockView.shared?.setup(force: true)
}
@IBAction func toggledCheckbox(_ sender: NSObject) {
- if let preferences = Preferences.shared {
- preferences.darkTheme = darkThemeCheckbox.state == .on
- preferences.nightTimeMode = nightTimeModeCheckbox.state == .on
- preferences.useAmPm = twentyfourHoursCheckbox.state == .off
- preferences.showSeconds = showSecondsCheckbox.state == .on
- preferences.showTimeSeparators = showTimeSeparatorsCheckbox.state == .on
- preferences.font = SupportedFonts.named(fontSelector.selectedItem?.title ?? "")
- preferences.fontWeight = NSFont.Weight.from(name: fontWeightSelector.selectedItem?.title ?? "")
-
- self.setup()
- }
+ // Write all settings once one was changed.
+
+ // Continue only if the preferences can be loaded correctly
+ guard let preferences = Preferences.shared else { return }
+
+ preferences.darkTheme = darkThemeCheckbox.state == .on
+ preferences.nightTimeMode = nightTimeModeCheckbox.state == .on
+ preferences.useAmPm = twentyfourHoursCheckbox.state == .off
+ preferences.showSeconds = showSecondsCheckbox.state == .on
+ preferences.showTimeSeparators = showTimeSeparatorsCheckbox.state == .on
+ preferences.font = SupportedFont.named(fontSelector.selectedItem?.title ?? "")
+ preferences.fontWeight = NSFont.Weight.from(name: fontWeightSelector.selectedItem?.title ?? "")
+ preferences.mainScreenOnly = mainScreenCheckbox.state == .on
+
+ // Update the options. Font weight might have changed.
+ self.setup()
}
@IBAction func closeConfigureSheet(_ sender: AnyObject) {
+ // Close the sheet
window?.sheetParent?.endSheet(window!)
}
@IBAction func openGithubLink(_ sender: Any) {
+ // Open the link to the GitHub repository
NSWorkspace.shared.open(URL(string: "https://github.com/Kamik423/Padbury-Clock-Revived")!)
}
}
diff --git a/Padbury Clock Revived/Info.plist b/Padbury Clock Revived/Info.plist
index b4251ef..b8fd0ef 100644
--- a/Padbury Clock Revived/Info.plist
+++ b/Padbury Clock Revived/Info.plist
@@ -17,7 +17,7 @@
CFBundleShortVersionString$(MARKETING_VERSION)CFBundleVersion
- 1
+ $(CURRENT_PROJECT_VERSION)NSPrincipalClassClockView
diff --git a/Padbury Clock Revived/Preferences.swift b/Padbury Clock Revived/Preferences.swift
index f4838da..236aea9 100644
--- a/Padbury Clock Revived/Preferences.swift
+++ b/Padbury Clock Revived/Preferences.swift
@@ -15,21 +15,15 @@ class Preferences: NSObject {
private let defaults: UserDefaults
override init() {
+ // Configure Defaults for bundle
defaults = ScreenSaverDefaults(forModuleWithName: Bundle(for: Preferences.self).bundleIdentifier!)!
super.init()
Preferences.shared = self
}
-
- var useSystemFont: Bool {
- get { return (defaults.value(forKey: "UseSystemFont") as? Bool) ?? true }
- set {
- defaults.setValue(newValue, forKey: "UseSystemFont")
- defaults.synchronize()
- }
- }
- var font: SupportedFonts {
- get { return SupportedFonts.named(defaults.value(forKey: "Font") as? String ?? "") }
+ var font: SupportedFont {
+ // Which font should be used
+ get { return SupportedFont.named(defaults.value(forKey: "Font") as? String ?? "") }
set {
defaults.setValue(newValue.name, forKey: "Font")
defaults.synchronize()
@@ -37,31 +31,64 @@ class Preferences: NSObject {
}
func nsFont(ofSize fontSize: CGFloat) -> NSFont {
+ // The NSFont to use with correct weight and size set
let fallback = NSFont.monospacedDigitSystemFont(ofSize: fontSize, weight: fontWeight)
switch font {
case .sanFrancisco:
+ // Default system font
return .monospacedDigitSystemFont(ofSize: fontSize, weight: fontWeight)
case .sanFranciscoMono:
+ // Monospace default system font
return .monospacedSystemFont(ofSize: fontSize, weight: fontWeight)
case .newYork:
+ // Serif default system font
let descriptor = NSFont.monospacedDigitSystemFont(ofSize: fontSize, weight: fontWeight).fontDescriptor
return NSFont(descriptor: descriptor.withDesign(.serif) ?? descriptor, size: 0.0) ?? fallback
- case .helveticaNeue:
+ case .neueHelvetica:
+ // Neue Helvetica
+ // Get the name of the font file to load
let fontName: String
switch fontWeight {
- case .ultraLight: fontName = "Helvetica Neue UltraLight"
- case .thin: fontName = "Helvetica Neue Thin"
- case .light: fontName = "Helvetica Neue Light"
- case .regular: fontName = "Helvetica Neue"
- case .medium: fontName = "Helvetica Neue Medium"
- case .bold: fontName = "Helvetica Neue Bold"
- default: fontName = "Helvetica Neue"
+ case .ultraLight:
+ fontName = "Helvetica Neue UltraLight"
+ case .thin:
+ fontName = "Helvetica Neue Thin"
+ case .light:
+ fontName = "Helvetica Neue Light"
+ case .regular:
+ fontName = "Helvetica Neue"
+ case .medium:
+ fontName = "Helvetica Neue Medium"
+ case .bold:
+ fontName = "Helvetica Neue Bold"
+ default:
+ fontName = "Helvetica Neue"
}
- return NSFont(name: fontName, size: fontSize) ?? fallback
+ // Load the font
+ guard var font = NSFont(name: fontName, size: fontSize) else { return fallback }
+ // Apply TrueType stylistic sets to get proportional numbers and the raised colon.
+ let fontAttributes: [NSFontDescriptor.AttributeName: Any] = [
+ .featureSettings: [
+ [
+ // Proportional Numbers
+ NSFontDescriptor.FeatureKey.typeIdentifier: 6,
+ NSFontDescriptor.FeatureKey.selectorIdentifier: 1
+ ],
+ [
+ // Alternate Punctuation (rounded, raised colon)
+ NSFontDescriptor.FeatureKey.typeIdentifier: 17,
+ NSFontDescriptor.FeatureKey.selectorIdentifier: 1
+ ]
+ ]
+ ]
+ // Apply the attributes
+ font = NSFont(descriptor: font.fontDescriptor.addingAttributes(fontAttributes), size: 0.0) ?? font
+ return font
}
}
var darkTheme: Bool {
+ // Should the dark theme be used
get { return (defaults.value(forKey: "DarkTheme") as? Bool) ?? true }
set {
defaults.setValue(newValue, forKey: "DarkTheme")
@@ -70,6 +97,7 @@ class Preferences: NSObject {
}
var nightTimeMode: Bool {
+ // Should the night time mode be used that makes the font red at night
get { return (defaults.value(forKey: "NightTimeMode") as? Bool) ?? false }
set {
defaults.setValue(newValue, forKey: "NightTimeMode")
@@ -78,6 +106,7 @@ class Preferences: NSObject {
}
var useAmPm: Bool {
+ // Use AM/PM or 24h time
get { return !((defaults.value(forKey: "24h") as? Bool) ?? true) }
set {
defaults.setValue(!newValue, forKey: "24h")
@@ -86,6 +115,7 @@ class Preferences: NSObject {
}
var showTimeSeparators: Bool {
+ // Show the time separators (colons)
get { return (defaults.value(forKey: "showTimeSeparators") as? Bool) ?? false }
set {
defaults.setValue(newValue, forKey: "showTimeSeparators")
@@ -94,6 +124,7 @@ class Preferences: NSObject {
}
var fontWeight: NSFont.Weight {
+ // The font weight to be used
get { return NSFont.Weight.from(name: (defaults.value(forKey: "fontWeight") as? String) ?? "Ultra Light") }
set {
defaults.setValue(newValue.name, forKey: "fontWeight")
@@ -102,23 +133,35 @@ class Preferences: NSObject {
}
var showSeconds: Bool {
+ // Should seconds be displayed or just HH and MM
get { return (defaults.value(forKey: "ShowSeconds") as? Bool) ?? true }
set {
defaults.setValue(newValue, forKey: "ShowSeconds")
defaults.synchronize()
}
}
+
+ var mainScreenOnly: Bool {
+ // Show the time only on the main screen
+ get { return (defaults.value(forKey: "MainScreenOnly") as? Bool) ?? false }
+ set {
+ defaults.setValue(newValue, forKey: "MainScreenOnly")
+ defaults.synchronize()
+ }
+ }
}
// MARK: - Supported Fonts ENum
-enum SupportedFonts: String, CaseIterable {
+enum SupportedFont: String, CaseIterable {
+ // Enum of the supported fonts
case sanFrancisco
case sanFranciscoMono
case newYork
- case helveticaNeue
+ case neueHelvetica
var name: String {
+ // Get the name of the font for UI and storing purposes
switch self {
case .sanFrancisco:
return "San Francisco (System Font)"
@@ -126,16 +169,18 @@ enum SupportedFonts: String, CaseIterable {
return "San Francisco Mono"
case .newYork:
return "New York"
- case .helveticaNeue:
- return "Helvetica Neue (Padbury Original)"
+ case .neueHelvetica:
+ return "Neue Helvetica (Padbury Original)"
}
}
- static func named(_ name: String) -> SupportedFonts {
- SupportedFonts.allCases.first(where: { $0.name == name }) ?? .sanFrancisco
+ static func named(_ name: String) -> SupportedFont {
+ // Get the font from the name
+ SupportedFont.allCases.first(where: { $0.name == name }) ?? .sanFrancisco
}
var availableWeights: [NSFont.Weight] {
+ // List of available font weights for each font
switch self {
case .sanFrancisco:
return [.ultraLight, .thin, .light, .regular, .medium, .semibold, .bold, .heavy, .black]
@@ -143,7 +188,7 @@ enum SupportedFonts: String, CaseIterable {
return [.light, .regular, .medium, .semibold, .bold, .heavy, .black]
case .newYork:
return [.regular, .medium, .semibold, .bold, .heavy, .black]
- case .helveticaNeue:
+ case .neueHelvetica:
return [.ultraLight, .thin, .light, .regular, .medium, .bold]
}
}
@@ -153,6 +198,7 @@ enum SupportedFonts: String, CaseIterable {
extension NSFont.Weight {
var name: String {
+ // Names for font weights
get {
switch self {
case .ultraLight: return "Ultra Light"
@@ -170,6 +216,7 @@ extension NSFont.Weight {
}
static func from(name: String) -> NSFont.Weight {
+ // Font weight from name
switch name {
case "Ultra Light": return .ultraLight
case "Thin": return .thin
diff --git a/README.md b/README.md
index b6ceb11..7b288ac 100644
--- a/README.md
+++ b/README.md
@@ -1,13 +1,17 @@
# Padbury Clock Revived
+![macOS](https://img.shields.io/badge/macOS-10.15-informational)
+![swift](https://img.shields.io/badge/language-Swift-orange)
+![license](https://img.shields.io/github/license/Kamik423/Padbury-Clock-Revived)
+
The [Padbury Clock](https://padbury.app) is a minimalist screensaver created by [Robert Padbury](https://twitter.com/Padbury).
It has not been updated in ages and actually broke for me during the Big Sur beta cycle (although that issue resolved itself).
At that point I decided to recreate it.
-This new version retains most of the settings from the original (if you require the single monitor setting feel free to add a pull request) and ads a new font family and font weight selection system.
-The original screensaver used Helvetia Neue Ultra Light.
+This new version retains most of the settings from the original (I honestly don't get what the alternate theme was supposed to do) and adds a new font family and font weight selection system.
+The original screensaver used Neue Helvetica Ultra Light.
With the new version you will also be able to select San Francisco, Apple's new system font as the font used.
The night time mode from the original is also supported.
@@ -21,6 +25,14 @@ Download [the latest version](https://github.com/Kamik423/Padbury-Clock-Revived/
## Changelog
+### 1.1.1 (2022-02-10)
+
+* Added option for main screen only
+* Matched shade of red to original Padbury Clock
+* Neue Helvetica now uses rounded, raised colons (TrueType Stylistic Sets 6 and 17). Not available for *Ultra Thin* and *Thin*
+* Reduced deployment target to macOS 10.15
+* Made SF Mono slightly smaller as not to cut it off with am/pm
+
### 1.1.0 (2022-02-10)
* Added more font options
diff --git a/screenshots/screenshot-0.png b/screenshots/screenshot-0.png
index 3beaa21..db08ec9 100644
Binary files a/screenshots/screenshot-0.png and b/screenshots/screenshot-0.png differ
diff --git a/screenshots/screenshot-2.png b/screenshots/screenshot-2.png
index fcc5748..c2c7221 100644
Binary files a/screenshots/screenshot-2.png and b/screenshots/screenshot-2.png differ
diff --git a/screenshots/settings.png b/screenshots/settings.png
index b8974a7..73a2ce9 100644
Binary files a/screenshots/settings.png and b/screenshots/settings.png differ