Commit ed67f6dd authored by Marvin Scholz's avatar Marvin Scholz

macosx: Add ability to hide knob to VLCSlider

When nothing is playing, the knob and progress should not be shown,
this adds an option for this to the VLCSlider
parent 7e6cda08
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
@interface VLCSlider : NSSlider @interface VLCSlider : NSSlider
@property (nonatomic, getter=getIndefinite,setter=setIndefinite:) BOOL indefinite; @property (nonatomic, getter=getIndefinite,setter=setIndefinite:) BOOL indefinite;
@property (nonatomic, getter=getKnobHidden,setter=setKnobHidden:) BOOL isKnobHidden;
- (void)setSliderStyleLight; - (void)setSliderStyleLight;
- (void)setSliderStyleDark; - (void)setSliderStyleDark;
......
...@@ -50,6 +50,16 @@ ...@@ -50,6 +50,16 @@
[(VLCSliderCell*)[self cell] setIndefinite:indefinite]; [(VLCSliderCell*)[self cell] setIndefinite:indefinite];
} }
- (BOOL)getKnobHidden
{
return [(VLCSliderCell*)[self cell] isKnobHidden];
}
- (void)setKnobHidden:(BOOL)isKnobHidden
{
[(VLCSliderCell*)[self cell] setKnobHidden:isKnobHidden];
}
- (BOOL)isFlipped - (BOOL)isFlipped
{ {
return NO; return NO;
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
@property NSInteger animationWidth; @property NSInteger animationWidth;
@property (nonatomic, setter=setIndefinite:) BOOL indefinite; @property (nonatomic, setter=setIndefinite:) BOOL indefinite;
@property (nonatomic, setter=setKnobHidden:) BOOL isKnobHidden;
- (void)setSliderStyleLight; - (void)setSliderStyleLight;
- (void)setSliderStyleDark; - (void)setSliderStyleDark;
......
...@@ -184,6 +184,9 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt ...@@ -184,6 +184,9 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
- (void)drawKnob:(NSRect)knobRect - (void)drawKnob:(NSRect)knobRect
{ {
if (_isKnobHidden)
return;
// Draw knob // Draw knob
NSBezierPath* knobPath = [NSBezierPath bezierPathWithOvalInRect:NSInsetRect(knobRect, 2.0, 2.0)]; NSBezierPath* knobPath = [NSBezierPath bezierPathWithOvalInRect:NSInsetRect(knobRect, 2.0, 2.0)];
if (self.isHighlighted) { if (self.isHighlighted) {
...@@ -218,6 +221,13 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt ...@@ -218,6 +221,13 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
NSBezierPath* emptyTrackPath = [NSBezierPath bezierPathWithRoundedRect:rect xRadius:3 yRadius:3]; NSBezierPath* emptyTrackPath = [NSBezierPath bezierPathWithRoundedRect:rect xRadius:3 yRadius:3];
[_trackGradient drawInBezierPath:emptyTrackPath angle:-90]; [_trackGradient drawInBezierPath:emptyTrackPath angle:-90];
if (_isKnobHidden) {
[_trackStrokeColor setStroke];
emptyTrackPath.lineWidth = 1;
[emptyTrackPath stroke];
return;
}
// Calculate filled track // Calculate filled track
NSRect filledTrackRect = rect; NSRect filledTrackRect = rect;
NSRect knobRect = [self knobRectFlipped:NO]; NSRect knobRect = [self knobRectFlipped:NO];
...@@ -324,5 +334,11 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt ...@@ -324,5 +334,11 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
_indefinite = indefinite; _indefinite = indefinite;
} }
- (void)setKnobHidden:(BOOL)isKnobHidden
{
_isKnobHidden = isKnobHidden;
[self.controlView setNeedsDisplay:YES];
}
@end @end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment