Commit 87fe9845 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

MacOSX/VLC_app: port the fullscreen zoom and the fspanel from gui/macosx to VLC_app.

parent ff7830bb
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -6,6 +6,8 @@
* $Id$
*
* Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
* Felix Kühne <fkuehne at videolan dot org>
* Jérôme Decoodt <djc at videolan dot org>
*
* 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
......@@ -24,20 +26,33 @@
#import <Cocoa/Cocoa.h>
/*****************************************************************************
* NSIndexPath (VLCAppAddition)
*****************************************************************************/
@interface NSIndexPath (VLCAppAddition)
- (NSIndexPath *)indexPathByRemovingFirstIndex;
- (NSUInteger)lastIndex;
@end
/*****************************************************************************
* NSArray (VLCAppAddition)
*****************************************************************************/
@interface NSArray (VLCAppAddition)
- (id)objectAtIndexPath:(NSIndexPath *)path withNodeKeyPath:(NSString *)nodeKeyPath;
@end
/*****************************************************************************
* NSView (VLCAppAdditions)
*****************************************************************************/
@interface NSView (VLCAppAdditions)
- (void)moveSubviewsToVisible;
@end
/* Split view that supports slider animation */
/*****************************************************************************
* VLCOneSplitView
*
* Missing functionality to a one-split view
*****************************************************************************/
@interface VLCOneSplitView : NSSplitView
{
BOOL fixedCursorDuringResize;
......@@ -46,3 +61,64 @@
- (float)sliderPosition;
- (void)setSliderPosition:(float)newPosition;
@end
/*****************************************************************************
* NSScreen (VLCAdditions)
*
* Missing extension to NSScreen
*****************************************************************************/
@interface NSScreen (VLCAdditions)
+ (NSScreen *)screenWithDisplayID: (CGDirectDisplayID)displayID;
- (BOOL)isMainScreen;
- (BOOL)isScreen: (NSScreen*)screen;
- (CGDirectDisplayID)displayID;
- (void)blackoutOtherScreens;
+ (void)unblackoutScreens;
@end
/*****************************************************************************
* VLCWindow
*
* Missing extension to NSWindow (Used only when needing setCanBecomeKeyWindow)
*****************************************************************************/
@interface VLCWindow : NSWindow
{
BOOL canBecomeKeyWindow;
BOOL isset_canBecomeKeyWindow;
}
- (void)setCanBecomeKeyWindow: (BOOL)canBecomeKey;
@end
/*****************************************************************************
* VLCImageCustomizedSlider
*
* Slider personalized by backgroundImage and knobImage
*****************************************************************************/
@interface VLCImageCustomizedSlider : NSSlider
{
NSImage * knobImage;
NSImage * backgroundImage;
}
@property (retain) NSImage * knobImage;
@property (retain) NSImage * backgroundImage;
- (void)drawKnobInRect: (NSRect)knobRect;
- (void)drawBackgroundInRect: (NSRect)knobRect;
- (void)drawRect: (NSRect)rect;
@end
/*****************************************************************************
* NSImageView (VLCAppAdditions)
*
* Make the image view move the window by mouse down by default
*****************************************************************************/
@interface NSImageView (VLCAppAdditions)
- (void)mouseDownCanMoveWindow;
@end
......@@ -6,6 +6,8 @@
* $Id$
*
* Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
* Felix Kühne <fkuehne at videolan dot org>
* Jérôme Decoodt <djc at videolan dot org>
*
* 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
......@@ -123,3 +125,205 @@
}
@end
/*****************************************************************************
* NSScreen (VLCAdditions)
*
* Missing extension to NSScreen
*****************************************************************************/
@implementation NSScreen (VLCAdditions)
static NSMutableArray *blackoutWindows = NULL;
+ (void)load
{
/* init our fake object attribute */
blackoutWindows = [[NSMutableArray alloc] initWithCapacity:1];
}
+ (NSScreen *)screenWithDisplayID: (CGDirectDisplayID)displayID
{
int i;
for( i = 0; i < [[NSScreen screens] count]; i++ )
{
NSScreen *screen = [[NSScreen screens] objectAtIndex: i];
if([screen displayID] == displayID)
return screen;
}
return nil;
}
- (BOOL)isMainScreen
{
return ([self displayID] == [[[NSScreen screens] objectAtIndex:0] displayID]);
}
- (BOOL)isScreen: (NSScreen*)screen
{
return ([self displayID] == [screen displayID]);
}
- (CGDirectDisplayID)displayID
{
return (CGDirectDisplayID)_screenNumber;
}
- (void)blackoutOtherScreens
{
unsigned int i;
/* Free our previous blackout window (follow blackoutWindow alloc strategy) */
[blackoutWindows makeObjectsPerformSelector:@selector(close)];
[blackoutWindows removeAllObjects];
for(i = 0; i < [[NSScreen screens] count]; i++)
{
NSScreen *screen = [[NSScreen screens] objectAtIndex: i];
VLCWindow *blackoutWindow;
NSRect screen_rect;
if([self isScreen: screen])
continue;
screen_rect = [screen frame];
screen_rect.origin.x = screen_rect.origin.y = 0.0f;
/* blackoutWindow alloc strategy
- The NSMutableArray blackoutWindows has the blackoutWindow references
- blackoutOtherDisplays is responsible for alloc/releasing its Windows
*/
blackoutWindow = [[VLCWindow alloc] initWithContentRect: screen_rect styleMask: NSBorderlessWindowMask
backing: NSBackingStoreBuffered defer: NO screen: screen];
[blackoutWindow setBackgroundColor:[NSColor blackColor]];
[blackoutWindow setLevel: NSFloatingWindowLevel]; /* Disappear when Expose is triggered */
[blackoutWindow orderFront: self];
[blackoutWindows addObject: blackoutWindow];
[blackoutWindow release];
}
}
+ (void)unblackoutScreens
{
unsigned int i;
for(i = 0; i < [blackoutWindows count]; i++)
{
VLCWindow *blackoutWindow = [blackoutWindows objectAtIndex: i];
[blackoutWindow close];
}
}
@end
/*****************************************************************************
* 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 )
isset_canBecomeKeyWindow = NO;
return self;
}
- (void)setCanBecomeKeyWindow: (BOOL)canBecomeKey
{
isset_canBecomeKeyWindow = YES;
canBecomeKeyWindow = canBecomeKey;
}
- (BOOL)canBecomeKeyWindow
{
if(isset_canBecomeKeyWindow)
return canBecomeKeyWindow;
return [super canBecomeKeyWindow];
}
@end
/*****************************************************************************
* VLCImageCustomizedSlider
*
* Slider personalized by backgroundImage and knobImage
*****************************************************************************/
@implementation VLCImageCustomizedSlider
@synthesize backgroundImage;
@synthesize knobImage;
- (id)initWithFrame:(NSRect)frame
{
if(self = [super initWithFrame:frame])
{
knobImage = nil;
backgroundImage = nil;
}
return self;
}
- (void)dealloc
{
[knobImage release];
[knobImage release];
[super dealloc];
}
- (void)drawKnobInRect:(NSRect) knobRect
{
NSRect imageRect;
imageRect.size = [self.knobImage size];
imageRect.origin.x = 0;
imageRect.origin.y = 0;
knobRect.origin.x += (knobRect.size.width - imageRect.size.width) / 2;
knobRect.origin.y += (knobRect.size.width - imageRect.size.width) / 2;
knobRect.size.width = imageRect.size.width;
knobRect.size.height = imageRect.size.height;
[self.knobImage drawInRect:knobRect fromRect:imageRect operation:NSCompositeSourceOver fraction:1];
}
- (void)drawBackgroundInRect:(NSRect) drawRect
{
NSRect imageRect = drawRect;
imageRect.origin.y += ([self.backgroundImage size].height - [self bounds].size.height ) / 2;
[self.backgroundImage drawInRect:drawRect fromRect:imageRect operation:NSCompositeSourceOver fraction:1];
}
- (void)drawRect:(NSRect)rect
{
/* Draw default to make sure the slider behaves correctly */
[[NSGraphicsContext currentContext] saveGraphicsState];
NSRectClip(NSZeroRect);
[super drawRect:rect];
[[NSGraphicsContext currentContext] restoreGraphicsState];
if( self.backgroundImage )
[self drawBackgroundInRect: rect];
if( self.knobImage )
{
NSRect knobRect = [[self cell] knobRectFlipped:NO];
[[[NSColor blackColor] colorWithAlphaComponent:0.6] set];
[self drawKnobInRect: knobRect];
}
}
@end
/*****************************************************************************
* NSImageView (VLCAppAdditions)
*
* Make the image view move the window by mouse down by default
*****************************************************************************/
@implementation NSImageView (VLCAppAdditions)
- (void)mouseDownCanMoveWindow
{
return YES;
}
@end
......@@ -201,6 +201,14 @@
{
return [NSSet setWithObjects:@"state", @"playing", @"canPause", nil];
}
+ (NSSet *)keyPathsForValuesAffectingStateAsFullScreenButtonImage
{
return [NSSet setWithObjects:@"state", @"playing", @"canPause", nil];
}
+ (NSSet *)keyPathsForValuesAffectingStateAsFullScreenButtonAlternateImage
{
return [NSSet setWithObjects:@"state", @"playing", @"canPause", nil];
}
- (NSString *)description
{
......@@ -229,4 +237,25 @@
else
return [NSImage imageNamed:@"play_blue.png"];
}
- (NSImage *)stateAsFullScreenButtonImage
{
if([self state] == VLCMediaPlayerStatePlaying && [self canPause])
return [NSImage imageNamed:@"fs_pause.png"];
else if( [self state] == VLCMediaPlayerStatePlaying )
return [NSImage imageNamed:@"fs_stop.png"];
else
return [NSImage imageNamed:@"fs_play.png"];
}
- (NSImage *)stateAsFullScreenButtonAlternateImage
{
if([self state] == VLCMediaPlayerStatePlaying && [self canPause])
return [NSImage imageNamed:@"fs_pause_highlight.png"];
else if( [self state] == VLCMediaPlayerStatePlaying )
return [NSImage imageNamed:@"fs_stop_highlight.png"];
else
return [NSImage imageNamed:@"fs_play_highlight.png"];
}
@end
......@@ -25,6 +25,7 @@
#import <QuartzCore/QuartzCore.h>
#import <VLCKit/VLCKit.h>
#import "VLCAppAdditions.h"
@interface VLCBrowsableVideoView : VLCVideoView {
BOOL menuDisplayed;
......@@ -43,6 +44,12 @@
/* Actions on non-node items*/
id target;
SEL action;
/* FullScreenTransition */
VLCWindow * fullScreenWindow;
NSViewAnimation * fullScreenAnim1;
NSViewAnimation * fullScreenAnim2;
NSView * tempFullScreenView;
}
/* Binds an nsarray to that property. But don't forget the set the access keys. */
......
/*****************************************************************************
* VLCFullScreenControllerWindow.m: class that allow media controlling in
* fullscreen (with the mouse)
*****************************************************************************
* Copyright (C) 2007 Pierre d'Herbemont
* Copyright (C) 2007 the VideoLAN team
* $Id: VLCBrowsableVideoView.h 24154 2008-01-06 20:27:55Z pdherbemont $
*
* Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
*
* 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 <VLCKit/VLCKit.h>
#import "VLCAppAdditions.h"
#import "VLCMainWindow.h"
@interface VLCFullScreenControllerWindow : NSPanel
{
/* IBOutlets */
IBOutlet VLCImageCustomizedSlider * volumeSlider;
IBOutlet VLCImageCustomizedSlider * mediaPositionSlider;
IBOutlet NSButton * mediaPlayerForwardNextButton;
IBOutlet NSButton * mediaPlayerBackwardPrevButton;
IBOutlet NSButton * mediaPlayerPlayPauseStopButton;
IBOutlet id fillScreenButton;
IBOutlet id fullScreenButton;
IBOutlet NSTextField * mediaReadingProgressText;
IBOutlet NSTextField * mediaDescriptionText;
NSTimer * hideWindowTimer;
NSTrackingArea * videoViewTrackingArea;
BOOL active;
/* Owner */
IBOutlet VLCMainWindow * mainWindow;
/* Draging the window using its content */
NSPoint mouseClic;
}
@end
This diff is collapsed.
......@@ -64,7 +64,7 @@
IBOutlet NSView * toolbarMediaDescription;
IBOutlet NSView * toolbarMediaControl;
VLCMediaPlayer * mediaPlayer;
IBOutlet VLCMediaPlayer * mediaPlayer;
IBOutlet VLCController * controller; /* This is a VLCController binded to the File's Owner of the nib */
......@@ -77,4 +77,6 @@
}
@property BOOL navigatorViewVisible;
@property (readonly) VLCMediaPlayer * mediaPlayer;
@property (readonly) VLCBrowsableVideoView * videoView;
@end
......@@ -27,6 +27,7 @@
#import "VLCMediaArrayController.h"
#import "VLCBrowsableVideoView.h"
#import "VLCAppAdditions.h"
#import "VLCFullScreenControllerWindow.h"
@interface VLCMainWindow (NavigatorViewHidingShowing)
@property float contentHeight; /* animatable, keep the mainSplitView cursor at the same place, enabling playlist(navigator) togling */
......@@ -106,6 +107,10 @@
* VLCMainWindow
*/
@implementation VLCMainWindow
@synthesize mediaPlayer;
@synthesize videoView;
- (void)awakeFromNib;
{
NSTableColumn * tableColumn;
......@@ -117,7 +122,7 @@
/***********************************
* Init the media player
*/
mediaPlayer = [[VLCMediaPlayer alloc] initWithVideoView:videoView];
[mediaPlayer setVideoView:videoView];
/***********************************
* CategoriesList OutlineView content
......@@ -252,7 +257,7 @@
[mediaPlayerBackwardPrevButton setAction:@selector(rewind)];
[mediaPlayerPlayPauseStopButton setTarget:mediaPlayer];
[mediaPlayerPlayPauseStopButton setAction:@selector(pause)];
/* Last minute setup */
[categoriesListView expandItem:nil expandChildren:YES];
[categoriesListView selectRowIndexes:[NSIndexSet indexSetWithIndex:[categoriesListView numberOfRows] > 0 ? [categoriesListView numberOfRows]-1 : 0] byExtendingSelection:NO];
......
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