[vlc-commits] [Git][videolan/vlc][master] 6 commits: macosx: Fix bugs with large empty spaces at top of 'Library' section in the video collection view

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Wed Dec 21 14:52:26 UTC 2022



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
ae9bdb3c by Claudio Cambra at 2022-12-21T14:35:32+00:00
macosx: Fix bugs with large empty spaces at top of 'Library' section in the video collection view

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
2406d1b1 by Claudio Cambra at 2022-12-21T14:35:32+00:00
macosx: Fix VLCLibraryVideoCollectionViewContainerView's collectionViewFrameChanged method early return check

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
839f4dc4 by Claudio Cambra at 2022-12-21T14:35:32+00:00
macosx: Use accurate width for container view intrinsic sizing

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
ca68e529 by Claudio Cambra at 2022-12-21T14:35:32+00:00
macosx: Add ability to disable scroll on VLCSubScrollView while still scrolling parent scroll view, useful for collection views

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
2ccab19a by Claudio Cambra at 2022-12-21T14:35:32+00:00
macosx: Work around flashing collection view items issue in video library

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
0c923456 by Claudio Cambra at 2022-12-21T14:35:32+00:00
macosx: Remove unneeded class check in collectionViewFrameChanged

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -


3 changed files:

- modules/gui/macosx/library/video-library/VLCLibraryVideoCollectionViewContainerView.m
- modules/gui/macosx/views/VLCSubScrollView.h
- modules/gui/macosx/views/VLCSubScrollView.m


Changes:

=====================================
modules/gui/macosx/library/video-library/VLCLibraryVideoCollectionViewContainerView.m
=====================================
@@ -145,6 +145,7 @@
     _collectionViewLayout.scrollDirection = _groupDescriptor.isHorizontalBarCollectionView ?
                                             NSCollectionViewScrollDirectionHorizontal :
                                             NSCollectionViewScrollDirectionVertical;
+    _scrollView.scrollSelf = _groupDescriptor.isHorizontalBarCollectionView;
 }
 
 - (void)setVideoGroup:(VLCLibraryVideoGroup)group
@@ -159,7 +160,7 @@
 
 - (void)collectionViewFrameChanged:(NSNotification *)notification
 {
-    if (notification.object != self) {
+    if ((NSCollectionView *)notification.object != _collectionView) {
         return;
     }
 
@@ -172,28 +173,40 @@
 
 - (NSSize)intrinsicContentSize
 {
-    NSSize collectionViewContentSize = _collectionViewLayout.collectionViewContentSize;
-    NSEdgeInsets scrollViewInsets = _collectionView.enclosingScrollView.contentInsets;
-    NSEdgeInsets collectionViewLayoutInset = _collectionViewLayout.sectionInset;
-    CGFloat insetsHeight = scrollViewInsets.top +
-                           scrollViewInsets.bottom +
-                           collectionViewLayoutInset.top +
-                           collectionViewLayoutInset.bottom +
-                           15; // Account for the scrollbar size
-
-    if (collectionViewContentSize.height == 0 || _groupDescriptor.isHorizontalBarCollectionView) {
-        CGFloat fallback = _collectionViewLayout.itemSize.height + insetsHeight;
-
-        if (fallback <= 0) {
-            NSLog(@"Unable to provide reasonable fallback or accurate rowheight -- providing rough rowheight");
-            fallback = 400;
-        }
-
-        return NSMakeSize(fallback, fallback);
+    const NSSize collectionViewContentSize = _collectionViewLayout.collectionViewContentSize;
+    const NSEdgeInsets scrollViewInsets = _collectionView.enclosingScrollView.contentInsets;
+    const NSEdgeInsets collectionViewLayoutInset = _collectionViewLayout.sectionInset;
+    const CGFloat insetsHeight = scrollViewInsets.top +
+                                 scrollViewInsets.bottom +
+                                 collectionViewLayoutInset.top +
+                                 collectionViewLayoutInset.bottom;
+    const CGFloat width = scrollViewInsets.left +
+                          scrollViewInsets.right +
+                          collectionViewLayoutInset.left +
+                          collectionViewLayoutInset.right +
+                          self.frame.size.width;
+
+    if (collectionViewContentSize.height == 0) {
+        // If we don't return a size larger than 0 then we run into issues with the collection
+        // view layout not trying to properly calculate its size. So let's return something
+        NSLog(@"Unable to provide accurate height for container -- providing rough size");
+        const CGFloat roughValue = _collectionViewLayout.itemSize.height + insetsHeight;
+        return NSMakeSize(width, roughValue);
     }
 
-    collectionViewContentSize.height += insetsHeight;
-    return collectionViewContentSize;
+    if (_groupDescriptor.isHorizontalBarCollectionView) {
+        const CGFloat viewHeight = _collectionViewLayout.itemSize.height +
+                                   insetsHeight +
+                                   15; // Account for horizontal scrollbar
+        return NSMakeSize(width, viewHeight);
+    }
+
+    // HACK: At very specific widths of the container, the full height containers
+    // can have a bug where the top rows of the collection view are not displayed
+    // at all. By reducing the height of the container to below the height of the
+    // collection view contents we can eliminate this, so we reduce the height
+    // just enough to not be noticeable but enough for the bug to not manifest
+    return NSMakeSize(width, collectionViewContentSize.height - 15);
 }
 
 @end


=====================================
modules/gui/macosx/views/VLCSubScrollView.h
=====================================
@@ -31,6 +31,7 @@ NS_ASSUME_NONNULL_BEGIN
 @property (readwrite, assign) NSScrollView *parentScrollView;
 @property (readwrite, assign) BOOL scrollParentY;
 @property (readwrite, assign) BOOL scrollParentX;
+ at property (readwrite, assign) BOOL scrollSelf;
 
 // Scroll views containing collection views can disobey hasVerticalScroller -> NO.
 // This lets us forcefully override this behaviour


=====================================
modules/gui/macosx/views/VLCSubScrollView.m
=====================================
@@ -32,6 +32,7 @@
     if(self) {
         _scrollParentX = NO;
         _scrollParentY = NO;
+        _scrollSelf = YES;
     }
 
     return self;
@@ -39,6 +40,11 @@
 
 - (void)scrollWheel:(NSEvent *)event
 {
+    if (!_scrollSelf) {
+        [_parentScrollView scrollWheel:event];
+        return;
+    }
+
     [super scrollWheel:event];
 
     if(_parentScrollView == nil || (!_scrollParentX && !_scrollParentY)) {



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/1b99a3893497e527dbdd8f049f0ce5c7953b2357...0c923456ebd1970a3b86600256820af099c42260

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/1b99a3893497e527dbdd8f049f0ce5c7953b2357...0c923456ebd1970a3b86600256820af099c42260
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list