Commit 1eb5cbd6 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: add a basic collection view for future implementation while retaining...

macosx: add a basic collection view for future implementation while retaining the current main window behavior
parent db375997
......@@ -25,13 +25,42 @@
<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">
<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"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES"/>
<color key="primaryBackgroundColor" name="systemGreenColor" catalog="System" colorSpace="catalog"/>
<connections>
<outlet property="itemPrototype" destination="jCi-fI-3Z2" id="hDE-WR-6dZ"/>
</connections>
</collectionView>
</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"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="CoO-yc-KK4">
<rect key="frame" x="234" y="1" width="15" height="143"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
<customView focusRingType="none" translatesAutoresizingMaskIntoConstraints="NO" id="4665" customClass="VLCVoutView">
<rect key="frame" x="0.0" y="0.0" width="716" height="297"/>
</customView>
</subviews>
<constraints>
<constraint firstAttribute="bottom" secondItem="5Ke-Vb-9dU" secondAttribute="bottom" id="90T-Zr-m2C"/>
<constraint firstItem="5Ke-Vb-9dU" firstAttribute="leading" secondItem="3Bj-Gx-5iu" secondAttribute="leading" id="Fc8-GH-CLd"/>
<constraint firstItem="4665" firstAttribute="leading" secondItem="3Bj-Gx-5iu" secondAttribute="leading" id="P14-cO-Y3q"/>
<constraint firstAttribute="bottom" secondItem="4665" secondAttribute="bottom" id="Tzn-Qi-iVK"/>
<constraint firstItem="5Ke-Vb-9dU" firstAttribute="top" secondItem="3Bj-Gx-5iu" secondAttribute="top" id="VhT-Bp-0jB"/>
<constraint firstAttribute="trailing" secondItem="5Ke-Vb-9dU" secondAttribute="trailing" id="lCs-r3-s73"/>
<constraint firstAttribute="trailing" secondItem="4665" secondAttribute="trailing" id="lec-La-MnM"/>
<constraint firstItem="4665" firstAttribute="top" secondItem="3Bj-Gx-5iu" secondAttribute="top" id="nz6-sf-xgK"/>
</constraints>
......@@ -342,6 +371,7 @@
</constraints>
</view>
<connections>
<outlet property="collectionView" destination="9My-dJ-ffm" id="c6h-CY-Y2b"/>
<outlet property="controlsBar" destination="5339" id="5624"/>
<outlet property="videoView" destination="4665" id="5622"/>
<outlet property="videoViewBottomConstraint" destination="ZVn-EJ-9CG" id="8F2-BP-yVS"/>
......@@ -376,6 +406,15 @@
<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>
</objects>
<resources>
<image name="backward-6btns" width="28" height="23"/>
......
/*****************************************************************************
* VLCMainWindow.h: MacOS X interface module
*****************************************************************************
* Copyright (C) 2002-2014 VLC authors and VideoLAN
* Copyright (C) 2002-2018 VLC authors and VideoLAN
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
......@@ -50,6 +50,8 @@ typedef enum {
@property (readonly) BOOL nativeFullscreenMode;
@property (readwrite) BOOL nonembedded;
@property (strong) IBOutlet NSCollectionView *collectionView;
@property (readonly) VLCFSPanelController* fspanel;
- (void)changePlaylistState:(VLCPlaylistStateEvent)event;
......
......@@ -51,16 +51,13 @@
BOOL videoPlaybackEnabled;
BOOL dropzoneActive;
BOOL minimizedView;
BOOL collectionViewRemoved;
BOOL b_video_playback_enabled;
BOOL b_minimized_view;
CGFloat f_lastSplitViewHeight;
CGFloat f_lastLeftSplitViewWidth;
CGFloat lastCollectionViewHeight;
NSRect frameBeforePlayback;
}
@end
static const float f_min_window_height = 307.;
......@@ -188,22 +185,60 @@ 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];
}
- (void)makeCollectionViewVisible
{
[self setContentMinSize: NSMakeSize(604., f_min_window_height)];
NSRect old_frame = [self frame];
CGFloat newHeight = [self minSize].height;
if (old_frame.size.height < newHeight) {
NSRect new_frame = old_frame;
new_frame.origin.y = old_frame.origin.y + old_frame.size.height - newHeight;
new_frame.size.height = newHeight;
[[self animator] setFrame:new_frame display:YES animate:YES];
}
[self.videoView setHidden:YES];
[_collectionView setHidden:NO];
if (self.nativeFullscreenMode && [self fullscreen]) {
[self showControlsBar];
[self.fspanel setNonActive];
}
[self makeFirstResponder:_collectionView];
}
// 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)changePlaylistState:(VLCPlaylistStateEvent)event
{
// Beware, this code is really ugly
msg_Dbg(getIntf(), "toggle playlist from state: minimized view %i. Event %i", b_minimized_view, event);
msg_Dbg(getIntf(), "toggle playlist from state: removed collectionview %i, minimized view %i. Event %i", collectionViewRemoved, minimizedView, event);
if (![self isVisible] && event == psUserMenuEvent) {
[self makeKeyAndOrderFront: nil];
return;
}
BOOL b_activeVideo = [[VLCMain sharedInstance] activeVideoPlayback];
BOOL b_restored = NO;
BOOL activeVideo = [[VLCMain sharedInstance] activeVideoPlayback];
BOOL restored = NO;
// ignore alt if triggered through main menu shortcut
BOOL b_have_alt_key = ([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask) != 0;
......@@ -214,20 +249,74 @@ static const float f_min_window_height = 307.;
if(event == psUserMenuEvent)
event = psUserEvent;
if (!(self.nativeFullscreenMode && self.fullscreen) && ((b_have_alt_key && b_activeVideo)
|| (self.nonembedded && event == psUserEvent)
|| (!b_activeVideo && event == psUserEvent)
|| (b_minimized_view && event == psVideoStartedOrStoppedEvent))) {
if (!(self.nativeFullscreenMode && self.fullscreen) && !collectionViewRemoved && ((b_have_alt_key && activeVideo)
|| (self.nonembedded && event == psUserEvent)
|| (!activeVideo && event == psUserEvent)
|| (minimizedView && event == psVideoStartedOrStoppedEvent))) {
// for starting playback, window is resized through resized events
// for stopping playback, resize through reset to previous frame
b_minimized_view = NO;
[self hideCollectionView: event != psVideoStartedOrStoppedEvent];
minimizedView = NO;
} else {
if (collectionViewRemoved) {
if (!self.nonembedded || (event == psUserEvent && self.nonembedded))
[self showCollectionView: event != psVideoStartedOrStoppedEvent];
if (event != psUserEvent)
minimizedView = YES;
else
minimizedView = NO;
if (activeVideo)
restored = YES;
}
if (!self.nonembedded) {
if (([self.videoView isHidden] && activeVideo) || restored || (activeVideo && event != psUserEvent))
[self makeCollectionViewHidden];
else
[self makeCollectionViewVisible];
} else {
[_collectionView setHidden: NO];
[self.videoView setHidden: YES];
[self showControlsBar];
}
}
msg_Dbg(getIntf(), "toggle playlist to state: minimized view %i", b_minimized_view);
msg_Dbg(getIntf(), "toggle playlist to state: removed collectionview %i, minimized view %i", collectionViewRemoved, minimizedView);
}
- (IBAction)dropzoneButtonAction:(id)sender
- (void)hideCollectionView:(BOOL)resize
{
[[[VLCMain sharedInstance] open] openFileGeneric];
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 -
......@@ -409,7 +498,7 @@ static const float f_min_window_height = 307.;
// only resize back to minimum view of this is still desired final state
CGFloat f_threshold_height = f_min_video_height + [self.controlsBar height];
if(frameBeforePlayback.size.height > f_threshold_height || b_minimized_view) {
if(frameBeforePlayback.size.height > f_threshold_height || minimizedView) {
if ([[VLCMain sharedInstance] isTerminating])
[self setFrame:frameBeforePlayback display:YES];
......
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