+/*****************************************************************************
+ * ProgressView
+ *****************************************************************************/
+
+@implementation VLCProgressView : NSView
+
+- (void)scrollWheel:(NSEvent *)o_event
+{
+ BOOL b_forward = NO;
+ CGFloat f_deltaY = [o_event deltaY];
+ CGFloat f_deltaX = [o_event deltaX];
+
+ if (!OSX_SNOW_LEOPARD && [o_event isDirectionInvertedFromDevice])
+ f_deltaX = -f_deltaX; // optimisation, actually double invertion of f_deltaY here
+ else
+ f_deltaY = -f_deltaY;
+
+ // positive for left / down, negative otherwise
+ CGFloat f_delta = f_deltaX + f_deltaY;
+ CGFloat f_abs;
+ int i_vlckey;
+
+ if (f_delta > 0.0f)
+ f_abs = f_delta;
+ else {
+ b_forward = YES;
+ f_abs = -f_delta;
+ }
+
+ for (NSUInteger i = 0; i < (int)(f_abs/4.+1.) && f_abs > 0.05 ; i++) {
+ if (b_forward)
+ [[VLCCoreInteraction sharedInstance] forwardExtraShort];
+ else
+ [[VLCCoreInteraction sharedInstance] backwardExtraShort];
+ }
+}
+
+- (BOOL)acceptsFirstResponder
+{
+ return YES;
+}
+
+@end
+
+/*****************************************************************************
+ * TimeLineSlider
+ *****************************************************************************/
+
+@implementation TimeLineSlider
+
+- (void)awakeFromNib
+{
+ if (config_GetInt( VLCIntf, "macosx-interfacestyle" )) {
+ o_knob_img = imageFromRes(@"progression-knob_dark");
+ b_dark = YES;
+ } else {
+ o_knob_img = imageFromRes(@"progression-knob");
+ b_dark = NO;
+ }
+ img_rect.size = [o_knob_img size];
+ img_rect.origin.x = img_rect.origin.y = 0;
+}
+
+- (void)dealloc
+{
+ [o_knob_img release];
+ [super dealloc];
+}
+
+- (CGFloat)knobPosition
+{
+ NSRect knobRect = [[self cell] knobRectFlipped:NO];
+ knobRect.origin.x += knobRect.size.width / 2;
+ return knobRect.origin.x;
+}
+
+- (void)drawKnobInRect:(NSRect)knobRect
+{
+ knobRect.origin.x += (knobRect.size.width - img_rect.size.width) / 2;
+ knobRect.size.width = img_rect.size.width;
+ knobRect.size.height = img_rect.size.height;
+ [o_knob_img drawInRect:knobRect fromRect:img_rect operation:NSCompositeSourceOver fraction:1];
+}
+
+- (void)drawRect:(NSRect)rect
+{
+ [[(VLCVideoWindowCommon *)[self window] controlsBar] drawFancyGradientEffectForTimeSlider];
+ msleep(10000); //wait for the gradient to draw completely
+
+ /* Draw default to make sure the slider behaves correctly */
+ [[NSGraphicsContext currentContext] saveGraphicsState];
+ NSRectClip(NSZeroRect);
+ [super drawRect:rect];
+ [[NSGraphicsContext currentContext] restoreGraphicsState];
+
+ NSRect knobRect = [[self cell] knobRectFlipped:NO];
+ knobRect.origin.y+=1;
+ [self drawKnobInRect: knobRect];
+}
+
+@end
+
+/*****************************************************************************
+ * VLCVolumeSliderCommon
+ *****************************************************************************/
+
+@implementation VLCVolumeSliderCommon : NSSlider
+
+@synthesize usesBrightArtwork = _usesBrightArtwork;
+
+- (void)scrollWheel:(NSEvent *)o_event
+{
+ BOOL b_up = NO;
+ CGFloat f_deltaY = [o_event deltaY];
+ CGFloat f_deltaX = [o_event deltaX];
+
+ if (!OSX_SNOW_LEOPARD && [o_event isDirectionInvertedFromDevice])
+ f_deltaX = -f_deltaX; // optimisation, actually double invertion of f_deltaY here
+ else
+ f_deltaY = -f_deltaY;
+
+ // positive for left / down, negative otherwise
+ CGFloat f_delta = f_deltaX + f_deltaY;
+ CGFloat f_abs;
+
+ if (f_delta > 0.0f)
+ f_abs = f_delta;
+ else {
+ b_up = YES;
+ f_abs = -f_delta;
+ }
+
+ for (NSUInteger i = 0; i < (int)(f_abs/4.+1.) && f_abs > 0.05 ; i++) {
+ if (b_up)
+ [[VLCCoreInteraction sharedInstance] volumeUp];
+ else
+ [[VLCCoreInteraction sharedInstance] volumeDown];
+ }
+}
+
+- (void)drawFullVolumeMarker
+{
+ CGFloat maxAudioVol = self.maxValue / AOUT_VOLUME_DEFAULT;
+ if (maxAudioVol < 1.)
+ return;
+
+ NSColor *drawingColor;
+ // for bright artwork, a black color is used and vice versa
+ if (_usesBrightArtwork)
+ drawingColor = [[NSColor blackColor] colorWithAlphaComponent:.4];
+ else
+ drawingColor = [[NSColor whiteColor] colorWithAlphaComponent:.4];
+
+ NSBezierPath* bezierPath = [NSBezierPath bezierPath];
+ [self drawFullVolBezierPath:bezierPath];
+ [bezierPath closePath];
+
+ bezierPath.lineWidth = 1.;
+ [drawingColor setStroke];
+ [bezierPath stroke];
+}
+
+- (CGFloat)fullVolumePos
+{
+ CGFloat maxAudioVol = self.maxValue / AOUT_VOLUME_DEFAULT;
+ CGFloat sliderRange = [self frame].size.width - [self knobThickness];
+ CGFloat sliderOrigin = [self knobThickness] / 2.;
+
+ return 1. / maxAudioVol * sliderRange + sliderOrigin;
+}
+
+- (void)drawFullVolBezierPath:(NSBezierPath*)bezierPath
+{
+ CGFloat fullVolPos = [self fullVolumePos];
+ [bezierPath moveToPoint:NSMakePoint(fullVolPos, [self frame].size.height - 3.)];
+ [bezierPath lineToPoint:NSMakePoint(fullVolPos, 2.)];
+}
+
+@end
+
+@implementation VolumeSliderCell
+
+- (BOOL)continueTracking:(NSPoint)lastPoint at:(NSPoint)currentPoint inView:(NSView *)controlView
+{
+ VLCVolumeSliderCommon *o_slider = (VLCVolumeSliderCommon *)controlView;
+ CGFloat fullVolumePos = [o_slider fullVolumePos] + 2.;
+
+ CGPoint snapToPoint = currentPoint;
+ if (ABS(fullVolumePos - currentPoint.x) <= 4.)
+ snapToPoint.x = fullVolumePos;
+
+ return [super continueTracking:lastPoint at:snapToPoint inView:controlView];
+}
+
+@end