Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
69a30659 by Bob Moriasi at 2025-07-14T17:08:21+00:00
macosx: Horizontal scroll support on iCarousel

- - - - -


2 changed files:

- modules/gui/macosx/UI/VLCLibraryWindow.xib
- modules/gui/macosx/views/iCarousel/iCarousel.m


Changes:

=====================================
modules/gui/macosx/UI/VLCLibraryWindow.xib
=====================================
@@ -631,7 +631,7 @@
             <rect key="frame" x="0.0" y="0.0" width="869" height="808"/>
             <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" 
flexibleMinY="YES"/>
             <subviews>
-                <scrollView borderType="none" horizontalLineScroll="10" 
horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" 
hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" 
translatesAutoresizingMaskIntoConstraints="NO" id="HXH-MZ-tkf">
+                <scrollView borderType="none" horizontalLineScroll="10" 
horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" 
hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" 
translatesAutoresizingMaskIntoConstraints="NO" 
horizontalScrollElasticity="none" verticalScrollElasticity="none" 
id="HXH-MZ-tkf">
                     <rect key="frame" x="0.0" y="0.0" width="869" 
height="808"/>
                     <clipView key="contentView" id="EeU-rT-tSP">
                         <rect key="frame" x="0.0" y="0.0" width="869" 
height="808"/>


=====================================
modules/gui/macosx/views/iCarousel/iCarousel.m
=====================================
@@ -2348,6 +2348,44 @@ NSComparisonResult compareViewDepth(UIView *view1, 
UIView *view2, iCarousel *sel
     }
 }
 
+- (void)scrollWheel:(NSEvent *)event
+{
+    const CGFloat deltaX = event.scrollingDeltaX;
+    const CGFloat deltaY = event.scrollingDeltaY;
+
+    BOOL isHorizontalGesture = fabs(deltaX) > fabs(deltaY);
+    BOOL isTrackpadGesture = event.hasPreciseScrollingDeltas &&
+                            (event.phase != NSEventPhaseNone || 
event.momentumPhase != NSEventPhaseNone);
+    
+    if (isHorizontalGesture && fabs(deltaX) > 0.1 && _scrollEnabled) {
+        if (isTrackpadGesture) {
+            CGFloat currentOffset = self.scrollOffset;
+            CGFloat newOffset = currentOffset - (deltaX / 600.0);
+
+            const NSInteger numberOfItems = self.numberOfItems;
+            if (numberOfItems > 0) {
+                newOffset = MAX(0.0, MIN((CGFloat)(numberOfItems - 1), 
newOffset));
+                self.scrollOffset = newOffset;
+            }
+            [self scrollToItemAtIndex:self.currentItemIndex animated:YES];
+        } else {
+            const NSInteger currentIndex = self.currentItemIndex;
+            const NSInteger numberOfItems = self.numberOfItems;
+
+            if (deltaX > 0.1 && currentIndex > 0) {
+                [self scrollToItemAtIndex:(currentIndex - 1) animated:YES];
+            } else if (deltaX < -0.1 && currentIndex < numberOfItems - 1) {
+                [self scrollToItemAtIndex:(currentIndex + 1) animated:YES];
+            }
+        }
+        return;
+    }
+
+    if (fabs(deltaY) > 0.5 && fabs(deltaX) <= 0.1) {
+        [super scrollWheel:event];
+    }
+}
+
 #pragma mark -
 #pragma mark Keyboard control
 



View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/commit/69a306591c27daa4904681f64082f2e5d2555c33

-- 
View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/commit/69a306591c27daa4904681f64082f2e5d2555c33
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance
_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to