Commit 5980e67d authored by Vibhoothi's avatar Vibhoothi

MainWindow: Introduce libraryView

- Loads the image from default location which is hardcoded as of now using NSColelctionVIewDataSource and NSFileManager.
- Uses FlowLayout for showing the items in the collectionView
- Shows Highlight of selection with blue colour (alternateSelectedControlColor).
- Get the index of selection using delegate following NSCollectionViewDelegate protocol and for debugging and all have displayed the log of it to command line.
- Scrolling function is also there with this, when the user resizes Window,it dynamically resizes the collection view items
parent 13ef6287
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14269.12" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14113" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14269.12"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14113"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
......@@ -17,7 +17,7 @@
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" topStrut="YES"/>
<rect key="contentRect" x="53" y="419" width="716" height="333"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1178"/>
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="900"/>
<view key="contentView" id="2">
<rect key="frame" x="0.0" y="0.0" width="716" height="333"/>
<autoresizingMask key="autoresizingMask"/>
......@@ -25,16 +25,16 @@
<customView translatesAutoresizingMaskIntoConstraints="NO" id="3Bj-Gx-5iu" userLabel="Middle Content">
<rect key="frame" x="0.0" y="36" width="716" height="297"/>
<subviews>
<scrollView wantsLayer="YES" autohidesScrollers="YES" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5Ke-Vb-9dU">
<scrollView wantsLayer="YES" autohidesScrollers="YES" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5Ke-Vb-9dU">
<rect key="frame" x="0.0" y="0.0" width="716" height="297"/>
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="V1V-11-Tss">
<rect key="frame" x="1" y="1" width="714" height="295"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<collectionView id="9My-dJ-ffm">
<rect key="frame" x="0.0" y="0.0" width="714" height="158"/>
<collectionView selectable="YES" id="9My-dJ-ffm">
<rect key="frame" x="0.0" y="0.0" width="714" height="295"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES"/>
<color key="primaryBackgroundColor" name="systemGreenColor" catalog="System" colorSpace="catalog"/>
<color key="primaryBackgroundColor" red="0.48883186943438339" green="0.52322152074126116" blue="0.52881107233502544" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<connections>
<outlet property="itemPrototype" destination="jCi-fI-3Z2" id="hDE-WR-6dZ"/>
</connections>
......@@ -42,7 +42,7 @@
</subviews>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="EAD-vz-amF">
<rect key="frame" x="1" y="144" width="233" height="15"/>
<rect key="frame" x="-100" y="-100" width="233" height="15"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="CoO-yc-KK4">
......@@ -406,15 +406,7 @@
<outlet property="volumeUpButton" destination="3652" id="vXR-KC-L2N"/>
</connections>
</customObject>
<collectionViewItem id="jCi-fI-3Z2">
<connections>
<outlet property="view" destination="LL0-re-ZbQ" id="mmD-XP-2Sr"/>
</connections>
</collectionViewItem>
<view id="LL0-re-ZbQ">
<rect key="frame" x="0.0" y="0.0" width="100" height="100"/>
<autoresizingMask key="autoresizingMask"/>
</view>
<collectionViewItem id="jCi-fI-3Z2"/>
</objects>
<resources>
<image name="backward-6btns" width="28" height="23"/>
......
......@@ -33,6 +33,7 @@
#import "VLCVideoWindowCommon.h"
#import "misc.h"
#import "VLCFSPanelController.h"
#import "VLCMainWindowCollectionViewItem.h"
@class VLCDetachedVideoWindow;
@class VLCMainWindowControlsBar;
......@@ -49,10 +50,13 @@ typedef enum {
@property (readonly) BOOL nativeFullscreenMode;
@property (readwrite) BOOL nonembedded;
@property (weak) IBOutlet NSCollectionView *collectionView;
@property (strong) VLCMainWindowCollectionViewItem *collectionViewItem;
@property (strong) NSMutableArray *images;
@property (readonly) VLCFSPanelController* fspanel;
@property (nonatomic, copy) NSDictionary *overrideClassNames;
@property (strong) IBOutlet NSCollectionView *collectionView;
@property (readonly) VLCFSPanelController* fspanel;
- (void)changePlaylistState:(VLCPlaylistStateEvent)event;
......
......@@ -45,13 +45,13 @@
#import "VLCVoutView.h"
#import "VLCVideoOutputProvider.h"
@interface VLCMainWindow() <NSWindowDelegate, NSAnimationDelegate>
@interface VLCMainWindow() <NSWindowDelegate, NSAnimationDelegate, NSCollectionViewDelegate,NSCollectionViewDataSource>
{
BOOL videoPlaybackEnabled;
BOOL dropzoneActive;
BOOL minimizedView;
BOOL collectionViewRemoved;
NSSet<NSIndexPath *> * VLCLibraryViewItem;
CGFloat lastCollectionViewHeight;
NSRect frameBeforePlayback;
......@@ -132,8 +132,14 @@ static const float f_min_window_height = 307.;
/* update fs button to reflect state for next startup */
if (var_InheritBool(pl_Get(getIntf()), "fullscreen"))
[self.controlsBar setFullscreenState:YES];
/* Make collectionview visible when Player loads */
[self makeCollectionViewVisible];
[self.collectionView reloadData];
}
#pragma mark - key and event handling
- (BOOL)isEvent:(NSEvent *)o_event forKey:(const char *)keyString
......@@ -206,6 +212,67 @@ static const float f_min_window_height = 307.;
}
[self makeFirstResponder:_collectionView];
self.collectionViewItem = [VLCMainWindowCollectionViewItem new];
self.collectionView.wantsLayer = YES;
self.images = [NSMutableArray arrayWithCapacity:0];
[self prepareData];
self.collectionView.delegate = self;
self.collectionView.dataSource = self;
self.collectionView.wantsLayer = YES;
[self.collectionView registerClass:[VLCMainWindowCollectionViewItem class] forItemWithIdentifier:@"fr_item"];
NSCollectionViewFlowLayout *flowLayout = [[NSCollectionViewFlowLayout alloc] init];
flowLayout.itemSize = NSMakeSize(100, 100);
flowLayout.sectionInset = NSEdgeInsetsMake(10, 10, 10, 10);
flowLayout.minimumInteritemSpacing = 20.0;
flowLayout.minimumLineSpacing = 20.0;
self.collectionView.collectionViewLayout = flowLayout;
[self.collectionView reloadData];
}
- (void)prepareData {
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *rootPath = @"/Users/vibhoothiiaanand/Desktop/Image ";
NSError *error = nil;
NSArray *paths = [fileManager contentsOfDirectoryAtPath:rootPath error:&error];
for (NSString *path in paths) {
NSString *imagePath = [rootPath stringByAppendingFormat:@"/%@",path];
NSLog(@"imagepath = %@",imagePath);
NSImage *image = [[NSImage alloc] initWithContentsOfFile:imagePath];
if (image) {
[self.images addObject:image];
}
}
}
#pragma mark - NSCollectionViewDelegate
- (NSSet<NSIndexPath *> *)collectionView:(NSCollectionView *)collectionView shouldChangeItemsAtIndexPaths:(NSSet<NSIndexPath *> *)indexPaths toHighlightState:(NSCollectionViewItemHighlightState)highlightState {
return indexPaths;
}
#pragma mark - NSCollectionViewDataSource
- (void)collectionView:(NSCollectionView *)collectionView didSelectItemsAtIndexPaths:VLCLibraryViewItem
{
NSLog(@"Video at:%@ is Selected",VLCLibraryViewItem);
}
- (NSInteger)collectionView:(NSCollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.images.count;
}
- (NSCollectionViewItem *)collectionView:(NSCollectionView *)collectionView itemForRepresentedObjectAtIndexPath:(NSIndexPath *)indexPath {
VLCMainWindowCollectionViewItem *item = [collectionView makeItemWithIdentifier:@"fr_item" forIndexPath:indexPath];
item.VLCItemImageView.image= [self.images objectAtIndex:indexPath.item];
return item;
}
- (NSInteger)numberOfSectionsInCollectionView:(NSCollectionView *)collectionView {
return 1;
}
// Hides the collection view and makes the vout view in foreground
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment