From e89c858ab7c73ef5bcad6b2d3d4764c8c0243817 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Wed, 16 Aug 2017 21:15:03 -0700 Subject: [PATCH] Revert "[kit] Dynamically build the style dropdown menu" This reverts commit f6e7217b2c7c7c21ea72d71cf8be556481c27e5e. --- MetaballsKit/PreferencesViewController.swift | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/MetaballsKit/PreferencesViewController.swift b/MetaballsKit/PreferencesViewController.swift index 5f9cb82..04ddaef 100644 --- a/MetaballsKit/PreferencesViewController.swift +++ b/MetaballsKit/PreferencesViewController.swift @@ -11,6 +11,15 @@ import Cocoa internal let PreferencesDidChange_Color = Notification.Name("PreferencesDidChange_Color") class PreferencesViewController: NSViewController { + private static var styleItems: [(name: String, tag: Int)] { + return [ + (name: NSLocalizedString("Single Color", comment: "single color menu item"), + tag: Int(ColorStyle.singleColor.rawValue)), + (name: NSLocalizedString("Two Color Gradient — Horizontal", comment: "two color horizontal gradient menu item"), + tag: Int(ColorStyle.gradient2Horizontal.rawValue)), + ] + } + public var defaults = UserDefaults.standard private var colorStackView = NSStackView() @@ -21,8 +30,13 @@ class PreferencesViewController: NSViewController { button.translatesAutoresizingMaskIntoConstraints = false let menu = NSMenu() - menu.addItem(withTitle: NSLocalizedString("Single Color", comment: "single color menu item"), action: nil, keyEquivalent: "") - menu.addItem(withTitle: NSLocalizedString("Two Color Gradient — Horizontal", comment: "two color horizontal gradient menu item"), action: nil, keyEquivalent: "") + for item in PreferencesViewController.styleItems { + // TODO: Set action here. + let menuItem = NSMenuItem(title: item.name, action: nil, keyEquivalent: "") + menuItem.target = self + menuItem.tag = item.tag + menu.addItem(menuItem) + } button.menu = menu return button