OSDN Git Service

BuildSystem: darwin
[handbrake-jp/handbrake-jp-git.git] / macosx / HBPreviewController.mm
index a74282c..0eb6500 100644 (file)
@@ -108,6 +108,8 @@ return YES;
 
 - (void)windowWillClose:(NSNotification *)aNotification
 {
+    
+    
     /* Upon Closing the picture window, we make sure we clean up any
      * preview movie that might be playing
      */
@@ -118,10 +120,6 @@ return YES;
     [fPictureView setHidden:NO];
     [fMovieView pause:nil];
     [fMovieView setHidden:YES];
-    if (isFullScreen)
-    {
-        [self goWindowedScreen:nil];
-    }
     
     isFullScreen = NO;
     hudTimerSeconds = 0;
@@ -130,7 +128,8 @@ return YES;
 
 - (BOOL)windowShouldClose:(id)fPictureWindow
 {
-    return YES;
+     
+     return YES;
 }
 
 - (void) dealloc
@@ -219,11 +218,8 @@ return YES;
     [fMovieCreationProgressIndicator setHidden: YES];
     
     [fPictureView setHidden:NO];
-
     [fPictureView setImage: [self imageForPicture: fPicture]];
     
-       
-       
     NSSize displaySize = NSMakeSize( ( CGFloat )fTitle->width, ( CGFloat )fTitle->height );
     /* Set the picture size display fields below the Preview Picture*/
     if( fTitle->job->anamorphic.mode == 1 ) // Original PAR Implementation
@@ -232,7 +228,7 @@ return YES;
         output_height = fTitle->height-fTitle->job->crop[0]-fTitle->job->crop[1];
         display_width = output_width * fTitle->job->anamorphic.par_width / fTitle->job->anamorphic.par_height;
         [fInfoField setStringValue:[NSString stringWithFormat:
-                                    @"Source: %dx%d, Output: %dx%d, Anamorphic: %dx%d",
+                                    @"Source: %dx%d, Output: %dx%d, Anamorphic: %dx%d Strict",
                                     fTitle->width, fTitle->height, output_width, output_height, display_width, output_height]];
         displaySize.width *= ( ( CGFloat )fTitle->job->anamorphic.par_width ) / ( ( CGFloat )fTitle->job->anamorphic.par_height );   
     }
@@ -241,7 +237,7 @@ return YES;
     hb_set_anamorphic_size(job, &output_width, &output_height, &output_par_width, &output_par_height);
         display_width = output_width * output_par_width / output_par_height;
         [fInfoField setStringValue:[NSString stringWithFormat:
-                                    @"Source: %dx%d, Output: %dx%d, Anamorphic: %dx%d",
+                                    @"Source: %dx%d, Output: %dx%d, Anamorphic: %dx%d Loose",
                                     fTitle->width, fTitle->height, output_width, output_height, display_width, output_height]];
         
         displaySize.width = display_width;
@@ -252,7 +248,8 @@ return YES;
                                      @"Source: %dx%d, Output: %dx%d", fTitle->width, fTitle->height,
                                      fTitle->job->width, fTitle->job->height]];
     }
-
+    
+    
     NSSize viewSize = [self optimalViewSizeForImageSize:displaySize];
     /* we also need to take into account scaling to full screen to activate switching the view size */
     if( [self viewNeedsToResizeToSize:viewSize])
@@ -342,12 +339,18 @@ return YES;
         isFullScreen = NO;
         scaleToScreen = NO;
         hudTimerSeconds = 0;
+        [self pictureSliderChanged:nil];
         [self startHudTimer];
         
     }
     
 }
 
+- (NSString*) pictureSizeInfoString
+{
+    return [fInfoField stringValue];
+}
+
 - (IBAction)showPictureSettings:(id)sender
 {
     [fHBController showPicturePanel:self];
@@ -514,7 +517,7 @@ return YES;
 - (IBAction)goFullScreen:(id)sender 
 { 
     // Get the screen information. 
-    NSScreen* mainScreen = [NSScreen mainScreen];
+    NSScreen* mainScreen = [fPreviewWindow screen];
     NSDictionary* screenInfo = [mainScreen deviceDescription]; 
     NSNumber* screenID = [screenInfo objectForKey:@"NSScreenNumber"]; 
     // Capture the screen. 
@@ -537,7 +540,7 @@ return YES;
                                                         styleMask:NSBorderlessWindowMask 
                                                           backing:NSBackingStoreBuffered 
                                                             defer:NO 
-                                                           screen:[NSScreen mainScreen]]; 
+                                                           screen:mainScreen]; 
         
         // Establish the window attributes. 
         [fFullScreenWindow setReleasedWhenClosed:NO]; 
@@ -548,26 +551,27 @@ return YES;
         [fFullScreenWindow setContentView:fPictureViewArea]; 
         [fPictureViewArea setNeedsDisplay:YES];
         
-        // Center the window 
-        
         /* Better to center the window using the screen's frame
          * and the windows origin. Note that we should take into
          * account the auto sizing and alignment that occurs in 
          * setViewSize each time the preview changes.
+         * Note: by using [fFullScreenWindow screen] (instead of
+         * [NSScreen mainScreen]) in referencing the screen
+         * coordinates, the full screen window will show up on
+         * whichever display was being used in windowed mode
+         * on multi-display systems
          */
         
-        NSSize screenSize = [[NSScreen mainScreen] frame].size;
+        NSSize screenSize = [[fFullScreenWindow screen] frame].size;
         NSSize windowSize = [fFullScreenWindow frame].size;
         NSPoint windowOrigin = [fFullScreenWindow frame].origin;
         
         /* Adjust our origin y (vertical) based on the screen height */
-        windowOrigin.y = (screenSize.height - windowSize.height) / 2.0;
-        windowOrigin.x = (screenSize.width - windowSize.width) / 2.0;
+        windowOrigin.y += (screenSize.height - windowSize.height) / 2.0;
+        windowOrigin.x += (screenSize.width - windowSize.width) / 2.0;
         
         [fFullScreenWindow setFrameOrigin:windowOrigin];
         
-        
-        
         /* lets kill the timer for now */
         [self stopReceivingLibhbNotifications];
         
@@ -584,6 +588,7 @@ return YES;
         // Show the window. 
         [fFullScreenWindow makeKeyAndOrderFront:self];
         
+        
         /* Change the name of fFullScreenToggleButton appropriately */
         [fFullScreenToggleButton setTitle: @"Windowed"];
         
@@ -605,6 +610,20 @@ return YES;
     } 
 } 
 
+// Title-less windows normally don't receive key presses, override this
+- (BOOL)canBecomeKeyWindow
+{
+    return YES;
+}
+
+// Title-less windows normally can't become main which means that another
+// non-fullscreen window will have the "active" titlebar in expose. Bad, fix it.
+- (BOOL)canBecomeMainWindow
+{
+    return YES;
+}
+
+
 - (IBAction)goWindowedScreen:(id)sender
 {
     
@@ -1068,22 +1087,21 @@ return YES;
         [fMovieView setMovie:nil];
         
         aMovie = [QTMovie movieWithFile:path error:nil];
-        
+
         /* we get some size information from the preview movie */
-        Rect movieBox;
-        GetMovieBox ([aMovie quickTimeMovie], &movieBox);
+        NSSize movieSize= [[aMovie attributeForKey:QTMovieNaturalSizeAttribute] sizeValue];
         movieBounds = [fMovieView movieBounds];
-        movieBounds.size.height = movieBox.bottom - movieBox.top;
-        
+        movieBounds.size.height = movieSize.height;
+
         if ([fMovieView isControllerVisible])
             movieBounds.size.height += [fMovieView controllerBarHeight];
         /* since for whatever the reason I cannot seem to get the [fMovieView controllerBarHeight]
          * For now just use 15 for additional height as it seems to line up well
          */
         movieBounds.size.height += 15;
-        
-        movieBounds.size.width = movieBox.right - movieBox.left;
-        
+
+        movieBounds.size.width = movieSize.width;
+
         /* We need to find out if the preview movie needs to be scaled down so
          * that it doesn't overflow our available viewing container (just like for image
          * in -displayPreview) for HD sources, etc. [fPictureViewArea frame].size.height*/