feat: allow negative spacing on combined modules

This commit is contained in:
2026-03-13 04:21:27 +09:00
parent d96409d9c0
commit 885d68c0fe
2 changed files with 13 additions and 8 deletions

View File

@@ -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)
}

View File

@@ -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