diff --git a/sushibar.xcodeproj/project.pbxproj b/sushibar.xcodeproj/project.pbxproj index fc73bc7..c329588 100644 --- a/sushibar.xcodeproj/project.pbxproj +++ b/sushibar.xcodeproj/project.pbxproj @@ -88,7 +88,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0810; - LastUpgradeCheck = 0810; + LastUpgradeCheck = 0830; ORGANIZATIONNAME = mzp; TargetAttributes = { 13E88E441DC4AEDC00AF08B0 = { @@ -169,6 +169,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_SUSPICIOUS_MOVES = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -218,6 +219,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_SUSPICIOUS_MOVES = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; diff --git a/sushibar/AppDelegate.swift b/sushibar/AppDelegate.swift index 2084a9a..1e7f71f 100644 --- a/sushibar/AppDelegate.swift +++ b/sushibar/AppDelegate.swift @@ -12,7 +12,10 @@ fileprivate extension NSTouchBarItemIdentifier { static let kome = NSTouchBarItemIdentifier("jp.mzp.touchbar.kome") static let fish = NSTouchBarItemIdentifier("jp.mzp.touchbar.fish") static let sushi = NSTouchBarItemIdentifier("jp.mzp.touchbar.sushi") - static let lane = NSTouchBarItemIdentifier("jp.mzp.touchbar.lane") +// static let lane = NSTouchBarItemIdentifier("jp.mzp.touchbar.lane") + static let komelane = NSTouchBarItemIdentifier("jp.mzp.touchbar.lane.kome") + static let fishlane = NSTouchBarItemIdentifier("jp.mzp.touchbar.lane.fish") + static let sushilane = NSTouchBarItemIdentifier("jp.mzp.touchbar.lane.sushi") } @available(OSX 10.12.2, *) @@ -46,32 +49,46 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSTouchBarProvider, NSTouchB return mainBar } - func makeSecondaryTouchBar() -> NSTouchBar { + func makeSecondaryTouchBar(tLane _tLane:NSTouchBarItemIdentifier) -> NSTouchBar { let mainBar = NSTouchBar() mainBar.delegate = self - mainBar.defaultItemIdentifiers = [.lane] + mainBar.defaultItemIdentifiers = [_tLane] return mainBar } func touchBar(_ touchBar: NSTouchBar, makeItemForIdentifier identifier: NSTouchBarItemIdentifier) -> NSTouchBarItem? { if identifier == .kome { - let item = NSCustomTouchBarItem(identifier: identifier) - let button = NSButton(title: "🍚", target: self, action: #selector(AppDelegate.tapped(_:))) - item.view = button + let item = NSPopoverTouchBarItem(identifier: identifier) + item.collapsedRepresentationLabel = "🍚" + item.popoverTouchBar = makeSecondaryTouchBar(tLane: .komelane) return item } else if identifier == .fish { + let item = NSPopoverTouchBarItem(identifier: identifier) + item.collapsedRepresentationLabel = "🐟" + item.popoverTouchBar = makeSecondaryTouchBar(tLane: .fishlane) + return item + }else if identifier == .sushi { + let item = NSPopoverTouchBarItem(identifier: identifier) + item.collapsedRepresentationLabel = "🍣" + item.popoverTouchBar = makeSecondaryTouchBar(tLane: .sushilane) + return item + } else if identifier == .sushilane { let item = NSCustomTouchBarItem(identifier: identifier) - let button = NSButton(title: "🐟", target: self, action: #selector(AppDelegate.tapped(_:))) - item.view = button + let sushiLaneVC = SushiLaneController() + sushiLaneVC.setStr(str:"🍣") + item.viewController = sushiLaneVC return item - } else if identifier == .lane { + } else if identifier == .fishlane { let item = NSCustomTouchBarItem(identifier: identifier) - item.viewController = SushiLaneController() + let sushiLaneVC = SushiLaneController() + sushiLaneVC.setStr(str:"🐟") + item.viewController = sushiLaneVC return item - } else if identifier == .sushi { - let item = NSPopoverTouchBarItem(identifier: identifier) - item.collapsedRepresentationLabel = "🍣" - item.popoverTouchBar = makeSecondaryTouchBar() + } else if identifier == .komelane { + let item = NSCustomTouchBarItem(identifier: identifier) + let sushiLaneVC = SushiLaneController() + sushiLaneVC.setStr(str:"🍚") + item.viewController = sushiLaneVC return item } else { return nil diff --git a/sushibar/SushiLaneController.swift b/sushibar/SushiLaneController.swift index e9ce666..584d5f1 100644 --- a/sushibar/SushiLaneController.swift +++ b/sushibar/SushiLaneController.swift @@ -11,7 +11,8 @@ import AppKit class SushiLaneController : NSViewController { let lane = NSView() - + var mvString="🍣" + override func loadView() { self.view = NSView() } @@ -25,13 +26,16 @@ class SushiLaneController : NSViewController { for x in 0...16 { lane.addSubview(makeSushi(x: x * 100)) } - start() } + func setStr(str: String){ + mvString = str + } + func makeSushi(x : Int) -> NSView { let sushi = NSTextView(frame: NSRect(x: x, y: 0, width: 30, height: 30)) - sushi.string = "🍣" + sushi.string = mvString sushi.drawsBackground = false sushi.isEditable = false sushi.isSelectable = false