From 885d68c0fee26ddb1e5cd68f9a2d738bc93bcc68 Mon Sep 17 00:00:00 2001 From: "Morgan J." Date: Fri, 13 Mar 2026 04:21:27 +0900 Subject: [PATCH] feat: allow negative spacing on combined modules --- Stats/Views/AppSettings.swift | 19 ++++++++++++------- Stats/Views/CombinedView.swift | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Stats/Views/AppSettings.swift b/Stats/Views/AppSettings.swift index 2faddc65..3fb68b7e 100644 --- a/Stats/Views/AppSettings.swift +++ b/Stats/Views/AppSettings.swift @@ -121,10 +121,12 @@ class ApplicationSettings: NSStackView { state: self.combinedModulesState )), PreferencesRow(component: self.moduleSelector), - PreferencesRow(localizedString("Spacing"), component: selectView( - action: #selector(self.toggleCombinedModulesSpacing), - items: CombinedModulesSpacings, - selected: self.combinedModulesSpacing + PreferencesRow(localizedString("Spacing"), component: sliderView( + action: #selector(self.changeCombinedModulesSpacing), + value: Int(self.combinedModulesSpacing) ?? 0, + initialValue: "\(Int(self.combinedModulesSpacing) ?? 0) px", + min: -8, + max: 8 )), PreferencesRow(localizedString("Separator"), component: switchView( action: #selector(self.toggleCombinedModulesSeparator), @@ -339,9 +341,12 @@ class ApplicationSettings: NSStackView { NotificationCenter.default.post(name: .toggleOneView, object: nil, userInfo: nil) } - @objc private func toggleCombinedModulesSpacing(_ sender: NSMenuItem) { - guard let key = sender.representedObject as? String else { return } - self.combinedModulesSpacing = key + @objc private func changeCombinedModulesSpacing(_ sender: NSSlider) { + let value = Int(sender.intValue) + self.combinedModulesSpacing = "\(value)" + if let valueField = sender.superview?.subviews.last as? NSTextField { + valueField.stringValue = "\(value) px" + } NotificationCenter.default.post(name: .moduleRearrange, object: nil, userInfo: nil) } diff --git a/Stats/Views/CombinedView.swift b/Stats/Views/CombinedView.swift index 10a5f619..c768a6db 100644 --- a/Stats/Views/CombinedView.swift +++ b/Stats/Views/CombinedView.swift @@ -125,7 +125,7 @@ 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 < 2 * self.activeModules.count - 1 { let separator = NSView(frame: NSRect(x: w, y: 3, width: 1, height: Constants.Widget.height-6)) separator.wantsLayer = true