diff --git a/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift b/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift
index ceffdaab6..815815545 100644
--- a/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift
+++ b/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift
@@ -140,9 +140,9 @@ class MachineDocument:
let missingROMs = NSMutableArray()
if let machine = CSMachine(analyser: analysis, missingROMs: missingROMs) {
self.machine = machine
- setupMachineOutput()
setupActivityDisplay()
machine.setVolume(userDefaultsVolume())
+ setupMachineOutput()
} else {
// Store the selected machine and list of missing ROMs, and
// show the missing ROMs dialogue.
@@ -373,6 +373,10 @@ class MachineDocument:
self.configureAs(selectedMachine)
}
+ @IBAction func tableViewDoubleClick(_ sender: NSTableView?) {
+ createMachine(nil)
+ }
+
@IBAction func cancelCreateMachine(_ sender: NSButton?) {
close()
}
@@ -593,7 +597,7 @@ class MachineDocument:
return super.validateUserInterfaceItem(item)
}
- /// Saves a screenshot of the
+ /// Saves a screenshot of the machine's current display.
@IBAction func saveScreenshot(_ sender: AnyObject!) {
// Grab a date formatter and form a file name.
let dateFormatter = DateFormatter()
@@ -602,8 +606,8 @@ class MachineDocument:
let filename = ("Clock Signal Screen Shot " + dateFormatter.string(from: Date()) + ".png").replacingOccurrences(of: "/", with: "-")
.replacingOccurrences(of: ":", with: ".")
- let pictursURL = FileManager.default.urls(for: .picturesDirectory, in: .userDomainMask)[0]
- let url = pictursURL.appendingPathComponent(filename)
+ let desktopURL = FileManager.default.urls(for: .desktopDirectory, in: .userDomainMask)[0]
+ let url = desktopURL.appendingPathComponent(filename)
// Obtain the machine's current display.
let imageRepresentation = self.machine.imageRepresentation
diff --git a/OSBindings/Mac/Clock Signal/MachinePicker/Base.lproj/MachinePicker.xib b/OSBindings/Mac/Clock Signal/MachinePicker/Base.lproj/MachinePicker.xib
index d233186dc..31e1925f8 100644
--- a/OSBindings/Mac/Clock Signal/MachinePicker/Base.lproj/MachinePicker.xib
+++ b/OSBindings/Mac/Clock Signal/MachinePicker/Base.lproj/MachinePicker.xib
@@ -17,14 +17,14 @@
-
+
-
+
-
-
+
+
If you use File -> Open... to select a disk, tape or cartridge directly, the emulator will select and configure a machine for you.
@@ -58,17 +58,17 @@ Gw
-
-
+
+
-
+
-
+
@@ -76,7 +76,7 @@ Gw
-
+
@@ -84,7 +84,7 @@ Gw
-
+
@@ -99,7 +99,7 @@ Gw
-
+
@@ -129,12 +129,12 @@ Gw
-
-
+
+
-
+
@@ -142,7 +142,7 @@ Gw
-
+
@@ -150,7 +150,7 @@ Gw
-
+
@@ -164,7 +164,7 @@ Gw
-
+
@@ -186,20 +186,20 @@ Gw
-
+
-
+
-
+
@@ -213,7 +213,7 @@ Gw
-
+
@@ -233,11 +233,11 @@ Gw
-
+
-
+
@@ -254,32 +254,32 @@ Gw
-
+
-
+
-
+
@@ -317,7 +317,7 @@ Gw
-
+
@@ -344,18 +344,18 @@ Gw
-
+
-
+
@@ -369,7 +369,7 @@ Gw
-
+
@@ -392,11 +392,11 @@ Gw
-
+
-
+
@@ -404,7 +404,7 @@ Gw
-
+
@@ -418,7 +418,7 @@ Gw
-
+
@@ -434,7 +434,7 @@ Gw
-
+
@@ -457,50 +457,13 @@ Gw
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
@@ -516,7 +479,7 @@ Gw
-
+
@@ -530,7 +493,7 @@ Gw
-
+
@@ -538,7 +501,7 @@ Gw
-
+
@@ -546,7 +509,7 @@ Gw
-
+
-
+
@@ -591,7 +554,7 @@ Gw
-
+
@@ -599,7 +562,7 @@ Gw
-
+
-
+
@@ -639,7 +602,7 @@ Gw
-
+
@@ -657,25 +620,120 @@ Gw
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
+
+
-
+
-
+
@@ -688,7 +746,7 @@ Gw
-
+
diff --git a/OSBindings/Mac/Clock Signal/MachinePicker/MachinePicker.swift b/OSBindings/Mac/Clock Signal/MachinePicker/MachinePicker.swift
index 5c0675974..f358c8666 100644
--- a/OSBindings/Mac/Clock Signal/MachinePicker/MachinePicker.swift
+++ b/OSBindings/Mac/Clock Signal/MachinePicker/MachinePicker.swift
@@ -8,9 +8,16 @@
import Cocoa
-class MachinePicker: NSObject {
+// Quick note on structure below: I have an NSTableView to contain machine names,
+// programmatically manipulating the selected tab in an NSTabView. I admit that this
+// is odd. It's partly for historical reasons — this was purely an NSTabView until
+// the number of options got too large — and partly because it makes designing things
+// in the interface builder easier.
+//
+// I accept that I'll have to rethink this again if the machine list keeps growing.
+class MachinePicker: NSObject, NSTableViewDataSource, NSTableViewDelegate {
@IBOutlet var machineSelector: NSTabView!
- @IBOutlet var machineSelectionTabs: NSTabView!
+ @IBOutlet var machineNameTable: NSTableView!
// MARK: - Apple II properties
@IBOutlet var appleIIModelButton: NSPopUpButton!
@@ -59,9 +66,12 @@ class MachinePicker: NSObject {
func establishStoredOptions() {
let standardUserDefaults = UserDefaults.standard
+ // Set up data soure.
+
// TEMPORARY: remove the Apple IIgs option. It's not yet a fully-working machine; no need to publicise it.
- let appleIIgsTabIndex = machineSelectionTabs.indexOfTabViewItem(withIdentifier: "appleiigs")
- machineSelectionTabs.removeTabViewItem(machineSelectionTabs.tabViewItem(at: appleIIgsTabIndex))
+ let appleIIgsTabIndex = machineSelector.indexOfTabViewItem(withIdentifier: "appleiigs")
+ machineSelector.removeTabViewItem(machineSelector.tabViewItem(at: appleIIgsTabIndex))
+ machineNameTable.reloadData()
// Machine type
if let machineIdentifier = standardUserDefaults.string(forKey: "new.machine") {
@@ -70,6 +80,8 @@ class MachinePicker: NSObject {
let index = machineSelector.indexOfTabViewItem(withIdentifier: machineIdentifier as Any)
if index != NSNotFound {
machineSelector.selectTabViewItem(at: index)
+ machineNameTable.selectRowIndexes(IndexSet(integer: index), byExtendingSelection: false)
+ machineNameTable.scrollRowToVisible(index)
}
}
@@ -167,6 +179,27 @@ class MachinePicker: NSObject {
standardUserDefaults.set(zx81MemorySizeButton.selectedTag(), forKey: "new.zx81MemorySize")
}
+ // MARK: - Table view handling
+ func numberOfRows(in tableView: NSTableView) -> Int {
+ return machineSelector.numberOfTabViewItems
+ }
+
+ func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? {
+ return machineSelector.tabViewItem(at: row).label
+ }
+
+ func tableViewSelectionDidChange(_ notification: Notification) {
+ machineSelector.selectTabViewItem(at: machineNameTable.selectedRow)
+ }
+
+ func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat {
+ let font = NSFont.systemFont(ofSize: NSFont.systemFontSize)
+
+ // YUCK. TODO: find a way to use cells with vertically-centred text.
+ // Likely that means not using NSTextFieldCell.
+ return font.ascender - font.descender + 2.5
+ }
+
// MARK: - Machine builder
func selectedMachine() -> CSStaticAnalyser {
storeOptions()