Commit e6e14e4e authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

vlc_app: New media layer view. Enabled by default. Set bindings from...

vlc_app: New media layer view. Enabled by default. Set bindings from resources. (This commit is way too large.)
parent 762b3db9
......@@ -46,6 +46,56 @@
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
<dict>
<key>ACTIONS</key>
<dict>
<key>mediaListViewItemDoubleClicked</key>
<string>id</string>
<key>videoViewItemClicked</key>
<string>id</string>
</dict>
<key>CLASS</key>
<string>VLCMainWindowController</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>OUTLETS</key>
<dict>
<key>addPlaylistButton</key>
<string>NSButton</string>
<key>categoriesListView</key>
<string>NSOutlineView</string>
<key>categoriesTreeController</key>
<string>NSTreeController</string>
<key>controller</key>
<string>VLCController</string>
<key>mainSplitView</key>
<string>VLCOneSplitView</string>
<key>mediaArrayController</key>
<string>VLCMediaArrayController</string>
<key>mediaListView</key>
<string>NSTableView</string>
<key>mediaPlayer</key>
<string>VLCMediaPlayer</string>
<key>mediaPlayerBackwardPrevButton</key>
<string>NSButton</string>
<key>mediaPlayerForwardNextButton</key>
<string>NSButton</string>
<key>mediaPlayerPlayPauseStopButton</key>
<string>NSButton</string>
<key>removePlaylistButton</key>
<string>NSButton</string>
<key>toolbarMediaAudioVolume</key>
<string>NSView</string>
<key>toolbarMediaControl</key>
<string>NSView</string>
<key>toolbarMediaDescription</key>
<string>NSView</string>
<key>videoView</key>
<string>VLCBrowsableVideoView</string>
</dict>
<key>SUPERCLASS</key>
<string>NSWindowController</string>
</dict>
<dict>
<key>CLASS</key>
<string>FirstResponder</string>
......@@ -54,6 +104,22 @@
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
<dict>
<key>CLASS</key>
<string>VLCOneSplitView</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSSplitView</string>
</dict>
<dict>
<key>CLASS</key>
<string>VLCMediaArrayController</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSArrayController</string>
</dict>
<dict>
<key>ACTIONS</key>
<dict>
......@@ -68,6 +134,8 @@
<string>ObjC</string>
<key>OUTLETS</key>
<dict>
<key>mainWindowController</key>
<string>VLCMainWindowController</string>
<key>selectedObject</key>
<string>id</string>
<key>target</key>
......@@ -84,6 +152,12 @@
<key>SUPERCLASS</key>
<string>NSView</string>
</dict>
<dict>
<key>CLASS</key>
<string>VLCMediaPlayer</string>
<key>LANGUAGE</key>
<string>ObjC</string>
</dict>
</array>
<key>IBVersion</key>
<string>1</string>
......
......@@ -4,8 +4,6 @@
<dict>
<key>IBFramework Version</key>
<string>629</string>
<key>IBLastKnownRelativeProjectPath</key>
<string>../../VLC.xcodeproj</string>
<key>IBOldestOS</key>
<integer>5</integer>
<key>IBOpenObjects</key>
......
/*****************************************************************************
* AppleRemote.h
* AppleRemote
* $Id: AppleRemote.h 22000 2007-09-13 19:12:49Z funman $
*
* Created by Martin Kahr on 11.03.06 under a MIT-style license.
* Copyright (c) 2006 martinkahr.com. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*****************************************************************************
*
* Note that changes made by any members or contributors of the VideoLAN team
* (i.e. changes that were checked in exclusively into one of VideoLAN's source code
* repositories) are licensed under the GNU General Public License version 2,
* or (at your option) any later version.
* Thus, the following statements apply to our changes:
*
* Copyright (C) 2006-2007 the VideoLAN team
* Authors: Eric Petit <titer@m0k.org>
* Felix Kühne <fkuehne 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
* 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 <mach/mach.h>
#import <mach/mach_error.h>
#import <IOKit/IOKitLib.h>
#import <IOKit/IOCFPlugIn.h>
#import <IOKit/hid/IOHIDLib.h>
#import <IOKit/hid/IOHIDKeys.h>
enum AppleRemoteEventIdentifier
{
kRemoteButtonVolume_Plus =1<<1,
kRemoteButtonVolume_Minus =1<<2,
kRemoteButtonMenu =1<<3,
kRemoteButtonPlay =1<<4,
kRemoteButtonRight =1<<5,
kRemoteButtonLeft =1<<6,
kRemoteButtonRight_Hold =1<<7,
kRemoteButtonLeft_Hold =1<<8,
kRemoteButtonMenu_Hold =1<<9,
kRemoteButtonPlay_Sleep =1<<10,
kRemoteControl_Switched =1<<11,
kRemoteButtonVolume_Plus_Hold =1<<12,
kRemoteButtonVolume_Minus_Hold =1<<13
};
typedef enum AppleRemoteEventIdentifier AppleRemoteEventIdentifier;
/* Encapsulates usage of the apple remote control
This class is implemented as a singleton as there is exactly one remote per machine (until now)
The class is not thread safe
*/
@interface AppleRemote : NSObject {
IOHIDDeviceInterface** hidDeviceInterface;
IOHIDQueueInterface** queue;
NSMutableArray* allCookies;
NSMutableDictionary* cookieToButtonMapping;
BOOL openInExclusiveMode;
BOOL simulatePlusMinusHold;
BOOL processesBacklog;
/* state for simulating plus/minus hold */
BOOL lastEventSimulatedHold;
AppleRemoteEventIdentifier lastPlusMinusEvent;
NSTimeInterval lastPlusMinusEventTime;
int remoteId;
unsigned int clickCountEnabledButtons;
NSTimeInterval maxClickTimeDifference;
NSTimeInterval lastClickCountEventTime;
AppleRemoteEventIdentifier lastClickCountEvent;
unsigned int eventClickCount;
IBOutlet id delegate;
}
- (int) remoteId;
- (BOOL) isRemoteAvailable;
- (BOOL) isListeningToRemote;
- (void) setListeningToRemote: (BOOL) value;
- (BOOL) isOpenInExclusiveMode;
- (void) setOpenInExclusiveMode: (BOOL) value;
/* click counting makes it possible to recognize if the user has pressed a button repeatedly
* click counting does delay each event as it has to wait if there is another event (second click)
* therefore there is a slight time difference (maximumClickCountTimeDifference) between a single click
* of the user and the call of your delegate method
* click counting can be enabled individually for specific buttons. Use the property clickCountEnableButtons
* to set the buttons for which click counting shall be enabled */
- (BOOL) clickCountingEnabled;
- (void) setClickCountingEnabled: (BOOL) value;
- (unsigned int) clickCountEnabledButtons;
- (void) setClickCountEnabledButtons: (unsigned int)value;
/* the maximum time difference till which clicks are recognized as multi clicks */
- (NSTimeInterval) maximumClickCountTimeDifference;
- (void) setMaximumClickCountTimeDifference: (NSTimeInterval) timeDiff;
/* When your application needs to much time on the main thread when processing an event other events
* may already be received which are put on a backlog. As soon as your main thread
* has some spare time this backlog is processed and may flood your delegate with calls.
* Backlog processing is turned off by default. */
- (BOOL) processesBacklog;
- (void) setProcessesBacklog: (BOOL) value;
/* Sets an NSApplication delegate which starts listening when application is becoming active
* and stops listening when application resigns being active.
* If an NSApplication delegate has been already set all method calls will be forwarded to this delegate, too. */
- (BOOL) listeningOnAppActivate;
- (void) setListeningOnAppActivate: (BOOL) value;
/* Simulating plus/minus hold does deactivate sending of individual requests for plus/minus pressed down/released.
* Instead special hold events are being triggered when the user is pressing and holding plus/minus for a small period.
* With simulating enabled the plus/minus buttons do behave as the left/right buttons */
- (BOOL) simulatesPlusMinusHold;
- (void) setSimulatesPlusMinusHold: (BOOL) value;
/* Delegates are not retained */
- (void) setDelegate: (id) delegate;
- (id) delegate;
- (IBAction) startListening: (id) sender;
- (IBAction) stopListening: (id) sender;
@end
@interface AppleRemote (Singleton)
+ (AppleRemote*) sharedRemote;
@end
/* Method definitions for the delegate of the AppleRemote class */
@interface NSObject(NSAppleRemoteDelegate)
- (void) appleRemoteButton: (AppleRemoteEventIdentifier)buttonIdentifier pressedDown: (BOOL) pressedDown clickCount: (unsigned int) count;
@end
@interface AppleRemote (PrivateMethods)
- (void) setRemoteId: (int) aValue;
- (NSDictionary*) cookieToButtonMapping;
- (IOHIDQueueInterface**) queue;
- (IOHIDDeviceInterface**) hidDeviceInterface;
- (void) handleEventWithCookieString: (NSString*) cookieString sumOfValues: (SInt32) sumOfValues;
@end
@interface AppleRemote (IOKitMethods)
- (io_object_t) findAppleRemoteDevice;
- (IOHIDDeviceInterface**) createInterfaceForDevice: (io_object_t) hidDevice;
- (BOOL) initializeCookies;
- (BOOL) openDevice;
@end
/* A NSApplication delegate which is used to activate and deactivate listening to the remote control
* dependent on the activation state of your application.
* All events are delegated to the original NSApplication delegate if necessary */
@interface AppleRemoteApplicationDelegate : NSObject {
id applicationDelegate;
}
- (id) initWithApplicationDelegate: (id) delegate;
- (id) applicationDelegate;
@end
This diff is collapsed.
......@@ -55,9 +55,7 @@
*****************************************************************************/
@interface VLCOneSplitView : NSSplitView
{
BOOL fixedCursorDuringResize;
}
@property (assign) BOOL fixedCursorDuringResize;
- (float)sliderPosition;
- (void)setSliderPosition:(float)newPosition;
@end
......@@ -122,3 +120,13 @@
@interface NSImageView (VLCAppAdditions)
- (BOOL)mouseDownCanMoveWindow;
@end
/*****************************************************************************
* NSImage (VLCAppAdditions)
*
* Make the image view move the window by mouse down by default
*****************************************************************************/
@interface NSImage (VLCAppAdditions)
- (CGImageRef)CGImage;
@end
......@@ -86,10 +86,21 @@
/* Split view that supports slider animation */
@implementation VLCOneSplitView
@synthesize fixedCursorDuringResize;
- (CGFloat)dividerThickness
{
return 1.;
}
- (void)drawDividerInRect:(NSRect)aRect
{
[self lockFocus];
[[NSColor blackColor] set];
NSRectFill(aRect);
[self unlockFocus];
}
- (float)sliderPosition
{
return [[[self subviews] objectAtIndex:0] frame].size.height;
NSSize size = [[[self subviews] objectAtIndex:0] frame].size;
return [self isVertical] ? size.width : size.height;
}
- (void)setSliderPosition:(float)newPosition
{
......@@ -103,26 +114,6 @@
}
return [super defaultAnimationForKey: key];
}
- (void)adjustSubviews
{
if( !fixedCursorDuringResize )
{
[super adjustSubviews];
return;
}
NSRect frame0 = [[[self subviews] objectAtIndex:0] frame];
NSRect frame1 = [[[self subviews] objectAtIndex:1] frame];
frame1.size.height = [self bounds].size.height - frame0.size.height - [self dividerThickness];
if( frame1.size.height < 0. )
{
float delta = -frame1.size.height;
frame1.size.height = 0.;
frame0.size.height -= delta;
frame1.origin.y = frame0.size.height + [self dividerThickness];
[[[self subviews] objectAtIndex:1] setFrame: frame0];
}
[[[self subviews] objectAtIndex:1] setFrame: frame1];
}
@end
/*****************************************************************************
......@@ -327,3 +318,17 @@ static NSMutableArray *blackoutWindows = NULL;
}
@end
/*****************************************************************************
* NSImage (VLCAppAdditions)
*
* Make the image view move the window by mouse down by default
*****************************************************************************/
@implementation NSImage (VLCAppAdditions)
- (CGImageRef)CGImage
{
return [[NSBitmapImageRep imageRepWithData:[NSBitmapImageRep TIFFRepresentationOfImageRepsInArray: [self representations]]] CGImage];
}
@end
......@@ -27,7 +27,10 @@
#import <VLCKit/VLCKit.h>
#import "VLCAppAdditions.h"
@interface VLCBrowsableVideoView : VLCVideoView {
@class VLCMainWindowController;
@class VLCMediaListLayer;
@interface VLCBrowsableVideoView : NSView {
BOOL menuDisplayed;
NSArray * itemsTree;
NSRange displayedItems;
......@@ -50,6 +53,9 @@
NSViewAnimation * fullScreenAnim1;
NSViewAnimation * fullScreenAnim2;
NSView * tempFullScreenView;
IBOutlet VLCMainWindowController * mainWindowController;
VLCVideoLayer * videoLayer;
VLCMediaListLayer * mediaListLayer;
}
/* Binds an nsarray to that property. But don't forget the set the access keys. */
......@@ -60,6 +66,9 @@
@property (readonly, retain) id selectedObject;
@property (readwrite) BOOL fullScreen;
@property (readonly) BOOL hasVideo;
@property (readonly) VLCVideoLayer * videoLayer;
/* Set up a specific action to do, on items that don't have node.
* action first argument is the browsableVideoView. You can get the selected object,
......@@ -70,4 +79,6 @@
- (void)toggleMenu;
- (void)displayMenu;
- (void)hideMenu;
- (IBAction)backToMediaListView:(id)sender;
@end
......@@ -28,6 +28,8 @@
#import "VLCBrowsableVideoView.h"
#import "VLCAppAdditions.h"
#import "VLCMediaListLayer.h"
#import "VLCMainWindowController.h"
/* TODO: We may want to clean up the private functions a bit... */
......@@ -60,6 +62,7 @@
@end
#pragma mark -
/******************************************************************************
* VLCBrowsableVideoView
*/
......@@ -71,6 +74,7 @@
@synthesize selectedObject;
@synthesize target;
@synthesize action;
@synthesize videoLayer;
- (NSArray *)itemsTree {
return itemsTree;
......@@ -105,6 +109,39 @@
}
}
- (BOOL)hasVideo
{
return videoLayer.hasVideo;
}
/* Binded to VideoLayer's hasVideo */
- (void)setHasVideo:(BOOL)hasVideo
{
if( hasVideo )
{
[CATransaction begin];
[videoLayer removeFromSuperlayer];
[self.layer addSublayer:videoLayer];
videoLayer.frame = [self layer].bounds;
[videoLayer setAutoresizingMask:kCALayerWidthSizable|kCALayerHeightSizable];
[mediaListLayer removeFromSuperlayer];
[CATransaction commit];
}
else
{
[CATransaction begin];
[mediaListLayer removeFromSuperlayer];
[self.layer addSublayer:mediaListLayer];
mediaListLayer.frame = [self layer].bounds;
[mediaListLayer setAutoresizingMask:kCALayerWidthSizable|kCALayerHeightSizable];
[videoLayer removeFromSuperlayer];
[CATransaction commit];
}
[[self layer] setNeedsDisplay];
[self setNeedsDisplay:YES];
}
/* Initializer */
- (void)awakeFromNib
{
......@@ -118,18 +155,113 @@
selectedPath = [[NSIndexPath alloc] init];
tempFullScreenView = [[NSView alloc] init];
fullScreen = NO;
/* Observe our bindings */
//[self displayMenu];
//[self changeSelectedIndex:0];
videoLayer = [[VLCVideoLayer layer] retain];
[videoLayer addObserver:self forKeyPath:@"hasVideo" options:NSKeyValueObservingOptionInitial|NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld context:nil];
[videoLayer setDelegate:self];
NSAssert( mainWindowController, @"No mainWindowController" );
[mainWindowController.mediaPlayer setVideoLayer: videoLayer];
mediaListLayer = [[VLCMediaListLayer layerWithMediaArrayController:mainWindowController.mediaArrayController] retain];
[self registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, NSURLPboardType, @"VLCMediaURLType", nil]];
[mainWindowController.mediaArrayController setSelectsInsertedObjects:YES];
[mainWindowController.mediaArrayController setAvoidsEmptySelection:YES];
[[self layer] addSublayer:mediaListLayer];
mediaListLayer.frame = [self layer].bounds;
[mediaListLayer setAutoresizingMask:kCALayerWidthSizable|kCALayerHeightSizable];
[[self layer] setNeedsDisplay];
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if([keyPath isEqualToString:@"hasVideo"])
{
[self setHasVideo:[object hasVideo]];
return;
}
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
- (void)dealloc
{
/* Previously registered in */
[videoLayer removeObserver:self forKeyPath:@"hasVideo"];
[mediaListLayer release];
[videoLayer release];
[tempFullScreenView release];
[selectedPath release];
[super dealloc];
}
#pragma mark -
/* Drag and drop */
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
{
NSPasteboard *pboard;
pboard = [sender draggingPasteboard];
if ( [[pboard types] containsObject:NSFilenamesPboardType] &&
![mainWindowController.mediaArrayController.contentMediaList isReadOnly] )
{
self.layer.borderColor = CGColorCreateGenericGray(0.5, 0.5);
self.layer.cornerRadius = 10.f;
self.layer.borderWidth = 10.0;
return NSDragOperationCopy;
}
return NSDragOperationNone;
}
- (void)draggingEnded:(id < NSDraggingInfo >)sender
{
[CATransaction begin];
[CATransaction setValue:[NSNumber numberWithFloat:0.1] forKey:kCATransactionAnimationDuration];
self.layer.borderWidth = 0.;
[CATransaction commit];
[CATransaction begin];
[mainWindowController.mediaArrayController setFilterPredicate:nil];
[mainWindowController.mediaArrayController setSelectionIndex:[mainWindowController.mediaArrayController.contentMediaList count] - 1];
[CATransaction commit];
}
- (void)draggingExited:(id < NSDraggingInfo >)sender
{
self.layer.borderWidth = 0.;
}
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
NSPasteboard *pboard;
NSDragOperation sourceDragMask;
sourceDragMask = [sender draggingSourceOperationMask];
pboard = [sender draggingPasteboard];
if ( [[pboard types] containsObject:NSFilenamesPboardType] )
{
NSArray *files = [pboard propertyListForType:NSFilenamesPboardType];
VLCMediaList * mediaList = mainWindowController.mediaArrayController.contentMediaList;
if( [mediaList isReadOnly] )
return NO;
[CATransaction begin];
for( NSString * filePath in files )
[mediaList addMedia:[VLCMedia mediaWithPath:filePath]];
[CATransaction commit];
}
return YES;
}
- (void)showDrag
{
}
#pragma mark -
/* Hiding/Displaying the menu */
- (void)hideMenu
......@@ -184,21 +316,30 @@
[self displayMenu];
}
- (IBAction)backToMediaListView:(id)sender
{
[mainWindowController.mediaPlayer stop];
[self setHasVideo: NO];
}
#pragma mark -
/* drawRect */
- (void)drawRect:(NSRect)rect
{
if( [[[self layer] sublayers] count] )
if( [self hasVideo] )
{
/* Don't draw the empty view if we have a video output on screen */
[super drawRect:rect];
[[NSColor blackColor] set];
NSRectFill(rect);
return;
}
NSColor * bottomGradient = [NSColor colorWithCalibratedWhite:0.10 alpha:1.0];
NSColor * topGradient = [NSColor colorWithCalibratedWhite:0.45 alpha:1.0];
NSGradient * gradient = [[NSGradient alloc] initWithStartingColor:bottomGradient endingColor:topGradient];
[gradient drawInRect:self.bounds angle:90.0];
NSColor * topGradient = [NSColor colorWithCalibratedWhite:.0f alpha:1.0];
NSColor * bottomGradient = [NSColor colorWithCalibratedWhite:0.35f alpha:1.0];
NSGradient * gradient = [[NSGradient alloc] initWithColorsAndLocations:bottomGradient, 0.f, topGradient, 0.65f, topGradient, 1.f, nil];
[gradient drawInRect:self.bounds angle:100.0];
}
#pragma mark -
/* Event handling */
- (BOOL)acceptsFirstResponder
......@@ -218,10 +359,32 @@
- (void)mouseDown:(NSEvent *)theEvent
{
if([theEvent clickCount] != 2)
if([theEvent clickCount] == 1)
{
NSRect rect1 = [self bounds];
NSRect rect2 = [self bounds];
rect1.origin.x += [self bounds].size.width * 4./5.;
rect1.size.width /= 5.;
rect2.size.width /= 5.;
if(NSPointInRect([self convertPoint:[theEvent locationInWindow] fromView:nil], rect1))
{
[mainWindowController.mediaArrayController selectNext:self];
}
else if(NSPointInRect([self convertPoint:[theEvent locationInWindow] fromView:nil], rect2))
{
[mainWindowController.mediaArrayController selectPrevious:self];
}
return;
self.fullScreen = !self.fullScreen;
}
if([theEvent clickCount] == 2)
{
[mainWindowController mediaListViewItemDoubleClicked:self];
return;
}
if([theEvent clickCount] == 3)
{
self.fullScreen = !self.fullScreen;
}
}
- (void)keyDown:(NSEvent *)theEvent
......@@ -237,7 +400,7 @@
else
[self hideMenu];
}
else if(!menuDisplayed)
else if(!menuDisplayed && [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == NSRightArrowFunctionKey)
{
[self displayMenu];
}
......@@ -264,9 +427,11 @@
@end
#pragma mark -
/******************************************************************************
* VLCBrowsableVideoView (Private)
*/
@implementation VLCBrowsableVideoView (Private)
+ (CAScrollLayer *)menuLayer
{
......@@ -490,6 +655,8 @@
@end
#pragma mark -
@implementation VLCBrowsableVideoView (FullScreenTransition)
- (void)enterFullScreen:(NSScreen *)screen
......
......@@ -52,6 +52,9 @@
VLCURLToRepresentedFileNameTransformer *urlToRepresentedFileName;
urlToRepresentedFileName = [[[VLCURLToRepresentedFileNameTransformer alloc] init] autorelease];
[NSValueTransformer setValueTransformer:(id)urlToRepresentedFileName forName:@"URLToRepresentedFileNameTransformer"];
VLCSelectionIndexToDescriptionTransformer *indexToDescription;
indexToDescription = [[[VLCSelectionIndexToDescriptionTransformer alloc] init] autorelease];
[NSValueTransformer setValueTransformer:(id)indexToDescription forName:@"SelectionIndexToDescriptionTransformer"];
/***********************************
* categories: Main content
......@@ -59,17 +62,8 @@
NSArray * mediaDiscoverers = [NSArray arrayWithObjects:
[[[VLCMediaDiscoverer alloc] initWithName:@"shoutcasttv"] autorelease],
[[[VLCMediaDiscoverer alloc] initWithName:@"shoutcast"] autorelease],
[[[VLCMediaDiscoverer alloc] initWithName:@"sap"] autorelease], nil];
NSArray * playlists = [NSMutableArray arrayWithObjects:[VLCMedia mediaAsNodeWithName:@"Default Playlist"], nil];
NSDictionary * playlistsAsDictionary = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[@"Playlists" uppercaseString], @"descriptionInCategoriesList",
@"Playlists", @"descriptionInVideoView",
[NSNumber numberWithBool:NO], @"selectableInCategoriesList",
playlists, @"childrenInCategoriesList",
playlists, @"childrenInVideoView",
nil];
[[[VLCMediaDiscoverer alloc] initWithName:@"sap"] autorelease],
[[[VLCMediaDiscoverer alloc] initWithName:@"freebox"] autorelease], nil];
self.categories = [NSArray arrayWithObjects:
[NSMutableDictionary dictionaryWithObjectsAndKeys:
......@@ -79,7 +73,7 @@
mediaDiscoverers, @"childrenInCategoriesList",
mediaDiscoverers, @"childrenInVideoView",
nil],
playlistsAsDictionary,
[VLCMedia mediaAsNodeWithName:@"Playlist"],
nil];
/* Execution will continue in applicationDidFinishLaunching */
......
......@@ -46,11 +46,15 @@
- (BOOL)exceptionHandler:(NSExceptionHandler *)sender shouldLogException:(NSException *)exception mask:(unsigned int)aMask
{
[self printStackTrace:exception];
NSRunCriticalAlertPanel(@"Exception not handled!",
NSLog(@"*** Exception Handled! %@: %@", [exception name], [exception reason]);
int ret = NSRunCriticalAlertPanel(@"Exception not handled!",
[NSString stringWithFormat:@"%@: %@\n\nBack trace has been printed to Console.\n\nWe will now wait for debugger connection...\n",
[exception name], [exception reason]],
@"Wait Debugger", nil, nil);
NSLog(@"*** Exception Handled! %@: %@", [exception name], [exception reason]);
@"Quit", @"Wait Debugger", nil);
if( ret == NSOKButton )
{
[NSApp terminate:self];
}
return YES;
}
......
......@@ -26,7 +26,7 @@
#import <Cocoa/Cocoa.h>
#import <VLCKit/VLCKit.h>
#import "VLCAppAdditions.h"
#import "VLCMainWindow.h"
#import "VLCMainWindowController.h"
@interface VLCFullScreenControllerWindow : NSPanel
......@@ -49,7 +49,7 @@
BOOL active;
/* Owner */
IBOutlet VLCMainWindow * mainWindow;
IBOutlet VLCMainWindowController * mainWindowController;
/* Draging the window using its content */
NSPoint mouseClic;
......
......@@ -82,10 +82,10 @@
hideWindowTimer = nil;
/* WindowView setup */
[[mainWindow.videoView window] setAcceptsMouseMovedEvents:YES];
[[mainWindow.videoView window] makeFirstResponder:mainWindow.videoView];
[mainWindow.videoView setPostsBoundsChangedNotifications: YES];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoViewDidChangeBounds:) name:NSViewBoundsDidChangeNotification object:(id)mainWindow.videoView];
[[mainWindowController.videoView window] setAcceptsMouseMovedEvents:YES];
[[mainWindowController.videoView window] makeFirstResponder:mainWindowController.videoView];
[mainWindowController.videoView setPostsBoundsChangedNotifications: YES];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoViewDidChangeBounds:) name:NSViewBoundsDidChangeNotification object:(id)mainWindowController.videoView];
/* Make sure we can know when the mouse is inside us */
[[self contentView] addTrackingRect:[[self contentView] bounds] owner:self userData:nil assumeInside:NO];
......@@ -102,35 +102,35 @@
[mediaPositionSlider setBackgroundImage:[NSImage imageNamed:@"fs_time_slider.png"]];
[mediaPositionSlider setNeedsDisplay:YES];
[mediaPositionSlider bind:@"enabled" toObject:mainWindow.mediaPlayer withKeyPath:@"media" options: [NSDictionary dictionaryWithObject:@"NonNilAsBoolTransformer" forKey:NSValueTransformerNameBindingOption]];
[mediaPositionSlider bind:@"enabled2" toObject:mainWindow.mediaPlayer withKeyPath:@"seekable" options: nil];
[mediaPositionSlider bind:@"enabled" toObject:mainWindowController.mediaPlayer withKeyPath:@"media" options: [NSDictionary dictionaryWithObject:@"NonNilAsBoolTransformer" forKey:NSValueTransformerNameBindingOption]];
[mediaPositionSlider bind:@"enabled2" toObject:mainWindowController.mediaPlayer withKeyPath:@"seekable" options: nil];
[mediaPositionSlider bind:@"value" toObject:mainWindow.mediaPlayer withKeyPath:@"position" options:
[mediaPositionSlider bind:@"value" toObject:mainWindowController.mediaPlayer withKeyPath:@"position" options:
[NSDictionary dictionaryWithObjectsAndKeys:@"Float10000FoldTransformer", NSValueTransformerNameBindingOption,
[NSNumber numberWithBool:NO], NSConditionallySetsEnabledBindingOption, nil ]];
[fillScreenButton bind:@"value" toObject:mainWindow.videoView withKeyPath:@"fillScreen" options: nil];
[fullScreenButton bind:@"value" toObject:mainWindow.videoView withKeyPath:@"fullScreen" options: nil];
[fillScreenButton bind:@"value" toObject:mainWindowController.videoView withKeyPath:@"videoLayer.fillScreen" options: nil];
[fullScreenButton bind:@"value" toObject:mainWindowController.videoView withKeyPath:@"fullScreen" options: nil];
[mediaReadingProgressText bind:@"value" toObject:mainWindow.mediaPlayer withKeyPath:@"time.stringValue" options: nil];
[mediaDescriptionText bind:@"value" toObject:mainWindow.mediaPlayer withKeyPath:@"description" options: nil];
[mediaReadingProgressText bind:@"value" toObject:mainWindowController.mediaPlayer withKeyPath:@"time.stringValue" options: nil];
[mediaDescriptionText bind:@"value" toObject:mainWindowController.mediaPlayer withKeyPath:@"description" options: nil];
/* mediaPlayer */
[mediaPlayerPlayPauseStopButton bind:@"enabled" toObject:mainWindow.mediaPlayer withKeyPath:@"media" options: [NSDictionary dictionaryWithObject:@"NonNilAsBoolTransformer" forKey:NSValueTransformerNameBindingOption]];
[mediaPlayerPlayPauseStopButton bind:@"state" toObject:mainWindow.mediaPlayer withKeyPath:@"playing" options: nil];
[mediaPlayerPlayPauseStopButton bind:@"alternateImage" toObject:mainWindow.mediaPlayer withKeyPath:@"stateAsFullScreenButtonAlternateImage" options: nil];
[mediaPlayerPlayPauseStopButton bind:@"image" toObject:mainWindow.mediaPlayer withKeyPath:@"stateAsFullScreenButtonImage" options: nil];
[mediaPlayerBackwardPrevButton bind:@"enabled" toObject:mainWindow.mediaPlayer withKeyPath:@"playing" options: nil];
[mediaPlayerForwardNextButton bind:@"enabled" toObject:mainWindow.mediaPlayer withKeyPath:@"playing" options: nil];
[mediaPlayerForwardNextButton setTarget:mainWindow.mediaPlayer];
/* mainWindowController.mediaPlayer */
[mediaPlayerPlayPauseStopButton bind:@"enabled" toObject:mainWindowController.mediaPlayer withKeyPath:@"media" options: [NSDictionary dictionaryWithObject:@"NonNilAsBoolTransformer" forKey:NSValueTransformerNameBindingOption]];
[mediaPlayerPlayPauseStopButton bind:@"state" toObject:mainWindowController.mediaPlayer withKeyPath:@"playing" options: nil];
[mediaPlayerPlayPauseStopButton bind:@"alternateImage" toObject:mainWindowController.mediaPlayer withKeyPath:@"stateAsFullScreenButtonAlternateImage" options: nil];
[mediaPlayerPlayPauseStopButton bind:@"image" toObject:mainWindowController.mediaPlayer withKeyPath:@"stateAsFullScreenButtonImage" options: nil];
[mediaPlayerBackwardPrevButton bind:@"enabled" toObject:mainWindowController.mediaPlayer withKeyPath:@"playing" options: nil];
[mediaPlayerForwardNextButton bind:@"enabled" toObject:mainWindowController.mediaPlayer withKeyPath:@"playing" options: nil];
[mediaPlayerForwardNextButton setTarget:mainWindowController.mediaPlayer];
[mediaPlayerForwardNextButton setAction:@selector(fastForward)];
[mediaPlayerBackwardPrevButton setTarget:mainWindow.mediaPlayer];
[mediaPlayerBackwardPrevButton setTarget:mainWindowController.mediaPlayer];
[mediaPlayerBackwardPrevButton setAction:@selector(rewind)];
[mediaPlayerPlayPauseStopButton setTarget:mainWindow.mediaPlayer];
[mediaPlayerPlayPauseStopButton setTarget:mainWindowController.mediaPlayer];
[mediaPlayerPlayPauseStopButton setAction:@selector(pause)];
[self bind:@"fullScreen" toObject:mainWindow.videoView withKeyPath:@"fullScreen" options: nil];
[self bind:@"fullScreen" toObject:mainWindowController.videoView withKeyPath:@"fullScreen" options: nil];
active = NO;
}
......@@ -208,7 +208,7 @@
- (void)updateTrackingRect
{
VLCVideoView * videoView = mainWindow.videoView;
VLCBrowsableVideoView * videoView = mainWindowController.videoView;
if( videoViewTrackingArea )
{
......
......@@ -23,60 +23,8 @@
*****************************************************************************/
#import <Cocoa/Cocoa.h>
#import "VLCController.h"
#import "VLCMediaArrayController.h"
#import "VLCAppAdditions.h"
#import "VLCBrowsableVideoView.h"
@interface VLCMainWindow : NSWindow {
/* IB elements */
IBOutlet id mediaListItemFetchedStatus;
IBOutlet id mediaListItemsCount;
IBOutlet id mediaListSearchField;
IBOutlet NSOutlineView * categoriesListView;
IBOutlet NSTableView * mediaListView;
IBOutlet VLCBrowsableVideoView * videoView;
IBOutlet id fillScreenButton;
IBOutlet id fullScreenButton;
IBOutlet NSSlider * mediaReadingProgressSlider;
IBOutlet NSTextField * mediaReadingProgressText;
IBOutlet NSTextField * mediaDescriptionText;
IBOutlet NSSlider * mediaSoundVolume;
IBOutlet NSButton * mediaPlayerForwardNextButton;
IBOutlet NSButton * mediaPlayerBackwardPrevButton;
IBOutlet NSButton * mediaPlayerPlayPauseStopButton;
IBOutlet id navigatorViewToggleButton;
IBOutlet VLCOneSplitView * mainSplitView;
IBOutlet NSView * navigatorView;
IBOutlet NSView * videoPlayerAndControlView;
IBOutlet NSView * controlView;
IBOutlet NSButton * addPlaylistButton;
IBOutlet NSButton * removePlaylistButton;
/* Toolbar */
IBOutlet NSView * toolbarMediaAudioVolume;
IBOutlet NSView * toolbarMediaDescription;
IBOutlet NSView * toolbarMediaControl;
IBOutlet VLCMediaPlayer * mediaPlayer;
IBOutlet VLCController * controller; /* This is a VLCController binded to the File's Owner of the nib */
/* Controllers */
NSTreeController * categoriesTreeController;
VLCMediaArrayController * mediaArrayController;
/* Window state */
CGFloat navigatorHeight;
}
@property BOOL navigatorViewVisible;
@property (readonly) VLCMediaPlayer * mediaPlayer;
@property (readonly) VLCBrowsableVideoView * videoView;
@end
/*****************************************************************************
* VLCMainWindowController.h: VLCMainWindowController implementation
*****************************************************************************
* Copyright (C) 2007 Pierre d'Herbemont
* Copyright (C) 2007 the VideoLAN team
* $Id: VLCMainWindow.h 24209 2008-01-09 22:05:17Z 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 "VLCController.h"
#import "VLCMediaArrayController.h"
#import "VLCAppAdditions.h"
#import "VLCBrowsableVideoView.h"
#import "VLCMainWindow.h"
@interface VLCMainWindowController : NSWindowController
{
IBOutlet VLCOneSplitView * mainSplitView;
/* Media List */
IBOutlet NSTableView * mediaListView;
/* Categories List */
IBOutlet NSOutlineView * categoriesListView;
IBOutlet NSButton * addPlaylistButton;
IBOutlet NSButton * removePlaylistButton;
/* Toolbar control buttons */
IBOutlet NSButton * mediaPlayerForwardNextButton;
IBOutlet NSButton * mediaPlayerBackwardPrevButton;
IBOutlet NSButton * mediaPlayerPlayPauseStopButton;
/* Toolbar */
IBOutlet NSView * toolbarMediaAudioVolume;
IBOutlet NSView * toolbarMediaDescription;
IBOutlet NSView * toolbarMediaControl;
/* Video */
IBOutlet VLCBrowsableVideoView * videoView;
/* Controllers */
IBOutlet NSTreeController * categoriesTreeController;
IBOutlet VLCMediaArrayController * mediaArrayController;
IBOutlet VLCMediaPlayer * mediaPlayer;
IBOutlet VLCController * controller; /* This is a VLCController binded to the File's Owner of the nib */
/* States */
float navigatorViewWidth;
}
@property BOOL navigatorViewVisible;
- (void)setNavigatorViewVisible:(BOOL)wantsVisible animate:(BOOL)animate;
@property (readonly) VLCMediaPlayer * mediaPlayer;
@property (readonly) VLCBrowsableVideoView * videoView;
@property (readonly) VLCMediaArrayController * mediaArrayController;
- (IBAction)mediaListViewItemDoubleClicked:(id)sender;
- (void)videoViewItemClicked:(id)sender;
@end
This diff is collapsed.
......@@ -62,6 +62,9 @@
NSArray *droppedItems = [[info draggingPasteboard] propertyListForType:NSFilenamesPboardType];
if( !droppedItems )
droppedItems = [[info draggingPasteboard] propertyListForType:NSURLPboardType];
NSAssert( contentMediaList, @"No contentMediaList" );
for (i = 0; i < [droppedItems count]; i++)
{
NSString * filename = [droppedItems objectAtIndex:i];
......
//
// VLCMediaLayer.h
// VLC
//
// Created by Pierre d'Herbemont on 1/14/08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import <QuartzCore/QuartzCore.h>
#import <VLCKit/VLCKit.h>
@interface VLCMediaLayer : CALayer {
BOOL displayFullInformation;
VLCMedia * media;
CATextLayer * titleLayer;
CATextLayer * artistLayer;
CATextLayer * genreLayer;
CALayer * artworkLayer;
}
+ (id)layerWithMedia:(VLCMedia *)media;
@property (assign) BOOL displayFullInformation;
@property (retain,readonly) VLCMedia * media;
@property (retain,readonly) CATextLayer * titleLayer;
@property (retain,readonly) CATextLayer * artistLayer;
@property (retain,readonly) CATextLayer * genreLayer;
@property (retain,readonly) CALayer * artworkLayer;
@end
This diff is collapsed.
//
// VLCMediaListLayer.h
// VLC
//
// Created by Pierre d'Herbemont on 1/14/08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import <QuartzCore/QuartzCore.h>
#import <VLCKit/VLCKit.h>
#import "VLCMediaLayer.h"
#import "VLCMediaArrayController.h"
@interface VLCMediaListLayer : CALayer {
NSArray * content;
NSUInteger selectedIndex;
VLCMediaLayer * previousLayer;
VLCMediaLayer * selectedLayer;
VLCMediaLayer * nextLayer;
VLCMediaArrayController * controller;
}
+ (id)layer;
+ (id)layerWithMediaArrayController:(VLCMediaArrayController *)aController;
@property (retain,readwrite) NSArray * content;
@property (readwrite) NSUInteger selectedIndex;
@property (retain,readwrite) VLCMediaArrayController * controller;
@end
This diff is collapsed.
......@@ -36,3 +36,7 @@
}
@end
@interface VLCSelectionIndexToDescriptionTransformer : NSValueTransformer {
}
@end
......@@ -93,3 +93,25 @@
@end
@implementation VLCSelectionIndexToDescriptionTransformer
+ (Class)transformedValueClass
{
return [NSNumber class];
}
+ (BOOL)allowsReverseTransformation
{
return NO;
}
- (NSString *)transformedValue:(id)value
{
if( ![value isKindOfClass:[NSNumber class]])
return @"";
return [value intValue] == NSNotFound ? @"" : [NSString stringWithFormat:@"%@ of ", value];
}
@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