Commit ed832e6b authored by Daksh Shah's avatar Daksh Shah Committed by Marvin Scholz

macosx: Swiping on time slider enabled

Fixes #19964
Signed-off-by: Marvin Scholz's avatarMarvin Scholz <epirat07@gmail.com>
parent 7cc52d9c
...@@ -276,6 +276,9 @@ ...@@ -276,6 +276,9 @@
case NSLeftMouseDragged: case NSLeftMouseDragged:
f_updated = [sender floatValue]; f_updated = [sender floatValue];
break; break;
case NSScrollWheel:
f_updated = [sender floatValue];
break;
default: default:
return; return;
......
...@@ -28,6 +28,9 @@ ...@@ -28,6 +28,9 @@
@property (nonatomic, getter=getIndefinite,setter=setIndefinite:) BOOL indefinite; @property (nonatomic, getter=getIndefinite,setter=setIndefinite:) BOOL indefinite;
@property (nonatomic, getter=getKnobHidden,setter=setKnobHidden:) BOOL isKnobHidden; @property (nonatomic, getter=getKnobHidden,setter=setKnobHidden:) BOOL isKnobHidden;
/* Indicates if the slider is scrollable with the mouse or trackpad scrollwheel. */
@property (readwrite) BOOL isScrollable;
- (void)setSliderStyleLight; - (void)setSliderStyleLight;
- (void)setSliderStyleDark; - (void)setSliderStyleDark;
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
if (self) { if (self) {
NSAssert([self.cell isKindOfClass:[VLCSliderCell class]], NSAssert([self.cell isKindOfClass:[VLCSliderCell class]],
@"VLCSlider cell is not VLCSliderCell"); @"VLCSlider cell is not VLCSliderCell");
_isScrollable = YES;
} }
return self; return self;
} }
...@@ -42,6 +43,31 @@ ...@@ -42,6 +43,31 @@
return [VLCSliderCell class]; return [VLCSliderCell class];
} }
- (void)scrollWheel:(NSEvent *)event
{
if (!_isScrollable)
return [super scrollWheel:event];
double increment;
CGFloat deltaY = [event scrollingDeltaY];
double range = [self maxValue] - [self minValue];
// Scroll less for high precision, else it's too fast
if (event.hasPreciseScrollingDeltas) {
increment = (range * 0.002) * deltaY;
} else {
if (deltaY == 0.0)
return;
increment = (range * 0.01 * deltaY);
}
// If scrolling is inversed, increment in other direction
if (!event.isDirectionInvertedFromDevice)
increment = -increment;
[self setDoubleValue:self.doubleValue - increment];
[self sendAction:self.action to:self.target];
}
// Workaround for 10.7 // Workaround for 10.7
// http://stackoverflow.com/questions/3985816/custom-nsslidercell // http://stackoverflow.com/questions/3985816/custom-nsslidercell
- (void)setNeedsDisplayInRect:(NSRect)invalidRect { - (void)setNeedsDisplayInRect:(NSRect)invalidRect {
......
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