Commit 4531bbef authored by Vibhoothi's avatar Vibhoothi

libraryView: MVC based libraryView with dummyData

This commit fully revamp the current implementation of the dummyData with proper Guidelines
of MVC so now the data is made into a datamModel and passed to
VLCMainWindowCollectionViewItem with assignValueForDataModel with dataModel as an argument
parent 1919581e
......@@ -12,6 +12,10 @@
<outlet property="VLCItemLabel" destination="KFD-Gv-9GE" id="Y3t-Ag-E8M"/>
<outlet property="VLCPopOver" destination="IPI-0k-cD6" id="bHD-Ef-Aap"/>
<outlet property="VLCPopOverTriggerButton" destination="rgr-zW-apm" id="pcH-Tf-4VZ"/>
<outlet property="popOverImage" destination="0sa-wu-dPr" id="xYR-7X-Xbm"/>
<outlet property="popOverSize" destination="lSa-IC-VbL" id="8hD-9j-3Uz"/>
<outlet property="popOverTitle" destination="bNc-32-jG8" id="gR0-OK-6Oj"/>
<outlet property="popOveryear" destination="Ebf-j5-UtS" id="sJY-aq-A4G"/>
<outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
</connections>
</customObject>
......@@ -90,7 +94,7 @@
</imageView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Ebf-j5-UtS">
<rect key="frame" x="81" y="45" width="106" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Cone" id="WF4-b6-t4f">
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="2018" id="WF4-b6-t4f">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
......
......@@ -34,6 +34,7 @@
#import "misc.h"
#import "VLCFSPanelController.h"
#import "VLCMainWindowCollectionViewItem.h"
#import "VLCMainWindowDataModel.h"
@class VLCDetachedVideoWindow;
@class VLCMainWindowControlsBar;
......@@ -52,8 +53,10 @@ typedef enum {
@property (readwrite) BOOL nonembedded;
@property (weak) IBOutlet NSCollectionView *collectionView;
@property (strong) VLCMainWindowCollectionViewItem *collectionViewItem;
@property (strong) VLCMainWindowDataModel *dataModel;
@property (strong) NSMutableArray *thumbinails;
@property (strong) NSMutableArray *labels;
@property (strong) NSMutableArray *years;
@property (readonly) VLCFSPanelController* fspanel;
@property (nonatomic, copy) NSDictionary *overrideClassNames;
......
......@@ -53,7 +53,7 @@
BOOL collectionViewRemoved;
NSSet<NSIndexPath *> * VLCLibraryViewItem;
CGFloat lastCollectionViewHeight;
// VLCMainWindowDataModel *dataModel;
NSRect frameBeforePlayback;
}
@end
......@@ -134,8 +134,8 @@ static const float f_min_window_height = 307.;
[self.controlsBar setFullscreenState:YES];
/* Make collectionview visible when Player loads */
// [self makeCollectionViewVisible];
// [self.collectionView reloadData];
[self makeCollectionViewVisible];
[self.collectionView reloadData];
}
......@@ -213,15 +213,17 @@ static const float f_min_window_height = 307.;
[self makeFirstResponder:_collectionView];
self.collectionViewItem = [VLCMainWindowCollectionViewItem new];
// dataModel = [VLCMainWindowDataModel new];
self.collectionView.wantsLayer = YES;
self.thumbinails = [NSMutableArray arrayWithCapacity:0];
self.labels = [NSMutableArray arrayWithCapacity:0];
self.years = [NSMutableArray arrayWithCapacity:0];
[self prepareData];
self.collectionView.delegate = self;
self.collectionView.dataSource = self;
self.collectionView.wantsLayer = YES;
[self.collectionView registerClass:[VLCMainWindowCollectionViewItem class] forItemWithIdentifier:@"VLCItemT"];
[self.collectionView registerClass:[VLCMainWindowCollectionViewItem class] forItemWithIdentifier:@"dummyViews"];
NSCollectionViewFlowLayout *flowLayout = [[NSCollectionViewFlowLayout alloc] init];
flowLayout.itemSize = NSMakeSize(190,241);
......@@ -248,11 +250,14 @@ static const float f_min_window_height = 307.;
time.value = 0;
float duration = CMTimeGetSeconds([asset duration]);
CGImageRef imgRef = [imageGenerator copyCGImageAtTime:CMTimeMake(10, duration) actualTime:NULL error:nil];
self.dataModel.thumbnail=[[NSImage alloc] initWithCGImage:imgRef size:NSSizeFromCGSize(CGSizeMake(100.0, 100.0))];
NSImage *thumbinail =[[NSImage alloc] initWithCGImage:imgRef size:NSSizeFromCGSize(CGSizeMake(100.0, 100.0))];
if(thumbinail){
[self.thumbinails addObject:thumbinail];
[self.labels addObject:path];
[self.thumbinails addObject:thumbinail];
[self.labels addObject:path];
[self.years addObject:@"2012"];
}
}
}
......@@ -280,9 +285,16 @@ static const float f_min_window_height = 307.;
}
- (NSCollectionViewItem *)collectionView:(NSCollectionView *)collectionView itemForRepresentedObjectAtIndexPath:(NSIndexPath *)indexPath {
VLCMainWindowCollectionViewItem *item = [collectionView makeItemWithIdentifier:@"VLCItemT" forIndexPath:indexPath];
item.VLCItemImageView.image = [self.thumbinails objectAtIndex:indexPath.item];
item.VLCItemLabel.stringValue = [self.labels objectAtIndex:indexPath.item];
VLCMainWindowCollectionViewItem *item = [collectionView makeItemWithIdentifier:@"dummyViews" forIndexPath:indexPath];
VLCMainWindowDataModel *model =[VLCMainWindowDataModel new];
/*
Pass the metadata to the DataModel for assinging values to the views
and return updated view
*/
model.thumbnail = [self.thumbinails objectAtIndex:indexPath.item];
model.videoTitle = [self.labels objectAtIndex:indexPath.item];
model.year=[self.years objectAtIndex:indexPath.item];
[item assignValueForDataModel:model];
return item;
}
......
......@@ -22,16 +22,25 @@
*****************************************************************************/
#import <Cocoa/Cocoa.h>
#import "VLCMainWindowDataModel.h"
@interface VLCMainWindowCollectionViewItem : NSCollectionViewItem < NSCollectionViewDelegate>
//Library View
@property (nonatomic,strong) IBOutlet NSImageView *VLCItemImageView;
@property (strong) IBOutlet NSPopover *VLCPopOver;
@property (unsafe_unretained) IBOutlet NSButton *VLCPopOverTriggerButton;
@property (nonatomic,strong) IBOutlet NSTextField *VLCItemLabel;
@property (strong) IBOutlet NSPopover *VLCPopOver;
@property (strong) IBOutlet NSButton *VLCPopOverTriggerButton;
@property (nonatomic,strong) IBOutlet NSTextField *VLCItemLabel;
@end
@interface libraryView : NSView
//PopOver View
@property (strong) IBOutlet NSImageView *popOverImage;
@property (strong) IBOutlet NSTextField *popOverTitle;
@property (strong) IBOutlet NSTextField *popOverYear;
@property (strong) IBOutlet NSTextField *popOverSize;
//method for linking dataModel with View
-(void)assignValueForDataModel:(VLCMainWindowDataModel *) dataModel;
@end
......@@ -21,7 +21,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#import <Cocoa/Cocoa.h>
#import "VLCMainWindowCollectionViewItem.h"
#import "VLCMainWindowDataModel.h"
@interface VLCMainWindowCollectionViewItem ()
{
......@@ -37,13 +39,14 @@
[self.collectionView setDelegate:self];
}
-(void)setRepresentedObject:(id)representedObject{
[super setRepresentedObject:representedObject];
if (representedObject !=nil)
{
[self.imageView setImage:[[NSBundle mainBundle] imageForResource:[representedObject valueForKey:@"itemImage"]]];
}
-(void)assignValueForDataModel:(VLCMainWindowDataModel *) dataModel
{
NSLog(@"assigning values to views from dataModel");
self.VLCItemLabel.stringValue =dataModel.videoTitle;;
self.VLCItemImageView.image=dataModel.thumbnail;
self.popOverYear.stringValue = dataModel.year;
self.popOverImage=self.VLCItemImageView;
self.popOverTitle=self.VLCItemLabel;
}
- (void)setSelected:(BOOL)flag
......
......@@ -24,6 +24,9 @@
@interface VLCMainWindowDataModel : NSObject
@property (strong) NSString *videoTitle;
@property (strong) NSString *year;
@property (strong) NSString *length;
@property (strong) NSImage *thumbnail;
@end
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