[vlc-commits] [Git][videolan/vlc][master] 13 commits: macosx: Define default VLCLibraryCollectionViewItem size centrally, stop using magic numbers

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Sat Dec 31 12:05:41 UTC 2022



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


Commits:
bb6da418 by Claudio Cambra at 2022-12-31T11:51:42+00:00
macosx: Define default VLCLibraryCollectionViewItem size centrally, stop using magic numbers

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

- - - - -
003245da by Claudio Cambra at 2022-12-31T11:51:42+00:00
macosx: Stop using magic number for correct content view inset compensation for audio library options bar

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

- - - - -
29c81f73 by Claudio Cambra at 2022-12-31T11:51:42+00:00
macosx: Add new VLCLibraryUIUnits class to keep reused units centrally

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

- - - - -
87ec5947 by Claudio Cambra at 2022-12-31T11:51:42+00:00
macosx: Add spacing definitions to VLCLibraryUIUnits

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

- - - - -
32db7319 by Claudio Cambra at 2022-12-31T11:51:42+00:00
macosx: Declare standard size of small side of scrollbar in VLCLibraryUIUnits

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

- - - - -
accd9c31 by Claudio Cambra at 2022-12-31T11:51:42+00:00
macosx: Move pricate row height declarations in VLCLibraryWindow to VLCLibraryUIUnits

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

- - - - -
951e4a80 by Claudio Cambra at 2022-12-31T11:51:42+00:00
macosx: Use VLCLibraryUIUnits in VLCLibraryAlbumTableCellView

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

- - - - -
fa3dacfc by Claudio Cambra at 2022-12-31T11:51:42+00:00
macosx: Use VLCLibraryUIUnits scrollBarSmallSideSize in VLCLibraryVideoCollectionViewContainerView

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

- - - - -
cbca6369 by Claudio Cambra at 2022-12-31T11:51:42+00:00
macosx: Use VLCLibraryUIUnits largeSpacing in VLCLibraryVideCollectionViewsStackViewController

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

- - - - -
4058e407 by Claudio Cambra at 2022-12-31T11:51:42+00:00
macosx: Use VLCLibraryUIUtils in VLCLibraryCollectionViewFlowLayout

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

- - - - -
99d73e29 by Claudio Cambra at 2022-12-31T11:51:42+00:00
macosx: Fix VLCLibraryCollectionViewFlowLayout detail supplementary view alignment

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

- - - - -
7f33985b by Claudio Cambra at 2022-12-31T11:51:42+00:00
macosx: Use unified units in VLCLibraryCollectionViewDelegate

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

- - - - -
3c802935 by Claudio Cambra at 2022-12-31T11:51:42+00:00
macosx: Constify values returned in VLCLibraryUIUnits

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

- - - - -


12 changed files:

- extras/package/macosx/VLC.xcodeproj/project.pbxproj
- modules/gui/macosx/Makefile.am
- modules/gui/macosx/library/VLCLibraryCollectionViewDelegate.m
- modules/gui/macosx/library/VLCLibraryCollectionViewFlowLayout.m
- modules/gui/macosx/library/VLCLibraryCollectionViewItem.h
- modules/gui/macosx/library/VLCLibraryCollectionViewItem.m
- + modules/gui/macosx/library/VLCLibraryUIUnits.h
- + modules/gui/macosx/library/VLCLibraryUIUnits.m
- modules/gui/macosx/library/VLCLibraryWindow.m
- modules/gui/macosx/library/audio-library/VLCLibraryAlbumTableCellView.m
- modules/gui/macosx/library/video-library/VLCLibraryVideoCollectionViewContainerView.m
- modules/gui/macosx/library/video-library/VLCLibraryVideoCollectionViewsStackViewController.m


Changes:

=====================================
extras/package/macosx/VLC.xcodeproj/project.pbxproj
=====================================
@@ -92,6 +92,7 @@
 		536283F9291146BC00640C15 /* VLCLibraryCollectionViewFlowLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 536283EE291146BC00640C15 /* VLCLibraryCollectionViewFlowLayout.m */; };
 		53628402291147C500640C15 /* VLCBasicView.m in Sources */ = {isa = PBXBuildFile; fileRef = 536283FF291147C500640C15 /* VLCBasicView.m */; };
 		53628403291147C500640C15 /* VLCSubScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = 53628400291147C500640C15 /* VLCSubScrollView.m */; };
+		536EFBF5295BCB8300F4CB13 /* VLCLibraryUIUnits.m in Sources */ = {isa = PBXBuildFile; fileRef = 536EFBF4295BCB8300F4CB13 /* VLCLibraryUIUnits.m */; };
 		53B447CA2939823E00857588 /* VLCLibrarySongsTableViewSongPlayingTableCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = 53B447C92939823E00857588 /* VLCLibrarySongsTableViewSongPlayingTableCellView.m */; };
 		53B447F6293BB47B00857588 /* VLCLibraryVideoCollectionViewContainerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 53B447EC293BB47A00857588 /* VLCLibraryVideoCollectionViewContainerView.m */; };
 		53B447F7293BB47B00857588 /* VLCLibraryVideoCollectionViewContainerViewDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 53B447ED293BB47A00857588 /* VLCLibraryVideoCollectionViewContainerViewDataSource.m */; };
@@ -271,6 +272,8 @@
 		536283FF291147C500640C15 /* VLCBasicView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCBasicView.m; sourceTree = "<group>"; };
 		53628400291147C500640C15 /* VLCSubScrollView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCSubScrollView.m; sourceTree = "<group>"; };
 		53628401291147C500640C15 /* VLCSubScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCSubScrollView.h; sourceTree = "<group>"; };
+		536EFBF3295BCB8300F4CB13 /* VLCLibraryUIUnits.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCLibraryUIUnits.h; sourceTree = "<group>"; };
+		536EFBF4295BCB8300F4CB13 /* VLCLibraryUIUnits.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCLibraryUIUnits.m; sourceTree = "<group>"; };
 		53B447C82939823E00857588 /* VLCLibrarySongsTableViewSongPlayingTableCellView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCLibrarySongsTableViewSongPlayingTableCellView.h; sourceTree = "<group>"; };
 		53B447C92939823E00857588 /* VLCLibrarySongsTableViewSongPlayingTableCellView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCLibrarySongsTableViewSongPlayingTableCellView.m; sourceTree = "<group>"; };
 		53B447EC293BB47A00857588 /* VLCLibraryVideoCollectionViewContainerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCLibraryVideoCollectionViewContainerView.m; sourceTree = "<group>"; };
@@ -1153,6 +1156,8 @@
 				5317FE02294E3DD3001702F0 /* VLCLibraryCollectionViewDelegate.h */,
 				5317FE03294E3DD3001702F0 /* VLCLibraryCollectionViewDelegate.m */,
 				5317FE05294E8D1A001702F0 /* VLCLibraryCollectionViewDataSource.h */,
+				536EFBF3295BCB8300F4CB13 /* VLCLibraryUIUnits.h */,
+				536EFBF4295BCB8300F4CB13 /* VLCLibraryUIUnits.m */,
 			);
 			path = library;
 			sourceTree = "<group>";
@@ -1848,6 +1853,7 @@
 				536283F6291146BC00640C15 /* VLCLibraryCollectionViewAudioGroupSupplementaryDetailView.m in Sources */,
 				1CCC89022078A3D500E5626F /* ResumeDialog.xib in Sources */,
 				7DE7232E22A51F8D00D72616 /* VLCPositionFormatter.m in Sources */,
+				536EFBF5295BCB8300F4CB13 /* VLCLibraryUIUnits.m in Sources */,
 				1CCC89032078A3D500E5626F /* SimplePreferences.xib in Sources */,
 				7DE82E7922843781002D341A /* VLCLibraryAlbumTableCellView.m in Sources */,
 				7D67318622C8F4060000AD40 /* VLCMediaSourceCollectionViewItem.m in Sources */,


=====================================
modules/gui/macosx/Makefile.am
=====================================
@@ -93,6 +93,8 @@ libmacosx_plugin_la_SOURCES = \
 	gui/macosx/library/VLCLibraryTableView.m \
 	gui/macosx/library/VLCLibraryTableCellView.h \
 	gui/macosx/library/VLCLibraryTableCellView.m \
+	gui/macosx/library/VLCLibraryUIUnits.h \
+	gui/macosx/library/VLCLibraryUIUnits.m \
 	gui/macosx/library/VLCLibraryWindow.h \
 	gui/macosx/library/VLCLibraryWindow.m \
 	gui/macosx/library/VLCLibraryWindowController.h \


=====================================
modules/gui/macosx/library/VLCLibraryCollectionViewDelegate.m
=====================================
@@ -24,7 +24,9 @@
 
 #import "VLCLibraryCollectionViewDataSource.h"
 #import "VLCLibraryCollectionViewFlowLayout.h"
+#import "VLCLibraryCollectionViewItem.h"
 #import "VLCLibraryDataTypes.h"
+#import "VLCLibraryUIUnits.h"
 
 @implementation VLCLibraryCollectionViewDelegate
 
@@ -33,7 +35,7 @@
     self = [super init];
     if (self) {
         _dynamicItemSizing = YES;
-        _staticItemSize = NSMakeSize(214, 260);
+        _staticItemSize = [VLCLibraryCollectionViewItem defaultSize];
     }
     return self;
 }
@@ -85,22 +87,19 @@
 - (NSSize)adjustedItemSizeForCollectionView:(NSCollectionView *)collectionView
                                  withLayout:(VLCLibraryCollectionViewFlowLayout *)collectionViewLayout
 {
-    static const CGFloat maxItemWidth = 280;
-    static const CGFloat minItemWidth = 180;
-
     static uint numItemsInRow = 5;
 
     NSSize itemSize = [self itemSizeForCollectionView:collectionView
                                            withLayout:collectionViewLayout
                                withNumberOfItemsInRow:numItemsInRow];
 
-    while (itemSize.width > maxItemWidth) {
+    while (itemSize.width > [VLCLibraryUIUnits dynamicCollectionViewItemMaximumSize]) {
         ++numItemsInRow;
         itemSize = [self itemSizeForCollectionView:collectionView
                                         withLayout:collectionViewLayout
                             withNumberOfItemsInRow:numItemsInRow];
     }
-    while (itemSize.width < minItemWidth) {
+    while (itemSize.width < [VLCLibraryUIUnits dynamicCollectionViewItemMinimumSize]) {
         --numItemsInRow;
         itemSize = [self itemSizeForCollectionView:collectionView
                                         withLayout:collectionViewLayout
@@ -128,7 +127,7 @@
                                      1);
 
     const CGFloat itemWidth = rowOfItemsWidth / numItemsInRow;
-    return NSMakeSize(itemWidth, itemWidth + 46); // Text fields height needed
+    return NSMakeSize(itemWidth, itemWidth + [VLCLibraryCollectionViewItem bottomTextViewsHeight]);
 }
 
 - (BOOL)collectionView:(NSCollectionView *)collectionView


=====================================
modules/gui/macosx/library/VLCLibraryCollectionViewFlowLayout.m
=====================================
@@ -23,6 +23,7 @@
 #import "VLCLibraryCollectionViewFlowLayout.h"
 
 #import "library/VLCLibraryCollectionViewMediaItemSupplementaryDetailView.h"
+#import "library/VLCLibraryUIUnits.h"
 
 #import "library/audio-library/VLCLibraryAudioDataSource.h"
 #import "library/audio-library/VLCLibraryCollectionViewAlbumSupplementaryDetailView.h"
@@ -34,10 +35,7 @@
 static const NSUInteger kAnimationSteps = 32;
 static const NSUInteger kWrapAroundValue = (NSUInteger)-1;
 
-static const CGFloat kDetailViewMargin = 8.;
 static const CGFloat kDetailViewCollapsedHeight = 0.;
-static const CGFloat kDetailViewDefaultExpandedHeight = 300.;
-static const CGFloat kDetailViewLargeExpandedHeight = 500.;
 
 typedef NS_ENUM(NSUInteger, VLCDetailViewAnimationType)
 {
@@ -85,8 +83,8 @@ static CVReturn detailViewAnimationCallback(CVDisplayLinkRef displayLink,
 {
     self = [super init];
     if (self) {
-        _defaultHeightAnimationSteps = [NSArray arrayWithArray:[self generateAnimationStepsForExpandedViewHeight:kDetailViewDefaultExpandedHeight]];
-        _largeHeightAnimationSteps = [NSArray arrayWithArray:[self generateAnimationStepsForExpandedViewHeight:kDetailViewLargeExpandedHeight]];
+        _defaultHeightAnimationSteps = [NSArray arrayWithArray:[self generateAnimationStepsForExpandedViewHeight:[VLCLibraryUIUnits mediumDetailSupplementaryViewCollectionViewHeight]]];
+        _largeHeightAnimationSteps = [NSArray arrayWithArray:[self generateAnimationStepsForExpandedViewHeight:[VLCLibraryUIUnits largeDetailSupplementaryViewCollectionViewHeight]]];
         
         _animationType = VLCExpandAnimationTypeDefault;
         _prevProvidedAnimationStep = 0;
@@ -274,9 +272,9 @@ static CVReturn detailViewAnimationCallback(CVDisplayLinkRef displayLink,
                   elementKind);
         
         float selectedItemFrameMaxY = _selectedIndexPath == nil ? 0 : NSMaxY([[self layoutAttributesForItemAtIndexPath:_selectedIndexPath] frame]);
-        detailViewAttributes.frame = NSMakeRect(NSMinX(self.collectionView.frame),
-                                                selectedItemFrameMaxY + kDetailViewMargin,
-                                                self.collectionViewContentSize.width - 20.0,
+        detailViewAttributes.frame = NSMakeRect(NSMinX(self.collectionView.frame) + self.minimumInteritemSpacing,
+                                                selectedItemFrameMaxY + [VLCLibraryUIUnits mediumSpacing],
+                                                self.collectionViewContentSize.width - (self.minimumInteritemSpacing * 2),
                                                 [self currentAnimationStep]);
 
         return detailViewAttributes;
@@ -319,7 +317,7 @@ static CVReturn detailViewAnimationCallback(CVDisplayLinkRef displayLink,
         NSRect selectedItemFrame = selectedItemLayoutAttributes.frame;
         
         if (NSMinY(attributesFrame) > (NSMaxY(selectedItemFrame))) {
-            attributesFrame.origin.y += [self currentAnimationStep] + kDetailViewMargin;
+            attributesFrame.origin.y += [self currentAnimationStep] + [VLCLibraryUIUnits mediumSpacing];
         }
     }
 


=====================================
modules/gui/macosx/library/VLCLibraryCollectionViewItem.h
=====================================
@@ -32,6 +32,10 @@ extern NSString *VLCLibraryCellIdentifier;
 
 @interface VLCLibraryCollectionViewItem : NSCollectionViewItem
 
+// NOTE: These will need to be changed after changed to XIB
++ (NSSize)defaultSize;
++ (CGFloat)bottomTextViewsHeight;
+
 @property (readwrite, assign) IBOutlet NSTextField *mediaTitleTextField;
 @property (readwrite, assign) IBOutlet NSTextField *annotationTextField;
 @property (readwrite, assign) IBOutlet NSTextField *unplayedIndicatorTextField;


=====================================
modules/gui/macosx/library/VLCLibraryCollectionViewItem.m
=====================================
@@ -23,13 +23,17 @@
 #import "VLCLibraryCollectionViewItem.h"
 
 #import "main/VLCMain.h"
+
 #import "library/VLCLibraryController.h"
 #import "library/VLCLibraryDataTypes.h"
 #import "library/VLCLibraryModel.h"
 #import "library/VLCLibraryMenuController.h"
+#import "library/VLCLibraryUIUnits.h"
+
 #import "views/VLCImageView.h"
 #import "views/VLCLinearProgressIndicator.h"
 #import "views/VLCTrackingView.h"
+
 #import "extensions/NSString+Helpers.h"
 #import "extensions/NSFont+VLCAdditions.h"
 #import "extensions/NSColor+VLCAdditions.h"
@@ -48,6 +52,21 @@ const CGFloat VLCLibraryCollectionViewItemMaximumDisplayedProgress = 0.95;
 
 @implementation VLCLibraryCollectionViewItem
 
++ (NSSize)defaultSize
+{
+    CGFloat width = 214;
+    return CGSizeMake(width, width + [self bottomTextViewsHeight]);
+}
+
++ (CGFloat)bottomTextViewsHeight
+{
+    return [VLCLibraryUIUnits smallSpacing] +
+           16 +
+           [VLCLibraryUIUnits smallSpacing] +
+           16 +
+           [VLCLibraryUIUnits smallSpacing];
+}
+
 - (instancetype)initWithNibName:(NSNibName)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
 {
     self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];


=====================================
modules/gui/macosx/library/VLCLibraryUIUnits.h
=====================================
@@ -0,0 +1,49 @@
+/*****************************************************************************
+ * VLCLibraryAudioViewController.h: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2022 VLC authors and VideoLAN
+ *
+ * Authors: Claudio Cambra <developer at claudiocambra.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import <Cocoa/Cocoa.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+ at interface VLCLibraryUIUnits : NSObject
+
+// Note that these values are not necessarily linked to the layout defined in the .xib files.
+// If the spacing in the layout is changed you will want to change these values too.
++ (const CGFloat)largeSpacing;
++ (const CGFloat)mediumSpacing;
++ (const CGFloat)smallSpacing;
+
++ (const CGFloat)scrollBarSmallSideSize;
+
++ (const CGFloat)largeTableViewRowHeight;
++ (const CGFloat)mediumTableViewRowHeight;
++ (const CGFloat)smallTableViewRowHeight;
+
++ (const CGFloat)mediumDetailSupplementaryViewCollectionViewHeight;
++ (const CGFloat)largeDetailSupplementaryViewCollectionViewHeight;
+
++ (const CGFloat)dynamicCollectionViewItemMinimumSize;
++ (const CGFloat)dynamicCollectionViewItemMaximumSize;
+
+ at end
+
+NS_ASSUME_NONNULL_END


=====================================
modules/gui/macosx/library/VLCLibraryUIUnits.m
=====================================
@@ -0,0 +1,82 @@
+/*****************************************************************************
+ * VLCLibraryAudioViewController.m: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2022 VLC authors and VideoLAN
+ *
+ * Authors: Claudio Cambra <developer at claudiocambra.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import "VLCLibraryUIUnits.h"
+
+ at implementation VLCLibraryUIUnits
+
++ (const CGFloat)largeSpacing
+{
+    return 20;
+}
+
++ (const CGFloat)mediumSpacing
+{
+    return 10;
+}
+
++ (const CGFloat)smallSpacing
+{
+    return 5;
+}
+
++ (const CGFloat)scrollBarSmallSideSize
+{
+    return 16;
+}
+
++ (const CGFloat)largeTableViewRowHeight
+{
+    return 100;
+}
+
++ (const CGFloat)mediumTableViewRowHeight
+{
+    return 50;
+}
+
++ (const CGFloat)smallTableViewRowHeight
+{
+    return 25;
+}
+
++ (const CGFloat)mediumDetailSupplementaryViewCollectionViewHeight
+{
+    return 300;
+}
+
++ (const CGFloat)largeDetailSupplementaryViewCollectionViewHeight
+{
+    return 500;
+}
+
++ (const CGFloat)dynamicCollectionViewItemMinimumSize
+{
+    return 180;
+}
+
++ (const CGFloat)dynamicCollectionViewItemMaximumSize
+{
+    return 280;
+}
+
+ at end


=====================================
modules/gui/macosx/library/VLCLibraryWindow.m
=====================================
@@ -39,6 +39,7 @@
 #import "library/VLCLibraryCollectionViewSupplementaryElementView.h"
 #import "library/VLCLibrarySortingMenuController.h"
 #import "library/VLCLibraryNavigationStack.h"
+#import "library/VLCLibraryUIUnits.h"
 
 #import "library/video-library/VLCLibraryVideoCollectionViewsStackViewController.h"
 #import "library/video-library/VLCLibraryVideoTableViewDataSource.h"
@@ -64,10 +65,6 @@
 
 const CGFloat VLCLibraryWindowMinimalWidth = 604.;
 const CGFloat VLCLibraryWindowMinimalHeight = 307.;
-const CGFloat VLCLibraryWindowLargePlaylistRowHeight = 60.;
-const CGFloat VLCLibraryWindowSmallPlaylistRowHeight = 45.;
-const CGFloat VLCLibraryWindowSmallRowHeight = 24.;
-const CGFloat VLCLibraryWindowLargeRowHeight = 50.;
 const CGFloat VLCLibraryWindowDefaultPlaylistWidth = 340.;
 const CGFloat VLCLibraryWindowMinimalPlaylistWidth = 170.;
 const NSUserInterfaceItemIdentifier VLCLibraryWindowIdentifier = @"VLCLibraryWindow";
@@ -250,8 +247,8 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
     _libraryVideoTableViewDataSource.libraryModel = mainInstance.libraryController.libraryModel;
     _libraryVideoTableViewDataSource.groupsTableView = _videoLibraryGroupsTableView;
     _libraryVideoTableViewDataSource.groupSelectionTableView = _videoLibraryGroupSelectionTableView;
-    _videoLibraryGroupsTableView.rowHeight = VLCLibraryWindowLargeRowHeight;
-    _videoLibraryGroupSelectionTableView.rowHeight = VLCLibraryWindowLargeRowHeight;
+    _videoLibraryGroupsTableView.rowHeight = [VLCLibraryUIUnits mediumTableViewRowHeight];
+    _videoLibraryGroupSelectionTableView.rowHeight = [VLCLibraryUIUnits mediumTableViewRowHeight];
     [_libraryVideoTableViewDataSource setup];
 
     _libraryVideoCollectionViewsStackViewController = [[VLCLibraryVideoCollectionViewsStackViewController alloc] init];
@@ -259,7 +256,7 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
     _libraryVideoCollectionViewsStackViewController.collectionsStackView = _videoLibraryCollectionViewsStackView;
 
     _libraryAudioViewController = [[VLCLibraryAudioViewController alloc] initWithLibraryWindow:self];
-    _audioCollectionSelectionTableView.rowHeight = VLCLibraryWindowLargeRowHeight;
+    _audioCollectionSelectionTableView.rowHeight = [VLCLibraryUIUnits mediumTableViewRowHeight];
     _audioGroupSelectionTableView.rowHeight = [VLCLibraryAlbumTableCellView defaultHeight];
 
     _mediaSourceDataSource = [[VLCMediaSourceBaseDataSource alloc] init];
@@ -268,7 +265,7 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
     _mediaSourceDataSource.homeButton = _mediaSourceHomeButton;
     _mediaSourceDataSource.pathControl = _mediaSourcePathControl;
     _mediaSourceDataSource.gridVsListSegmentedControl = _gridVsListSegmentedControl;
-    _mediaSourceTableView.rowHeight = VLCLibraryWindowLargeRowHeight;
+    _mediaSourceTableView.rowHeight = [VLCLibraryUIUnits mediumTableViewRowHeight];
     _mediaSourceDataSource.tableView = _mediaSourceTableView;
     [_mediaSourceDataSource setupViews];
 
@@ -284,14 +281,17 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
     [self setViewForSelectedSegment];
     [self repeatStateUpdated:nil];
     [self shuffleStateUpdated:nil];
-    
-    const CGFloat scrollViewTopInset = 16.;
+
+    // We want all the insets to look even, and since the scrollbar is transparent,
+    // we have to compensate for this on the sides where there isn't a scrollbar to
+    // match up the perceived whitespace on all sides
+    const CGFloat scrollViewTopInset = [VLCLibraryUIUnits scrollBarSmallSideSize];
     const CGFloat scrollViewRightInset = 0.;
-    const CGFloat scrollViewBottomInset = 16.;
-    const CGFloat scrollViewLeftInset = 16.;
+    const CGFloat scrollViewBottomInset = [VLCLibraryUIUnits scrollBarSmallSideSize];
+    const CGFloat scrollViewLeftInset = [VLCLibraryUIUnits scrollBarSmallSideSize];
 
     // Need to account for the audio collection switcher at the top
-    const CGFloat audioScrollViewTopInset = scrollViewTopInset + 32.;
+    const CGFloat audioScrollViewTopInset = scrollViewTopInset + _optionBarView.frame.size.height;
 
     const NSEdgeInsets defaultInsets = NSEdgeInsetsMake(scrollViewTopInset,
                                                         scrollViewLeftInset,
@@ -338,21 +338,24 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
     _mediaSourceTableViewScrollView.contentInsets = defaultInsets;
     _mediaSourceTableViewScrollView.scrollerInsets = scrollerInsets;
 
-    const CGFloat collectionItemSpacing = 20.;
-    const NSEdgeInsets collectionViewSectionInset = NSEdgeInsetsMake(20., 20., 20., 20.);
+    const CGFloat collectionItemSpacing = [VLCLibraryUIUnits largeSpacing];
+    const NSEdgeInsets collectionViewSectionInset = NSEdgeInsetsMake(collectionItemSpacing,
+                                                                     collectionItemSpacing,
+                                                                     collectionItemSpacing,
+                                                                     collectionItemSpacing);
 
     NSCollectionViewFlowLayout *audioLibraryCollectionViewLayout = _audioLibraryCollectionView.collectionViewLayout;
     audioLibraryCollectionViewLayout.minimumLineSpacing = collectionItemSpacing;
     audioLibraryCollectionViewLayout.minimumInteritemSpacing = collectionItemSpacing;
     audioLibraryCollectionViewLayout.sectionInset = collectionViewSectionInset;
 
-    _libraryVideoCollectionViewsStackViewController.collectionViewItemSize = CGSizeMake(214., 260.);
+    _libraryVideoCollectionViewsStackViewController.collectionViewItemSize = [VLCLibraryCollectionViewItem defaultSize];
     _libraryVideoCollectionViewsStackViewController.collectionViewMinimumLineSpacing = collectionItemSpacing;
     _libraryVideoCollectionViewsStackViewController.collectionViewMinimumInteritemSpacing = collectionItemSpacing;
     _libraryVideoCollectionViewsStackViewController.collectionViewSectionInset = collectionViewSectionInset;
 
     NSCollectionViewFlowLayout *mediaSourceCollectionViewLayout = _mediaSourceCollectionView.collectionViewLayout;
-    mediaSourceCollectionViewLayout.itemSize = CGSizeMake(214., 246.);
+    mediaSourceCollectionViewLayout.itemSize = [VLCLibraryCollectionViewItem defaultSize];
     mediaSourceCollectionViewLayout.minimumLineSpacing = collectionItemSpacing;
     mediaSourceCollectionViewLayout.minimumInteritemSpacing = collectionItemSpacing;
     mediaSourceCollectionViewLayout.sectionInset = collectionViewSectionInset;
@@ -421,7 +424,9 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
 
 - (void)updateViewCellDimensionsBasedOnSetting:(NSNotification *)aNotification
 {
-    _playlistTableView.rowHeight = config_GetInt("macosx-large-text") ? VLCLibraryWindowLargePlaylistRowHeight : VLCLibraryWindowSmallPlaylistRowHeight;
+    _playlistTableView.rowHeight = config_GetInt("macosx-large-text") ?
+        [VLCLibraryUIUnits largeTableViewRowHeight] :
+        [VLCLibraryUIUnits mediumTableViewRowHeight];
 }
 
 #pragma mark - playmode state display and interaction


=====================================
modules/gui/macosx/library/audio-library/VLCLibraryAlbumTableCellView.m
=====================================
@@ -26,25 +26,24 @@
 #import "extensions/NSFont+VLCAdditions.h"
 #import "extensions/NSString+Helpers.h"
 #import "extensions/NSView+VLCAdditions.h"
+
 #import "views/VLCImageView.h"
 #import "views/VLCTrackingView.h"
+
 #import "main/VLCMain.h"
+
 #import "library/VLCLibraryController.h"
 #import "library/VLCLibraryDataTypes.h"
 #import "library/VLCLibraryTableCellView.h"
 #import "library/VLCLibraryTableView.h"
+#import "library/VLCLibraryUIUnits.h"
+
 #import "library/audio-library/VLCLibraryAlbumTracksDataSource.h"
 
 NSString *VLCAudioLibraryCellIdentifier = @"VLCAudioLibraryCellIdentifier";
 NSString *VLCLibraryAlbumTableCellTableViewColumnIdentifier = @"VLCLibraryAlbumTableCellTableViewColumnIdentifier";
 const CGFloat VLCLibraryAlbumTableCellViewDefaultHeight = 168.;
 
-// Note that these values are not necessarily linked to the layout defined in the .xib files.
-// If the spacing in the layout is changed you will want to change these values too.
-const CGFloat VLCLibraryAlbumTableCellViewLargeSpacing = 20;
-const CGFloat VLCLibraryAlbumTableCellViewMediumSpacing = 10;
-const CGFloat VLCLibraryAlbumTableCellViewSmallSpacing = 5;
-
 @interface VLCLibraryAlbumTableCellView ()
 {
     VLCLibraryController *_libraryController;
@@ -74,25 +73,25 @@ const CGFloat VLCLibraryAlbumTableCellViewSmallSpacing = 5;
         return -1;
     }
 
-    const CGFloat artworkAndSecondaryLabelsHeight = VLCLibraryAlbumTableCellViewLargeSpacing + 
+    const CGFloat artworkAndSecondaryLabelsHeight = [VLCLibraryUIUnits largeSpacing] +
                                                     _representedImageView.frame.size.height + 
-                                                    VLCLibraryAlbumTableCellViewMediumSpacing + 
+                                                    [VLCLibraryUIUnits mediumSpacing] +
                                                     _summaryTextField.frame.size.height + 
-                                                    VLCLibraryAlbumTableCellViewSmallSpacing +
+                                                    [VLCLibraryUIUnits smallSpacing] +
                                                     _yearTextField.frame.size.height + 
-                                                    VLCLibraryAlbumTableCellViewLargeSpacing;
+                                                    [VLCLibraryUIUnits largeSpacing];
     
     if(_tracksTableView == nil) {
         return artworkAndSecondaryLabelsHeight;
     }
 
-    const CGFloat titleAndTableViewHeight = VLCLibraryAlbumTableCellViewLargeSpacing +
+    const CGFloat titleAndTableViewHeight = [VLCLibraryUIUnits largeSpacing] +
                                             _albumNameTextField.frame.size.height +
-                                            VLCLibraryAlbumTableCellViewSmallSpacing +
+                                            [VLCLibraryUIUnits smallSpacing] +
                                             _artistNameTextField.frame.size.height + 
-                                            VLCLibraryAlbumTableCellViewSmallSpacing +
+                                            [VLCLibraryUIUnits smallSpacing] +
                                             [self expectedTableViewHeight] +
-                                            VLCLibraryAlbumTableCellViewLargeSpacing;
+                                            [VLCLibraryUIUnits largeSpacing];
 
     return titleAndTableViewHeight > artworkAndSecondaryLabelsHeight ? titleAndTableViewHeight : artworkAndSecondaryLabelsHeight;
 }
@@ -103,14 +102,14 @@ const CGFloat VLCLibraryAlbumTableCellViewSmallSpacing = 5;
     // to take into account the album's left spacing, right spacing, and the table view's
     // right spacing. In this case we are using large spacing for all of these. We also
     // throw in a little bit extra spacing to compensate for some mysterious internal spacing.
-    return self.frame.size.width - _representedImageView.frame.size.width - VLCLibraryAlbumTableCellViewLargeSpacing * 3.75;
+    return self.frame.size.width - _representedImageView.frame.size.width - [VLCLibraryUIUnits largeSpacing] * 3.75;
 }
 
 - (CGFloat)expectedTableViewHeight
 {
     const NSUInteger numberOfTracks = _representedAlbum.numberOfTracks;
     const CGFloat intercellSpacing = numberOfTracks > 1 ? (numberOfTracks - 1) * _tracksTableView.intercellSpacing.height : 0;
-    return numberOfTracks * VLCLibraryTracksRowHeight + intercellSpacing + VLCLibraryAlbumTableCellViewMediumSpacing;
+    return numberOfTracks * VLCLibraryTracksRowHeight + intercellSpacing + [VLCLibraryUIUnits mediumSpacing];
 }
 
 - (void)awakeFromNib
@@ -150,14 +149,14 @@ const CGFloat VLCLibraryAlbumTableCellViewSmallSpacing = 5;
     _tracksTableView.translatesAutoresizingMaskIntoConstraints = NO;
     [self addSubview:_tracksTableView];
     NSString *horizontalVisualConstraints = [NSString stringWithFormat:@"H:|-%f-[_representedImageView]-%f-[_tracksTableView]-%f-|",
-        VLCLibraryAlbumTableCellViewLargeSpacing,
-        VLCLibraryAlbumTableCellViewLargeSpacing,
-        VLCLibraryAlbumTableCellViewLargeSpacing];
+                                             [VLCLibraryUIUnits largeSpacing],
+                                             [VLCLibraryUIUnits largeSpacing],
+                                             [VLCLibraryUIUnits largeSpacing]];
     NSString *verticalVisualContraints = [NSString stringWithFormat:@"V:|-%f-[_albumNameTextField]-%f-[_artistNameTextField]-%f-[_tracksTableView]->=%f-|",
-        VLCLibraryAlbumTableCellViewLargeSpacing,
-        VLCLibraryAlbumTableCellViewSmallSpacing,
-        VLCLibraryAlbumTableCellViewMediumSpacing,
-        VLCLibraryAlbumTableCellViewLargeSpacing];
+                                          [VLCLibraryUIUnits largeSpacing],
+                                          [VLCLibraryUIUnits smallSpacing],
+                                          [VLCLibraryUIUnits mediumSpacing],
+                                          [VLCLibraryUIUnits largeSpacing]];
     NSDictionary *dict = NSDictionaryOfVariableBindings(_tracksTableView, _representedImageView, _albumNameTextField, _artistNameTextField);
     [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:horizontalVisualConstraints options:0 metrics:0 views:dict]];
     [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:verticalVisualContraints options:0 metrics:0 views:dict]];


=====================================
modules/gui/macosx/library/video-library/VLCLibraryVideoCollectionViewContainerView.m
=====================================
@@ -25,6 +25,7 @@
 #import "library/VLCLibraryCollectionViewDelegate.h"
 #import "library/VLCLibraryCollectionViewFlowLayout.h"
 #import "library/VLCLibraryCollectionViewSupplementaryElementView.h"
+#import "library/VLCLibraryUIUnits.h"
 
 #import "library/video-library/VLCLibraryVideoCollectionViewContainerViewDataSource.h"
 #import "library/video-library/VLCLibraryVideoGroupDescriptor.h"
@@ -200,7 +201,7 @@
     }
 
     if (_groupDescriptor.isHorizontalBarCollectionView) {
-        const CGFloat viewHeight = itemHeight + insetsHeight + 15; // Account for horizontal scrollbar
+        const CGFloat viewHeight = itemHeight + insetsHeight + [VLCLibraryUIUnits scrollBarSmallSideSize];
         return NSMakeSize(width, viewHeight);
     }
 


=====================================
modules/gui/macosx/library/video-library/VLCLibraryVideoCollectionViewsStackViewController.m
=====================================
@@ -26,6 +26,7 @@
 #import "library/VLCLibraryCollectionViewFlowLayout.h"
 #import "library/VLCLibraryCollectionViewSupplementaryElementView.h"
 #import "library/VLCLibraryModel.h"
+#import "library/VLCLibraryUIUnits.h"
 
 #import "library/video-library/VLCLibraryVideoCollectionViewContainerView.h"
 #import "library/video-library/VLCLibraryVideoCollectionViewContainerViewDataSource.h"
@@ -90,7 +91,7 @@
     }
 
     _collectionsStackView = collectionsStackView;
-    _collectionsStackView.spacing = 20.;
+    _collectionsStackView.spacing = [VLCLibraryUIUnits largeSpacing];
     _collectionsStackView.orientation = NSUserInterfaceLayoutOrientationVertical;
     _collectionsStackView.alignment = NSLayoutAttributeLeading;
     _collectionsStackView.distribution = NSStackViewDistributionFill;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/be5239676f25419822572edbcf78342eabfb8e1f...3c802935d0dbe947715bd4e5f4be8a72279fddca

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/be5239676f25419822572edbcf78342eabfb8e1f...3c802935d0dbe947715bd4e5f4be8a72279fddca
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