[kit] Pass colorStyle through too!
This commit is contained in:
parent
b73e4c7af1
commit
88c97d4bf5
3 changed files with 46 additions and 15 deletions
|
|
@ -118,20 +118,18 @@ class PreferencesViewController: NSViewController {
|
|||
// MARK: - Actions
|
||||
|
||||
func colorPanelDidUpdateValue(_ colorPanel: NSColorPanel) {
|
||||
var info = [String:NSColor]()
|
||||
for (idx, cv) in colorViews.enumerated() {
|
||||
if cv.colorWell.isActive {
|
||||
info["color\(idx)"] = colorPanel.color
|
||||
} else {
|
||||
info["color\(idx)"] = cv.colorWell.color
|
||||
}
|
||||
}
|
||||
NotificationCenter.default.post(name: PreferencesDidChange_Color, object: nil, userInfo: info)
|
||||
postColorNotification()
|
||||
}
|
||||
|
||||
func styleDidUpdate(sender: NSMenuItem) {
|
||||
guard let menu = styleMenu.menu else { return }
|
||||
let idx = menu.index(of: sender)
|
||||
updateColorViewVisibility()
|
||||
postColorNotification()
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
func updateColorViewVisibility() {
|
||||
let idx = styleMenu.indexOfSelectedItem
|
||||
guard idx != -1 && idx < PreferencesViewController.styleItems.count else { return }
|
||||
let styleItem = PreferencesViewController.styleItems[idx]
|
||||
for (idx, colorView) in colorViews.enumerated() {
|
||||
|
|
@ -143,6 +141,17 @@ class PreferencesViewController: NSViewController {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func postColorNotification() {
|
||||
var info = [String:Any]()
|
||||
if let item = styleMenu.selectedItem {
|
||||
info["colorStyle"] = ColorStyle(rawValue: UInt16(item.tag))
|
||||
}
|
||||
for (idx, cv) in colorViews.enumerated() {
|
||||
info["color\(idx)"] = cv.colorWell.color
|
||||
}
|
||||
NotificationCenter.default.post(name: PreferencesDidChange_Color, object: nil, userInfo: info)
|
||||
}
|
||||
}
|
||||
|
||||
class ColorView: NSView {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue