]> git.sesse.net Git - vlc/commitdiff
macosx: add visual markers for 100% of the volume (refs #8628)
authorFelix Paul Kühne <fkuehne@videolan.org>
Tue, 18 Jun 2013 19:30:08 +0000 (21:30 +0200)
committerFelix Paul Kühne <fkuehne@videolan.org>
Tue, 18 Jun 2013 19:31:04 +0000 (21:31 +0200)
modules/gui/macosx/fspanel.h
modules/gui/macosx/fspanel.m
modules/gui/macosx/misc.h
modules/gui/macosx/misc.m

index 56bd4b05a6ae00d62bdb12f94850b280c083e49c..636432c634d5a6f1ad3ab974de2593228d61dac5 100644 (file)
@@ -78,6 +78,7 @@
 @end
 
 @class VLCProgressView;
+@class VLCFSVolumeSlider;
 
 @interface VLCFSPanelView : NSView
 {
@@ -85,7 +86,8 @@
     NSButton *o_prev, *o_next, *o_bwd, *o_fwd, *o_play, *o_fullscreen;
     NSTextField *o_streamTitle_txt;
     VLCTimeField *o_streamPosition_txt, *o_streamLength_txt;
-    NSSlider *o_fs_timeSlider, *o_fs_volumeSlider;
+    NSSlider *o_fs_timeSlider;
+    VLCFSVolumeSlider *o_fs_volumeSlider;
     VLCProgressView *o_progress_view;
     NSImage *o_background_img, *o_vol_sld_img, *o_vol_mute_img, *o_vol_max_img, *o_time_sld_img;
     NSTimeInterval last_fwd_event;
index b22ca7e037f85d887bda2adf69daee6caaa22cc7..a64d2ad320537783ac69665b038cb1f341dbff1d 100644 (file)
     [o_fs_volumeSlider setContinuous: YES];
     [o_fs_volumeSlider setTarget: self];
     [o_fs_volumeSlider setAction: @selector(fsVolumeSliderUpdate:)];
+    [o_fs_volumeSlider setUsesBrightArtwork:YES];
     [[o_fs_volumeSlider cell] accessibilitySetOverrideValue:_NS("Volume") forAttribute:NSAccessibilityTitleAttribute];
     [[o_fs_volumeSlider cell] accessibilitySetOverrideValue:_NS("Click and move the mouse while keeping the button pressed to use this slider to change the volume.") forAttribute:NSAccessibilityDescriptionAttribute];
     [self addSubview: o_fs_volumeSlider];
 * VLCFSVolumeSlider
 *****************************************************************************/
 @implementation VLCFSVolumeSlider
+
 - (void)drawKnobInRect:(NSRect) knobRect
 {
     NSRect image_rect;
     [super drawRect:rect];
     [[NSGraphicsContext currentContext] restoreGraphicsState];
 
+    [self drawFullVolumeMarker];
+
     NSRect knobRect = [[self cell] knobRectFlipped:NO];
     knobRect.origin.y+=7.5;
     [[[NSColor blackColor] colorWithAlphaComponent:0.6] set];
index 4859611f8443d747321c28d08f5168934aecee68..0bd839f964cf5501f839b9092206135d46def5d2 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * misc.h: code not specific to vlc
  *****************************************************************************
- * Copyright (C) 2003-2012 VLC authors and VideoLAN
+ * Copyright (C) 2003-2013 VLC authors and VideoLAN
  * $Id$
  *
  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
  *****************************************************************************/
 
 @interface VLCVolumeSliderCommon : NSSlider
+{
+    BOOL _usesBrightArtwork;
+}
+@property (readwrite, nonatomic) BOOL usesBrightArtwork;
 
 - (void)scrollWheel:(NSEvent *)o_event;
+- (void)drawFullVolumeMarker;
 
 @end
 
index 7d055e98262e92ab45729396f3c66421cc48c1f6..875f4c50c70180ae1aaf761d91cecce0df50636f 100644 (file)
@@ -511,6 +511,8 @@ void _drawFrameInRect(NSRect frameRect)
 
 @implementation VLCVolumeSliderCommon : NSSlider
 
+@synthesize usesBrightArtwork = _usesBrightArtwork;
+
 - (void)scrollWheel:(NSEvent *)o_event
 {
     intf_thread_t * p_intf = VLCIntf;
@@ -543,6 +545,30 @@ void _drawFrameInRect(NSRect frameRect)
     }
 }
 
+- (void)drawFullVolumeMarker
+{
+    NSRect frame = [self frame];
+
+    NSColor *drawingColor;
+    if (_usesBrightArtwork)
+        drawingColor = [[NSColor whiteColor] colorWithAlphaComponent:.8];
+    else
+        drawingColor = [[NSColor blackColor] colorWithAlphaComponent:.6];
+
+    NSBezierPath* bezierPath = [NSBezierPath bezierPath];
+
+    float fullVolPos = frame.size.width / 2.;
+    [bezierPath moveToPoint:NSMakePoint(fullVolPos, frame.size.height - 3.)];
+    [bezierPath lineToPoint:NSMakePoint(fullVolPos, 3.)];
+    [bezierPath closePath];
+
+    bezierPath.lineWidth = 1.;
+    [drawingColor setStroke];
+    [bezierPath stroke];
+    [drawingColor setFill];
+    [bezierPath fill];
+}
+
 @end
 
 /*****************************************************************************
@@ -584,6 +610,8 @@ void _drawFrameInRect(NSRect frameRect)
     [super drawRect:rect];
     [[NSGraphicsContext currentContext] restoreGraphicsState];
 
+    [self drawFullVolumeMarker];
+
     NSRect knobRect = [[self cell] knobRectFlipped:NO];
     knobRect.origin.y+=2;
     [self drawKnobInRect: knobRect];