[vlc-commits] macosx: Convert VLCVideoEffects to NSWindowController subclass
David Fuhrmann
git at videolan.org
Sun Aug 2 13:26:38 CEST 2015
vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Sun Aug 2 13:22:53 2015 +0200| [7b66b72d7321bb68ab8056735ea1f2b78e9bd83f] | committer: David Fuhrmann
macosx: Convert VLCVideoEffects to NSWindowController subclass
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7b66b72d7321bb68ab8056735ea1f2b78e9bd83f
---
modules/gui/macosx/MainMenu.m | 10 +-----
modules/gui/macosx/VLCVoutWindowController.m | 2 +-
modules/gui/macosx/VideoEffects.h | 4 +--
modules/gui/macosx/VideoEffects.m | 44 ++++++++++----------------
modules/gui/macosx/intf.h | 2 ++
modules/gui/macosx/intf.m | 11 ++++++-
6 files changed, 32 insertions(+), 41 deletions(-)
diff --git a/modules/gui/macosx/MainMenu.m b/modules/gui/macosx/MainMenu.m
index 1727e4b..d3f1893 100644
--- a/modules/gui/macosx/MainMenu.m
+++ b/modules/gui/macosx/MainMenu.m
@@ -53,13 +53,11 @@
@interface VLCMainMenu()
{
- BOOL b_nib_videoeffects_loaded;
BOOL b_nib_bookmarks_loaded;
BOOL b_nib_convertandsave_loaded;
AboutWindowController *_aboutWindowController;
HelpWindowController *_helpWindowController;
- VLCVideoEffects *_videoEffectsWindowController;
VLCConvertAndSave *_convertAndSaveWindowController;
AddonsWindowController *_addonsController;
@@ -1279,13 +1277,7 @@
- (IBAction)showVideoEffects:(id)sender
{
- if (_videoEffectsWindowController == nil)
- _videoEffectsWindowController = [[VLCVideoEffects alloc] init];
-
- if (!b_nib_videoeffects_loaded)
- b_nib_videoeffects_loaded = [NSBundle loadNibNamed:@"VideoEffects" owner: _videoEffectsWindowController];
-
- [_videoEffectsWindowController toggleWindow:sender];
+ [[[VLCMain sharedInstance] videoEffectsPanel] toggleWindow:sender];
}
- (IBAction)showTrackSynchronization:(id)sender
diff --git a/modules/gui/macosx/VLCVoutWindowController.m b/modules/gui/macosx/VLCVoutWindowController.m
index 9564537..924d72f 100644
--- a/modules/gui/macosx/VLCVoutWindowController.m
+++ b/modules/gui/macosx/VLCVoutWindowController.m
@@ -589,7 +589,7 @@ void WindowClose(vout_window_t *p_wnd)
VLCMain *main = [VLCMain sharedInstance];
[[VLCMainWindow sharedInstance] setWindowLevel:i_level];
- [[VLCVideoEffects sharedInstance] updateCocoaWindowLevel:currentStatusWindowLevel];
+ [[main videoEffectsPanel] updateCocoaWindowLevel:currentStatusWindowLevel];
[[main audioEffectsPanel] updateCocoaWindowLevel:currentStatusWindowLevel];
[[VLCInfo sharedInstance] updateCocoaWindowLevel:currentStatusWindowLevel];
[[main bookmarks] updateCocoaWindowLevel:currentStatusWindowLevel];
diff --git a/modules/gui/macosx/VideoEffects.h b/modules/gui/macosx/VideoEffects.h
index 24af41a..aab1272 100644
--- a/modules/gui/macosx/VideoEffects.h
+++ b/modules/gui/macosx/VideoEffects.h
@@ -23,10 +23,9 @@
#import <Cocoa/Cocoa.h>
- at interface VLCVideoEffects : NSObject
+ at interface VLCVideoEffects : NSWindowController
/* generic */
- at property (readwrite, weak) IBOutlet NSWindow *window;
@property (readwrite, weak) IBOutlet NSTabView *tabView;
@property (readwrite, weak) IBOutlet NSPopUpButton *profilePopup;
@@ -162,7 +161,6 @@
@property (nonatomic) int posterizeValue;
/* generic */
-+ (VLCVideoEffects *)sharedInstance;
- (void)updateCocoaWindowLevel:(NSInteger)i_level;
- (void)saveCurrentProfile;
diff --git a/modules/gui/macosx/VideoEffects.m b/modules/gui/macosx/VideoEffects.m
index 4d8d07c..76dd694 100644
--- a/modules/gui/macosx/VideoEffects.m
+++ b/modules/gui/macosx/VideoEffects.m
@@ -38,18 +38,6 @@
@implementation VLCVideoEffects
-+ (VLCVideoEffects *)sharedInstance
-{
- static VLCVideoEffects *sharedInstance = nil;
- static dispatch_once_t pred;
-
- dispatch_once(&pred, ^{
- sharedInstance = [VLCVideoEffects new];
- });
-
- return sharedInstance;
-}
-
+ (void)initialize
{
NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:[NSArray arrayWithObject:@";;;0;1.000000;1.000000;1.000000;1.000000;0.050000;16;2.000000;OTA=;4;4;16711680;20;15;120;Z3JhZGllbnQ=;1;0;16711680;6;80;VkxD;-1;;-1;255;2;3;3"], @"VideoEffectProfiles",
@@ -59,17 +47,19 @@
- (id)init
{
- self = [super init];
- i_old_profile_index = -1;
+ self = [super initWithWindowNibName:@"VideoEffects"];
+ if (self) {
+ i_old_profile_index = -1;
+ }
return self;
}
-- (void)awakeFromNib
+- (void)windowDidLoad
{
- [_window setTitle: _NS("Video Effects")];
- [_window setExcludedFromWindowsMenu:YES];
- [_window setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary];
+ [self.window setTitle: _NS("Video Effects")];
+ [self.window setExcludedFromWindowsMenu:YES];
+ [self.window setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary];
[[_tabView tabViewItemAtIndex:[_tabView indexOfTabViewItemWithIdentifier:@"basic"]] setLabel:_NS("Basic")];
[[_tabView tabViewItemAtIndex:[_tabView indexOfTabViewItemWithIdentifier:@"crop"]] setLabel:_NS("Crop")];
@@ -217,8 +207,8 @@
- (void)updateCocoaWindowLevel:(NSInteger)i_level
{
- if (_window && [_window isVisible] && [_window level] != i_level)
- [_window setLevel: i_level];
+ if (self.window && [self.window isVisible] && [self.window level] != i_level)
+ [self.window setLevel: i_level];
}
#pragma mark -
@@ -562,11 +552,11 @@
- (IBAction)toggleWindow:(id)sender
{
- if ([_window isKeyWindow])
- [_window orderOut:sender];
+ if ([self.window isKeyWindow])
+ [self.window orderOut:sender];
else {
- [_window setLevel: [[[VLCMain sharedInstance] voutController] currentStatusWindowLevel]];
- [_window makeKeyAndOrderFront:sender];
+ [self.window setLevel: [[[VLCMain sharedInstance] voutController] currentStatusWindowLevel]];
+ [self.window makeKeyAndOrderFront:sender];
}
}
@@ -683,7 +673,7 @@
[panel setOKButtonLabel: _NS("Save")];
[panel setTarget:self];
- [panel runModalForWindow:_window];
+ [panel runModalForWindow:self.window];
}
- (void)panel:(VLCEnterTextPanel *)panel returnValue:(NSUInteger)value text:(NSString *)text
@@ -706,7 +696,7 @@
[alert setMessageText:_NS("Please enter a unique name for the new profile.")];
[alert setInformativeText:_NS("Multiple profiles with the same name are not allowed.")];
- [alert beginSheetModalForWindow:_window
+ [alert beginSheetModalForWindow:self.window
modalDelegate:nil
didEndSelector:nil
contextInfo:nil];
@@ -745,7 +735,7 @@
[panel setPopupButtonContent:[[NSUserDefaults standardUserDefaults] objectForKey:@"VideoEffectProfileNames"]];
[panel setTarget:self];
- [panel runModalForWindow:_window];
+ [panel runModalForWindow:self.window];
}
- (void)panel:(VLCSelectItemInPopupPanel *)panel returnValue:(NSUInteger)value item:(NSUInteger)item
diff --git a/modules/gui/macosx/intf.h b/modules/gui/macosx/intf.h
index 6c436a0..abae889 100644
--- a/modules/gui/macosx/intf.h
+++ b/modules/gui/macosx/intf.h
@@ -67,6 +67,7 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification";
@class VLCDebugMessageVisualizer;
@class VLCTrackSynchronization;
@class VLCAudioEffects;
+ at class VLCVideoEffects;
@interface VLCMain : NSObject <NSWindowDelegate, NSApplicationDelegate>
{
@@ -95,6 +96,7 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification";
- (VLCTrackSynchronization *)trackSyncPanel;
- (VLCAudioEffects *)audioEffectsPanel;
+- (VLCVideoEffects *)videoEffectsPanel;
- (void)setActiveVideoPlayback:(BOOL)b_value;
- (BOOL)activeVideoPlayback;
diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index 8fdc949..c9e87fe 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -157,6 +157,7 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
VLCDebugMessageVisualizer *_messagePanelController;
VLCTrackSynchronization *_trackSyncPanel;
VLCAudioEffects *_audioEffectsPanel;
+ VLCVideoEffects *_videoEffectsPanel;
bool b_intf_terminating; /* Makes sure applicationWillTerminate will be called only once */
}
@@ -344,7 +345,7 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
playlist_t * p_playlist = pl_Get(p_intf);
/* save current video and audio profiles */
- [[VLCVideoEffects sharedInstance] saveCurrentProfile];
+ [[self videoEffectsPanel] saveCurrentProfile];
[[self audioEffectsPanel] saveCurrentProfile];
/* Save some interface state in configuration, at module quit */
@@ -544,6 +545,14 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
return _audioEffectsPanel;
}
+- (VLCVideoEffects *)videoEffectsPanel
+{
+ if (!_videoEffectsPanel)
+ _videoEffectsPanel = [[VLCVideoEffects alloc] init];
+
+ return _videoEffectsPanel;
+}
+
- (VLCBookmarks *)bookmarks
{
if (!_bookmarks)
More information about the vlc-commits
mailing list