/*****************************************************************************
* MainWindow.m: MacOS X interface module
*****************************************************************************
- * Copyright (C) 2002-2012 VLC authors and VideoLAN
+ * Copyright (C) 2002-2013 VLC authors and VideoLAN
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
* Jon Lech Johansen <jon-vl@nanocrew.net>
* Christophe Massiot <massiot@via.ecp.fr>
* Derk-Jan Hartman <hartman at videolan.org>
+ * David Fuhrmann <david dot fuhrmann at googlemail dot com>
*
* 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
#import "SideBarItem.h"
#import <math.h>
#import <vlc_playlist.h>
-#import <vlc_aout_intf.h>
#import <vlc_url.h>
#import <vlc_strings.h>
#import <vlc_services_discovery.h>
-#import <vlc_aout_intf.h>
#import "ControlsBar.h"
+#import "VideoView.h"
+#import "VLCVoutWindowController.h"
-@interface VLCMainWindow ()
+@interface VLCMainWindow (Internal)
- (void)resizePlaylistAfterCollapse;
- (void)makeSplitViewVisible;
- (void)makeSplitViewHidden;
-
+- (void)showPodcastControls;
+- (void)hidePodcastControls;
@end
+
@implementation VLCMainWindow
-static const float f_min_video_height = 70.0;
+
+@synthesize nativeFullscreenMode=b_nativeFullscreenMode;
+@synthesize nonembedded=b_nonembedded;
+@synthesize fsPanel=o_fspanel;
static VLCMainWindow *_o_sharedInstance = nil;
[[NSNotificationCenter defaultCenter] removeObserver: self];
[o_sidebaritems release];
- if (o_extra_video_window) {
- [o_extra_video_window release];
- o_extra_video_window = nil;
- }
-
[super dealloc];
}
- (void)awakeFromNib
{
+ // sets lion fullscreen behaviour
+ [super awakeFromNib];
+
BOOL b_splitviewShouldBeHidden = NO;
/* setup the styled interface */
if (!OSX_SNOW_LEOPARD)
b_nativeFullscreenMode = var_InheritBool(VLCIntf, "macosx-nativefullscreenmode");
#endif
- t_hide_mouse_timer = nil;
[self useOptimizedDrawing: YES];
-
+
[[o_search_fld cell] setPlaceholderString: _NS("Search")];
[[o_search_fld cell] accessibilitySetOverrideValue:_NS("Enter a term to search the playlist. Results will be selected in the table.") forAttribute:NSAccessibilityDescriptionAttribute];
[self setTitle: _NS("VLC media player")];
b_dropzone_active = YES;
- o_temp_view = [[NSView alloc] init];
- [o_temp_view setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable];
[o_dropzone_view setFrame: [o_playlist_table frame]];
[o_left_split_view setFrame: [o_sidebar_view frame]];
-
- if (b_nativeFullscreenMode) {
- [self setCollectionBehavior: NSWindowCollectionBehaviorFullScreenPrimary];
- } else {
- [o_titlebar_view setFullscreenButtonHidden: YES];
- }
if (!OSX_SNOW_LEOPARD) {
/* the default small size of the search field is slightly different on Lion, let's work-around that */
o_color_backdrop = [[VLCColorView alloc] initWithFrame: [o_split_view frame]];
[[self contentView] addSubview: o_color_backdrop positioned: NSWindowBelow relativeTo: o_split_view];
[o_color_backdrop setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable];
-
+
} else {
[o_video_view setFrame: [o_split_view frame]];
[o_playlist_table setBorderType: NSNoBorder];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(someWindowWillClose:) name: NSWindowWillCloseNotification object: nil];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(someWindowWillMiniaturize:) name: NSWindowWillMiniaturizeNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(applicationWillTerminate:) name: NSApplicationWillTerminateNotification object: nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mainSplitViewWillResizeSubviews:) name:NSSplitViewWillResizeSubviewsNotification object:o_split_view];
- [o_split_view setAutosaveName:@"10thanniversary-splitview"];
if (b_splitviewShouldBeHidden) {
[self hideSplitView];
i_lastSplitViewHeight = 300;
nativeVideoSize = screenSize;
[self resizeWindow];
}
+
+ /* update fs button to reflect state for next startup */
+ if (var_InheritBool(pl_Get(VLCIntf), "fullscreen"))
+ [o_controls_bar setFullscreenState:YES];
+
+ /* restore split view */
+ i_lastLeftSplitViewWidth = 200;
+ /* trick NSSplitView implementation, which pretends to know better than us */
+ if (!config_GetInt(VLCIntf, "macosx-show-sidebar"))
+ [self performSelector:@selector(toggleLeftSubSplitView) withObject:nil afterDelay:0.05];
}
#pragma mark -
+#pragma mark appearance management
- (VLCMainWindowControlsBar *)controlsBar;
{
} else {
[o_split_view setHidden: NO];
[o_playlist_table setHidden: NO];
- [o_video_view setHidden: !b_activeVideo];
- if (b_activeVideo && [[o_video_view subviews] count] > 0)
- [[o_video_view window] makeFirstResponder: [[o_video_view subviews] objectAtIndex:0]];
+ [o_video_view setHidden: YES];
}
}
}
- (void)applicationWillTerminate:(NSNotification *)notification
{
+ config_PutInt(VLCIntf, "macosx-show-sidebar", ![o_split_view isSubviewCollapsed:o_left_split_view]);
+
[self saveFrameUsingName: [self frameAutosaveName]];
}
- (void)someWindowWillClose:(NSNotification *)notification
{
id obj = [notification object];
- if (obj == o_detached_video_window || obj == o_extra_video_window || (obj == self && !b_nonembedded)) {
+
+ // hasActiveVideo is defined for VLCVideoWindowCommon and subclasses
+ if ([obj respondsToSelector:@selector(hasActiveVideo)] && [obj hasActiveVideo]) {
if ([[VLCMain sharedInstance] activeVideoPlayback])
[[VLCCoreInteraction sharedInstance] stop];
}
{
if (config_GetInt(VLCIntf, "macosx-pause-minimized")) {
id obj = [notification object];
- if (obj == o_detached_video_window || obj == o_extra_video_window || (obj == self && !b_nonembedded)) {
+
+ if ([obj class] == [VLCVideoWindowCommon class] || [obj class] == [VLCDetachedVideoWindow class] || ([obj class] == [VLCMainWindow class] && !b_nonembedded)) {
if ([[VLCMain sharedInstance] activeVideoPlayback])
[[VLCCoreInteraction sharedInstance] pause];
}
}
}
-- (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize
-{
- id videoWindow = [o_video_view window];
- if (![[VLCMain sharedInstance] activeVideoPlayback] || nativeVideoSize.width == 0. || nativeVideoSize.height == 0. || window != videoWindow)
- return proposedFrameSize;
-
- // needed when entering lion fullscreen mode
- if (b_fullscreen)
- return proposedFrameSize;
-
- if ([[VLCCoreInteraction sharedInstance] aspectRatioIsLocked]) {
- NSRect videoWindowFrame = [videoWindow frame];
- NSRect viewRect = [o_video_view convertRect:[o_video_view bounds] toView: nil];
- NSRect contentRect = [videoWindow contentRectForFrameRect:videoWindowFrame];
- float marginy = viewRect.origin.y + videoWindowFrame.size.height - contentRect.size.height;
- float marginx = contentRect.size.width - viewRect.size.width;
- if (b_dark_interface)// && b_video_deco)
- marginy += [o_titlebar_view frame].size.height;
-
- proposedFrameSize.height = (proposedFrameSize.width - marginx) * nativeVideoSize.height / nativeVideoSize.width + marginy;
- }
-
- return proposedFrameSize;
-}
-
#pragma mark -
#pragma mark Update interface and respond to foreign events
- (void)showDropZone
- (void)updateTimeSlider
{
[o_controls_bar updateTimeSlider];
- [[self controlsBar] updatePosAndTimeInFSPanel:o_fspanel];
- if (o_detached_video_window)
- [[o_detached_video_window controlsBar] updateTimeSlider];
+ [o_fspanel updatePositionAndTime];
+
+ [[[VLCMain sharedInstance] voutController] updateWindowsControlsBarWithSelector:@selector(updateTimeSlider)];
}
- (void)updateName
NSURL * o_url = [NSURL URLWithString: [NSString stringWithUTF8String: uri]];
if ([o_url isFileURL]) {
[self setRepresentedURL: o_url];
- if (o_detached_video_window)
- [o_detached_video_window setRepresentedURL: o_url];
+ [[[VLCMain sharedInstance] voutController] updateWindowsUsingBlock:^(VLCVideoWindowCommon *o_window) {
+ [o_window setRepresentedURL:o_url];
+ }];
} else {
[self setRepresentedURL: nil];
- if (o_detached_video_window)
- [o_detached_video_window setRepresentedURL: nil];
+ [[[VLCMain sharedInstance] voutController] updateWindowsUsingBlock:^(VLCVideoWindowCommon *o_window) {
+ [o_window setRepresentedURL:nil];
+ }];
}
free(uri);
aString = [o_url absoluteString];
}
- [self setTitle: aString];
- if (b_nonembedded && o_detached_video_window && [[VLCMain sharedInstance] activeVideoPlayback])
- [o_detached_video_window setTitle: aString];
+ if ([aString length] > 0) {
+ [self setTitle: aString];
+ [[[VLCMain sharedInstance] voutController] updateWindowsUsingBlock:^(VLCVideoWindowCommon *o_window) {
+ [o_window setTitle:aString];
+ }];
+
+ [o_fspanel setStreamTitle: aString];
+ } else {
+ [self setTitle: _NS("VLC media player")];
+ [self setRepresentedURL: nil];
+ }
- [o_fspanel setStreamTitle: aString];
vlc_object_release(p_input);
} else {
[self setTitle: _NS("VLC media player")];
- (void)updateWindow
{
[o_controls_bar updateControls];
- if (o_detached_video_window)
- [[o_detached_video_window controlsBar] updateControls];
+ [[[VLCMain sharedInstance] voutController] updateWindowsControlsBarWithSelector:@selector(updateControls)];
bool b_seekable = false;
}
[self updateTimeSlider];
- [o_fspanel setSeekable: b_seekable];
+ if ([o_fspanel respondsToSelector:@selector(setSeekable:)])
+ [o_fspanel setSeekable: b_seekable];
PL_LOCK;
if ([[[VLCMain sharedInstance] playlist] currentPlaylistRoot] != p_playlist->p_local_category || p_playlist->p_local_category->i_children > 0)
- (void)setPause
{
[o_controls_bar setPause];
- if (o_detached_video_window)
- [[o_detached_video_window controlsBar] setPause];
[o_fspanel setPause];
+
+ [[[VLCMain sharedInstance] voutController] updateWindowsControlsBarWithSelector:@selector(setPause)];
}
- (void)setPlay
{
[o_controls_bar setPlay];
- if (o_detached_video_window)
- [[o_detached_video_window controlsBar] setPlay];
[o_fspanel setPlay];
+
+ [[[VLCMain sharedInstance] voutController] updateWindowsControlsBarWithSelector:@selector(setPlay)];
+
}
- (void)updateVolumeSlider
#pragma mark -
#pragma mark Video Output handling
-- (id)videoView
-{
- return o_video_view;
-}
-
-- (void)setupVideoView
-{
- BOOL b_video_deco = var_InheritBool(VLCIntf, "video-deco");
- BOOL b_video_wallpaper = var_InheritBool(VLCIntf, "video-wallpaper");
-
- // TODO: make lion fullscreen compatible with video-wallpaper and !embedded-video
- if ((b_video_wallpaper || !b_video_deco) && !b_nativeFullscreenMode) {
- // b_video_wallpaper is priorized over !b_video_deco
-
- msg_Dbg(VLCIntf, "Creating background / blank window");
- NSScreen *screen = [NSScreen screenWithDisplayID:(CGDirectDisplayID)var_InheritInteger(VLCIntf, "macosx-vdev")];
- if (!screen)
- screen = [self screen];
-
- NSRect window_rect;
- if (b_video_wallpaper)
- window_rect = [screen frame];
- else
- window_rect = [self frame];
-
- if (o_extra_video_window)
- [o_extra_video_window release];
-
- NSUInteger mask = NSBorderlessWindowMask;
- if (!OSX_SNOW_LEOPARD && !b_video_deco)
- mask |= NSResizableWindowMask;
-
- BOOL b_no_video_deco_only = !b_video_wallpaper;
- o_extra_video_window = [[VLCVideoWindowCommon alloc] initWithContentRect:window_rect styleMask:mask backing:NSBackingStoreBuffered defer:YES];
- [o_extra_video_window setDelegate:self];
-
- if (b_video_wallpaper)
- [o_extra_video_window setLevel:CGWindowLevelForKey(kCGDesktopWindowLevelKey) + 1];
-
- [o_extra_video_window setBackgroundColor: [NSColor blackColor]];
- [o_extra_video_window setCanBecomeKeyWindow: !b_video_wallpaper];
- [o_extra_video_window setCanBecomeMainWindow: !b_video_wallpaper];
- [o_extra_video_window setAcceptsMouseMovedEvents:!b_video_wallpaper];
- [o_extra_video_window setMovableByWindowBackground: !b_video_wallpaper];
- [o_extra_video_window useOptimizedDrawing: YES];
-
- [o_video_view retain];
- if ([o_video_view superview] != NULL)
- [o_video_view removeFromSuperviewWithoutNeedingDisplay];
- window_rect.origin.x = window_rect.origin.y = 0;
- [o_video_view setFrame: window_rect];
- [[o_extra_video_window contentView] addSubview: o_video_view positioned:NSWindowAbove relativeTo:nil];
- [o_video_view release];
-
- if (b_video_wallpaper)
- [o_extra_video_window orderBack:nil];
- else {
- [o_extra_video_window center];
- [o_extra_video_window setFrameAutosaveName:@"extra-videowindow"];
- [o_extra_video_window setContentMinSize: NSMakeSize(f_min_video_height, f_min_video_height)];
- }
-
- b_nonembedded = YES;
- } else {
- if (var_InheritBool(VLCIntf, "embedded-video") || b_nativeFullscreenMode) {
- if ([o_video_view window] != self) {
- [o_video_view removeFromSuperviewWithoutNeedingDisplay];
- [o_video_view setFrame: [o_split_view frame]];
- [[self contentView] addSubview:o_video_view positioned:NSWindowAbove relativeTo:nil];
- }
- b_nonembedded = NO;
- } else {
- if ([o_video_view superview] != NULL)
- [o_video_view removeFromSuperviewWithoutNeedingDisplay];
-
- if (!o_detached_video_window) {
- NSWindowController *o_controller = [[NSWindowController alloc] initWithWindowNibName:@"DetachedVideoWindow"];
- [o_controller loadWindow];
- o_detached_video_window = (VLCDetachedVideoWindow *)[o_controller window];
- [o_controller release];
-
- // event occurs before window is created, so call again
- [[VLCMain sharedInstance] playbackStatusUpdated];
- }
-
- [o_detached_video_window setDelegate: self];
- if (b_dark_interface) {
- [o_detached_video_window setContentMinSize: NSMakeSize(363., f_min_video_height + [[[o_detached_video_window controlsBar] bottomBarView] frame].size.height + [o_titlebar_view frame].size.height)];
- } else {
- [o_detached_video_window setContentMinSize: NSMakeSize(363., f_min_video_height + [[[o_detached_video_window controlsBar] bottomBarView] frame].size.height)];
- }
-
- NSRect videoFrame;
- videoFrame.size = [[o_detached_video_window contentView] frame].size;
- videoFrame.size.height -= [[[o_detached_video_window controlsBar] bottomBarView] frame].size.height;
- if (b_dark_interface)
- videoFrame.size.height -= [o_titlebar_view frame].size.height;
-
- videoFrame.origin.x = .0;
- videoFrame.origin.y = [[[o_detached_video_window controlsBar] bottomBarView] frame].size.height;
-
- [o_video_view setFrame: videoFrame];
- [[o_detached_video_window contentView] addSubview: o_video_view positioned:NSWindowAbove relativeTo:nil];
- [o_detached_video_window setLevel:NSNormalWindowLevel];
- [o_detached_video_window useOptimizedDrawing: YES];
-
- b_nonembedded = YES;
- }
- }
-
- if (!b_video_wallpaper) {
- [[o_video_view window] makeKeyAndOrderFront: self];
-
- vout_thread_t *p_vout = getVout();
- if (p_vout) {
- if (var_GetBool(p_vout, "video-on-top"))
- [[o_video_view window] setLevel: NSStatusWindowLevel];
- else
- [[o_video_view window] setLevel: NSNormalWindowLevel];
- vlc_object_release(p_vout);
- }
- }
-
- [[o_video_view window] setAlphaValue: config_GetFloat(VLCIntf, "macosx-opaqueness")];
-}
- (void)setVideoplayEnabled
{
BOOL b_videoPlayback = [[VLCMain sharedInstance] activeVideoPlayback];
if (b_videoPlayback) {
- frameBeforePlayback = [self frame];
-
- // look for 'start at fullscreen'
- [[VLCMain sharedInstance] fullscreenChanged];
+ if (!b_fullscreen)
+ frameBeforePlayback = [self frame];
} else {
- if (!b_nonembedded)
+ if (!b_nonembedded && !b_fullscreen && frameBeforePlayback.size.width > 0 && frameBeforePlayback.size.height > 0)
[[self animator] setFrame:frameBeforePlayback display:YES];
- [self makeFirstResponder: nil];
- if (o_detached_video_window)
- [o_detached_video_window orderOut: nil];
- if (o_extra_video_window)
- [o_extra_video_window orderOut: nil];
+ // update fs button to reflect state for next startup
+ if (var_InheritBool(pl_Get(VLCIntf), "fullscreen")) {
+ [o_controls_bar setFullscreenState:YES];
+ }
- if ([self level] != NSNormalWindowLevel)
- [self setLevel: NSNormalWindowLevel];
- if (o_detached_video_window && [o_detached_video_window level] != NSNormalWindowLevel)
- [o_detached_video_window setLevel: NSNormalWindowLevel];
+ [self makeFirstResponder: nil];
+ [[[VLCMain sharedInstance] voutController] updateWindowLevelForHelperWindows: NSNormalWindowLevel];
// restore alpha value to 1 for the case that macosx-opaqueness is set to < 1
[self setAlphaValue:1.0];
if (!b_videoPlayback)
[o_fspanel setNonActive: nil];
}
-
- if (!b_videoPlayback && b_fullscreen) {
- if (!b_nativeFullscreenMode)
- [[VLCCoreInteraction sharedInstance] toggleFullscreen];
- }
}
-- (void)resizeWindow
-{
- if (b_fullscreen || (b_nativeFullscreenMode && [NSApp presentationOptions] & NSApplicationPresentationFullScreen))
- return;
-
- id o_videoWindow = [o_video_view window];
- NSSize windowMinSize = [o_videoWindow minSize];
- NSRect screenFrame = [[o_videoWindow screen] visibleFrame];
-
- NSPoint topleftbase = NSMakePoint(0, [o_videoWindow frame].size.height);
- NSPoint topleftscreen = [o_videoWindow convertBaseToScreen: topleftbase];
-
- unsigned int i_width = nativeVideoSize.width;
- unsigned int i_height = nativeVideoSize.height;
- if (i_width < windowMinSize.width)
- i_width = windowMinSize.width;
- if (i_height < f_min_video_height)
- i_height = f_min_video_height;
-
- /* Calculate the window's new size */
- NSRect new_frame;
- new_frame.size.width = [o_videoWindow frame].size.width - [o_video_view frame].size.width + i_width;
- new_frame.size.height = [o_videoWindow frame].size.height - [o_video_view frame].size.height + i_height;
- new_frame.origin.x = topleftscreen.x;
- new_frame.origin.y = topleftscreen.y - new_frame.size.height;
-
- /* make sure the window doesn't exceed the screen size the window is on */
- if (new_frame.size.width > screenFrame.size.width) {
- new_frame.size.width = screenFrame.size.width;
- new_frame.origin.x = screenFrame.origin.x;
- }
- if (new_frame.size.height > screenFrame.size.height) {
- new_frame.size.height = screenFrame.size.height;
- new_frame.origin.y = screenFrame.origin.y;
- }
- if (new_frame.origin.y < screenFrame.origin.y)
- new_frame.origin.y = screenFrame.origin.y;
-
- CGFloat right_screen_point = screenFrame.origin.x + screenFrame.size.width;
- CGFloat right_window_point = new_frame.origin.x + new_frame.size.width;
- if (right_window_point > right_screen_point)
- new_frame.origin.x -= (right_window_point - right_screen_point);
-
- [[o_videoWindow animator] setFrame:new_frame display:YES];
-}
-
-- (void)setNativeVideoSize:(NSSize)size
-{
- nativeVideoSize = size;
-
- if (var_InheritBool(VLCIntf, "macosx-video-autoresize") && !b_fullscreen && !var_InheritBool(VLCIntf, "video-wallpaper"))
- [self performSelectorOnMainThread:@selector(resizeWindow) withObject:nil waitUntilDone:NO];
-}
-
-// Called automatically if window's acceptsMouseMovedEvents property is true
-- (void)mouseMoved:(NSEvent *)theEvent
+#pragma mark -
+#pragma mark Lion native fullscreen handling
+- (void)windowWillEnterFullScreen:(NSNotification *)notification
{
- if (b_fullscreen)
- [self recreateHideMouseTimer];
+ [super windowWillEnterFullScreen:notification];
- [super mouseMoved: theEvent];
+ // update split view frame after removing title bar
+ [o_split_view setFrame: [o_video_view frame]];
}
-- (void)recreateHideMouseTimer
+- (void)windowWillExitFullScreen:(NSNotification *)notification
{
- if (t_hide_mouse_timer != nil) {
- [t_hide_mouse_timer invalidate];
- [t_hide_mouse_timer release];
- }
-
- t_hide_mouse_timer = [NSTimer scheduledTimerWithTimeInterval:2
- target:self
- selector:@selector(hideMouseCursor:)
- userInfo:nil
- repeats:NO];
- [t_hide_mouse_timer retain];
-}
+ [super windowWillExitFullScreen: notification];
-// NSTimer selectors require this function signature as per Apple's docs
-- (void)hideMouseCursor:(NSTimer *)timer
-{
- [NSCursor setHiddenUntilMouseMoves: YES];
+ // update split view frame after readding title bar
+ [o_split_view setFrame: [o_video_view frame]];
}
-
#pragma mark -
#pragma mark Fullscreen support
-- (void)showFullscreenController
-{
- if (b_fullscreen && [[VLCMain sharedInstance] activeVideoPlayback])
- [o_fspanel fadeIn];
-}
-
-- (BOOL)fullscreen
-{
- return b_fullscreen;
-}
-
-- (void)lockFullscreenAnimation
-{
- [o_animation_lock lock];
-}
-
-- (void)unlockFullscreenAnimation
-{
- [o_animation_lock unlock];
-}
-
-- (void)enterFullscreen
-{
- NSMutableDictionary *dict1, *dict2;
- NSScreen *screen;
- NSRect screen_rect;
- NSRect rect;
- BOOL blackout_other_displays = var_InheritBool(VLCIntf, "macosx-black");
- o_current_video_window = [o_video_view window];
-
- screen = [NSScreen screenWithDisplayID:(CGDirectDisplayID)var_InheritInteger(VLCIntf, "macosx-vdev")];
- [self lockFullscreenAnimation];
-
- if (!screen) {
- msg_Dbg(VLCIntf, "chosen screen isn't present, using current screen for fullscreen mode");
- screen = [o_current_video_window screen];
- }
- if (!screen) {
- msg_Dbg(VLCIntf, "Using deepest screen");
- screen = [NSScreen deepestScreen];
- }
-
- screen_rect = [screen frame];
-
- [o_controls_bar setFullscreenState:YES];
- if (o_detached_video_window)
- [[o_detached_video_window controlsBar] setFullscreenState:YES];
-
- [self recreateHideMouseTimer];
-
- if (blackout_other_displays)
- [screen blackoutOtherScreens];
-
- /* Make sure we don't see the window flashes in float-on-top mode */
- i_originalLevel = [o_current_video_window level];
- [o_current_video_window setLevel:NSNormalWindowLevel];
-
- /* Only create the o_fullscreen_window if we are not in the middle of the zooming animation */
- if (!o_fullscreen_window) {
- /* We can't change the styleMask of an already created NSWindow, so we create another window, and do eye catching stuff */
-
- rect = [[o_video_view superview] convertRect: [o_video_view frame] toView: nil]; /* Convert to Window base coord */
- rect.origin.x += [o_current_video_window frame].origin.x;
- rect.origin.y += [o_current_video_window frame].origin.y;
- o_fullscreen_window = [[VLCWindow alloc] initWithContentRect:rect styleMask: NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES];
- [o_fullscreen_window setBackgroundColor: [NSColor blackColor]];
- [o_fullscreen_window setCanBecomeKeyWindow: YES];
- [o_fullscreen_window setCanBecomeMainWindow: YES];
-
- if (![o_current_video_window isVisible] || [o_current_video_window alphaValue] == 0.0) {
- /* We don't animate if we are not visible, instead we
- * simply fade the display */
- CGDisplayFadeReservationToken token;
-
- if (blackout_other_displays) {
- CGAcquireDisplayFadeReservation(kCGMaxDisplayReservationInterval, &token);
- CGDisplayFade(token, 0.5, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0, 0, 0, YES);
- }
-
- if ([screen mainScreen])
- [NSApp setPresentationOptions:(NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)];
-
- [[o_video_view superview] replaceSubview:o_video_view with:o_temp_view];
- [o_temp_view setFrame:[o_video_view frame]];
- [o_fullscreen_window setContentView:o_video_view];
-
- [o_fullscreen_window makeKeyAndOrderFront:self];
- [o_fullscreen_window orderFront:self animate:YES];
-
- [o_fullscreen_window setFrame:screen_rect display:YES animate:YES];
- [o_fullscreen_window setLevel:NSNormalWindowLevel];
-
- if (blackout_other_displays) {
- CGDisplayFade(token, 0.3, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, NO);
- CGReleaseDisplayFadeReservation(token);
- }
-
- /* Will release the lock */
- [self hasBecomeFullscreen];
-
- return;
- }
-
- /* Make sure we don't see the o_video_view disappearing of the screen during this operation */
- NSDisableScreenUpdates();
- [[o_video_view superview] replaceSubview:o_video_view with:o_temp_view];
- [o_temp_view setFrame:[o_video_view frame]];
- [o_fullscreen_window setContentView:o_video_view];
- [o_fullscreen_window makeKeyAndOrderFront:self];
- NSEnableScreenUpdates();
- }
-
- /* We are in fullscreen (and no animation is running) */
- if (b_fullscreen) {
- /* Make sure we are hidden */
- [o_current_video_window orderOut: self];
-
- [self unlockFullscreenAnimation];
- return;
- }
-
- if (o_fullscreen_anim1) {
- [o_fullscreen_anim1 stopAnimation];
- [o_fullscreen_anim1 release];
- }
- if (o_fullscreen_anim2) {
- [o_fullscreen_anim2 stopAnimation];
- [o_fullscreen_anim2 release];
- }
-
- if ([screen mainScreen])
- [NSApp setPresentationOptions:(NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)];
-
- dict1 = [[NSMutableDictionary alloc] initWithCapacity:2];
- dict2 = [[NSMutableDictionary alloc] initWithCapacity:3];
-
- [dict1 setObject:o_current_video_window forKey:NSViewAnimationTargetKey];
- [dict1 setObject:NSViewAnimationFadeOutEffect forKey:NSViewAnimationEffectKey];
-
- [dict2 setObject:o_fullscreen_window forKey:NSViewAnimationTargetKey];
- [dict2 setObject:[NSValue valueWithRect:[o_fullscreen_window frame]] forKey:NSViewAnimationStartFrameKey];
- [dict2 setObject:[NSValue valueWithRect:screen_rect] forKey:NSViewAnimationEndFrameKey];
-
- /* Strategy with NSAnimation allocation:
- - Keep at most 2 animation at a time
- - leaveFullscreen/enterFullscreen are the only responsible for releasing and alloc-ing
- */
- o_fullscreen_anim1 = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObject:dict1]];
- o_fullscreen_anim2 = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObject:dict2]];
-
- [dict1 release];
- [dict2 release];
-
- [o_fullscreen_anim1 setAnimationBlockingMode: NSAnimationNonblocking];
- [o_fullscreen_anim1 setDuration: 0.3];
- [o_fullscreen_anim1 setFrameRate: 30];
- [o_fullscreen_anim2 setAnimationBlockingMode: NSAnimationNonblocking];
- [o_fullscreen_anim2 setDuration: 0.2];
- [o_fullscreen_anim2 setFrameRate: 30];
- [o_fullscreen_anim2 setDelegate: self];
- [o_fullscreen_anim2 startWhenAnimation: o_fullscreen_anim1 reachesProgress: 1.0];
-
- [o_fullscreen_anim1 startAnimation];
- /* fullscreenAnimation will be unlocked when animation ends */
-}
-
-- (void)hasBecomeFullscreen
-{
- if ([[o_video_view subviews] count] > 0)
- [o_fullscreen_window makeFirstResponder: [[o_video_view subviews] objectAtIndex:0]];
-
- [o_fullscreen_window makeKeyWindow];
- [o_fullscreen_window setAcceptsMouseMovedEvents: YES];
-
- /* tell the fspanel to move itself to front next time it's triggered */
- [o_fspanel setVoutWasUpdated: (int)[[o_fullscreen_window screen] displayID]];
- [o_fspanel setActive: nil];
-
- if ([o_current_video_window isVisible])
- [o_current_video_window orderOut: self];
-
- b_fullscreen = YES;
- [self unlockFullscreenAnimation];
-}
-
-- (void)leaveFullscreen
-{
- [self leaveFullscreenAndFadeOut: NO];
-}
-
-- (void)leaveFullscreenAndFadeOut: (BOOL)fadeout
+- (void)showFullscreenController
{
- NSMutableDictionary *dict1, *dict2;
- NSRect frame;
- BOOL blackout_other_displays = var_InheritBool(VLCIntf, "macosx-black");
-
- if (!o_current_video_window)
- return;
- [self lockFullscreenAnimation];
+ id currentWindow = [NSApp keyWindow];
+ if ([currentWindow respondsToSelector:@selector(hasActiveVideo)] && [currentWindow hasActiveVideo]) {
+ if ([currentWindow respondsToSelector:@selector(fullscreen)] && [currentWindow fullscreen]) {
- [o_controls_bar setFullscreenState:NO];
- if (o_detached_video_window)
- [[o_detached_video_window controlsBar] setFullscreenState:NO];
-
- /* We always try to do so */
- [NSScreen unblackoutScreens];
-
- vout_thread_t *p_vout = getVout();
- if (p_vout) {
- if (var_GetBool(p_vout, "video-on-top"))
- [[o_video_view window] setLevel: NSStatusWindowLevel];
- else
- [[o_video_view window] setLevel: NSNormalWindowLevel];
- vlc_object_release(p_vout);
- }
- [[o_video_view window] makeKeyAndOrderFront: nil];
-
- /* Don't do anything if o_fullscreen_window is already closed */
- if (!o_fullscreen_window) {
- [self unlockFullscreenAnimation];
- return;
- }
-
- if (fadeout) {
- /* We don't animate if we are not visible, instead we
- * simply fade the display */
- CGDisplayFadeReservationToken token;
-
- if (blackout_other_displays) {
- CGAcquireDisplayFadeReservation(kCGMaxDisplayReservationInterval, &token);
- CGDisplayFade(token, 0.3, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0, 0, 0, YES);
- }
-
- [o_fspanel setNonActive: nil];
- [NSApp setPresentationOptions: NSApplicationPresentationDefault];
-
- /* Will release the lock */
- [self hasEndedFullscreen];
-
- /* Our window is hidden, and might be faded. We need to workaround that, so note it
- * here */
- b_window_is_invisible = YES;
-
- if (blackout_other_displays) {
- CGDisplayFade(token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, NO);
- CGReleaseDisplayFadeReservation(token);
+ if ([[VLCMain sharedInstance] activeVideoPlayback])
+ [o_fspanel fadeIn];
}
- return;
}
-
- [o_current_video_window setAlphaValue: 0.0];
- [o_current_video_window orderFront: self];
- [[o_video_view window] orderFront: self];
-
- [o_fspanel setNonActive: nil];
- [NSApp setPresentationOptions:(NSApplicationPresentationDefault)];
-
- if (o_fullscreen_anim1) {
- [o_fullscreen_anim1 stopAnimation];
- [o_fullscreen_anim1 release];
- }
- if (o_fullscreen_anim2) {
- [o_fullscreen_anim2 stopAnimation];
- [o_fullscreen_anim2 release];
- }
-
- frame = [[o_temp_view superview] convertRect: [o_temp_view frame] toView: nil]; /* Convert to Window base coord */
- frame.origin.x += [o_current_video_window frame].origin.x;
- frame.origin.y += [o_current_video_window frame].origin.y;
-
- dict2 = [[NSMutableDictionary alloc] initWithCapacity:2];
- [dict2 setObject:o_current_video_window forKey:NSViewAnimationTargetKey];
- [dict2 setObject:NSViewAnimationFadeInEffect forKey:NSViewAnimationEffectKey];
-
- o_fullscreen_anim2 = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObjects:dict2, nil]];
- [dict2 release];
-
- [o_fullscreen_anim2 setAnimationBlockingMode: NSAnimationNonblocking];
- [o_fullscreen_anim2 setDuration: 0.3];
- [o_fullscreen_anim2 setFrameRate: 30];
-
- [o_fullscreen_anim2 setDelegate: self];
-
- dict1 = [[NSMutableDictionary alloc] initWithCapacity:3];
-
- [dict1 setObject:o_fullscreen_window forKey:NSViewAnimationTargetKey];
- [dict1 setObject:[NSValue valueWithRect:[o_fullscreen_window frame]] forKey:NSViewAnimationStartFrameKey];
- [dict1 setObject:[NSValue valueWithRect:frame] forKey:NSViewAnimationEndFrameKey];
-
- o_fullscreen_anim1 = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObjects:dict1, nil]];
- [dict1 release];
-
- [o_fullscreen_anim1 setAnimationBlockingMode: NSAnimationNonblocking];
- [o_fullscreen_anim1 setDuration: 0.2];
- [o_fullscreen_anim1 setFrameRate: 30];
- [o_fullscreen_anim2 startWhenAnimation: o_fullscreen_anim1 reachesProgress: 1.0];
-
- /* Make sure o_fullscreen_window is the frontmost window */
- [o_fullscreen_window orderFront: self];
-
- [o_fullscreen_anim1 startAnimation];
- /* fullscreenAnimation will be unlocked when animation ends */
-}
-
-- (void)hasEndedFullscreen
-{
- b_fullscreen = NO;
-
- /* This function is private and should be only triggered at the end of the fullscreen change animation */
- /* Make sure we don't see the o_video_view disappearing of the screen during this operation */
- NSDisableScreenUpdates();
- [o_video_view retain];
- [o_video_view removeFromSuperviewWithoutNeedingDisplay];
- [[o_temp_view superview] replaceSubview:o_temp_view with:o_video_view];
- [o_video_view release];
- [o_video_view setFrame:[o_temp_view frame]];
- if ([[o_video_view subviews] count] > 0)
- [[o_video_view window] makeFirstResponder: [[o_video_view subviews] objectAtIndex:0]];
- if (!b_nonembedded)
- [super makeKeyAndOrderFront:self]; /* our version contains a workaround */
- else
- [[o_video_view window] makeKeyAndOrderFront: self];
- [o_fullscreen_window orderOut: self];
- NSEnableScreenUpdates();
-
- [o_fullscreen_window release];
- o_fullscreen_window = nil;
- [[o_video_view window] setLevel:i_originalLevel];
- [[o_video_view window] setAlphaValue: config_GetFloat(VLCIntf, "macosx-opaqueness")];
-
- // if we quit fullscreen because there is no video anymore, make sure non-embedded window is not visible
- if (![[VLCMain sharedInstance] activeVideoPlayback] && b_nonembedded)
- [o_current_video_window orderOut: self];
-
- o_current_video_window = nil;
- [self unlockFullscreenAnimation];
-}
-
-- (void)animationDidEnd:(NSAnimation*)animation
-{
- NSArray *viewAnimations;
- if (o_makekey_anim == animation) {
- [o_makekey_anim release];
- return;
- }
- if ([animation currentValue] < 1.0)
- return;
-
- /* Fullscreen ended or started (we are a delegate only for leaveFullscreen's/enterFullscren's anim2) */
- viewAnimations = [o_fullscreen_anim2 viewAnimations];
- if ([viewAnimations count] >=1 &&
- [[[viewAnimations objectAtIndex: 0] objectForKey: NSViewAnimationEffectKey] isEqualToString:NSViewAnimationFadeInEffect]) {
- /* Fullscreen ended */
- [self hasEndedFullscreen];
- } else
- /* Fullscreen started */
- [self hasBecomeFullscreen];
+
+
}
- (void)makeKeyAndOrderFront: (id)sender
/* fullscreenAnimation will be unlocked when animation ends */
}
-#pragma mark -
-#pragma mark Lion native fullscreen handling
-- (void)windowWillEnterFullScreen:(NSNotification *)notification
-{
- // workaround, see #6668
- [NSApp setPresentationOptions:(NSApplicationPresentationFullScreen | NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)];
-
- var_SetBool(pl_Get(VLCIntf), "fullscreen", true);
-
- vout_thread_t *p_vout = getVout();
- if (p_vout) {
- var_SetBool(p_vout, "fullscreen", true);
- vlc_object_release(p_vout);
- }
-
- [o_video_view setFrame: [[self contentView] frame]];
- b_fullscreen = YES;
-
- [self recreateHideMouseTimer];
- i_originalLevel = [self level];
- [self setLevel:NSNormalWindowLevel];
-
- if (b_dark_interface) {
- [o_titlebar_view removeFromSuperviewWithoutNeedingDisplay];
-
- NSRect winrect;
- CGFloat f_titleBarHeight = [o_titlebar_view frame].size.height;
- winrect = [self frame];
-
- winrect.size.height = winrect.size.height - f_titleBarHeight;
- [self setFrame: winrect display:NO animate:NO];
- winrect = [o_split_view frame];
- winrect.size.height = winrect.size.height + f_titleBarHeight;
- [o_split_view setFrame: winrect];
- }
-
- if ([[VLCMain sharedInstance] activeVideoPlayback])
- [[o_controls_bar bottomBarView] setHidden: YES];
-
- [self setMovableByWindowBackground: NO];
-}
-
-- (void)windowDidEnterFullScreen:(NSNotification *)notification
-{
- // Indeed, we somehow can have an "inactive" fullscreen (but a visible window!).
- // But this creates some problems when leaving fs over remote intfs, so activate app here.
- [NSApp activateIgnoringOtherApps:YES];
-
- [o_fspanel setVoutWasUpdated: (int)[[self screen] displayID]];
- [o_fspanel setActive: nil];
-}
-
-- (void)windowWillExitFullScreen:(NSNotification *)notification
-{
-
- var_SetBool(pl_Get(VLCIntf), "fullscreen", false);
-
- vout_thread_t *p_vout = getVout();
- if (p_vout) {
- var_SetBool(p_vout, "fullscreen", false);
- vlc_object_release(p_vout);
- }
-
- [o_video_view setFrame: [o_split_view frame]];
- [NSCursor setHiddenUntilMouseMoves: NO];
- [o_fspanel setNonActive: nil];
- [self setLevel:i_originalLevel];
- b_fullscreen = NO;
-
- if (b_dark_interface) {
- NSRect winrect;
- CGFloat f_titleBarHeight = [o_titlebar_view frame].size.height;
- winrect = [self frame];
-
- [o_titlebar_view setFrame: NSMakeRect(0, winrect.size.height - f_titleBarHeight,
- winrect.size.width, f_titleBarHeight)];
- [[self contentView] addSubview: o_titlebar_view];
-
- winrect.size.height = winrect.size.height + f_titleBarHeight;
- [self setFrame: winrect display:NO animate:NO];
- winrect = [o_split_view frame];
- winrect.size.height = winrect.size.height - f_titleBarHeight;
- [o_split_view setFrame: winrect];
- [o_video_view setFrame: winrect];
- }
-
- if ([[VLCMain sharedInstance] activeVideoPlayback])
- [[o_controls_bar bottomBarView] setHidden: NO];
-
- [self setMovableByWindowBackground: YES];
-}
-
#pragma mark -
#pragma mark split view delegate
- (CGFloat)splitView:(NSSplitView *)splitView constrainMaxCoordinate:(CGFloat)proposedMax ofSubviewAt:(NSInteger)dividerIndex
return YES;
}
+- (void)mainSplitViewWillResizeSubviews:(id)object
+{
+ i_lastLeftSplitViewWidth = [o_left_split_view frame].size.width;
+ config_PutInt(VLCIntf, "macosx-show-sidebar", ![o_split_view isSubviewCollapsed:o_left_split_view]);
+ [[[VLCMain sharedInstance] mainMenu] updateSidebarMenuItem];
+}
+
+- (void)toggleLeftSubSplitView
+{
+ [o_split_view adjustSubviews];
+ if ([o_split_view isSubviewCollapsed:o_left_split_view])
+ [o_split_view setPosition:i_lastLeftSplitViewWidth ofDividerAtIndex:0];
+ else
+ [o_split_view setPosition:[o_split_view minPossiblePositionOfDividerAtIndex:0] ofDividerAtIndex:0];
+}
+
#pragma mark -
#pragma mark Side Bar Data handling
/* taken under BSD-new from the PXSourceList sample project, adapted for VLC */
- (void)awakeFromNib
{
+ // sets lion fullscreen behaviour
+ [super awakeFromNib];
[self setAcceptsMouseMovedEvents: YES];
if (b_dark_interface) {
[self setBackgroundColor: [NSColor clearColor]];
+
[self setOpaque: NO];
[self display];
[self setHasShadow:NO];
[o_titlebar_view setFrame: NSMakeRect(0, winrect.size.height - f_titleBarHeight, winrect.size.width, f_titleBarHeight)];
[[self contentView] addSubview: o_titlebar_view positioned: NSWindowAbove relativeTo: nil];
- // native fs not supported with detached view yet
- [o_titlebar_view setFullscreenButtonHidden: YES];
+ } else {
+ [self setBackgroundColor: [NSColor blackColor]];
+ }
+
+ NSRect videoViewRect = [[self contentView] bounds];
+ if (b_dark_interface)
+ videoViewRect.size.height -= [o_titlebar_view frame].size.height;
+ CGFloat f_bottomBarHeight = [[[self controlsBar] bottomBarView] frame].size.height;
+ videoViewRect.size.height -= f_bottomBarHeight;
+ videoViewRect.origin.y = f_bottomBarHeight;
+ [o_video_view setFrame: videoViewRect];
+ if (b_dark_interface) {
+ o_color_backdrop = [[VLCColorView alloc] initWithFrame: [o_video_view frame]];
+ [[self contentView] addSubview: o_color_backdrop positioned: NSWindowBelow relativeTo: o_video_view];
+ [o_color_backdrop setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable];
+
+ [self setContentMinSize: NSMakeSize(363., f_min_video_height + [[[self controlsBar] bottomBarView] frame].size.height + [o_titlebar_view frame].size.height)];
+ } else {
+ [self setContentMinSize: NSMakeSize(363., f_min_video_height + [[[self controlsBar] bottomBarView] frame].size.height)];
}
}
+- (void)dealloc
+{
+ if (b_dark_interface)
+ [o_color_backdrop release];
+
+ [super dealloc];
+}
+
@end