Playback Buttons: Made stop button optional, hidden by default
parent
fa67b79b22
commit
4bc3a2a1f3
|
@ -467,11 +467,11 @@
|
|||
<point key="canvasLocation" x="450" y="-52"/>
|
||||
</customView>
|
||||
<customView id="CgN-sy-RmM" userLabel="AppearanceView">
|
||||
<rect key="frame" x="0.0" y="0.0" width="530" height="46"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="530" height="74"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="haX-dq-OIe">
|
||||
<rect key="frame" x="18" y="15" width="329" height="18"/>
|
||||
<rect key="frame" x="18" y="43" width="329" height="18"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<buttonCell key="cell" type="check" title="Colorful dock icons" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="GdX-5e-NeU">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
|
@ -481,6 +481,17 @@
|
|||
<binding destination="52" name="value" keyPath="values.colorfulDockIcons" id="NZt-v6-8iW"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="AA7-fr-NOk">
|
||||
<rect key="frame" x="18" y="15" width="329" height="18"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<buttonCell key="cell" type="check" title="Show stop button" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="vMI-lj-Lrz">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<binding destination="52" name="value" keyPath="values.enableStopButton" id="JH0-bm-IC4"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<point key="canvasLocation" x="450" y="139"/>
|
||||
</customView>
|
||||
|
|
|
@ -30,29 +30,47 @@ static NSString *PlaybackButtonsPlaybackStatusObservationContext = @"PlaybackBut
|
|||
- (void)startObserving
|
||||
{
|
||||
[playbackController addObserver:self forKeyPath:@"playbackStatus" options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionInitial) context:(__bridge void * _Nullable)(PlaybackButtonsPlaybackStatusObservationContext)];
|
||||
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.enableStopButton" options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionInitial) context:(__bridge void * _Nullable)(PlaybackButtonsPlaybackStatusObservationContext)];
|
||||
}
|
||||
|
||||
- (void)stopObserving
|
||||
{
|
||||
[playbackController removeObserver:self forKeyPath:@"playbackStatus"];
|
||||
[[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:@"values.enableStopButton"];
|
||||
}
|
||||
|
||||
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
|
||||
{
|
||||
if ([PlaybackButtonsPlaybackStatusObservationContext isEqual:(__bridge id)(context)])
|
||||
{
|
||||
NSInteger playbackStatus = [[change objectForKey:NSKeyValueChangeNewKey] integerValue];
|
||||
if ([keyPath isEqualToString:@"playbackStatus"])
|
||||
{
|
||||
NSInteger playbackStatus = [[change objectForKey:NSKeyValueChangeNewKey] integerValue];
|
||||
|
||||
NSImage *image = nil;
|
||||
NSImage *image = nil;
|
||||
|
||||
if (playbackStatus == CogStatusPlaying) {
|
||||
image = [NSImage imageNamed:@"pauseTemplate"];
|
||||
}
|
||||
else {
|
||||
image = [NSImage imageNamed:@"playTemplate"];
|
||||
}
|
||||
if (playbackStatus == CogStatusPlaying) {
|
||||
image = [NSImage imageNamed:@"pauseTemplate"];
|
||||
}
|
||||
else {
|
||||
image = [NSImage imageNamed:@"playTemplate"];
|
||||
}
|
||||
|
||||
[self setImage:image forSegment:1];
|
||||
[self setImage:image forSegment:1];
|
||||
}
|
||||
else if ([keyPath isEqualToString:@"values.enableStopButton"])
|
||||
{
|
||||
BOOL segmentEnabled = [[[NSUserDefaultsController sharedUserDefaultsController] defaults] boolForKey:@"enableStopButton"];
|
||||
if (segmentEnabled) {
|
||||
[self setSegmentCount:4];
|
||||
[self setImage:[NSImage imageNamed:@"stopTemplate"] forSegment:2];
|
||||
[self setImage:[NSImage imageNamed:@"nextTemplate"] forSegment:3];
|
||||
}
|
||||
else {
|
||||
[self setSegmentCount:3];
|
||||
[self setImage:[NSImage imageNamed:@"nextTemplate"] forSegment:2];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -63,8 +81,12 @@ static NSString *PlaybackButtonsPlaybackStatusObservationContext = @"PlaybackBut
|
|||
- (BOOL)sendAction:(SEL)theAction to:(id)theTarget
|
||||
{
|
||||
DLog(@"Mouse down!");
|
||||
|
||||
int clickedSegment = (int) [self selectedSegment];
|
||||
int segmentCount = (int) [self segmentCount];
|
||||
if (segmentCount == 3 && clickedSegment == 2)
|
||||
clickedSegment = 3;
|
||||
|
||||
int clickedSegment = (int) [self selectedSegment];
|
||||
if (clickedSegment == 0) //Previous
|
||||
{
|
||||
[playbackController prev:self];
|
||||
|
|
Loading…
Reference in New Issue