mirror of
https://github.com/danbee/persephone
synced 2025-03-04 08:39:11 +00:00
Update state of transport controls on state change
This commit is contained in:
parent
6bd29cdf00
commit
22926d343f
@ -18,5 +18,8 @@
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
},
|
||||
"properties" : {
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
@ -696,7 +696,7 @@
|
||||
<toolbarItem implicitItemIdentifier="2D01DD0F-DDD1-411E-9270-20E2B5B07FC2" label="Controls" paletteLabel="Controls" sizingBehavior="auto" id="p3r-ty-Pxf">
|
||||
<nil key="toolTip"/>
|
||||
<segmentedControl key="view" verticalHuggingPriority="750" id="Bbf-C6-1Gu">
|
||||
<rect key="frame" x="0.0" y="14" width="153" height="23"/>
|
||||
<rect key="frame" x="0.0" y="14" width="153" height="24"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<segmentedCell key="cell" borderStyle="border" alignment="left" style="texturedRounded" trackingMode="momentary" id="EBk-sD-nG7">
|
||||
<font key="font" metaFont="system"/>
|
||||
@ -740,6 +740,7 @@
|
||||
</window>
|
||||
<connections>
|
||||
<outlet property="stateLabel" destination="KVt-e7-7I5" id="xMD-Iq-CSh"/>
|
||||
<outlet property="transportControls" destination="EBk-sD-nG7" id="yOo-58-Fby"/>
|
||||
<segue destination="fnD-7K-pHK" kind="relationship" relationship="window.shadowedContentViewController" id="fQQ-kB-KVc"/>
|
||||
</connections>
|
||||
</windowController>
|
||||
|
||||
@ -33,6 +33,20 @@ class WindowController: NSWindowController {
|
||||
else { return }
|
||||
|
||||
stateLabel.stringValue = "\(state)".localizedCapitalized
|
||||
setTransportControlState(state)
|
||||
}
|
||||
|
||||
func setTransportControlState(_ state: MPDClient.State) {
|
||||
transportControls.setEnabled([.playing, .paused].contains(state), forSegment: 0)
|
||||
transportControls.setEnabled([.playing, .paused, .stopped].contains(state), forSegment: 1)
|
||||
transportControls.setEnabled([.playing, .paused].contains(state), forSegment: 2)
|
||||
transportControls.setEnabled([.playing, .paused].contains(state), forSegment: 3)
|
||||
|
||||
if [.paused, .stopped, .unknown].contains(state) {
|
||||
transportControls.setImage(NSImage(named: NSImage.Name(rawValue: "playButton")), forSegment: 1)
|
||||
} else {
|
||||
transportControls.setImage(NSImage(named: NSImage.Name(rawValue: "pauseButton")), forSegment: 1)
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func handleTransportControl(_ sender: NSSegmentedControl) {
|
||||
@ -52,4 +66,5 @@ class WindowController: NSWindowController {
|
||||
}
|
||||
|
||||
@IBOutlet var stateLabel: NSTextField!
|
||||
@IBOutlet var transportControls: NSSegmentedCell!
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user