Commit 87c56df7 authored by David Fuhrmann's avatar David Fuhrmann

macosx: add new common window class in order to deduplicate code

moved custom zoom/minimize/close implementation, added new file for window related stuff
fixed minimize / close support for !video-deco window
parent 8c59214e
......@@ -973,6 +973,8 @@
DC769AB8085DF0DB001A838D /* wizard.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; name = wizard.h; path = ../../../modules/gui/macosx/wizard.h; sourceTree = SOURCE_ROOT; };
DCE7BD0608A5724D007B10AE /* bookmarks.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = bookmarks.m; path = ../../../modules/gui/macosx/bookmarks.m; sourceTree = SOURCE_ROOT; };
DCE7BD0708A5724D007B10AE /* bookmarks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = bookmarks.h; path = ../../../modules/gui/macosx/bookmarks.h; sourceTree = SOURCE_ROOT; };
E06CF7F416020F6200C698B7 /* Windows.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Windows.h; path = ../../../modules/gui/macosx/Windows.h; sourceTree = SOURCE_ROOT; };
E06CF7F516020F6200C698B7 /* Windows.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Windows.m; path = ../../../modules/gui/macosx/Windows.m; sourceTree = SOURCE_ROOT; };
F69B0CA702E24F6401A80112 /* English */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = text.plist.strings; name = English; path = Resources/English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
/* End PBXFileReference section */
......@@ -1170,6 +1172,8 @@
CC017A0E14A4C8B600C09A4F /* custom UI code */ = {
isa = PBXGroup;
children = (
E06CF7F416020F6200C698B7 /* Windows.h */,
E06CF7F516020F6200C698B7 /* Windows.m */,
8ED6C27F03E2EB1C0059A3A7 /* misc.h */,
8ED6C28003E2EB1C0059A3A7 /* misc.m */,
CC017A0B14A4C8AF00C09A4F /* MainWindowTitle.h */,
......
......@@ -29,11 +29,12 @@
#import "PXSourceList.h"
#import "PXSourceListDataSource.h"
#import <vlc_input.h>
#import "Windows.h"
#import "misc.h"
#import "fspanel.h"
#import "MainWindowTitle.h"
@interface VLCMainWindow : NSWindow <PXSourceListDataSource, PXSourceListDelegate, NSWindowDelegate, NSAnimationDelegate, NSSplitViewDelegate> {
@interface VLCMainWindow : VLCVideoWindowCommon <PXSourceListDataSource, PXSourceListDelegate, NSWindowDelegate, NSAnimationDelegate, NSSplitViewDelegate> {
IBOutlet id o_play_btn;
IBOutlet id o_bwd_btn;
IBOutlet id o_fwd_btn;
......@@ -103,7 +104,6 @@
IBOutlet id o_podcast_unsubscribe_ok_btn;
IBOutlet id o_podcast_unsubscribe_cancel_btn;
BOOL b_dark_interface;
BOOL b_nativeFullscreenMode;
BOOL b_video_playback_enabled;
BOOL b_dropzone_active;
......@@ -156,7 +156,6 @@
VLCColorView * o_color_backdrop;
NSInteger i_originalLevel;
NSRect previousSavedFrame;
VLCWindow *o_extra_video_window;
id o_current_video_window;
......@@ -189,7 +188,6 @@
- (IBAction)removePodcastWindowAction:(id)sender;
- (void)setTitle:(NSString *)title;
- (void)customZoom:(id)sender;
- (void)windowResizedOrMoved:(NSNotification *)notification;
- (void)showDropZone;
......@@ -238,12 +236,6 @@
- (id)detachedTitlebarView;
@end
@interface VLCDetachedVideoWindow : NSWindow
{
BOOL b_dark_interface;
NSRect previousSavedFrame;
}
- (void)customZoom:(id)sender;
@interface VLCDetachedVideoWindow : VLCVideoWindowCommon
@end
\ No newline at end of file
This diff is collapsed.
......@@ -80,4 +80,6 @@ SOURCES_macosx = \
ConvertAndSave.m \
SharedDialogs.h \
SharedDialogs.m \
Windows.h \
Windows.m \
$(NULL)
/*****************************************************************************
* Windows.h: MacOS X interface module
*****************************************************************************
* Copyright (C) 2012 VLC authors and VideoLAN
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- 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
* 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>
#import "CompatibilityFixes.h"
/*****************************************************************************
* VLCWindow
*
* Missing extension to NSWindow
*****************************************************************************/
@interface VLCWindow : NSWindow <NSWindowDelegate>
{
BOOL b_canBecomeKeyWindow;
BOOL b_isset_canBecomeKeyWindow;
BOOL b_canBecomeMainWindow;
BOOL b_isset_canBecomeMainWindow;
NSViewAnimation *animation;
}
@property (readwrite) BOOL canBecomeKeyWindow;
@property (readwrite) BOOL canBecomeMainWindow;
/* animate mode is only supported in >=10.4 */
- (void)orderFront: (id)sender animate: (BOOL)animate;
/* animate mode is only supported in >=10.4 */
- (void)orderOut: (id)sender animate: (BOOL)animate;
/* animate mode is only supported in >=10.4 */
- (void)orderOut: (id)sender animate: (BOOL)animate callback:(NSInvocation *)callback;
/* animate mode is only supported in >=10.4 */
- (void)closeAndAnimate: (BOOL)animate;
@end
/*****************************************************************************
* VLCVideoWindowCommon
*
* Common code for main window, detached window and extra video window
*****************************************************************************/
@interface VLCVideoWindowCommon : VLCWindow
{
NSRect previousSavedFrame;
BOOL b_dark_interface;
}
@end
\ No newline at end of file
This diff is collapsed.
......@@ -67,37 +67,6 @@
+ (void)unblackoutScreens;
@end
/*****************************************************************************
* VLCWindow
*
* Missing extension to NSWindow
*****************************************************************************/
@interface VLCWindow : NSWindow <NSWindowDelegate>
{
BOOL b_canBecomeKeyWindow;
BOOL b_isset_canBecomeKeyWindow;
BOOL b_canBecomeMainWindow;
BOOL b_isset_canBecomeMainWindow;
NSViewAnimation *animation;
}
@property (readwrite) BOOL canBecomeKeyWindow;
@property (readwrite) BOOL canBecomeMainWindow;
/* animate mode is only supported in >=10.4 */
- (void)orderFront: (id)sender animate: (BOOL)animate;
/* animate mode is only supported in >=10.4 */
- (void)orderOut: (id)sender animate: (BOOL)animate;
/* animate mode is only supported in >=10.4 */
- (void)orderOut: (id)sender animate: (BOOL)animate callback:(NSInvocation *)callback;
/* animate mode is only supported in >=10.4 */
- (void)closeAndAnimate: (BOOL)animate;
@end
/*****************************************************************************
* VLBrushedMetalImageView
......
......@@ -249,198 +249,6 @@ static NSMutableArray *blackoutWindows = NULL;
@end
/*****************************************************************************
* VLCWindow
*
* Missing extension to NSWindow
*****************************************************************************/
@implementation VLCWindow
- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)styleMask
backing:(NSBackingStoreType)backingType defer:(BOOL)flag
{
self = [super initWithContentRect:contentRect styleMask:styleMask backing:backingType defer:flag];
if ( self ) {
b_isset_canBecomeKeyWindow = NO;
/* we don't want this window to be restored on relaunch */
if (!OSX_SNOW_LEOPARD)
[self setRestorable:NO];
}
return self;
}
- (void)setCanBecomeKeyWindow: (BOOL)canBecomeKey
{
b_isset_canBecomeKeyWindow = YES;
b_canBecomeKeyWindow = canBecomeKey;
}
- (BOOL)canBecomeKeyWindow
{
if (b_isset_canBecomeKeyWindow)
return b_canBecomeKeyWindow;
return [super canBecomeKeyWindow];
}
- (void)setCanBecomeMainWindow: (BOOL)canBecomeMain
{
b_isset_canBecomeMainWindow = YES;
b_canBecomeMainWindow = canBecomeMain;
}
- (BOOL)canBecomeMainWindow
{
if (b_isset_canBecomeMainWindow)
return b_canBecomeMainWindow;
return [super canBecomeMainWindow];
}
- (void)closeAndAnimate: (BOOL)animate
{
NSInvocation *invoc;
if (!animate) {
[super close];
return;
}
invoc = [NSInvocation invocationWithMethodSignature:[super methodSignatureForSelector:@selector(close)]];
[invoc setTarget: self];
if (![self isVisible] || [self alphaValue] == 0.0) {
[super close];
return;
}
[self orderOut: self animate: YES callback: invoc];
}
- (void)orderOut: (id)sender animate: (BOOL)animate
{
NSInvocation *invoc = [NSInvocation invocationWithMethodSignature:[super methodSignatureForSelector:@selector(orderOut:)]];
[invoc setTarget: self];
[invoc setArgument: sender atIndex: 0];
[self orderOut: sender animate: animate callback: invoc];
}
- (void)orderOut: (id)sender animate: (BOOL)animate callback:(NSInvocation *)callback
{
NSViewAnimation *anim;
NSViewAnimation *current_anim;
NSMutableDictionary *dict;
if (!animate) {
[self orderOut: sender];
return;
}
dict = [[NSMutableDictionary alloc] initWithCapacity:2];
[dict setObject:self forKey:NSViewAnimationTargetKey];
[dict setObject:NSViewAnimationFadeOutEffect forKey:NSViewAnimationEffectKey];
anim = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObjects:dict, nil]];
[dict release];
[anim setAnimationBlockingMode:NSAnimationNonblocking];
[anim setDuration:0.9];
[anim setFrameRate:30];
[anim setUserInfo: callback];
@synchronized(self) {
current_anim = self->animation;
if ([[[current_anim viewAnimations] objectAtIndex:0] objectForKey: NSViewAnimationEffectKey] == NSViewAnimationFadeOutEffect && [current_anim isAnimating]) {
[anim release];
} else {
if (current_anim) {
[current_anim stopAnimation];
[anim setCurrentProgress:1.0-[current_anim currentProgress]];
[current_anim release];
}
else
[anim setCurrentProgress:1.0 - [self alphaValue]];
self->animation = anim;
[self setDelegate: self];
[anim startAnimation];
}
}
}
- (void)orderFront: (id)sender animate: (BOOL)animate
{
NSViewAnimation *anim;
NSViewAnimation *current_anim;
NSMutableDictionary *dict;
if (!animate) {
[super orderFront: sender];
[self setAlphaValue: 1.0];
return;
}
if (![self isVisible]) {
[self setAlphaValue: 0.0];
[super orderFront: sender];
}
else if ([self alphaValue] == 1.0) {
[super orderFront: self];
return;
}
dict = [[NSMutableDictionary alloc] initWithCapacity:2];
[dict setObject:self forKey:NSViewAnimationTargetKey];
[dict setObject:NSViewAnimationFadeInEffect forKey:NSViewAnimationEffectKey];
anim = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObjects:dict, nil]];
[dict release];
[anim setAnimationBlockingMode:NSAnimationNonblocking];
[anim setDuration:0.5];
[anim setFrameRate:30];
@synchronized(self) {
current_anim = self->animation;
if ([[[current_anim viewAnimations] objectAtIndex:0] objectForKey: NSViewAnimationEffectKey] == NSViewAnimationFadeInEffect && [current_anim isAnimating]) {
[anim release];
} else {
if (current_anim) {
[current_anim stopAnimation];
[anim setCurrentProgress:1.0 - [current_anim currentProgress]];
[current_anim release];
}
else
[anim setCurrentProgress:[self alphaValue]];
self->animation = anim;
[self setDelegate: self];
[self orderFront: sender];
[anim startAnimation];
}
}
}
- (void)animationDidEnd:(NSAnimation*)anim
{
if ([self alphaValue] <= 0.0) {
NSInvocation * invoc;
[super orderOut: nil];
[self setAlphaValue: 1.0];
if ((invoc = [anim userInfo]))
[invoc invoke];
}
}
- (IBAction)fullscreen:(id)sender
{
[[VLCCoreInteraction sharedInstance] toggleFullscreen];
}
@end
/*****************************************************************************
* VLBrushedMetalImageView
*****************************************************************************/
......
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