OSDN Git Service

MacGui: Preview Window
authordynaflash <dynaflash@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Mon, 12 Jan 2009 18:49:16 +0000 (18:49 +0000)
committerdynaflash <dynaflash@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Mon, 12 Jan 2009 18:49:16 +0000 (18:49 +0000)
- Add a 20 second no mouse movement delay then fade out the hud overlay controls so that the controls are not always visible as long as the cursor is inside the preview area.
- Note: the 20 seconds might make a nice setting in preferences.

git-svn-id: svn://localhost/HandBrake/trunk@2078 b64f7644-9d1e-0410-96f1-a4d463321fa5

macosx/HBPreviewController.h
macosx/HBPreviewController.mm

index 21e262b..16dd75e 100644 (file)
     BOOL                     isEncoding;
 
        
-    int     MaxOutputWidth;
-    int     MaxOutputHeight;
+    int                      MaxOutputWidth;
+    int                      MaxOutputHeight;
 
     int output_width, output_height, output_par_width, output_par_height;
     int display_width;
-
+    
+    /* Hud Control Overlay */
+    NSTimer                         * fHudTimer;
+    int                               hudTimerSeconds;
+    
     /* Full Screen Mode Toggle */
     IBOutlet NSButton               * fFullScreenToggleButton;
     IBOutlet NSButton               * fPictureSettingsToggleButton;
 - (IBAction)goFullScreen:(id)sender;
 - (IBAction)goWindowedScreen:(id)sender;
 
+/* HUD overlay */
+- (void) startHudTimer;
+- (void) stopHudTimer;
+
 /* Movie Previews */
 - (void) startReceivingLibhbNotifications;
 - (void) stopReceivingLibhbNotifications;
index d2d5dae..575a2c6 100644 (file)
 - (void) mouseMoved:(NSEvent *)theEvent
 {
     [super mouseMoved:theEvent];
-       
-    [self showHideHudControls];
+    
+    if (isEncoding == NO)
+    {    
+        if (hudTimerSeconds == 0)
+        {
+            hudTimerSeconds ++;
+            [self startHudTimer];
+        }
+        
+        if (hudTimerSeconds > 20)
+        {
+            
+            
+            [self stopHudTimer];
+            [self showHideHudControls];
+        }
+        
+    }
 }
 
+- (void) startHudTimer
+{
+    if (!fHudTimer)
+    {
+        fHudTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(hudTimerFired:) userInfo:nil repeats:YES];
+        [fHudTimer retain];
+    }
+}
+
+- (void) stopHudTimer
+{
+    if (fHudTimer)
+    {
+        [fHudTimer invalidate];
+        [fHudTimer release];
+        fHudTimer = nil;
+        hudTimerSeconds = 0;
+    }
+}
+
+- (void) hudTimerFired: (NSTimer*)theTimer
+{
+    hudTimerSeconds ++;
+    [self showHideHudControls];
+
+}
 
 - (void) showHideHudControls
 {
     /* Test for mouse location to show/hide hud controls */
     NSPoint    mouseLoc;
-    NSRect    targetFrame;
+    NSRect     targetFrame;
+    NSRect     controlBoxFrame;
+    targetFrame = [fPictureViewArea frame];
+    controlBoxFrame = [fPictureControlBox frame];
+    
     if (isFullScreen)
     {
-    mouseLoc = [fFullScreenWindow mouseLocationOutsideOfEventStream];
+        mouseLoc = [fFullScreenWindow mouseLocationOutsideOfEventStream];
     }
     else
     {
-    mouseLoc = [fPreviewWindow mouseLocationOutsideOfEventStream];
+        mouseLoc = [fPreviewWindow mouseLocationOutsideOfEventStream];
     }
-    targetFrame = [fPictureViewArea frame];
-    /* If we are not encoding a preview, we show/hide the hud controls */
-    if (isEncoding == NO)
+    
+    /* if the pointer is inside the picture view areas but not
+     * in the controlbox, check the hudTimerSeconds to see if
+     * its in the allowable time span
+     */
+    if ( hudTimerSeconds > 0 && hudTimerSeconds < 20)
     {
-        if (NSPointInRect (mouseLoc, targetFrame))
-        {
-            /* Mouse is over the preview area so show hud controls */
-            [[fPictureControlBox animator] setHidden: NO];
-       }
-        else
+        if (NSPointInRect (mouseLoc, controlBoxFrame))
+            {
+                /* Mouse is over the preview area so show hud controls so just
+                 * reset the timer to keep the control box visible
+                */
+                //[fPictureControlBox setHidden: NO];
+                hudTimerSeconds = 1;
+                return;
+            }
+        
+        /* Else, if we are not encoding a preview, we show/hide the hud controls */
+        if (isEncoding == NO)
         {
-            [[fPictureControlBox animator] setHidden: YES];
+            /* Re-verify we are within the target frame */
+            if (NSPointInRect (mouseLoc, targetFrame))
+            {
+                /* Mouse is over the preview area so show hud controls */
+                [[fPictureControlBox animator] setHidden: NO];
+                /* increment our timer by one */
+                hudTimerSeconds ++;
+            }
+            else
+            {
+                [[fPictureControlBox animator] setHidden: YES];
+                [self stopHudTimer];
+            }
         }
+        
     }
+    else
+    {
+        [[fPictureControlBox animator] setHidden: YES];
+    }
+    
 }
 
 
     [self startReceivingLibhbNotifications];
     
     isFullScreen = NO;
+    hudTimerSeconds = 0;
     
     /* Setup our layers for core animation */
     [fPictureViewArea setWantsLayer:YES];
     
     [fMovieView setWantsLayer:YES];
     
-    [fEncodingControlBox setWantsLayer:YES];
     [fCancelPreviewMovieButton setWantsLayer:YES];
     [fMovieCreationProgressIndicator setWantsLayer:YES];
     
     [fFullScreenToggleButton setWantsLayer:YES];
     [fPictureSettingsToggleButton setWantsLayer:YES];
     [fCreatePreviewMovieButton setWantsLayer:YES];
+    
+    [fEncodingControlBox setWantsLayer:YES];
+    
     [fShowPreviewMovieButton setWantsLayer:YES];
     
     
@@ -151,7 +227,7 @@ return YES;
     }
     
     isFullScreen = NO;
-    
+    hudTimerSeconds = 0;
 }
 
 - (BOOL)windowShouldClose:(id)fPictureWindow
@@ -171,6 +247,9 @@ return YES;
     [fLibhbTimer invalidate];
     [fLibhbTimer release];
     
+    [fHudTimer invalidate];
+    [fHudTimer release];
+    
     [fPicturePreviews release];
     [fFullScreenWindow release];
 
@@ -346,6 +425,7 @@ MaxOutputWidth = title->width - job->crop[2] - job->crop[3];
     [self SetTitle:title];
     [self showWindow:sender];
     isFullScreen = NO;
+    hudTimerSeconds = 0;
 
 }