mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-13 15:54:10 +09:00
feat: allow negative spacing on combined modules
This commit is contained in:
@@ -121,10 +121,12 @@ class ApplicationSettings: NSStackView {
|
|||||||
state: self.combinedModulesState
|
state: self.combinedModulesState
|
||||||
)),
|
)),
|
||||||
PreferencesRow(component: self.moduleSelector),
|
PreferencesRow(component: self.moduleSelector),
|
||||||
PreferencesRow(localizedString("Spacing"), component: selectView(
|
PreferencesRow(localizedString("Spacing"), component: sliderView(
|
||||||
action: #selector(self.toggleCombinedModulesSpacing),
|
action: #selector(self.changeCombinedModulesSpacing),
|
||||||
items: CombinedModulesSpacings,
|
value: Int(self.combinedModulesSpacing) ?? 0,
|
||||||
selected: self.combinedModulesSpacing
|
initialValue: "\(Int(self.combinedModulesSpacing) ?? 0) px",
|
||||||
|
min: -8,
|
||||||
|
max: 8
|
||||||
)),
|
)),
|
||||||
PreferencesRow(localizedString("Separator"), component: switchView(
|
PreferencesRow(localizedString("Separator"), component: switchView(
|
||||||
action: #selector(self.toggleCombinedModulesSeparator),
|
action: #selector(self.toggleCombinedModulesSeparator),
|
||||||
@@ -339,9 +341,12 @@ class ApplicationSettings: NSStackView {
|
|||||||
NotificationCenter.default.post(name: .toggleOneView, object: nil, userInfo: nil)
|
NotificationCenter.default.post(name: .toggleOneView, object: nil, userInfo: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc private func toggleCombinedModulesSpacing(_ sender: NSMenuItem) {
|
@objc private func changeCombinedModulesSpacing(_ sender: NSSlider) {
|
||||||
guard let key = sender.representedObject as? String else { return }
|
let value = Int(sender.intValue)
|
||||||
self.combinedModulesSpacing = key
|
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)
|
NotificationCenter.default.post(name: .moduleRearrange, object: nil, userInfo: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ internal class CombinedView: NSObject, NSGestureRecognizerDelegate {
|
|||||||
self.view.subviews[i].setFrameOrigin(NSPoint(x: w, y: 0))
|
self.view.subviews[i].setFrameOrigin(NSPoint(x: w, y: 0))
|
||||||
w += m.menuBar.view.frame.width + self.spacing
|
w += m.menuBar.view.frame.width + self.spacing
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
if self.separator && i < 2 * self.activeModules.count - 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))
|
let separator = NSView(frame: NSRect(x: w, y: 3, width: 1, height: Constants.Widget.height-6))
|
||||||
separator.wantsLayer = true
|
separator.wantsLayer = true
|
||||||
|
|||||||
Reference in New Issue
Block a user