Commit d6343816 authored by Vibhoothi's avatar Vibhoothi

libraryView:Final cleanup and Ready-to use

This is the final cleanup of the codebase
- Added pragma-marks to the classes for more readability
- Reordered code in mainWindow in favour to the pragma-marks
parent 29278198
/*****************************************************************************
* VLCMainWindowDataModel.h: MacOS X interface module
* VLCLibraryItem.h: MacOS X interface module
*****************************************************************************
* Copyright (C) 2018 VLC authors and VideoLAN
* $Id$
* $Id $
*
* Authors: Vibhoothi <vibhoothiiaanand -at- googlemail dot com>
*
......
/*****************************************************************************
* VLCMainWindowDataModel.m: MacOS X interface module
* VLCLibraryItem.m: MacOS X interface module
*****************************************************************************
* Copyright (C) 2018 VLC authors and VideoLAN
* $Id $
......
/*****************************************************************************
* VLCMainWindowCollectionView.h: MacOS X interface module
* VLCLibraryView.h: MacOS X interface module
*****************************************************************************
* Copyright (C) 2018 VLC authors and VideoLAN
* $Id $
......
/*****************************************************************************
* VLCMainWindowCollectionView.m: MacOS X interface module
* VLCLibraryView.m: MacOS X interface module
*****************************************************************************
* Copyright (C) 2002-2018 VLC authors and VideoLAN
* $Id $
......@@ -35,10 +35,22 @@
- (void)viewDidLoad {
[super viewDidLoad];
// Do view setup here.
[self.collectionView setDelegate:self];
}
#pragma mark - dataModel and View handling
/*
Assigning values from the dataModel to the view fields like
- Thumbnail
- Video Title
- Fields in the popOver where diffrent metadatas are shown
- Small thumbnail
- Title of the video
- Size of the video
- Year of the video
*/
-(void)assignValueForDataModel:(VLCLibraryItem *) dataModel
{
self.VLCItemLabel.stringValue = dataModel.videoTitle;;
......@@ -46,8 +58,11 @@
self.popOverYear.stringValue = dataModel.year;
self.popOverImage.image = self.VLCItemImageView.image;
self.popOverTitle.stringValue = self.VLCItemLabel.stringValue;
self.popOverSize.stringValue= dataModel.length;
}
#pragma mark - Selection Highlighting in the libraryView
- (void)setSelected:(BOOL)flag
{
[super setSelected:flag];
......@@ -71,6 +86,8 @@
}
}
#pragma mark - popOver Initialisation of the indexed files
- (BOOL)buttonIsPressed
{
return self.VLCPopOverTriggerButton.intValue == 1;
......
......@@ -187,8 +187,8 @@ static const float f_min_window_height = 307.;
[coreInteraction keyEvent:o_event];
}
#pragma mark - data view vs video output handling
#pragma mark - LibraryView
#pragma mark data view vs video output handling
- (void)makeCollectionViewVisible
{
[self setContentMinSize: NSMakeSize(604., f_min_window_height)];
......@@ -212,7 +212,6 @@ static const float f_min_window_height = 307.;
[self makeFirstResponder:_collectionView];
// self.dataModel = [[VLCMainWindowDataModel alloc] init ] ;
self.dummyData=[NSMutableArray arrayWithCapacity:0 ];
self.collectionView.wantsLayer = YES;
[self prepareData];
......@@ -230,6 +229,60 @@ static const float f_min_window_height = 307.;
[self.collectionView reloadData];
}
// Hides the collection view and makes the vout view in foreground
- (void)makeCollectionViewHidden
{
[self setContentMinSize: NSMakeSize(604., f_min_video_height)];
[_collectionView setHidden:YES];
[self.videoView setHidden:NO];
if (self.nativeFullscreenMode && [self fullscreen]) {
[self hideControlsBar];
[self.fspanel setActive];
}
if ([[self.videoView subviews] count] > 0)
[self makeFirstResponder: [[self.videoView subviews] firstObject]];
}
- (void)hideCollectionView:(BOOL)resize
{
if (resize) {
NSRect winrect = [self frame];
lastCollectionViewHeight = [_collectionView frame].size.height;
winrect.size.height = winrect.size.height - lastCollectionViewHeight;
winrect.origin.y = winrect.origin.y + lastCollectionViewHeight;
[self setFrame:winrect display:YES animate:YES];
}
[self setContentMinSize: NSMakeSize(604., [self.controlsBar height])];
[self setContentMaxSize: NSMakeSize(FLT_MAX, [self.controlsBar height])];
collectionViewRemoved = YES;
}
- (void)showCollectionView:(BOOL)resize
{
[self updateWindow];
[self setContentMinSize:NSMakeSize(604., f_min_window_height)];
[self setContentMaxSize: NSMakeSize(FLT_MAX, FLT_MAX)];
if (resize) {
NSRect winrect;
winrect = [self frame];
winrect.size.height = winrect.size.height + lastCollectionViewHeight;
winrect.origin.y = winrect.origin.y - lastCollectionViewHeight;
[self setFrame:winrect display:YES animate:YES];
}
collectionViewRemoved = NO;
}
#pragma mark Generating dummyData for the libraryView
/*
Assigning values from local source to the dataModel
*/
- (void)prepareData {
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *rootPath = @"/Users/vibhoothiiaanand/Desktop/dummyVideos";
......@@ -252,7 +305,7 @@ static const float f_min_window_height = 307.;
self.dataModel.thumbnail = thumbinail;
self.dataModel.videoTitle= path;
self.dataModel.year = @"2012";
self.dataModel.length = @"303";
self.dataModel.length = @"40.4 MB";
[self.dummyData addObject:self.dataModel] ;
}
......@@ -260,15 +313,12 @@ static const float f_min_window_height = 307.;
NSLog(@"DataModel dummy %@",self.dummyData);
}
#pragma mark - NSCollectionViewDelegate
#pragma mark libraryView generation using modern APIs
- (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);
......@@ -286,8 +336,8 @@ static const float f_min_window_height = 307.;
- (NSCollectionViewItem *)collectionView:(NSCollectionView *)collectionView itemForRepresentedObjectAtIndexPath:(NSIndexPath *)indexPath
{
/*
Pass the metadata to the DataModel for assinging values to the views
and return updated view
Pass the metadata to the DataModel for assinging values to the views
and return updated view
*/
VLCLibraryView *item = [collectionView makeItemWithIdentifier:@"dummyViews" forIndexPath:indexPath];
VLCLibraryItem *libraryItem = [self.dummyData objectAtIndex:indexPath.item];
......@@ -299,22 +349,8 @@ static const float f_min_window_height = 307.;
return 1;
}
// Hides the collection view and makes the vout view in foreground
- (void)makeCollectionViewHidden
{
[self setContentMinSize: NSMakeSize(604., f_min_video_height)];
[_collectionView setHidden:YES];
[self.videoView setHidden:NO];
if (self.nativeFullscreenMode && [self fullscreen]) {
[self hideControlsBar];
[self.fspanel setActive];
}
if ([[self.videoView subviews] count] > 0)
[self makeFirstResponder: [[self.videoView subviews] firstObject]];
}
#pragma mark -
#pragma mark Playlist State toggle
- (void)changePlaylistState:(VLCPlaylistStateEvent)event
{
// Beware, this code is really ugly
......@@ -374,39 +410,6 @@ static const float f_min_window_height = 307.;
msg_Dbg(getIntf(), "toggle playlist to state: removed collectionview %i, minimized view %i", collectionViewRemoved, minimizedView);
}
- (void)hideCollectionView:(BOOL)resize
{
if (resize) {
NSRect winrect = [self frame];
lastCollectionViewHeight = [_collectionView frame].size.height;
winrect.size.height = winrect.size.height - lastCollectionViewHeight;
winrect.origin.y = winrect.origin.y + lastCollectionViewHeight;
[self setFrame:winrect display:YES animate:YES];
}
[self setContentMinSize: NSMakeSize(604., [self.controlsBar height])];
[self setContentMaxSize: NSMakeSize(FLT_MAX, [self.controlsBar height])];
collectionViewRemoved = YES;
}
- (void)showCollectionView:(BOOL)resize
{
[self updateWindow];
[self setContentMinSize:NSMakeSize(604., f_min_window_height)];
[self setContentMaxSize: NSMakeSize(FLT_MAX, FLT_MAX)];
if (resize) {
NSRect winrect;
winrect = [self frame];
winrect.size.height = winrect.size.height + lastCollectionViewHeight;
winrect.origin.y = winrect.origin.y - lastCollectionViewHeight;
[self setFrame:winrect display:YES animate:YES];
}
collectionViewRemoved = NO;
}
#pragma mark -
#pragma mark overwritten default window functionality
......
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