]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/fspanel.m
macosx: moved preliminary vout to main window, removed most interface related parts...
[vlc] / modules / gui / macosx / fspanel.m
index 5ca46d80bb68d02324d592831eb5d60e0089e29b..6a3748d036dfefabbab0400d98243bee33cda102 100644 (file)
  * Preamble
  *****************************************************************************/
 #import "intf.h"
-#import "controls.h"
+#import "CoreInteraction.h"
 #import "vout.h"
 #import "misc.h"
 #import "fspanel.h"
+#import "MainWindow.h"
+
+@interface VLCFSPanel ()
+- (void)hideMouse;
+@end
 
 /*****************************************************************************
  * VLCFSPanel
@@ -37,7 +42,7 @@
 @implementation VLCFSPanel
 /* We override this initializer so we can set the NSBorderlessWindowMask styleMask, and set a few other important settings */
 - (id)initWithContentRect:(NSRect)contentRect 
-                styleMask:(unsigned int)aStyle 
+                styleMask:(NSUInteger)aStyle 
                   backing:(NSBackingStoreType)bufferingType 
                     defer:(BOOL)flag
 {
@@ -50,8 +55,8 @@
     [win setLevel:NSModalPanelWindowLevel];
     i_device = 0;
     [win center];
+    hideAgainTimer = fadeTimer = nil;
     [self setNonActive:nil];
-
     return win;
 }
 
          object: NSApp];
 }
 
-/* Windows created with NSBorderlessWindowMask normally can't be key, but we want ours to be */
+/* make sure that we don't become key, since we can't handle hotkeys */
 - (BOOL)canBecomeKeyWindow
 {
-    return YES;
+    return NO;
 }
 
 - (BOOL)mouseDownCanMoveWindow
 -(void)dealloc
 {
     [[NSNotificationCenter defaultCenter] removeObserver: self];
-    
+
     if( hideAgainTimer )
+    {
+        [hideAgainTimer invalidate];
         [hideAgainTimer release];
+    }
     [self setFadeTimer:nil];
     [super dealloc];
 }
 
 - (void)setActive:(id)noData
 {
-    if( [[[[VLCMain sharedInstance] getControls] getVoutView] isFullscreen] )
+    if( [[VLCCoreInteraction sharedInstance] voutView] != nil )
     {
-        b_nonActive = NO;
-        [self fadeIn];
+        if( [[[VLCCoreInteraction sharedInstance] voutView] isFullscreen] )
+        {
+            b_nonActive = NO;
+            [self fadeIn];
+        }
     }
 }
 
 - (void)mouseExited:(NSEvent *)theEvent
 {
     /* give up our focus, so the vout may show us again without letting the user clicking it */
-    if( [[[[VLCMain sharedInstance] getControls] getVoutView] isFullscreen] )
-        [[[[[VLCMain sharedInstance] getControls] getVoutView] window] makeKeyWindow];
+    if( [[[VLCCoreInteraction sharedInstance] voutView] isFullscreen] )
+        [[[[VLCCoreInteraction sharedInstance] voutView] window] makeKeyWindow];
+}
+
+- (void)hideMouse
+{
+    [NSCursor setHiddenUntilMouseMoves: YES];
 }
 
 - (void)fadeIn
 {
-    /* in case that the user don't want us to appear, just return here */
-    if(! config_GetInt( VLCIntf, "macosx-fspanel" ) || b_nonActive )
+    /* in case that the user don't want us to appear, make sure we hide the mouse */
+
+    if( !config_GetInt( VLCIntf, "macosx-fspanel" ) )
+    {
+        float time = (float)var_CreateGetInteger( VLCIntf, "mouse-hide-timeout" ) / 1000.;
+        [self setFadeTimer:[NSTimer scheduledTimerWithTimeInterval:time target:self selector:@selector(hideMouse) userInfo:nil repeats:NO]];
         return;
-    
+    }
+
+    if( b_nonActive )
+        return;
+
     [self orderFront: nil];
     
     if( [self alphaValue] < 1.0 || b_displayed != YES )
     /* get us a valid timer */
     if(! b_alreadyCounting )
     {
-        i_timeToKeepVisibleInSec = config_GetInt( VLCIntf, "mouse-hide-timeout" ) / 500;
-        hideAgainTimer = [NSTimer scheduledTimerWithTimeInterval: 0.5
+        i_timeToKeepVisibleInSec = var_CreateGetInteger( VLCIntf, "mouse-hide-timeout" ) / 500;
+        if( hideAgainTimer )
+        {
+            [hideAgainTimer invalidate];
+            [hideAgainTimer autorelease];
+        }
+        /* released in -autoHide and -dealloc */
+        hideAgainTimer = [[NSTimer scheduledTimerWithTimeInterval: 0.5
                                                           target: self 
                                                         selector: @selector(keepVisible:)
                                                         userInfo: nil 
-                                                         repeats: YES];
-        [hideAgainTimer fire];
-        [hideAgainTimer retain];
+                                                         repeats: YES] retain];
         b_alreadyCounting = YES;
     }
 }
         b_keptVisible = NO;
 
     /* count down until we hide ourselfes again and do so if necessary */
-    i_timeToKeepVisibleInSec -= 1;
-    if( i_timeToKeepVisibleInSec < 1 )
+    if( --i_timeToKeepVisibleInSec < 1 )
     {
-        [NSCursor setHiddenUntilMouseMoves: YES];
+        [self hideMouse];
         [self fadeOut];
-        [timer invalidate];
-        [timer release];
+        [hideAgainTimer invalidate]; /* released in -autoHide and -dealloc */
         b_alreadyCounting = NO;
-        timer = NULL;
     }
 }
 
 {
     [timer retain];
     [fadeTimer invalidate];
-    [fadeTimer release];
+    [fadeTimer autorelease];
     fadeTimer=timer;
 }
 
     [o_button setAction: @selector(action:)];                                                   \
     [self addSubview:o_button];
 
-#define addTextfield( o_text, align, font, color, size )                                    \
-    o_text = [[NSTextField alloc] initWithFrame: s_rc];                            \
+#define addTextfield( class, o_text, align, font, color, size )                                    \
+    o_text = [[class alloc] initWithFrame: s_rc];                            \
     [o_text setDrawsBackground: NO];                                                        \
     [o_text setBordered: NO];                                                               \
     [o_text setEditable: NO];                                                               \
     s_rc.origin.y = 64;
     s_rc.size.width = 352;
     s_rc.size.height = 14;
-    addTextfield( o_streamTitle_txt, NSCenterTextAlignment, systemFontOfSize, whiteColor, 0 );
-    s_rc.origin.x = 486;
+    addTextfield( NSTextField, o_streamTitle_txt, NSCenterTextAlignment, systemFontOfSize, whiteColor, 0 );
+    s_rc.origin.x = 481;
     s_rc.origin.y = 64;
-    s_rc.size.width = 50;
-    addTextfield( o_streamPosition_txt, NSRightTextAlignment, systemFontOfSize, whiteColor, 0 );
+    s_rc.size.width = 55;
+    addTextfield( VLCTimeField, o_streamPosition_txt, NSRightTextAlignment, systemFontOfSize, whiteColor, 0 );
 
     return view;
 }
 
 - (IBAction)play:(id)sender
 {
-    [[[VLCMain sharedInstance] getControls] play: sender];
+    [[[VLCMain sharedInstance] controls] play: sender];
 }
 
 - (IBAction)forward:(id)sender
 {
-    [[[VLCMain sharedInstance] getControls] forward: sender];
+    [[[VLCMain sharedInstance] controls] forward: sender];
 }
 
 - (IBAction)backward:(id)sender
 {
-    [[[VLCMain sharedInstance] getControls] backward: sender];
+    [[[VLCMain sharedInstance] controls] backward: sender];
 }
 
 - (IBAction)prev:(id)sender
 {
-    [[[VLCMain sharedInstance] getControls] prev: sender];
+    [[[VLCMain sharedInstance] controls] prev: sender];
 }
 
 - (IBAction)next:(id)sender
 {
-    [[[VLCMain sharedInstance] getControls] next: sender];
+    [[[VLCMain sharedInstance] controls] next: sender];
 }
 
 - (IBAction)windowAction:(id)sender
 {
-    [[[VLCMain sharedInstance] getControls] windowAction: sender];
+    [[[VLCMain sharedInstance] controls] windowAction: sender];
 }
 
 - (IBAction)fsTimeSliderUpdate:(id)sender
 {
-    [[VLCMain sharedInstance] timesliderUpdate: sender];
+    [[VLCMainWindow sharedInstance] updateTimeSlider];
 }
 
 - (IBAction)fsVolumeSliderUpdate:(id)sender
 {
-    [[[VLCMain sharedInstance] getControls] volumeSliderUpdated: sender];
+    [[VLCCoreInteraction sharedInstance] setVolume: [sender intValue]];
 }
 
 #define addImage(image, _x, _y, mode, _width)                                               \