From 207af6468e775b93100843eb02084a83b029b4e4 Mon Sep 17 00:00:00 2001 From: ad Date: Sat, 28 Apr 2018 02:22:05 +0300 Subject: [PATCH 1/4] * button highlight on touch --- MTMR/CustomButtonTouchBarItem.swift | 12 +++++++++++- MTMR/Info.plist | 6 +++++- MTMR/TouchBarController.swift | 1 + 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/MTMR/CustomButtonTouchBarItem.swift b/MTMR/CustomButtonTouchBarItem.swift index 636d3ce..01996ec 100644 --- a/MTMR/CustomButtonTouchBarItem.swift +++ b/MTMR/CustomButtonTouchBarItem.swift @@ -27,6 +27,7 @@ class CustomButtonTouchBarItem: NSCustomTouchBarItem, NSGestureRecognizerDelegat button.cell?.title = title button.title = title + button.bezelStyle = .rounded button.bezelColor = bezelColor self.view = button @@ -91,13 +92,22 @@ class CustomButtonCell: NSButtonCell { super.init(textCell: "") if backgroundColor != .clear { self.isBordered = true - self.bezelStyle = .rounded self.backgroundColor = backgroundColor } else { self.isBordered = false } } + override func highlight(_ flag: Bool, withFrame cellFrame: NSRect, in controlView: NSView) { + if flag { + controlView.layer?.masksToBounds = true + self.isBordered = true + } else { + self.isBordered = false + } + super.highlight(flag, withFrame: cellFrame, in: controlView) + } + required init(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } diff --git a/MTMR/Info.plist b/MTMR/Info.plist index cd19220..3e1f8fb 100644 --- a/MTMR/Info.plist +++ b/MTMR/Info.plist @@ -26,8 +26,12 @@ NSHumanReadableCopyright Copyright © 2018 Anton Palgunov. All rights reserved. + NSLocationAlwaysUsageDescription + Weather widget need your location for correct work NSLocationUsageDescription - ... + Weather widget need your location for correct work + NSLocationWhenInUseUsageDescription + Weather widget need your location for correct work NSMainStoryboardFile Main NSPrincipalClass diff --git a/MTMR/TouchBarController.swift b/MTMR/TouchBarController.swift index c9a890b..945d464 100644 --- a/MTMR/TouchBarController.swift +++ b/MTMR/TouchBarController.swift @@ -208,6 +208,7 @@ class TouchBarController: NSObject, NSTouchBarDelegate { let button = item.button! button.imageScaling = .scaleProportionallyDown button.imagePosition = .imageLeading + button.imageHugsTitle = true button.cell?.image = source.image button.bezelColor = .clear } From 0808f0617a685c99b4b15adcf3ccb688cd59624b Mon Sep 17 00:00:00 2001 From: ad Date: Sat, 28 Apr 2018 02:28:09 +0300 Subject: [PATCH 2/4] * fix --- MTMR/CustomButtonTouchBarItem.swift | 3 --- 1 file changed, 3 deletions(-) diff --git a/MTMR/CustomButtonTouchBarItem.swift b/MTMR/CustomButtonTouchBarItem.swift index 01996ec..9d54cb0 100644 --- a/MTMR/CustomButtonTouchBarItem.swift +++ b/MTMR/CustomButtonTouchBarItem.swift @@ -100,10 +100,7 @@ class CustomButtonCell: NSButtonCell { override func highlight(_ flag: Bool, withFrame cellFrame: NSRect, in controlView: NSView) { if flag { - controlView.layer?.masksToBounds = true self.isBordered = true - } else { - self.isBordered = false } super.highlight(flag, withFrame: cellFrame, in: controlView) } From 788927edb3efd9c8f7f0cdc529a6ede7c1066b7e Mon Sep 17 00:00:00 2001 From: ad Date: Mon, 30 Apr 2018 00:57:09 +0300 Subject: [PATCH 3/4] + highlighting button background on press --- MTMR/CustomButtonTouchBarItem.swift | 2 ++ MTMR/ScrollViewItem.swift | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/MTMR/CustomButtonTouchBarItem.swift b/MTMR/CustomButtonTouchBarItem.swift index dd22d50..300e8fe 100644 --- a/MTMR/CustomButtonTouchBarItem.swift +++ b/MTMR/CustomButtonTouchBarItem.swift @@ -101,6 +101,8 @@ class CustomButtonCell: NSButtonCell { override func highlight(_ flag: Bool, withFrame cellFrame: NSRect, in controlView: NSView) { if flag { self.isBordered = true + } else { + self.isBordered = false } super.highlight(flag, withFrame: cellFrame, in: controlView) } diff --git a/MTMR/ScrollViewItem.swift b/MTMR/ScrollViewItem.swift index 850039b..c4fc12c 100644 --- a/MTMR/ScrollViewItem.swift +++ b/MTMR/ScrollViewItem.swift @@ -10,7 +10,7 @@ class ScrollViewItem: NSCustomTouchBarItem { stackView.orientation = .horizontal let scrollView = NSScrollView(frame: CGRect(origin: .zero, size: stackView.fittingSize)) scrollView.documentView = stackView - scrollView.documentView?.bounds.origin = CGPoint(x: 0.0, y: -2.5) +// scrollView.documentView?.bounds.origin = CGPoint(x: 0.0, y: -2.5) self.view = scrollView } From 6b553c4d0d152f27d1d2de0f50e1c003e71c2a1e Mon Sep 17 00:00:00 2001 From: ad Date: Mon, 30 Apr 2018 00:57:32 +0300 Subject: [PATCH 4/4] + deinit inputsource observer --- MTMR/Widgets/InputSourceBarItem.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MTMR/Widgets/InputSourceBarItem.swift b/MTMR/Widgets/InputSourceBarItem.swift index c56e26e..f32abd0 100644 --- a/MTMR/Widgets/InputSourceBarItem.swift +++ b/MTMR/Widgets/InputSourceBarItem.swift @@ -31,6 +31,10 @@ class InputSourceBarItem: CustomButtonTouchBarItem { fatalError("init(coder:) has not been implemented") } + deinit { + CFNotificationCenterRemoveEveryObserver(notificationCenter, UnsafeRawPointer(Unmanaged.passUnretained(self).toOpaque())); + } + @objc override func handleGestureSingle(gr: NSClickGestureRecognizer) { super.handleGestureSingle(gr: gr) switchInputSource()