From c325924886013d5aa8c9d7c46f787d244da082bf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Felix=20Paul=20K=C3=BChne?= Date: Tue, 18 Jun 2013 21:30:08 +0200 Subject: [PATCH] macosx: add visual markers for 100% of the volume (refs #8628) --- modules/gui/macosx/fspanel.h | 4 +++- modules/gui/macosx/fspanel.m | 4 ++++ modules/gui/macosx/misc.h | 7 ++++++- modules/gui/macosx/misc.m | 28 ++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/modules/gui/macosx/fspanel.h b/modules/gui/macosx/fspanel.h index 56bd4b05a6..636432c634 100644 --- a/modules/gui/macosx/fspanel.h +++ b/modules/gui/macosx/fspanel.h @@ -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; diff --git a/modules/gui/macosx/fspanel.m b/modules/gui/macosx/fspanel.m index b22ca7e037..a64d2ad320 100644 --- a/modules/gui/macosx/fspanel.m +++ b/modules/gui/macosx/fspanel.m @@ -459,6 +459,7 @@ [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]; @@ -708,6 +709,7 @@ * VLCFSVolumeSlider *****************************************************************************/ @implementation VLCFSVolumeSlider + - (void)drawKnobInRect:(NSRect) knobRect { NSRect image_rect; @@ -729,6 +731,8 @@ [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]; diff --git a/modules/gui/macosx/misc.h b/modules/gui/macosx/misc.h index 4859611f84..0bd839f964 100644 --- a/modules/gui/macosx/misc.h +++ b/modules/gui/macosx/misc.h @@ -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 @@ -121,8 +121,13 @@ *****************************************************************************/ @interface VLCVolumeSliderCommon : NSSlider +{ + BOOL _usesBrightArtwork; +} +@property (readwrite, nonatomic) BOOL usesBrightArtwork; - (void)scrollWheel:(NSEvent *)o_event; +- (void)drawFullVolumeMarker; @end diff --git a/modules/gui/macosx/misc.m b/modules/gui/macosx/misc.m index 7d055e9826..875f4c50c7 100644 --- a/modules/gui/macosx/misc.m +++ b/modules/gui/macosx/misc.m @@ -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]; -- 2.39.2