diff --git a/Stats/Views/AppSettings.swift b/Stats/Views/AppSettings.swift index 5c2e2382..ab97d9c1 100644 --- a/Stats/Views/AppSettings.swift +++ b/Stats/Views/AppSettings.swift @@ -30,6 +30,10 @@ class ApplicationSettings: NSStackView { get { Store.shared.string(key: "CombinedModules_spacing", defaultValue: "none") } set { Store.shared.set(key: "CombinedModules_spacing", value: newValue) } } + private var combinedModulesSeparator: Bool { + get { Store.shared.bool(key: "CombinedModules_separator", defaultValue: false) } + set { Store.shared.set(key: "CombinedModules_separator", value: newValue) } + } private var combinedModulesPopup: Bool { get { Store.shared.bool(key: "CombinedModules_popup", defaultValue: true) } set { Store.shared.set(key: "CombinedModules_popup", value: newValue) } @@ -125,6 +129,10 @@ class ApplicationSettings: NSStackView { items: CombinedModulesSpacings, selected: self.combinedModulesSpacing )), + PreferencesRow(localizedString("Separator"), component: switchView( + action: #selector(self.toggleCombinedModulesSeparator), + state: self.combinedModulesSeparator + )), PreferencesRow(localizedString("Combined details"), component: switchView( action: #selector(self.toggleCombinedModulesPopup), state: self.combinedModulesPopup @@ -304,6 +312,11 @@ class ApplicationSettings: NSStackView { NotificationCenter.default.post(name: .moduleRearrange, object: nil, userInfo: nil) } + @objc private func toggleCombinedModulesSeparator(_ sender: NSButton) { + self.combinedModulesSeparator = sender.state == NSControl.StateValue.on + NotificationCenter.default.post(name: .moduleRearrange, object: nil, userInfo: nil) + } + @objc private func toggleCombinedModulesPopup(_ sender: NSButton) { self.combinedModulesPopup = sender.state == NSControl.StateValue.on NotificationCenter.default.post(name: .combinedModulesPopup, object: nil, userInfo: nil) diff --git a/Stats/Views/CombinedView.swift b/Stats/Views/CombinedView.swift index 77040aff..e8d51c5a 100644 --- a/Stats/Views/CombinedView.swift +++ b/Stats/Views/CombinedView.swift @@ -23,6 +23,9 @@ internal class CombinedView: NSObject, NSGestureRecognizerDelegate { private var spacing: CGFloat { CGFloat(Int(Store.shared.string(key: "CombinedModules_spacing", defaultValue: "")) ?? 0) } + private var separator: Bool { + Store.shared.bool(key: "CombinedModules_separator", defaultValue: false) + } private var activeModules: [Module] { modules.filter({ $0.enabled }).sorted(by: { $0.combinedPosition < $1.combinedPosition }) @@ -115,6 +118,15 @@ internal class CombinedView: NSObject, NSGestureRecognizerDelegate { self.view.subviews[i].setFrameOrigin(NSPoint(x: w, y: 0)) w += m.menuBar.view.frame.width + self.spacing i += 1 + + if self.separator && i < self.activeModules.count { + let separator = NSView(frame: NSRect(x: w, y: 3, width: 1, height: Constants.Widget.height-6)) + separator.wantsLayer = true + separator.layer?.backgroundColor = (separator.isDarkMode ? NSColor.black : NSColor.white).cgColor + self.view.addSubview(separator) + w += 3 + self.spacing + i += 1 + } } self.view.setFrameSize(NSSize(width: w, height: self.view.frame.height)) self.menuBarItem?.length = w