Commit 9f7609f2 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: added window title to the detached video output window when using the black ui mode

code needs factorization with the main window
(cherry picked from commit 9b3cf5b99725417958a2fb30cb0f64eac04b1524)
parent be825b77
...@@ -70,6 +70,7 @@ ...@@ -70,6 +70,7 @@
IBOutlet VLCFSPanel *o_fspanel; IBOutlet VLCFSPanel *o_fspanel;
IBOutlet id o_titlebar_view; IBOutlet id o_titlebar_view;
IBOutlet id o_resize_view; IBOutlet id o_resize_view;
IBOutlet id o_detached_resize_view;
IBOutlet id o_detached_play_btn; IBOutlet id o_detached_play_btn;
IBOutlet id o_detached_fwd_btn; IBOutlet id o_detached_fwd_btn;
...@@ -196,8 +197,10 @@ ...@@ -196,8 +197,10 @@
@end @end
@interface VLCDetachedVideoWindow : NSWindow @interface VLCDetachedVideoWindow : NSWindow
{ {
BOOL b_dark_interface;
NSRect previousSavedFrame;
} }
- (BOOL)isFullscreen; - (BOOL)isFullscreen;
......
...@@ -321,7 +321,10 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -321,7 +321,10 @@ static VLCMainWindow *_o_sharedInstance = nil;
[o_fullscreen_btn removeFromSuperviewWithoutNeedingDisplay]; [o_fullscreen_btn removeFromSuperviewWithoutNeedingDisplay];
} }
else else
{
[o_titlebar_view setFullscreenButtonHidden: YES]; [o_titlebar_view setFullscreenButtonHidden: YES];
[o_detached_titlebar_view setFullscreenButtonHidden: YES];
}
if (OSX_LION) if (OSX_LION)
{ {
...@@ -471,6 +474,11 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -471,6 +474,11 @@ static VLCMainWindow *_o_sharedInstance = nil;
[o_split_view setFrame: winrect]; [o_split_view setFrame: winrect];
[o_video_view setFrame: winrect]; [o_video_view setFrame: winrect];
/* detached video window */
winrect = [o_detached_video_window frame];
[o_detached_titlebar_view setFrame: NSMakeRect( 0, winrect.size.height - f_titleBarHeight, winrect.size.width, f_titleBarHeight )];
[[o_detached_video_window contentView] addSubview: o_detached_titlebar_view positioned: NSWindowAbove relativeTo: nil];
o_color_backdrop = [[VLCColorView alloc] initWithFrame: [o_split_view frame]]; o_color_backdrop = [[VLCColorView alloc] initWithFrame: [o_split_view frame]];
[[self contentView] addSubview: o_color_backdrop positioned: NSWindowBelow relativeTo: o_split_view]; [[self contentView] addSubview: o_color_backdrop positioned: NSWindowBelow relativeTo: o_split_view];
[o_color_backdrop setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable]; [o_color_backdrop setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable];
...@@ -503,10 +511,16 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -503,10 +511,16 @@ static VLCMainWindow *_o_sharedInstance = nil;
[o_detached_time_sld_fancygradient_view setFrame: frame]; [o_detached_time_sld_fancygradient_view setFrame: frame];
if (OSX_LION) if (OSX_LION)
{
[o_resize_view setImage: NULL]; [o_resize_view setImage: NULL];
[o_detached_resize_view setImage: NULL];
}
if ([self styleMask] & NSResizableWindowMask) if ([self styleMask] & NSResizableWindowMask)
{
[o_resize_view removeFromSuperviewWithoutNeedingDisplay]; [o_resize_view removeFromSuperviewWithoutNeedingDisplay];
[o_detached_resize_view removeFromSuperviewWithoutNeedingDisplay];
}
if (OSX_LEOPARD) if (OSX_LEOPARD)
[o_time_sld_fancygradient_view removeFromSuperviewWithoutNeedingDisplay]; [o_time_sld_fancygradient_view removeFromSuperviewWithoutNeedingDisplay];
...@@ -830,7 +844,10 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -830,7 +844,10 @@ static VLCMainWindow *_o_sharedInstance = nil;
- (void)setTitle:(NSString *)title - (void)setTitle:(NSString *)title
{ {
if (b_dark_interface) if (b_dark_interface)
{
[o_titlebar_view setWindowTitle: title]; [o_titlebar_view setWindowTitle: title];
[o_detached_titlebar_view setWindowTitle: title];
}
if (b_nonembedded && [[VLCMain sharedInstance] activeVideoPlayback]) if (b_nonembedded && [[VLCMain sharedInstance] activeVideoPlayback])
[o_detached_video_window setTitle: title]; [o_detached_video_window setTitle: title];
[super setTitle: title]; [super setTitle: title];
...@@ -2232,8 +2249,8 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -2232,8 +2249,8 @@ static VLCMainWindow *_o_sharedInstance = nil;
- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)styleMask - (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)styleMask
backing:(NSBackingStoreType)backingType defer:(BOOL)flag backing:(NSBackingStoreType)backingType defer:(BOOL)flag
{ {
BOOL b_dark_interface = config_GetInt( VLCIntf, "macosx-interfacestyle" ); b_dark_interface = config_GetInt( VLCIntf, "macosx-interfacestyle" );
if (b_dark_interface) if (b_dark_interface)
{ {
#ifdef MAC_OS_X_VERSION_10_7 #ifdef MAC_OS_X_VERSION_10_7
...@@ -2245,17 +2262,17 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -2245,17 +2262,17 @@ static VLCMainWindow *_o_sharedInstance = nil;
styleMask = NSBorderlessWindowMask; styleMask = NSBorderlessWindowMask;
#endif #endif
} }
self = [super initWithContentRect:contentRect styleMask:styleMask self = [super initWithContentRect:contentRect styleMask:styleMask
backing:backingType defer:flag]; backing:backingType defer:flag];
/* we want to be moveable regardless of our style */ /* we want to be moveable regardless of our style */
[self setMovableByWindowBackground: YES]; [self setMovableByWindowBackground: YES];
/* we don't want this window to be restored on relaunch */ /* we don't want this window to be restored on relaunch */
if (OSX_LION) if (OSX_LION)
[self setRestorable:NO]; [self setRestorable:NO];
return self; return self;
} }
...@@ -2264,4 +2281,154 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -2264,4 +2281,154 @@ static VLCMainWindow *_o_sharedInstance = nil;
return [[VLCMainWindow sharedInstance] isFullscreen]; return [[VLCMainWindow sharedInstance] isFullscreen];
} }
- (void)performClose:(id)sender
{
[[VLCMainWindow sharedInstance] performClose: sender];
}
- (void)performMiniaturize:(id)sender
{
if (b_dark_interface)
{
[self miniaturize: sender];
if (config_GetInt( VLCIntf, "macosx-pause-minimized" ))
{
if ([[VLCMain sharedInstance] activeVideoPlayback])
[[VLCCoreInteraction sharedInstance] pause];
}
}
else
[super performMiniaturize: sender];
}
- (void)performZoom:(id)sender
{
if (b_dark_interface)
[self customZoom: sender];
else
[super performZoom: sender];
}
- (void)zoom:(id)sender
{
if (b_dark_interface)
[self customZoom: sender];
else
[super zoom: sender];
}
- (BOOL)canBecomeKeyWindow
{
return YES;
}
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
{
SEL s_menuAction = [menuItem action];
if ((s_menuAction == @selector(performClose:)) || (s_menuAction == @selector(performMiniaturize:)) || (s_menuAction == @selector(performZoom:)))
return YES;
return [super validateMenuItem:menuItem];
}
/**
* Given a proposed frame rectangle, return a modified version
* which will fit inside the screen.
*
* This method is based upon NSWindow.m, part of the GNUstep GUI Library, licensed under LGPLv2+.
* Authors: Scott Christley <scottc@net-community.com>, Venkat Ajjanagadde <venkat@ocbi.com>,
* Felipe A. Rodriguez <far@ix.netcom.com>, Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Copyright (C) 1996 Free Software Foundation, Inc.
*/
- (NSRect) customConstrainFrameRect: (NSRect)frameRect toScreen: (NSScreen*)screen
{
NSRect screenRect = [screen visibleFrame];
float difference;
/* Move top edge of the window inside the screen */
difference = NSMaxY (frameRect) - NSMaxY (screenRect);
if (difference > 0)
{
frameRect.origin.y -= difference;
}
/* If the window is resizable, resize it (if needed) so that the
bottom edge is on the screen or can be on the screen when the user moves
the window */
difference = NSMaxY (screenRect) - NSMaxY (frameRect);
if (_styleMask & NSResizableWindowMask)
{
float difference2;
difference2 = screenRect.origin.y - frameRect.origin.y;
difference2 -= difference;
// Take in account the space between the top of window and the top of the
// screen which can be used to move the bottom of the window on the screen
if (difference2 > 0)
{
frameRect.size.height -= difference2;
frameRect.origin.y += difference2;
}
/* Ensure that resizing doesn't makewindow smaller than minimum */
difference2 = [self minSize].height - frameRect.size.height;
if (difference2 > 0)
{
frameRect.size.height += difference2;
frameRect.origin.y -= difference2;
}
}
return frameRect;
}
#define DIST 3
/**
Zooms the receiver. This method calls the delegate method
windowShouldZoom:toFrame: to determine if the window should
be allowed to zoom to full screen.
*
* This method is based upon NSWindow.m, part of the GNUstep GUI Library, licensed under LGPLv2+.
* Authors: Scott Christley <scottc@net-community.com>, Venkat Ajjanagadde <venkat@ocbi.com>,
* Felipe A. Rodriguez <far@ix.netcom.com>, Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Copyright (C) 1996 Free Software Foundation, Inc.
*/
- (void) customZoom: (id)sender
{
NSRect maxRect = [[self screen] visibleFrame];
NSRect currentFrame = [self frame];
if ([[self delegate] respondsToSelector: @selector(windowWillUseStandardFrame:defaultFrame:)])
{
maxRect = [[self delegate] windowWillUseStandardFrame: self defaultFrame: maxRect];
}
maxRect = [self customConstrainFrameRect: maxRect toScreen: [self screen]];
// Compare the new frame with the current one
if ((abs(NSMaxX(maxRect) - NSMaxX(currentFrame)) < DIST)
&& (abs(NSMaxY(maxRect) - NSMaxY(currentFrame)) < DIST)
&& (abs(NSMinX(maxRect) - NSMinX(currentFrame)) < DIST)
&& (abs(NSMinY(maxRect) - NSMinY(currentFrame)) < DIST))
{
// Already in zoomed mode, reset user frame, if stored
if ([self frameAutosaveName] != nil)
{
[self setFrame: previousSavedFrame display: YES animate: YES];
[self saveFrameUsingName: [self frameAutosaveName]];
}
return;
}
if ([self frameAutosaveName] != nil)
{
[self saveFrameUsingName: [self frameAutosaveName]];
previousSavedFrame = [self frame];
}
[self setFrame: maxRect display: YES animate: YES];
}
@end @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