Skip to content

Commit

Permalink
Multiple inspector panels can run side by side (#854)
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkwhoffmann committed Dec 31, 2024
1 parent 69fb41d commit 394e9f7
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 23 deletions.
33 changes: 20 additions & 13 deletions GUI/Dialogs/Inspector/Inspector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -610,8 +610,10 @@ class Inspector: DialogController {
override func showWindow(_ sender: Any?) {

super.showWindow(self)

// Enter debug mode
emu.trackOn()
updateInspectionTarget()
amiga.autoInspectionMask = 0xFF
}

override func awakeFromNib() {
Expand Down Expand Up @@ -781,13 +783,7 @@ class Inspector: DialogController {
break
}
}


func showMessage(_ msg: String) {

message.stringValue = msg
}

func scrollToPC() {

if cpuInfo != nil {
Expand Down Expand Up @@ -839,14 +835,26 @@ extension Inspector {

super.windowWillClose(notification)

// Leave debug mode
emu?.trackOff()
emu?.amiga.autoInspectionMask = 0
// Unregister the inspector
if let index = parent.inspectors.firstIndex(where: { $0 === self }) {

// print("Removing inspector at index \(parent.inspectors.count)")
parent.inspectors.remove(at: index)
}

// Leave debug mode if no more inspectors are open
if parent.inspectors.isEmpty {

// print("Leaving debug mode")
emu?.trackOff()
amiga.autoInspectionMask = 0
}
}
}

extension Inspector: NSTabViewDelegate {

/*
func updateInspectionTarget() {

func mask(_ types: [CType]) -> Int {
Expand Down Expand Up @@ -878,11 +886,10 @@ extension Inspector: NSTabViewDelegate {
fullRefresh()
}
}
*/

func tabView(_ tabView: NSTabView, didSelect tabViewItem: NSTabViewItem?) {

if tabView === panel {
updateInspectionTarget()
}
fullRefresh()
}
}
8 changes: 4 additions & 4 deletions GUI/MyController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class MyController: NSWindowController, MessageReceiver {
var emu: EmulatorProxy!

// Inspector panel of this emulator instance
var inspector: Inspector?
var inspectors: [Inspector] = []

// Monitor panel of this emulator instance
var monitor: Monitor?
Expand Down Expand Up @@ -282,7 +282,8 @@ extension MyController {
if frames % 5 == 0 {

// Animate the inspectors
if inspector?.window?.isVisible == true { inspector!.continuousRefresh() }
for inspector in inspectors { inspector.continuousRefresh() }
// if inspector?.window?.isVisible == true { inspector!.continuousRefresh() }
}

// Do less times...
Expand Down Expand Up @@ -368,8 +369,7 @@ extension MyController {
var acceleration: Double { return Double(msg.value == 0 ? 1 : msg.value) }

func passToInspector() {

inspector?.processMessage(msg)
for inspector in inspectors { inspector.processMessage(msg) }
}

// Only proceed if the proxy object is still alive
Expand Down
14 changes: 11 additions & 3 deletions GUI/MyControllerMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,18 @@ extension MyController: NSMenuItemValidation {

@IBAction func inspectorAction(_ sender: Any!) {

if inspector == nil {
inspector = Inspector(with: self, nibName: "Inspector")
let count = inspectors.count

// Only allow 8 inspectors at a time
if count < 8, let inspector = Inspector(with: self, nibName: "Inspector") {

inspectors.append(inspector)
inspector.showWindow(self)

} else {

NSSound.beep();
}
inspector?.showWindow(self)
}

@IBAction func monitorAction(_ sender: Any!) {
Expand Down
8 changes: 5 additions & 3 deletions GUI/WindowDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ extension MyController: NSWindowDelegate {
debug(.shutdown, "Shut down the audio unit...")
macAudio.shutDown()

debug(.shutdown, "Close the inspector...")
inspector?.close()
inspector?.join()
debug(.shutdown, "Close the inspectors...")
for inspector in inspectors {
inspector.close()
inspector.join()
}

debug(.shutdown, "Close the monitor...")
monitor?.close()
Expand Down

0 comments on commit 394e9f7

Please sign in to comment.