macosx: Convert VLCVideoEffects to NSWindowController subclass
authorDavid Fuhrmann <dfuhrmann@videolan.org>
Sun, 2 Aug 2015 11:22:53 +0000 (13:22 +0200)
committerDavid Fuhrmann <dfuhrmann@videolan.org>
Sun, 2 Aug 2015 11:26:19 +0000 (13:26 +0200)
modules/gui/macosx/MainMenu.m
modules/gui/macosx/VLCVoutWindowController.m
modules/gui/macosx/VideoEffects.h
modules/gui/macosx/VideoEffects.m
modules/gui/macosx/intf.h
modules/gui/macosx/intf.m

index 1727e4b..d3f1893 100644 (file)
 
 @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;
 
 
 - (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
index 9564537..924d72f 100644 (file)
@@ -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];
index 24af41a..aab1272 100644 (file)
 
 #import <Cocoa/Cocoa.h>
 
-@interface VLCVideoEffects : NSObject
+@interface VLCVideoEffects : NSWindowController
 
 /* generic */
-@property (readwrite, weak) IBOutlet NSWindow *window;
 @property (readwrite, weak) IBOutlet NSTabView *tabView;
 @property (readwrite, weak) IBOutlet NSPopUpButton *profilePopup;
 
 @property (nonatomic) int posterizeValue;
 
 /* generic */
-+ (VLCVideoEffects *)sharedInstance;
 - (void)updateCocoaWindowLevel:(NSInteger)i_level;
 - (void)saveCurrentProfile;
 
index 4d8d07c..76dd694 100644 (file)
 
 @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",
 
 - (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")];
 
 - (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 -
 
 - (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];
     }
 }
 
     [panel setOKButtonLabel: _NS("Save")];
     [panel setTarget:self];
 
-    [panel runModalForWindow:_window];
+    [panel runModalForWindow:self.window];
 }
 
 - (void)panel:(VLCEnterTextPanel *)panel returnValue:(NSUInteger)value text:(NSString *)text
         [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];
     [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
index 6c436a0..abae889 100644 (file)
@@ -67,6 +67,7 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification";
 @class VLCDebugMessageVisualizer;
 @class VLCTrackSynchronization;
 @class VLCAudioEffects;
+@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;
index 8fdc949..c9e87fe 100644 (file)
@@ -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)