Commit 74fd152d authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

Zoom fullscreen effect on Mac OS X 10.4.

parent bfae05be
......@@ -67,6 +67,7 @@
"o_btn_play" = id;
"o_slider" = id;
"o_time" = id;
"o_view" = id;
};
SUPERCLASS = NSWindow;
},
......
......@@ -25,10 +25,10 @@
<array/>
<key>IBOpenObjects</key>
<array>
<integer>29</integer>
<integer>21</integer>
<integer>2769</integer>
<integer>2730</integer>
<integer>29</integer>
<integer>2769</integer>
</array>
<key>IBSystem Version</key>
<string>8L2127</string>
......
......@@ -99,7 +99,7 @@
o_vout_view = [o_embedded_vout_list getViewForWindow: o_window];
}
/* We have a detached vout */
else if( [[o_window className] isEqualToString: @"VLCWindow"] )
else if( [[o_window className] isEqualToString: @"VLCVoutWindow"] )
{
msg_Dbg( VLCIntf, "detached vout controls.m call getVoutView" );
o_vout_view = [o_window getVoutView];
......@@ -894,7 +894,7 @@
while( (o_window = [o_enumerator nextObject]))
{
if( [[o_window className] isEqualToString: @"VLCWindow"] ||
if( [[o_window className] isEqualToString: @"VLCVoutWindow"] ||
[[[VLCMain sharedInstance] getEmbeddedList]
windowContainsEmbedded: o_window])
{
......
......@@ -25,6 +25,7 @@
* VLCEmbeddedWindow interface
*****************************************************************************/
#import "misc.h"
@interface VLCEmbeddedWindow : NSWindow
{
......@@ -34,6 +35,7 @@
IBOutlet id o_btn_play;
IBOutlet id o_slider;
IBOutlet id o_time;
IBOutlet id o_view;
NSImage * o_img_play;
NSImage * o_img_play_pressed;
......@@ -41,12 +43,22 @@
NSImage * o_img_pause_pressed;
NSRect o_saved_frame;
VLCWindow * o_fullscreen_window;
NSViewAnimation * o_fullscreen_anim1;
NSViewAnimation * o_fullscreen_anim2;
NSView * o_temp_view;
}
- (void)setTime:(NSString *)o_arg_ime position:(float)f_position;
- (void)playStatusUpdated:(int)i_status;
- (void)setSeekable:(BOOL)b_seekable;
- (void)setFullscreen:(BOOL)b_fullscreen;
- (void)enterFullscreen;
- (void)leaveFullscreen;
/* private */
- (void)hasEndedFullscreen;
- (void)hasBecomeFullscreen;
@end
This diff is collapsed.
......@@ -381,7 +381,7 @@ static VLCExtended *_o_sharedInstance = nil;
while ((o_window = [o_enumerator nextObject]))
{
if( [[o_window className] isEqualToString: @"VLCWindow"] ||
if( [[o_window className] isEqualToString: @"VLCVoutWindow"] ||
[[[VLCMain sharedInstance] getEmbeddedList]
windowContainsEmbedded: o_window])
{
......
......@@ -159,7 +159,7 @@
while( ( o_window = [o_enum nextObject] ) )
{
if( [[o_window className] isEqualToString: @"VLCWindow"] )
if( [[o_window className] isEqualToString: @"VLCVoutWindow"] )
{
vlc_object_release( (vlc_object_t *)p_vout );
break;
......
......@@ -472,8 +472,6 @@ static VLCMain *_o_sharedMainInstance = nil;
var_AddCallback( p_playlist, "fullscreen", FullscreenChanged, self);
var_AddCallback( p_playlist, "intf-show", ShowController, self);
[o_embedded_window setFullscreen: var_GetBool( p_playlist,
"fullscreen" )];
vlc_object_release( p_playlist );
var_Create( p_intf, "interaction", VLC_VAR_ADDRESS );
......
......@@ -21,6 +21,22 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* VLCWindow
*
* Missing extension to NSWindow
*****************************************************************************/
@interface VLCWindow : NSWindow
{
BOOL b_canBecomeKeyWindow;
BOOL b_isset_canBecomeKeyWindow;
}
- (void)setCanBecomeKeyWindow: (BOOL)canBecomeKey;
@end
/*****************************************************************************
* VLCControllerWindow
*****************************************************************************/
......
......@@ -28,6 +28,36 @@
#include "playlist.h"
#include "controls.h"
/*****************************************************************************
* VLCWindow
*
* Missing extension to NSWindow
*****************************************************************************/
@implementation VLCWindow
- (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)styleMask
backing:(NSBackingStoreType)backingType defer:(BOOL)flag
{
self = [super initWithContentRect:contentRect styleMask:styleMask backing:backingType defer:flag];
if( self )
b_isset_canBecomeKeyWindow = 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];
}
@end
/*****************************************************************************
* VLCControllerWindow
*****************************************************************************/
......
......@@ -44,12 +44,17 @@
/*****************************************************************************
* VLCVoutView interface
*****************************************************************************/
@protocol VLCVoutViewResetting
+ (void)resetVout: (vout_thread_t *)p_vout;
@end
@interface VLCVoutView : NSView
{
vout_thread_t * p_vout;
NSView * o_view;
NSRect * s_frame;
NSView <VLCVoutViewResetting> * o_view;
vout_thread_t * p_real_vout;
id o_window;
}
......@@ -70,6 +75,8 @@
frame: (NSRect *) s_frame;
+ (vout_thread_t *)getRealVout: (vout_thread_t *)p_vout;
- (void)enterFullscreen;
- (void)leaveFullscreen;
@end
/*****************************************************************************
......@@ -102,17 +109,19 @@
/*****************************************************************************
* VLCDetachedEmbeddedView interface
*****************************************************************************/
@class VLCEmbeddedWindow;
@interface VLCDetachedEmbeddedVoutView : VLCEmbeddedVoutView
{
id o_embeddedwindow;
}
@end
/*****************************************************************************
* VLCWindow interface
* VLCVoutWindow interface
*****************************************************************************/
@interface VLCWindow : NSWindow
@interface VLCVoutWindow : NSWindow
{
vout_thread_t * p_vout;
VLCVoutView * o_view;
......
......@@ -43,6 +43,7 @@
#include "fspanel.h"
#include "vout.h"
#import "controls.h"
#import "embeddedwindow.h"
/*****************************************************************************
* DeviceCallback: Callback triggered when the video-device variable is changed
......@@ -113,9 +114,9 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
- (BOOL)windowContainsEmbedded: (id)o_window
{
/* if( ![[o_window className] isEqualToString: @"VLCWindow"] )
/* if( ![[o_window className] isEqualToString: @"VLCVoutWindow"] )
{
NSLog( @"We were not given a VLCWindow" );
NSLog( @"We were not given a VLCVoutWindow" );
}*/
return ([self getViewForWindow: o_window] == nil ? NO : YES );
}
......@@ -392,10 +393,6 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
var_Get( p_real_vout, "fullscreen", &val );
val.b_bool = !val.b_bool;
var_Set( p_real_vout, "fullscreen", val );
if( [self isFullscreen] )
[[[[VLCMain sharedInstance] getControls] getFSPanel] setActive: nil];
else
[[[[VLCMain sharedInstance] getControls] getFSPanel] setNonActive: nil];
}
- (BOOL)isFullscreen
......@@ -732,6 +729,18 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
return o_return;
}
- (void)enterFullscreen
{
[[o_view class] resetVout: p_vout];
[[[[VLCMain sharedInstance] getControls] getFSPanel] setActive: nil];
}
- (void)leaveFullscreen
{
[[o_view class] resetVout: p_vout];
[[[[VLCMain sharedInstance] getControls] getFSPanel] setNonActive: nil];
}
@end
/*****************************************************************************
......@@ -751,7 +760,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
{
BOOL b_return = [super setVout: p_arg_vout subView: view frame:s_arg_frame];
i_time_mouse_last_moved = mdate();
o_window = [[VLCWindow alloc] initWithVout: p_arg_vout view: self
o_window = [[VLCVoutWindow alloc] initWithVout: p_arg_vout view: self
frame: s_arg_frame];
[self updateTitle];
[view setFrame: [self frame]];
......@@ -875,6 +884,10 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
@end
@implementation VLCDetachedEmbeddedVoutView
- (void)awakeFromNib
{
o_embeddedwindow = [self window];
}
- (BOOL)setVout: (vout_thread_t *) p_arg_vout subView: (NSView *) view
frame: (NSRect *) s_arg_frame
......@@ -897,12 +910,23 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
[super closeVout];
}
- (void)enterFullscreen
{
/* We are in a VLCEmbeddedWindow */
[o_embeddedwindow performSelectorOnMainThread: @selector(enterFullscreen) withObject: NULL waitUntilDone: YES];
}
- (void)leaveFullscreen
{
/* We are in a VLCEmbeddedWindow */
[o_embeddedwindow performSelectorOnMainThread: @selector(leaveFullscreen) withObject: NULL waitUntilDone: YES];
}
@end
/*****************************************************************************
* VLCWindow implementation
* VLCVoutWindow implementation
*****************************************************************************/
@implementation VLCWindow
@implementation VLCVoutWindow
- (id) initWithVout: (vout_thread_t *) vout view: (VLCVoutView *) view
frame: (NSRect *) frame
......
......@@ -44,13 +44,14 @@
#include <AGL/agl.h>
/*****************************************************************************
* VLCView interface
* VLCGLView interface
*****************************************************************************/
@interface VLCGLView : NSOpenGLView
@interface VLCGLView : NSOpenGLView <VLCVoutViewResetting>
{
vout_thread_t * p_vout;
}
+ (void)resetVout: (vout_thread_t *)p_vout;
- (id) initWithVout: (vout_thread_t *) p_vout;
@end
......@@ -241,38 +242,12 @@ static int Manage( vout_thread_t * p_vout )
{
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
if( !p_vout->b_fullscreen )
{
/* Save window size and position */
p_vout->p_sys->s_frame.size =
[p_vout->p_sys->o_vout_view frame].size;
p_vout->p_sys->s_frame.origin =
[[p_vout->p_sys->o_vout_view getWindow ]frame].origin;
p_vout->p_sys->b_saved_frame = VLC_TRUE;
}
[p_vout->p_sys->o_vout_view closeVout];
p_vout->b_fullscreen = !p_vout->b_fullscreen;
#define o_glview p_vout->p_sys->o_glview
o_glview = [[VLCGLView alloc] initWithVout: p_vout];
[o_glview autorelease];
if( p_vout->p_sys->b_saved_frame )
{
p_vout->p_sys->o_vout_view = [VLCVoutView getVoutView: p_vout
subView: o_glview
frame: &p_vout->p_sys->s_frame];
}
if( p_vout->b_fullscreen )
[p_vout->p_sys->o_vout_view enterFullscreen];
else
{
p_vout->p_sys->o_vout_view = [VLCVoutView getVoutView: p_vout
subView: o_glview frame: nil];
}
[[o_glview openGLContext] makeCurrentContext];
#undef o_glview
[p_vout->p_sys->o_vout_view leaveFullscreen];
[o_pool release];
......@@ -327,6 +302,42 @@ static void Unlock( vout_thread_t * p_vout )
*****************************************************************************/
@implementation VLCGLView
/* This function will reset the o_vout_view. It's useful to go fullscreen. */
+ (void)resetVout: (vout_thread_t *)p_vout
{
if( p_vout->b_fullscreen )
{
/* Save window size and position */
p_vout->p_sys->s_frame.size =
[p_vout->p_sys->o_vout_view frame].size;
p_vout->p_sys->s_frame.origin =
[[p_vout->p_sys->o_vout_view getWindow ]frame].origin;
p_vout->p_sys->b_saved_frame = VLC_TRUE;
}
[p_vout->p_sys->o_vout_view closeVout];
#define o_glview p_vout->p_sys->o_glview
o_glview = [[VLCGLView alloc] initWithVout: p_vout];
[o_glview autorelease];
if( p_vout->p_sys->b_saved_frame )
{
p_vout->p_sys->o_vout_view = [VLCVoutView getVoutView: p_vout
subView: o_glview
frame: &p_vout->p_sys->s_frame];
}
else
{
p_vout->p_sys->o_vout_view = [VLCVoutView getVoutView: p_vout
subView: o_glview frame: nil];
}
[[o_glview openGLContext] makeCurrentContext];
#undef o_glview
}
- (id) initWithVout: (vout_thread_t *) vout
{
p_vout = vout;
......
......@@ -46,13 +46,13 @@
/*****************************************************************************
* VLCView interface
*****************************************************************************/
@interface VLCQTView : NSQuickDrawView
@interface VLCQTView : NSQuickDrawView <VLCVoutViewResetting>
{
vout_thread_t * p_vout;
}
+ (void)resetVout: (vout_thread_t *)p_vout;
- (id) initWithVout:(vout_thread_t *)p_vout;
@end
struct vout_sys_t
......@@ -479,74 +479,12 @@ static int CoToggleFullscreen( vout_thread_t *p_vout )
{
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
QTDestroySequence( p_vout );
if( !p_vout->b_fullscreen )
{
if( !p_vout->p_sys->b_embedded )
{
/* Save window size and position */
p_vout->p_sys->s_frame.size =
[p_vout->p_sys->o_vout_view frame].size;
p_vout->p_sys->s_frame.origin =
[[p_vout->p_sys->o_vout_view getWindow] frame].origin;
p_vout->p_sys->b_saved_frame = VLC_TRUE;
}
else
{
var_DelCallback(p_vout->p_libvlc, "drawableredraw", DrawableRedraw, p_vout);
DisposeRgn(p_vout->p_sys->clip_mask);
}
}
[p_vout->p_sys->o_vout_view closeVout];
p_vout->b_fullscreen = !p_vout->b_fullscreen;
if( p_vout->b_fullscreen || !p_vout->p_sys->b_embedded )
{
Rect s_rect;
p_vout->p_sys->clip_mask = NULL;
#define o_qtview p_vout->p_sys->o_qtview
o_qtview = [[VLCQTView alloc] initWithVout: p_vout];
[o_qtview autorelease];
if( p_vout->p_sys->b_saved_frame )
{
p_vout->p_sys->o_vout_view = [VLCVoutView getVoutView: p_vout
subView: o_qtview
frame: &p_vout->p_sys->s_frame];
}
else
{
p_vout->p_sys->o_vout_view = [VLCVoutView getVoutView: p_vout
subView: o_qtview frame: nil];
}
/* Retrieve the QuickDraw port */
[o_qtview lockFocus];
p_vout->p_sys->p_qdport = [o_qtview qdPort];
[o_qtview unlockFocus];
#undef o_qtview
GetPortBounds( p_vout->p_sys->p_qdport, &s_rect );
p_vout->p_sys->i_origx = s_rect.left;
p_vout->p_sys->i_origy = s_rect.top;
p_vout->p_sys->i_width = s_rect.right - s_rect.left;
p_vout->p_sys->i_height = s_rect.bottom - s_rect.top;
}
if( p_vout->b_fullscreen )
[p_vout->p_sys->o_vout_view enterFullscreen];
else
{
/* Create the clipping mask */
p_vout->p_sys->clip_mask = NewRgn();
UpdateEmbeddedGeometry(p_vout);
var_AddCallback(p_vout->p_libvlc, "drawableredraw", DrawableRedraw, p_vout);
}
QTScaleMatrix( p_vout );
if( QTCreateSequence( p_vout ) )
{
msg_Err( p_vout, "unable to initialize QT: QTCreateSequence failed" );
return( 1 );
}
[p_vout->p_sys->o_vout_view leaveFullscreen];
[o_pool release];
return 0;
......@@ -862,6 +800,76 @@ static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic )
*****************************************************************************/
@implementation VLCQTView
/* This function will reset the o_vout_view. It's useful to go fullscreen. */
+ (void)resetVout: (vout_thread_t *)p_vout
{
QTDestroySequence( p_vout );
if( p_vout->b_fullscreen )
{
if( !p_vout->p_sys->b_embedded )
{
/* Save window size and position */
p_vout->p_sys->s_frame.size =
[p_vout->p_sys->o_vout_view frame].size;
p_vout->p_sys->s_frame.origin =
[[p_vout->p_sys->o_vout_view getWindow] frame].origin;
p_vout->p_sys->b_saved_frame = VLC_TRUE;
}
else
{
var_DelCallback(p_vout->p_libvlc, "drawableredraw", DrawableRedraw, p_vout);
DisposeRgn(p_vout->p_sys->clip_mask);
}
}
if( p_vout->b_fullscreen || !p_vout->p_sys->b_embedded )
{
Rect s_rect;
p_vout->p_sys->clip_mask = NULL;
#define o_qtview p_vout->p_sys->o_qtview
o_qtview = [[VLCQTView alloc] initWithVout: p_vout];
[o_qtview autorelease];
if( p_vout->p_sys->b_saved_frame )
{
p_vout->p_sys->o_vout_view = [VLCVoutView getVoutView: p_vout
subView: o_qtview
frame: &p_vout->p_sys->s_frame];
}
else
{
p_vout->p_sys->o_vout_view = [VLCVoutView getVoutView: p_vout
subView: o_qtview frame: nil];
}
/* Retrieve the QuickDraw port */
[o_qtview lockFocus];
p_vout->p_sys->p_qdport = [o_qtview qdPort];
[o_qtview unlockFocus];
#undef o_qtview
GetPortBounds( p_vout->p_sys->p_qdport, &s_rect );
p_vout->p_sys->i_origx = s_rect.left;
p_vout->p_sys->i_origy = s_rect.top;
p_vout->p_sys->i_width = s_rect.right - s_rect.left;
p_vout->p_sys->i_height = s_rect.bottom - s_rect.top;
}
else
{
/* Create the clipping mask */
p_vout->p_sys->clip_mask = NewRgn();
UpdateEmbeddedGeometry(p_vout);
var_AddCallback(p_vout->p_libvlc, "drawableredraw", DrawableRedraw, p_vout);
}
QTScaleMatrix( p_vout );
if( QTCreateSequence( p_vout ) )
{
msg_Err( p_vout, "unable to initialize QT: QTCreateSequence failed" );
return;
}
}
- (id) initWithVout:(vout_thread_t *)_p_vout
{
p_vout = _p_vout;
......
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