mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-27 06:35:04 +00:00
This will likely do for the Swift/XIB side of things: the play/pause button is enabled or disabled as per the user's choice of automatic tape control, and toggles function when pressed. It communicates activity down to the Objective-C[++] layer, giving it a route through to the actual machine.
This commit is contained in:
parent
28412150e6
commit
23e989e170
@ -38,12 +38,12 @@
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="setAutomaticTapeConrol:" target="ota-g7-hOL" id="7ak-HW-rQM"/>
|
||||
<action selector="setAutomaticTapeMotorConrol:" target="ota-g7-hOL" id="bpF-1P-tga"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="tkN-gI-RmT">
|
||||
<rect key="frame" x="20" y="19" width="221" height="19"/>
|
||||
<buttonCell key="cell" type="roundRect" title="Play Tape" bezelStyle="roundedRect" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="cTq-f9-Gzx">
|
||||
<buttonCell key="cell" type="roundRect" title="Play Tape" bezelStyle="roundedRect" alignment="center" enabled="NO" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="cTq-f9-Gzx">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="cellTitle"/>
|
||||
</buttonCell>
|
||||
@ -66,8 +66,9 @@
|
||||
</constraints>
|
||||
</view>
|
||||
<connections>
|
||||
<outlet property="automaticTapeMotorControlButton" destination="qSb-72-6Os" id="bB6-FP-TKM"/>
|
||||
<outlet property="fastLoadingButton" destination="sBT-cU-h7s" id="uWa-EB-mbd"/>
|
||||
<outlet property="tapeControlButton" destination="tkN-gI-RmT" id="KW5-gA-RN3"/>
|
||||
<outlet property="playOrPauseTapeButton" destination="tkN-gI-RmT" id="UnJ-nb-3mv"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="28.5" y="15"/>
|
||||
</window>
|
||||
|
@ -10,6 +10,7 @@
|
||||
#import "CSElectron.h"
|
||||
#import "CSOric.h"
|
||||
#import "CSVic20.h"
|
||||
#import "CSZX8081.h"
|
||||
|
||||
#import "CSStaticAnalyser.h"
|
||||
|
||||
|
@ -6,15 +6,43 @@
|
||||
// Copyright © 2017 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
class ZX8081OptionsPanel: MachinePanel {
|
||||
|
||||
@IBOutlet var tapeControlButton: NSButton!
|
||||
@IBAction func setAutomaticTapeConrol(_ sender: NSButton!) {
|
||||
Swift.print("tape control \(tapeControlButton)")
|
||||
var zx8081: CSZX8081! {
|
||||
get {
|
||||
return self.machine as! CSZX8081
|
||||
}
|
||||
}
|
||||
|
||||
@IBOutlet var automaticTapeMotorControlButton: NSButton!
|
||||
var automaticTapeMotorControlDefaultsKey: String {
|
||||
get { return prefixedUserDefaultsKey("automaticTapeMotorControl") }
|
||||
}
|
||||
@IBAction func setAutomaticTapeMotorConrol(_ sender: NSButton!) {
|
||||
let isEnabled = sender.state == NSOnState
|
||||
UserDefaults.standard.set(isEnabled, forKey: self.automaticTapeMotorControlDefaultsKey)
|
||||
self.playOrPauseTapeButton.isEnabled = !isEnabled
|
||||
self.zx8081.useAutomaticTapeMotorControl = isEnabled
|
||||
}
|
||||
|
||||
@IBOutlet var playOrPauseTapeButton: NSButton!
|
||||
@IBAction func playOrPauseTape(_ sender: NSButton!) {
|
||||
Swift.print("play/pause")
|
||||
self.zx8081.tapeIsPlaying = !self.zx8081.tapeIsPlaying
|
||||
self.playOrPauseTapeButton.title = self.zx8081.tapeIsPlaying
|
||||
? NSLocalizedString("Stop Tape", comment: "Text for a button that will stop tape playback")
|
||||
: NSLocalizedString("Play Tape", comment: "Text for a button that will start tape playback")
|
||||
}
|
||||
|
||||
// MARK: option restoration
|
||||
override func establishStoredOptions() {
|
||||
super.establishStoredOptions()
|
||||
|
||||
let standardUserDefaults = UserDefaults.standard
|
||||
standardUserDefaults.register(defaults: [
|
||||
self.automaticTapeMotorControlDefaultsKey: true
|
||||
])
|
||||
|
||||
let automaticTapeMotorControlIsEnabled = standardUserDefaults.bool(forKey: self.automaticTapeMotorControlDefaultsKey)
|
||||
self.automaticTapeMotorControlButton.state = automaticTapeMotorControlIsEnabled ? NSOnState : NSOffState
|
||||
self.playOrPauseTapeButton.isEnabled = !automaticTapeMotorControlIsEnabled
|
||||
}
|
||||
}
|
||||
|
@ -14,4 +14,7 @@
|
||||
|
||||
@property (nonatomic, assign) BOOL useFastLoadingHack;
|
||||
|
||||
@property (nonatomic, assign) BOOL useAutomaticTapeMotorControl;
|
||||
@property (nonatomic, assign) BOOL tapeIsPlaying;
|
||||
|
||||
@end
|
||||
|
Loading…
x
Reference in New Issue
Block a user