[vlc-commits] macosx: Swiping on time slider enabled
Daksh Shah
git at videolan.org
Sat Mar 17 12:41:13 CET 2018
vlc | branch: master | Daksh Shah <daksh17336 at iiitd.ac.in> | Sun Mar 11 10:01:57 2018 +0530| [ed832e6bdb5873a811028613d0ad8b4e43d31936] | committer: Marvin Scholz
macosx: Swiping on time slider enabled
Fixes #19964
Signed-off-by: Marvin Scholz <epirat07 at gmail.com>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ed832e6bdb5873a811028613d0ad8b4e43d31936
---
modules/gui/macosx/VLCControlsBarCommon.m | 3 +++
modules/gui/macosx/VLCSlider.h | 3 +++
modules/gui/macosx/VLCSlider.m | 26 ++++++++++++++++++++++++++
3 files changed, 32 insertions(+)
diff --git a/modules/gui/macosx/VLCControlsBarCommon.m b/modules/gui/macosx/VLCControlsBarCommon.m
index 391371706e..996b9aa92f 100644
--- a/modules/gui/macosx/VLCControlsBarCommon.m
+++ b/modules/gui/macosx/VLCControlsBarCommon.m
@@ -276,6 +276,9 @@
case NSLeftMouseDragged:
f_updated = [sender floatValue];
break;
+ case NSScrollWheel:
+ f_updated = [sender floatValue];
+ break;
default:
return;
diff --git a/modules/gui/macosx/VLCSlider.h b/modules/gui/macosx/VLCSlider.h
index ba95b63ab0..36e8659c8c 100644
--- a/modules/gui/macosx/VLCSlider.h
+++ b/modules/gui/macosx/VLCSlider.h
@@ -28,6 +28,9 @@
@property (nonatomic, getter=getIndefinite,setter=setIndefinite:) BOOL indefinite;
@property (nonatomic, getter=getKnobHidden,setter=setKnobHidden:) BOOL isKnobHidden;
+/* Indicates if the slider is scrollable with the mouse or trackpad scrollwheel. */
+ at property (readwrite) BOOL isScrollable;
+
- (void)setSliderStyleLight;
- (void)setSliderStyleDark;
diff --git a/modules/gui/macosx/VLCSlider.m b/modules/gui/macosx/VLCSlider.m
index 245c4faab0..b89d2c3f0d 100644
--- a/modules/gui/macosx/VLCSlider.m
+++ b/modules/gui/macosx/VLCSlider.m
@@ -33,6 +33,7 @@
if (self) {
NSAssert([self.cell isKindOfClass:[VLCSliderCell class]],
@"VLCSlider cell is not VLCSliderCell");
+ _isScrollable = YES;
}
return self;
}
@@ -42,6 +43,31 @@
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
// http://stackoverflow.com/questions/3985816/custom-nsslidercell
- (void)setNeedsDisplayInRect:(NSRect)invalidRect {
More information about the vlc-commits
mailing list