[vlc-commits] macosx: Add ability to hide knob to VLCSlider
Marvin Scholz
git at videolan.org
Sun Jul 23 14:19:27 CEST 2017
vlc | branch: master | Marvin Scholz <epirat07 at gmail.com> | Sun Jul 23 14:15:01 2017 +0200| [ed67f6ddb54014af9dc13dd927a42e88d70c0b28] | committer: 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
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ed67f6ddb54014af9dc13dd927a42e88d70c0b28
---
modules/gui/macosx/VLCSlider.h | 1 +
modules/gui/macosx/VLCSlider.m | 10 ++++++++++
modules/gui/macosx/VLCSliderCell.h | 1 +
modules/gui/macosx/VLCSliderCell.m | 16 ++++++++++++++++
4 files changed, 28 insertions(+)
diff --git a/modules/gui/macosx/VLCSlider.h b/modules/gui/macosx/VLCSlider.h
index d5ab0c8115..ba95b63ab0 100644
--- a/modules/gui/macosx/VLCSlider.h
+++ b/modules/gui/macosx/VLCSlider.h
@@ -26,6 +26,7 @@
@interface VLCSlider : NSSlider
@property (nonatomic, getter=getIndefinite,setter=setIndefinite:) BOOL indefinite;
+ at property (nonatomic, getter=getKnobHidden,setter=setKnobHidden:) BOOL isKnobHidden;
- (void)setSliderStyleLight;
- (void)setSliderStyleDark;
diff --git a/modules/gui/macosx/VLCSlider.m b/modules/gui/macosx/VLCSlider.m
index f5cc5ff8aa..e7eba8ae05 100644
--- a/modules/gui/macosx/VLCSlider.m
+++ b/modules/gui/macosx/VLCSlider.m
@@ -50,6 +50,16 @@
[(VLCSliderCell*)[self cell] setIndefinite:indefinite];
}
+- (BOOL)getKnobHidden
+{
+ return [(VLCSliderCell*)[self cell] isKnobHidden];
+}
+
+- (void)setKnobHidden:(BOOL)isKnobHidden
+{
+ [(VLCSliderCell*)[self cell] setKnobHidden:isKnobHidden];
+}
+
- (BOOL)isFlipped
{
return NO;
diff --git a/modules/gui/macosx/VLCSliderCell.h b/modules/gui/macosx/VLCSliderCell.h
index eca0b17344..d5508a04e6 100644
--- a/modules/gui/macosx/VLCSliderCell.h
+++ b/modules/gui/macosx/VLCSliderCell.h
@@ -48,6 +48,7 @@
@property NSInteger animationWidth;
@property (nonatomic, setter=setIndefinite:) BOOL indefinite;
+ at property (nonatomic, setter=setKnobHidden:) BOOL isKnobHidden;
- (void)setSliderStyleLight;
- (void)setSliderStyleDark;
diff --git a/modules/gui/macosx/VLCSliderCell.m b/modules/gui/macosx/VLCSliderCell.m
index 4c005f9cab..51cee0e653 100644
--- a/modules/gui/macosx/VLCSliderCell.m
+++ b/modules/gui/macosx/VLCSliderCell.m
@@ -184,6 +184,9 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
- (void)drawKnob:(NSRect)knobRect
{
+ if (_isKnobHidden)
+ return;
+
// Draw knob
NSBezierPath* knobPath = [NSBezierPath bezierPathWithOvalInRect:NSInsetRect(knobRect, 2.0, 2.0)];
if (self.isHighlighted) {
@@ -218,6 +221,13 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
NSBezierPath* emptyTrackPath = [NSBezierPath bezierPathWithRoundedRect:rect xRadius:3 yRadius:3];
[_trackGradient drawInBezierPath:emptyTrackPath angle:-90];
+ if (_isKnobHidden) {
+ [_trackStrokeColor setStroke];
+ emptyTrackPath.lineWidth = 1;
+ [emptyTrackPath stroke];
+ return;
+ }
+
// Calculate filled track
NSRect filledTrackRect = rect;
NSRect knobRect = [self knobRectFlipped:NO];
@@ -324,5 +334,11 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
_indefinite = indefinite;
}
+- (void)setKnobHidden:(BOOL)isKnobHidden
+{
+ _isKnobHidden = isKnobHidden;
+ [self.controlView setNeedsDisplay:YES];
+}
+
@end
More information about the vlc-commits
mailing list