Commit 740370c5 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: move re-useable code from VLCControls to a custom class

this also prepares a mainwindow object and includes some clean-up
parent d8549ccd
......@@ -12,12 +12,12 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="283"/>
<integer value="24"/>
<integer value="915"/>
<integer value="2417"/>
<integer value="2730"/>
<integer value="2"/>
<integer value="283"/>
<integer value="2417"/>
<integer value="915"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
......@@ -828,6 +828,7 @@
</object>
<string key="NSFrame">{{1, 17}, {604, 231}}</string>
<reference key="NSSuperview" ref="915491793"/>
<reference key="NSNextKeyView" ref="23448837"/>
<reference key="NSDocView" ref="23448837"/>
<reference key="NSBGColor" ref="885475112"/>
<int key="NScvFlags">4</int>
......@@ -860,6 +861,7 @@
</object>
<string key="NSFrame">{{1, 0}, {604, 17}}</string>
<reference key="NSSuperview" ref="915491793"/>
<reference key="NSNextKeyView" ref="823165105"/>
<reference key="NSDocView" ref="823165105"/>
<reference key="NSBGColor" ref="885475112"/>
<int key="NScvFlags">4</int>
......@@ -867,6 +869,7 @@
</object>
<string key="NSFrame">{{-1, 36}, {606, 249}}</string>
<reference key="NSSuperview" ref="429932428"/>
<reference key="NSNextKeyView" ref="343242432"/>
<int key="NSsFlags">133682</int>
<reference key="NSVScroller" ref="573737110"/>
<reference key="NSHScroller" ref="297523533"/>
......@@ -5018,14 +5021,6 @@ LCAuLi4</string>
</object>
<int key="connectionID">2759</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">o_fs_panel</string>
<reference key="source" ref="113811151"/>
<reference key="destination" ref="662599125"/>
</object>
<int key="connectionID">2786</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">o_btn_shuffle</string>
......@@ -6802,6 +6797,14 @@ LCAuLi4</string>
</object>
<int key="connectionID">4594</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">o_fs_panel</string>
<reference key="source" ref="113811151"/>
<reference key="destination" ref="662599125"/>
</object>
<int key="connectionID">4595</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
......@@ -10273,9 +10276,9 @@ LCAuLi4</string>
<string>{{473, 633}, {137, 103}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES"/>
<string>{{71, 176}, {604, 310}}</string>
<string>{{329, 176}, {604, 310}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{71, 176}, {604, 310}}</string>
<string>{{329, 176}, {604, 310}}</string>
<boolean value="YES"/>
<boolean value="YES"/>
<boolean value="YES"/>
......@@ -10885,7 +10888,7 @@ LCAuLi4</string>
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">4594</int>
<int key="maxID">4595</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.1+">
......@@ -11174,6 +11177,7 @@ LCAuLi4</string>
<bool key="EncodedWithXMLCoder">YES</bool>
<string>o_btn_repeat</string>
<string>o_btn_shuffle</string>
<string>o_fs_panel</string>
<string>o_main</string>
<string>o_specificTime_cancel_btn</string>
<string>o_specificTime_enter_fld</string>
......@@ -11189,6 +11193,7 @@ LCAuLi4</string>
<bool key="EncodedWithXMLCoder">YES</bool>
<string>id</string>
<string>id</string>
<string>VLCFSPanel</string>
<string>id</string>
<string>id</string>
<string>id</string>
......@@ -11207,6 +11212,7 @@ LCAuLi4</string>
<bool key="EncodedWithXMLCoder">YES</bool>
<string>o_btn_repeat</string>
<string>o_btn_shuffle</string>
<string>o_fs_panel</string>
<string>o_main</string>
<string>o_specificTime_cancel_btn</string>
<string>o_specificTime_enter_fld</string>
......@@ -11228,6 +11234,10 @@ LCAuLi4</string>
<string key="name">o_btn_shuffle</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">o_fs_panel</string>
<string key="candidateClassName">VLCFSPanel</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">o_main</string>
<string key="candidateClassName">id</string>
......@@ -11270,11 +11280,19 @@ LCAuLi4</string>
</object>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier" id="361672446">
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBDocumentRelativeSource</string>
<string key="minorKey">../../../../../modules/gui/macosx/controls.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">VLCFSPanel</string>
<string key="superclassName">NSWindow</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBDocumentRelativeSource</string>
<string key="minorKey">../../../../../modules/gui/macosx/fspanel.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">VLCMain</string>
<string key="superclassName">NSObject</string>
......@@ -11368,6 +11386,7 @@ LCAuLi4</string>
<string>o_btn_stop</string>
<string>o_controls</string>
<string>o_coredialogs</string>
<string>o_coreinteraction</string>
<string>o_crashrep_desc_txt</string>
<string>o_crashrep_dontSend_btn</string>
<string>o_crashrep_fld</string>
......@@ -11410,6 +11429,7 @@ LCAuLi4</string>
<string>NSButton</string>
<string>VLCControls</string>
<string>id</string>
<string>id</string>
<string>NSTextField</string>
<string>NSButton</string>
<string>NSTextView</string>
......@@ -11455,6 +11475,7 @@ LCAuLi4</string>
<string>o_btn_stop</string>
<string>o_controls</string>
<string>o_coredialogs</string>
<string>o_coreinteraction</string>
<string>o_crashrep_desc_txt</string>
<string>o_crashrep_dontSend_btn</string>
<string>o_crashrep_fld</string>
......@@ -11533,6 +11554,10 @@ LCAuLi4</string>
<string key="name">o_coredialogs</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">o_coreinteraction</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">o_crashrep_desc_txt</string>
<string key="candidateClassName">NSTextField</string>
......@@ -13178,7 +13203,7 @@ LCAuLi4</string>
<object class="IBPartialClassDescription">
<string key="className">VLCTimeField</string>
<string key="superclassName">NSTextField</string>
<reference key="sourceIdentifier" ref="361672446"/>
<reference key="sourceIdentifier" ref="690328904"/>
</object>
</object>
</object>
......
......@@ -420,6 +420,10 @@
CC426FD01020D44F00A32659 /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Sparkle.framework; path = ../../contrib/Sparkle/Sparkle.framework; sourceTree = SOURCE_ROOT; };
CC448A5A13B61D49009F72E0 /* MainMenu.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = MainMenu.h; path = ../../../modules/gui/macosx/MainMenu.h; sourceTree = "<group>"; };
CC448A5B13B61D49009F72E0 /* MainMenu.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = MainMenu.m; path = ../../../modules/gui/macosx/MainMenu.m; sourceTree = "<group>"; };
CC448A6013B68A0B009F72E0 /* CoreInteraction.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CoreInteraction.h; path = ../../../modules/gui/macosx/CoreInteraction.h; sourceTree = "<group>"; };
CC448A6113B68A0B009F72E0 /* CoreInteraction.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = CoreInteraction.m; path = ../../../modules/gui/macosx/CoreInteraction.m; sourceTree = "<group>"; };
CC448A6213B68A0B009F72E0 /* MainWindow.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = MainWindow.h; path = ../../../modules/gui/macosx/MainWindow.h; sourceTree = "<group>"; };
CC448A6313B68A0B009F72E0 /* MainWindow.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = MainWindow.m; path = ../../../modules/gui/macosx/MainWindow.m; sourceTree = "<group>"; };
CC4A33210F8CB017000FC4A7 /* coredialogs.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = coredialogs.m; path = ../../../modules/gui/macosx/coredialogs.m; sourceTree = SOURCE_ROOT; };
CC4A33220F8CB017000FC4A7 /* coredialogs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = coredialogs.h; path = ../../../modules/gui/macosx/coredialogs.h; sourceTree = SOURCE_ROOT; };
CC4D67F51348F587003FCC5B /* quartztext.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = quartztext.c; path = ../../../modules/misc/text_renderer/quartztext.c; sourceTree = "<group>"; };
......@@ -564,6 +568,10 @@
8ED6C27D03E2EB1C0059A3A7 /* intf.m */,
CC448A5A13B61D49009F72E0 /* MainMenu.h */,
CC448A5B13B61D49009F72E0 /* MainMenu.m */,
CC448A6013B68A0B009F72E0 /* CoreInteraction.h */,
CC448A6113B68A0B009F72E0 /* CoreInteraction.m */,
CC448A6213B68A0B009F72E0 /* MainWindow.h */,
CC448A6313B68A0B009F72E0 /* MainWindow.m */,
CC4A33220F8CB017000FC4A7 /* coredialogs.h */,
CC4A33210F8CB017000FC4A7 /* coredialogs.m */,
8E6BC6FA041684EC0059A3A7 /* controls.h */,
......
/*****************************************************************************
* CoreInteraction.h: MacOS X interface module
*****************************************************************************
* Copyright (C) 2011 Felix Paul Kühne
* $Id$
*
* Authors: Felix Paul 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 <vlc_common.h>
#import <vlc_interface.h>
@interface VLCCoreInteraction : NSObject {
intf_thread_t * p_intf;
BOOL b_lockAspectRatio;
}
+ (VLCCoreInteraction *)sharedInstance;
- (void)play;
- (void)stop;
- (void)faster;
- (void)slower;
- (void)normalSpeed;
- (void)next;
- (void)previous;
- (void)forward;
- (void)backward;
- (void)repeatOne;
- (void)repeatAll;
- (void)repeatOff;
- (void)shuffle;
- (void)volumeUp;
- (void)volumeDown;
- (void)mute;
- (void)setVolume: (int)i_value;
- (void)setAspectRatioLocked:(BOOL)b_value;
- (BOOL)aspectRatioIsLocked;
- (void)toggleFullscreen;
- (id)voutView;
@end
/*****************************************************************************
* CoreInteraction.m: MacOS X interface module
*****************************************************************************
* Copyright (C) 2011 Felix Paul Kühne
* $Id$
*
* Authors: Felix Paul 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 "CoreInteraction.h"
#import "intf.h"
#import "vout.h"
#import "open.h"
#import <vlc_playlist.h>
#import <vlc_input.h>
#import <vlc_keys.h>
#import <vlc_osd.h>
@implementation VLCCoreInteraction
static VLCCoreInteraction *_o_sharedInstance = nil;
+ (VLCCoreInteraction *)sharedInstance
{
return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
}
#pragma mark -
#pragma mark Initialization
- (id)init
{
if( _o_sharedInstance)
{
[self dealloc];
return _o_sharedInstance;
}
else
{
_o_sharedInstance = [super init];
b_lockAspectRatio = YES;
}
return _o_sharedInstance;
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver: self];
[super dealloc];
}
- (void)awakeFromNib
{
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(applicationWillFinishLaunching:)
name: NSApplicationWillFinishLaunchingNotification
object: nil];
}
- (void)applicationWillFinishLaunching:(NSNotification *)o_notification
{
p_intf = VLCIntf;
}
#pragma mark -
#pragma mark Playback Controls
- (void)play
{
playlist_t * p_playlist = pl_Get( p_intf );
bool empty;
PL_LOCK;
empty = playlist_IsEmpty( p_playlist );
PL_UNLOCK;
if( empty )
[[[VLCMain sharedInstance] open] openFileGeneric];
var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_PLAY_PAUSE );
}
- (void)stop
{
var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_STOP );
/* Close the window directly, because we do know that there
* won't be anymore video. It's currently waiting a bit. */
[[[self voutView] window] orderOut:self];
}
- (void)faster
{
var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_FASTER );
}
- (void)slower
{
var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_SLOWER );
}
- (void)normalSpeed
{
var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_RATE_NORMAL );
}
- (void)previous
{
var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_PREV );
}
- (void)next
{
var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_NEXT );
}
- (void)forward
{
var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_JUMP_FORWARD_SHORT );
}
- (void)backward
{
var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_JUMP_BACKWARD_SHORT );
}
- (void)shuffle
{
vlc_value_t val;
playlist_t * p_playlist = pl_Get( p_intf );
var_Get( p_playlist, "random", &val );
val.b_bool = !val.b_bool;
var_Set( p_playlist, "random", val );
if( val.b_bool )
{
//vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Random On" ) );
config_PutInt( p_playlist, "random", 1 );
}
else
{
//vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Random Off" ) );
config_PutInt( p_playlist, "random", 0 );
}
p_intf->p_sys->b_playmode_update = true;
p_intf->p_sys->b_intf_update = true;
}
- (void)repeatAll
{
playlist_t * p_playlist = pl_Get( p_intf );
var_SetBool( p_playlist, "repeat", NO );
var_SetBool( p_playlist, "loop", YES );
config_PutInt( p_playlist, "repeat", NO );
config_PutInt( p_playlist, "loop", YES );
//vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Repeat All" ) );
p_intf->p_sys->b_playmode_update = true;
p_intf->p_sys->b_intf_update = true;
}
- (void)repeatOne
{
playlist_t * p_playlist = pl_Get( p_intf );
var_SetBool( p_playlist, "repeat", YES );
var_SetBool( p_playlist, "loop", NO );
config_PutInt( p_playlist, "repeat", YES );
config_PutInt( p_playlist, "loop", NO );
//vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Repeat One" ) );
p_intf->p_sys->b_playmode_update = true;
p_intf->p_sys->b_intf_update = true;
}
- (void)repeatOff
{
playlist_t * p_playlist = pl_Get( p_intf );
var_SetBool( p_playlist, "repeat", NO );
var_SetBool( p_playlist, "loop", NO );
config_PutInt( p_playlist, "repeat", NO );
config_PutInt( p_playlist, "loop", NO );
//vout_OSDMessage( p_intf, SPU_DEFAULT_CHANNEL, "%s", _( "Repeat Off" ) );
p_intf->p_sys->b_playmode_update = true;
p_intf->p_sys->b_intf_update = true;
}
// CAVE: [o_main manageVolumeSlider]
- (void)volumeUp
{
var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_VOL_UP );
}
- (void)volumeDown
{
var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_VOL_DOWN );
}
- (void)mute
{
var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_VOL_MUTE );
}
- (void)setVolume: (int)i_value
{
playlist_t * p_playlist = pl_Get( p_intf );
int i_volume_step = config_GetInt( p_intf->p_libvlc, "volume-step" );
aout_VolumeSet( p_playlist, i_value * i_volume_step );
}
#pragma mark -
#pragma mark video output stuff
- (void)setAspectRatioLocked:(BOOL)b_value
{
b_lockAspectRatio = b_value;
}
- (BOOL)aspectRatioIsLocked
{
return b_lockAspectRatio;
}
- (void)toggleFullscreen
{
input_thread_t * p_input = pl_CurrentInput( VLCIntf );
if( p_input != NULL )
{
vout_thread_t *p_vout = input_GetVout( p_input );
if( p_vout != NULL )
{
id o_vout_view = [self voutView];
if( o_vout_view )
[o_vout_view toggleFullscreen];
vlc_object_release( p_vout );
}
else
{
playlist_t * p_playlist = pl_Get( VLCIntf );
var_ToggleBool( p_playlist, "fullscreen" );
}
vlc_object_release( p_input );
}
}
- (id)voutView
{
id o_window;
id o_voutView = nil;
id o_embeddedViewList = [[VLCMain sharedInstance] embeddedList];
NSEnumerator *o_enumerator = [[NSApp orderedWindows] objectEnumerator];
while( !o_voutView && ( o_window = [o_enumerator nextObject] ) )
{
/* We have an embedded vout */
if( [o_embeddedViewList windowContainsEmbedded: o_window] )
{
o_voutView = [o_embeddedViewList viewForWindow: o_window];
}
/* We have a detached vout */
else if( [[o_window className] isEqualToString: @"VLCVoutWindow"] )
{
o_voutView = [o_window voutView];
}
}
return [[o_voutView retain] autorelease];
}
@end
......@@ -38,6 +38,7 @@
#import "controls.h"
#import "playlistinfo.h"
#import "vout.h"
#import "CoreInteraction.h"
@implementation VLCMainMenu
static VLCMainMenu *_o_sharedInstance = nil;
......@@ -789,7 +790,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
o_lmi_tmp2 = [o_menu addItemWithTitle: _NS("Lock Aspect Ratio") action: @selector(lockVideosAspectRatio:) keyEquivalent: @""];
[o_lmi_tmp2 setTarget: self];
[o_lmi_tmp2 setEnabled: YES];
[o_lmi_tmp2 setState: [[[VLCMain sharedInstance] controls] aspectRatioIsLocked]];
[o_lmi_tmp2 setState: [[VLCCoreInteraction sharedInstance] aspectRatioIsLocked]];
[o_parent setEnabled: YES];
[o_menu addItem: [NSMenuItem separatorItem]];
}
......
/*****************************************************************************
* MainWindow.h: MacOS X interface module
*****************************************************************************
* Copyright (C) 2011 Felix Paul Kühne
* $Id$
*
* Authors: Felix Paul 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>
@interface VLCMainWindow : NSObject {
}
@end
\ No newline at end of file
/*****************************************************************************