diff --git a/modules/gui/macosx/library/audio-library/VLCLibraryAudioDataSource.m b/modules/gui/macosx/library/audio-library/VLCLibraryAudioDataSource.m index a19b4b09b4bd..6e857a581845 100644 --- a/modules/gui/macosx/library/audio-library/VLCLibraryAudioDataSource.m +++ b/modules/gui/macosx/library/audio-library/VLCLibraryAudioDataSource.m @@ -721,26 +721,30 @@ - (NSSize)collectionView:(NSCollectionView *)collectionView { if (collectionViewLayout == _collectionViewFlowLayout && collectionView == _collectionView) { + return [self adjustedCollectionViewItemSize]; + } - static const CGFloat maxItemWidth = 280; - static const CGFloat minItemWidth = 180; + return NSZeroSize; +} - static uint numItemsInRow = 5; +- (NSSize)adjustedCollectionViewItemSize +{ + static const CGFloat maxItemWidth = 280; + static const CGFloat minItemWidth = 180; - NSSize itemSize = [self collectionViewItemSizeForNumberOfItemsInRow:numItemsInRow]; - while (itemSize.width > maxItemWidth) { - ++numItemsInRow; - itemSize = [self collectionViewItemSizeForNumberOfItemsInRow:numItemsInRow]; - } - while (itemSize.width < minItemWidth) { - --numItemsInRow; - itemSize = [self collectionViewItemSizeForNumberOfItemsInRow:numItemsInRow]; - } + static uint numItemsInRow = 5; - return itemSize; + NSSize itemSize = [self collectionViewItemSizeForNumberOfItemsInRow:numItemsInRow]; + while (itemSize.width > maxItemWidth) { + ++numItemsInRow; + itemSize = [self collectionViewItemSizeForNumberOfItemsInRow:numItemsInRow]; + } + while (itemSize.width < minItemWidth) { + --numItemsInRow; + itemSize = [self collectionViewItemSizeForNumberOfItemsInRow:numItemsInRow]; } - return NSZeroSize; + return itemSize; } - (NSSize)collectionViewItemSizeForNumberOfItemsInRow:(uint)numItemsInRow