1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 23:52:26 +00:00

macOS: ensure activity and options panels change upon a drag-and-drop state.

This commit is contained in:
Thomas Harte 2021-05-08 14:35:57 -04:00
parent 1290a8e32b
commit 4db792591a

View File

@ -87,6 +87,14 @@ class MachineDocument:
} }
} }
private func dismissPanels() {
activityPanel?.setIsVisible(false)
activityPanel = nil
optionsPanel?.setIsVisible(false)
optionsPanel = nil
}
override func close() { override func close() {
// Close any dangling sheets. // Close any dangling sheets.
// //
@ -105,11 +113,7 @@ class MachineDocument:
machine?.stop() machine?.stop()
// Dismiss panels. // Dismiss panels.
activityPanel?.setIsVisible(false) dismissPanels()
activityPanel = nil
optionsPanel?.setIsVisible(false)
optionsPanel = nil
// End the update cycle. // End the update cycle.
actionLock.lock() actionLock.lock()
@ -143,7 +147,6 @@ class MachineDocument:
let missingROMs = NSMutableArray() let missingROMs = NSMutableArray()
if let machine = CSMachine(analyser: analysis, missingROMs: missingROMs) { if let machine = CSMachine(analyser: analysis, missingROMs: missingROMs) {
self.machine = machine self.machine = machine
setupActivityDisplay()
machine.setVolume(userDefaultsVolume()) machine.setVolume(userDefaultsVolume())
setupMachineOutput() setupMachineOutput()
} else { } else {
@ -205,6 +208,9 @@ class MachineDocument:
let aspectRatio = self.aspectRatio() let aspectRatio = self.aspectRatio()
machine.setView(scanTargetView, aspectRatio: Float(aspectRatio.width / aspectRatio.height)) machine.setView(scanTargetView, aspectRatio: Float(aspectRatio.width / aspectRatio.height))
// Get rid of all existing accessory panels.
dismissPanels()
// Attach an options panel if one is available. // Attach an options panel if one is available.
if let optionsPanelNibName = self.machineDescription?.optionsPanelNibName { if let optionsPanelNibName = self.machineDescription?.optionsPanelNibName {
Bundle.main.loadNibNamed(optionsPanelNibName, owner: self, topLevelObjects: nil) Bundle.main.loadNibNamed(optionsPanelNibName, owner: self, topLevelObjects: nil)
@ -213,6 +219,9 @@ class MachineDocument:
showOptions(self) showOptions(self)
} }
// Create and populate an activity display if required.
setupActivityDisplay()
machine.delegate = self machine.delegate = self
// Callbacks from the OpenGL may come on a different thread, immediately following the .delegate set; // Callbacks from the OpenGL may come on a different thread, immediately following the .delegate set;