Skip to content

Commit 59990df

Browse files
committed
UI workarounds, had to move the deployment target to 10.12 (meh didnt work on lower either way :/)
1 parent ff29ba8 commit 59990df

15 files changed

Lines changed: 132 additions & 109 deletions

File tree

native/Podfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ source 'https://github.com/AudioKit/Specs.git'
22
source 'https://github.com/CocoaPods/Specs.git'
33

44
# Uncomment the next line to define a global platform for your project
5-
platform :osx, '10.10'
5+
platform :osx, '10.12'
66
workspace 'eqMac.xcworkspace'
77
use_frameworks!
88

99
post_install do |installer|
1010
installer.pods_project.targets.each do |target|
1111
target.build_configurations.each do |config|
12-
config.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '10.10'
12+
config.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '10.12'
1313
end
1414
end
1515
end

native/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,6 @@ SPEC CHECKSUMS:
7575
WebViewJavascriptBridge: 7f5bc4d3581e672e8f32bd0f812d54bc69bb8e29
7676
Zip: 8877eede3dda76bcac281225c20e71c25270774c
7777

78-
PODFILE CHECKSUM: cee823746742e10772f720624e2505a594a9dd6d
78+
PODFILE CHECKSUM: 5eeb37efeacb8d92dd1cc94cad68018927f4d280
7979

8080
COCOAPODS: 1.9.3

native/app/Source/AppDelegate.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ class AppDelegate: NSObject, NSApplicationDelegate, SUUpdaterDelegate {
2020
var willBeDownloadingUpdate = false
2121

2222
func applicationDidFinishLaunching(_ aNotification: Notification) {
23-
for window in NSApplication.shared.windows {
24-
window.resignFirstResponder()
25-
window.close()
26-
}
23+
// for window in NSApplication.shared.windows {
24+
// window.resignFirstResponder()
25+
// window.close()
26+
// }
2727

2828
updater.delegate = self
2929
updateProcessed.once { _ in
@@ -64,7 +64,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, SUUpdaterDelegate {
6464
}
6565

6666
func applicationDidBecomeActive(_ notification: Notification) {
67-
UI.show()
67+
if (UI.hasLoaded) {
68+
UI.show()
69+
}
6870
}
6971

7072
func updaterDidNotFindUpdate(_ updater: SUUpdater) {

native/app/Source/Application.swift

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,12 @@ class Application {
6666
Sources.getInputPermission {
6767
AudioDevice.register = true
6868
audioPipelineIsRunningListener = audioPipelineIsRunning.once {
69-
self.setupUI()
70-
if (User.isFirstLaunch || Constants.DEBUG) {
71-
UI.show()
72-
} else {
73-
UI.close()
69+
self.setupUI {
70+
if (User.isFirstLaunch || Constants.DEBUG) {
71+
UI.show()
72+
} else {
73+
UI.close()
74+
}
7475
}
7576
}
7677
setupAudio()
@@ -342,7 +343,7 @@ class Application {
342343
}
343344
}
344345

345-
private static func setupUI () {
346+
private static func setupUI (_ completion: @escaping () -> Void) {
346347
Console.log("Setting up UI")
347348
ui = UI {
348349
setupDataBus()

native/app/Source/ApplicationDataBus.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ class ApplicationDataBus: DataBus {
5050
}
5151

5252
self.on(.GET, "/haptic") { _, _ in
53-
if #available(macOS 10.11, *) {
54-
NSHapticFeedbackManager.defaultPerformer.perform(NSHapticFeedbackManager.FeedbackPattern.alignment, performanceTime: NSHapticFeedbackManager.PerformanceTime.now)
55-
}
53+
NSHapticFeedbackManager.defaultPerformer.perform(NSHapticFeedbackManager.FeedbackPattern.alignment, performanceTime: NSHapticFeedbackManager.PerformanceTime.now)
5654
return "Haptic feedback performed"
5755
}
5856

native/app/Source/Settings/Settings.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,7 @@ class Settings: StoreSubscriber {
7171
let showDockIcon = self.iconMode == .both || self.iconMode == .dock
7272
NSApp.setActivationPolicy(showDockIcon ? .regular : .accessory)
7373
let showStatusBarIcon = self.iconMode == .both || self.iconMode == .statusBar
74-
if #available(macOS 10.12, *) {
75-
UI.statusItem.item.isVisible = showStatusBarIcon
76-
}
74+
UI.statusItem.item.isVisible = showStatusBarIcon
7775
}
7876
}
7977

native/app/Source/UI/DraggableView.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import Cocoa
1111

1212
class DraggableView: NSView {
1313
override func mouseDragged(with event: NSEvent) {
14-
if #available(macOS 10.11, *) {
15-
event.window?.performDrag(with: event)
16-
}
14+
event.window?.performDrag(with: event)
1715
}
1816
}

native/app/Source/UI/Main.storyboard

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<dependencies>
44
<deployment identifier="macosx"/>
55
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="17701"/>
6+
<plugIn identifier="com.apple.WebKit2IBPlugin" version="17701"/>
67
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
78
</dependencies>
89
<scenes>
@@ -107,6 +108,14 @@
107108
</progressIndicator>
108109
</subviews>
109110
</customView>
111+
<wkWebView wantsLayer="YES" fixedFrame="YES" allowsLinkPreview="NO" translatesAutoresizingMaskIntoConstraints="NO" id="zJG-9b-cg4">
112+
<rect key="frame" x="0.0" y="0.0" width="400" height="400"/>
113+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
114+
<wkWebViewConfiguration key="configuration">
115+
<audiovisualMediaTypes key="mediaTypesRequiringUserActionForPlayback" none="YES"/>
116+
<wkPreferences key="preferences" javaScriptCanOpenWindowsAutomatically="NO"/>
117+
</wkWebViewConfiguration>
118+
</wkWebView>
110119
<customView autoresizesSubviews="NO" wantsLayer="YES" appearanceType="darkAqua" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="bLB-gh-lJZ" customClass="DraggableView" customModule="eqMac" customModuleProvider="target">
111120
<rect key="frame" x="0.0" y="372" width="400" height="28"/>
112121
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
@@ -117,7 +126,8 @@
117126
<outlet property="draggableView" destination="bLB-gh-lJZ" id="7cR-to-BQs"/>
118127
<outlet property="loadingSpinner" destination="cyp-ij-N0e" id="ZwC-yt-JeR"/>
119128
<outlet property="loadingView" destination="RBl-OJ-pth" id="TVK-E1-Dbz"/>
120-
<outlet property="view" destination="eMQ-jC-nnX" id="XuJ-1w-qES"/>
129+
<outlet property="parentView" destination="eMQ-jC-nnX" id="tX5-iK-1f8"/>
130+
<outlet property="webView" destination="zJG-9b-cg4" id="ALI-gZ-yXs"/>
121131
</connections>
122132
</viewController>
123133
</objects>

native/app/Source/UI/UI.swift

Lines changed: 49 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,23 @@ class UI: StoreSubscriber {
6363
return Application.supportPath.appendingPathComponent("ui")
6464
}
6565

66-
static let storyboard = NSStoryboard(name: "Main", bundle: Bundle.main)
6766
static let statusItem = StatusItem(image: NSImage(named: "statusBarIcon")!)
68-
69-
static var windowController: NSWindowController = (storyboard.instantiateController(withIdentifier: "EQMWindowController") as! NSWindowController)
70-
static var window: Window = (windowController.window! as! Window)
71-
static var viewController = (storyboard.instantiateController(withIdentifier: "EQMViewController") as! ViewController)
7267

68+
static let storyboard = NSStoryboard(name: "Main", bundle: Bundle.main)
69+
70+
static var windowController: NSWindowController = (
71+
storyboard.instantiateController(
72+
withIdentifier: "EQMWindowController"
73+
) as! NSWindowController)
74+
static var window: Window = (windowController.window! as! Window)
7375
static var popover = Popover(statusItem)
7476

75-
76-
static let loadingWindowController = storyboard.instantiateController(withIdentifier: "LoadingWindow") as! NSWindowController
77-
// var popover: Popover!
78-
77+
static var viewController = (
78+
storyboard.instantiateController(
79+
withIdentifier: "EQMViewController"
80+
) as! ViewController)
81+
82+
7983
static var cachedIsShown: Bool = false
8084
static var isShownChanged = Event<Bool>()
8185
static var isShown: Bool {
@@ -129,16 +133,15 @@ class UI: StoreSubscriber {
129133
window.resignFirstResponder()
130134
window.contentViewController = nil
131135
popover.popover.contentViewController = viewController
132-
popover.show()
133136
popover.popover.becomeFirstResponder()
134137
} else {
135138
popover.hide()
136139
popover.popover.resignFirstResponder()
137140
popover.popover.contentViewController = nil
138141
window.contentViewController = viewController
139-
window.show()
140142
window.becomeFirstResponder()
141143
}
144+
UI.show()
142145
}
143146
}
144147
}
@@ -202,32 +205,46 @@ class UI: StoreSubscriber {
202205

203206
init (_ completion: @escaping () -> Void) {
204207
DispatchQueue.main.async {
205-
({
206-
UI.mode = Application.store.state.ui.mode
207-
UI.width = Application.store.state.ui.width
208-
UI.height = Application.store.state.ui.height
209-
})()
210208

211-
// TODO: Fix window position state saving (need to look if the current position is still accessible, what if the monitor isn't there anymore)
212-
// if let windowPosition = Application.store.state.ui.windowPosition {
213-
// window.position = windowPosition
214-
// }
215-
self.setupStateListener()
216-
UI.setupBridge()
217-
UI.setupListeners()
218-
UI.load()
209+
func setup () {
210+
({
211+
UI.mode = Application.store.state.ui.mode
212+
UI.width = Application.store.state.ui.width
213+
UI.height = Application.store.state.ui.height
214+
})()
219215

220-
func checkIfVisible () {
221-
let shown = UI.isShown
222-
if (UI.cachedIsShown != shown) {
223-
UI.cachedIsShown = shown
224-
UI.isShownChanged.emit(shown)
216+
// TODO: Fix window position state saving (need to look if the current position is still accessible, what if the monitor isn't there anymore)
217+
// if let windowPosition = Application.store.state.ui.windowPosition {
218+
// window.position = windowPosition
219+
// }
220+
self.setupStateListener()
221+
UI.setupBridge()
222+
UI.setupListeners()
223+
UI.load()
224+
225+
func checkIfVisible () {
226+
let shown = UI.isShown
227+
if (UI.cachedIsShown != shown) {
228+
UI.cachedIsShown = shown
229+
UI.isShownChanged.emit(shown)
230+
}
231+
Utilities.delay(1000) { checkIfVisible() }
225232
}
226-
Utilities.delay(1000) { checkIfVisible() }
233+
234+
checkIfVisible()
235+
completion()
227236
}
228237

229-
checkIfVisible()
230-
completion()
238+
if (!UI.viewController.isViewLoaded) {
239+
UI.viewController.loaded.once {
240+
setup()
241+
}
242+
let _ = UI.viewController.view
243+
} else {
244+
setup()
245+
}
246+
247+
231248
}
232249

233250
}

native/app/Source/UI/ViewController.swift

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ import EmitterKit
1212

1313
class ViewController: NSViewController, WKNavigationDelegate {
1414
// MARK: - Properties
15-
var webView: WKWebView!
15+
@IBOutlet var parentView: View!
16+
@IBOutlet var webView: WKWebView!
1617
@IBOutlet var draggableView: DraggableView!
1718
@IBOutlet var loadingView: NSView!
1819
@IBOutlet var loadingSpinner: NSProgressIndicator!
20+
let loaded = Event<Void>()
1921

2022
var height: Double {
2123
get {
@@ -40,26 +42,10 @@ class ViewController: NSViewController, WKNavigationDelegate {
4042
}
4143

4244
// MARK: - Initialization
43-
override init(nibName: String?, bundle: Bundle? = Bundle.main) {
44-
super.init(nibName: nibName, bundle: bundle)
45-
createWebView()
46-
}
47-
48-
required init?(coder: NSCoder) {
49-
super.init(coder: coder)
50-
createWebView()
51-
}
52-
53-
convenience init(){
54-
self.init()
55-
createWebView()
56-
}
57-
58-
private func createWebView () {
59-
webView = WKWebView(frame: view.frame)
60-
webView.autoresizingMask = [.height, .width]
61-
view.addSubview(webView, positioned: .below, relativeTo: loadingView)
45+
override func viewDidLoad () {
46+
super.viewDidLoad()
6247
loadingSpinner.startAnimation(nil)
48+
loaded.emit()
6349
}
6450

6551
func load (_ url: URL) {
@@ -94,19 +80,32 @@ class ViewController: NSViewController, WKNavigationDelegate {
9480
}
9581

9682
class View: NSView {
83+
var backgroundAdded = false
84+
9785
override func viewDidMoveToWindow() {
98-
99-
// guard let frameView = window?.contentView?.superview else {
100-
// return
101-
// }
102-
//
103-
// let backgroundView = NSView(frame: frameView.bounds)
104-
// backgroundView.wantsLayer = true
105-
// backgroundView.layer?.backgroundColor = NSColor(red: 62 / 255, green: 62 / 255, blue: 62 / 255, alpha: 1).cgColor
106-
// backgroundView.autoresizingMask = [.width, .height]
107-
//
108-
// frameView.addSubview(backgroundView, positioned: .below, relativeTo: frameView)
109-
86+
addBackground()
87+
}
88+
89+
// This is a workaround to color the popover top triangle to a non-default system color
90+
func addBackground () {
91+
if backgroundAdded { return }
92+
93+
// Should only apply this to the popover
94+
guard window == UI.popover.popover.contentViewController?.view.window else {
95+
return
96+
}
97+
98+
guard let frameView = window!.contentView?.superview else {
99+
return
100+
}
101+
102+
let backgroundView = NSView(frame: frameView.bounds)
103+
backgroundView.wantsLayer = true
104+
backgroundView.layer?.backgroundColor = NSColor(red: 62 / 255, green: 62 / 255, blue: 62 / 255, alpha: 1).cgColor
105+
backgroundView.autoresizingMask = [.width, .height]
106+
107+
frameView.addSubview(backgroundView, positioned: .below, relativeTo: frameView)
108+
backgroundAdded = true
110109
}
111110

112111
override var acceptsFirstResponder: Bool { true }

0 commit comments

Comments
 (0)