macosx: Add ability to disable dynamic item sizing in VLCLibraryCollectionViewDelegate

Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
This commit is contained in:
Claudio Cambra 2022-12-18 01:55:58 +01:00 committed by Felix Paul Kühne
parent a53ae4898c
commit 6279fcd121
2 changed files with 15 additions and 0 deletions

View File

@ -26,6 +26,8 @@ NS_ASSUME_NONNULL_BEGIN
@interface VLCLibraryCollectionViewDelegate : NSObject <NSCollectionViewDelegate, NSCollectionViewDelegateFlowLayout>
@property (readwrite, assign) BOOL dynamicItemSizing;
@end
NS_ASSUME_NONNULL_END

View File

@ -28,6 +28,15 @@
@implementation VLCLibraryCollectionViewDelegate
- (instancetype)init
{
self = [super init];
if (self) {
_dynamicItemSizing = YES;
}
return self;
}
- (void)collectionView:(NSCollectionView *)collectionView didSelectItemsAtIndexPaths:(NSSet<NSIndexPath *> *)indexPaths
{
NSIndexPath *indexPath = indexPaths.anyObject;
@ -58,6 +67,10 @@
layout:(NSCollectionViewLayout *)collectionViewLayout
sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
if (!_dynamicItemSizing) {
return CGSizeMake(214., 260.);
}
VLCLibraryCollectionViewFlowLayout *collectionViewFlowLayout = (VLCLibraryCollectionViewFlowLayout*)collectionViewLayout;
if (collectionViewLayout) {
VLCLibraryCollectionViewFlowLayout *collectionViewFlowLayout = (VLCLibraryCollectionViewFlowLayout*)collectionViewLayout;