vlc | branch: master | Felix Paul Kühne <[email protected]> | Wed Jan 30 17:58:30 2019 +0100| [e49882a7828c8034474b06701d4d6ffc778eeea7] | committer: Felix Paul Kühne
macosx/library window: implement library view and fill with sample data > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e49882a7828c8034474b06701d4d6ffc778eeea7 --- .../package/macosx/VLC.xcodeproj/project.pbxproj | 20 ++++++++ modules/gui/macosx/Makefile.am | 4 ++ .../librarywindow/[email protected] | Bin 0 -> 631 bytes .../librarywindow/[email protected] | Bin 0 -> 659 bytes .../gui/macosx/UI/VLCLibraryCollectionViewItem.xib | 52 +++++++++++++++++++++ modules/gui/macosx/UI/VLCLibraryWindow.xib | 5 +- modules/gui/macosx/VLCLibraryCollectionViewItem.h | 34 ++++++++++++++ modules/gui/macosx/VLCLibraryCollectionViewItem.m | 27 +++++++++++ modules/gui/macosx/VLCLibraryWindow.h | 4 ++ modules/gui/macosx/VLCLibraryWindow.m | 33 +++++++++++++ 10 files changed, 177 insertions(+), 2 deletions(-) diff --git a/extras/package/macosx/VLC.xcodeproj/project.pbxproj b/extras/package/macosx/VLC.xcodeproj/project.pbxproj index 96c931f7c9..bac1891aab 100644 --- a/extras/package/macosx/VLC.xcodeproj/project.pbxproj +++ b/extras/package/macosx/VLC.xcodeproj/project.pbxproj @@ -119,6 +119,7 @@ 6BF093F91EE0182B0049D8B0 /* VLCTimeField.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BF093F81EE0182B0049D8B0 /* VLCTimeField.m */; }; 6BF5C5041EFE66EF008A9C12 /* VLCHUDTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BF5C5031EFE66EF008A9C12 /* VLCHUDTableView.m */; }; 7D0F63FF2201F63400FDB91F /* VLCPlaylistTableCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D0F63FE2201F63400FDB91F /* VLCPlaylistTableCellView.m */; }; + 7D0F64062202047900FDB91F /* VLCLibraryCollectionViewItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D0F64042202047900FDB91F /* VLCLibraryCollectionViewItem.m */; }; 7D2E0EDB20CD204D0033A221 /* VLCWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D2E0ED920CD204D0033A221 /* VLCWindow.m */; }; 7D2E0EDE20CD206F0033A221 /* VLCVideoWindowCommon.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D2E0EDD20CD206F0033A221 /* VLCVideoWindowCommon.m */; }; 7D66D4362200BC340040D04A /* VLCClickerManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D66D4352200BC340040D04A /* VLCClickerManager.m */; }; @@ -436,6 +437,11 @@ 7D0F63FD2201F63400FDB91F /* VLCPlaylistTableCellView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCPlaylistTableCellView.h; sourceTree = "<group>"; }; 7D0F63FE2201F63400FDB91F /* VLCPlaylistTableCellView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCPlaylistTableCellView.m; sourceTree = "<group>"; }; 7D0F64002201F66D00FDB91F /* VLCPlaylistTableCellView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = VLCPlaylistTableCellView.xib; sourceTree = "<group>"; }; + 7D0F64032202047900FDB91F /* VLCLibraryCollectionViewItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCLibraryCollectionViewItem.h; sourceTree = "<group>"; }; + 7D0F64042202047900FDB91F /* VLCLibraryCollectionViewItem.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCLibraryCollectionViewItem.m; sourceTree = "<group>"; }; + 7D0F64052202047900FDB91F /* VLCLibraryCollectionViewItem.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = VLCLibraryCollectionViewItem.xib; sourceTree = "<group>"; }; + 7D0F64082202058700FDB91F /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "[email protected]"; path = "../librarywindow/[email protected]"; sourceTree = "<group>"; }; + 7D0F64092202058700FDB91F /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "[email protected]"; path = "../librarywindow/[email protected]"; sourceTree = "<group>"; }; 7D2E0ED920CD204D0033A221 /* VLCWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCWindow.m; sourceTree = "<group>"; }; 7D2E0EDA20CD204D0033A221 /* VLCWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCWindow.h; sourceTree = "<group>"; }; 7D2E0EDC20CD206F0033A221 /* VLCVideoWindowCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCVideoWindowCommon.h; sourceTree = "<group>"; }; @@ -975,6 +981,15 @@ name = "Streaming and Remote Playback"; sourceTree = "<group>"; }; + 7D0F64072202057C00FDB91F /* Library Window */ = { + isa = PBXGroup; + children = ( + 7D0F64082202058700FDB91F /* [email protected] */, + 7D0F64092202058700FDB91F /* [email protected] */, + ); + path = "Library Window"; + sourceTree = "<group>"; + }; 7D2E0ED820CD201F0033A221 /* Windows */ = { isa = PBXGroup; children = ( @@ -1295,6 +1310,8 @@ 7D713D312201AE350042BEB7 /* VLCLibraryWindow.m */, 7D0F63FD2201F63400FDB91F /* VLCPlaylistTableCellView.h */, 7D0F63FE2201F63400FDB91F /* VLCPlaylistTableCellView.m */, + 7D0F64032202047900FDB91F /* VLCLibraryCollectionViewItem.h */, + 7D0F64042202047900FDB91F /* VLCLibraryCollectionViewItem.m */, ); name = "Library Window"; sourceTree = "<group>"; @@ -1408,6 +1425,7 @@ CC0430EE13B2461A00D7D52E /* UI Graphics */ = { isa = PBXGroup; children = ( + 7D0F64072202057C00FDB91F /* Library Window */, 6B82255A1E4D2BE400833BE1 /* Main Window */, 6B8229CB1E4D2D2C00833BE1 /* Sidebar Icons */, 6B8229FD1E4D2DB400833BE1 /* noart.png */, @@ -1516,6 +1534,7 @@ 6B82240A1E4D2A9000833BE1 /* MainWindow.xib */, 7D713D332201BB130042BEB7 /* VLCLibraryWindow.xib */, 7D0F64002201F66D00FDB91F /* VLCPlaylistTableCellView.xib */, + 7D0F64052202047900FDB91F /* VLCLibraryCollectionViewItem.xib */, 6B82241A1E4D2A9000833BE1 /* VLCStatusBarIconMainMenu.xib */, 6B8224181E4D2A9000833BE1 /* VLCFullScreenPanel.xib */, 6B8223FE1E4D2A8F00833BE1 /* About.xib */, @@ -1695,6 +1714,7 @@ 6B0292E61F43256300A50082 /* VLCBottomBarView.m in Sources */, 1C3113C51E508C6900D4DD76 /* misc.m in Sources */, 1C3113C71E508C6900D4DD76 /* VLCOpenWindowController.m in Sources */, + 7D0F64062202047900FDB91F /* VLCLibraryCollectionViewItem.m in Sources */, 7D713D322201AE350042BEB7 /* VLCLibraryWindow.m in Sources */, 1C3113C91E508C6900D4DD76 /* VLCOutput.m in Sources */, 1C1C62011F8260A90052DD4F /* VLCWrappableTextField.m in Sources */, diff --git a/modules/gui/macosx/Makefile.am b/modules/gui/macosx/Makefile.am index 2f533aa041..bd69ff7105 100644 --- a/modules/gui/macosx/Makefile.am +++ b/modules/gui/macosx/Makefile.am @@ -92,6 +92,7 @@ libmacosx_plugin_la_SOURCES = \ gui/macosx/VLCMainWindow.h gui/macosx/VLCMainWindow.m \ gui/macosx/VLCLibraryWindow.h gui/macosx/VLCLibraryWindow.m \ gui/macosx/VLCPlaylistTableCellView.h gui/macosx/VLCPlaylistTableCellView.m \ + gui/macosx/VLCLibraryCollectionViewItem.h gui/macosx/VLCLibraryCollectionViewItem.m \ gui/macosx/VLCDetachedVideoWindow.h gui/macosx/VLCDetachedVideoWindow.m \ gui/macosx/VLCRendererDiscovery.h gui/macosx/VLCRendererDiscovery.m \ gui/macosx/VLCRendererItem.h gui/macosx/VLCRendererItem.m \ @@ -152,6 +153,7 @@ libmacosx_plugin_la_XIB_SOURCES = \ gui/macosx/UI/MainWindow.xib \ gui/macosx/UI/VLCLibraryWindow.xib \ gui/macosx/UI/VLCPlaylistTableCellView.xib \ + gui/macosx/UI/VLCLibraryCollectionViewItem.xib \ gui/macosx/UI/MediaInfo.xib \ gui/macosx/UI/Open.xib \ gui/macosx/UI/PlaylistAccessoryView.xib \ @@ -199,6 +201,8 @@ libmacosx_plugin_la_RES = \ gui/macosx/Resources/File-Icons/wav.icns \ gui/macosx/Resources/File-Icons/wma.icns \ gui/macosx/Resources/File-Icons/wmv.icns \ + gui/macosx/Resources/librarywindow/[email protected] \ + gui/macosx/Resources/librarywindow/[email protected] \ gui/macosx/Resources/mainwindow/backward-3btns-pressed.png \ gui/macosx/Resources/mainwindow/[email protected] \ gui/macosx/Resources/mainwindow/backward-3btns.png \ diff --git a/modules/gui/macosx/Resources/librarywindow/[email protected] b/modules/gui/macosx/Resources/librarywindow/[email protected] new file mode 100644 index 0000000000..ae65fd2ae5 Binary files /dev/null and b/modules/gui/macosx/Resources/librarywindow/[email protected] differ diff --git a/modules/gui/macosx/Resources/librarywindow/[email protected] b/modules/gui/macosx/Resources/librarywindow/[email protected] new file mode 100644 index 0000000000..6c88fd40f3 Binary files /dev/null and b/modules/gui/macosx/Resources/librarywindow/[email protected] differ diff --git a/modules/gui/macosx/UI/VLCLibraryCollectionViewItem.xib b/modules/gui/macosx/UI/VLCLibraryCollectionViewItem.xib new file mode 100644 index 0000000000..d87148cb57 --- /dev/null +++ b/modules/gui/macosx/UI/VLCLibraryCollectionViewItem.xib @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="UTF-8"?> +<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct"> + <dependencies> + <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14460.31"/> + <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> + </dependencies> + <objects> + <customObject id="-2" userLabel="File's Owner" customClass="VLCLibraryCollectionViewItem"> + <connections> + <outlet property="mediaImageView" destination="vP5-5j-rVa" id="YJb-5w-9sW"/> + <outlet property="mediaTitleTextField" destination="OBS-Eh-1mT" id="h1n-PU-IAx"/> + <outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/> + </connections> + </customObject> + <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> + <customObject id="-3" userLabel="Application" customClass="NSObject"/> + <customView id="Hz6-mo-xeY"> + <rect key="frame" x="0.0" y="0.0" width="480" height="272"/> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> + <subviews> + <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="vP5-5j-rVa"> + <rect key="frame" x="0.0" y="0.0" width="480" height="272"/> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> + <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" id="hY9-UD-hSk"/> + </imageView> + <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="A5y-ue-y7t"> + <rect key="frame" x="0.0" y="0.0" width="480" height="272"/> + <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="axesIndependently" image="libraryCellGradient" id="kbU-NG-wPM"/> + </imageView> + <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="OBS-Eh-1mT"> + <rect key="frame" x="18" y="20" width="52" height="24"/> + <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="7Hy-o3-LvX"> + <font key="font" size="20" name=".AppleSystemUIFont"/> + <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/> + <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> + </textFieldCell> + </textField> + </subviews> + <constraints> + <constraint firstItem="A5y-ue-y7t" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="NpD-8l-D5s"/> + <constraint firstAttribute="bottom" secondItem="A5y-ue-y7t" secondAttribute="bottom" id="cnQ-bx-Fmn"/> + <constraint firstAttribute="bottom" secondItem="OBS-Eh-1mT" secondAttribute="bottom" constant="20" id="dy4-gP-Sdi"/> + <constraint firstAttribute="trailing" secondItem="A5y-ue-y7t" secondAttribute="trailing" id="rKQ-WW-oC6"/> + <constraint firstItem="A5y-ue-y7t" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="x7v-58-kKz"/> + <constraint firstItem="OBS-Eh-1mT" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" constant="20" id="yvp-xr-geN"/> + </constraints> + </customView> + </objects> + <resources> + <image name="libraryCellGradient" width="2" height="190"/> + </resources> +</document> diff --git a/modules/gui/macosx/UI/VLCLibraryWindow.xib b/modules/gui/macosx/UI/VLCLibraryWindow.xib index 845ccb9487..7fa27acd4d 100644 --- a/modules/gui/macosx/UI/VLCLibraryWindow.xib +++ b/modules/gui/macosx/UI/VLCLibraryWindow.xib @@ -53,13 +53,14 @@ <rect key="frame" x="0.0" y="0.0" width="242" height="235"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> - <collectionView id="B8x-e8-7zp"> + <collectionView selectable="YES" id="B8x-e8-7zp"> <rect key="frame" x="0.0" y="0.0" width="242" height="235"/> <autoresizingMask key="autoresizingMask" widthSizable="YES"/> <collectionViewFlowLayout key="collectionViewLayout" minimumInteritemSpacing="10" minimumLineSpacing="10" id="Rag-cM-k1g"> - <size key="itemSize" width="50" height="50"/> + <size key="itemSize" width="240" height="120"/> </collectionViewFlowLayout> <color key="primaryBackgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/> + <color key="secondaryBackgroundColor" name="controlAlternatingRowColor" catalog="System" colorSpace="catalog"/> </collectionView> </subviews> </clipView> diff --git a/modules/gui/macosx/VLCLibraryCollectionViewItem.h b/modules/gui/macosx/VLCLibraryCollectionViewItem.h new file mode 100644 index 0000000000..e4b46e6b7d --- /dev/null +++ b/modules/gui/macosx/VLCLibraryCollectionViewItem.h @@ -0,0 +1,34 @@ +/***************************************************************************** + * VLCLibraryCollectionViewItem.h: MacOS X interface module + ***************************************************************************** + * Copyright (C) 2019 VLC authors and VideoLAN + * + * Authors: Felix Paul Kühne <fkuehne # videolan -dot- org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#import <Cocoa/Cocoa.h> + +NS_ASSUME_NONNULL_BEGIN + +@interface VLCLibraryCollectionViewItem : NSCollectionViewItem + +@property (readwrite, assign) IBOutlet NSTextField *mediaTitleTextField; +@property (readwrite, assign) IBOutlet NSImageView *mediaImageView; + +@end + +NS_ASSUME_NONNULL_END diff --git a/modules/gui/macosx/VLCLibraryCollectionViewItem.m b/modules/gui/macosx/VLCLibraryCollectionViewItem.m new file mode 100644 index 0000000000..f3ff065d72 --- /dev/null +++ b/modules/gui/macosx/VLCLibraryCollectionViewItem.m @@ -0,0 +1,27 @@ +/***************************************************************************** + * VLCLibraryCollectionViewItem.m: MacOS X interface module + ***************************************************************************** + * Copyright (C) 2019 VLC authors and VideoLAN + * + * Authors: Felix Paul Kühne <fkuehne # videolan -dot- org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#import "VLCLibraryCollectionViewItem.h" + +@implementation VLCLibraryCollectionViewItem + +@end diff --git a/modules/gui/macosx/VLCLibraryWindow.h b/modules/gui/macosx/VLCLibraryWindow.h index f28a3a3d7c..ff46748952 100644 --- a/modules/gui/macosx/VLCLibraryWindow.h +++ b/modules/gui/macosx/VLCLibraryWindow.h @@ -42,4 +42,8 @@ NS_ASSUME_NONNULL_BEGIN @end +@interface VLCLibraryDataSource : NSObject <NSCollectionViewDataSource, NSCollectionViewDelegate> + +@end + NS_ASSUME_NONNULL_END diff --git a/modules/gui/macosx/VLCLibraryWindow.m b/modules/gui/macosx/VLCLibraryWindow.m index 8b6b8293f8..d1b762ede9 100644 --- a/modules/gui/macosx/VLCLibraryWindow.m +++ b/modules/gui/macosx/VLCLibraryWindow.m @@ -23,16 +23,19 @@ #import "VLCLibraryWindow.h" #import "NSString+Helpers.h" #import "VLCPlaylistTableCellView.h" +#import "VLCLibraryCollectionViewItem.h" static const float f_min_window_width = 604.; static const float f_min_window_height = 307.; static const float f_playlist_row_height = 40.; static NSString *VLCPlaylistCellIdentifier = @"VLCPlaylistCellIdentifier"; +static NSString *VLCLibraryCellIdentifier = @"VLCLibraryCellIdentifier"; @interface VLCLibraryWindow () { VLCPlaylistDataSource *_playlistDataSource; + VLCLibraryDataSource *_libraryDataSource; } @end @@ -54,6 +57,12 @@ static NSString *VLCPlaylistCellIdentifier = @"VLCPlaylistCellIdentifier"; _playlistTableView.delegate = _playlistDataSource; _playlistTableView.rowHeight = f_playlist_row_height; [_playlistTableView reloadData]; + + _libraryDataSource = [[VLCLibraryDataSource alloc] init]; + _libraryCollectionView.dataSource = _libraryDataSource; + _libraryCollectionView.delegate = _libraryDataSource; + [_libraryCollectionView registerClass:[VLCLibraryCollectionViewItem class] forItemWithIdentifier:VLCLibraryCellIdentifier]; + [_libraryCollectionView reloadData]; } - (void)segmentedControlAction @@ -104,6 +113,30 @@ static NSString *VLCPlaylistCellIdentifier = @"VLCPlaylistCellIdentifier"; @end +@implementation VLCLibraryDataSource + +- (NSInteger)collectionView:(NSCollectionView *)collectionView numberOfItemsInSection:(NSInteger)section +{ + return 2; +} + +- (NSCollectionViewItem *)collectionView:(NSCollectionView *)collectionView itemForRepresentedObjectAtIndexPath:(NSIndexPath *)indexPath +{ + VLCLibraryCollectionViewItem *viewItem = [collectionView makeItemWithIdentifier:VLCLibraryCellIdentifier forIndexPath:indexPath]; + + viewItem.mediaTitleTextField.stringValue = @"Custom Cell Label Text"; + viewItem.mediaImageView.image = [NSImage imageNamed: @"noart.png"]; + + return viewItem; +} + +- (void)collectionView:(NSCollectionView *)collectionView didSelectItemsAtIndexPaths:(NSSet<NSIndexPath *> *)indexPaths +{ + NSLog(@"library selection changed: %@", indexPaths); +} + +@end + @implementation VLCLibraryWindowController - (instancetype)initWithLibraryWindow _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
