]> granicus.if.org Git - handbrake/commitdiff
MacGui: Preview Window postioning fixes
authordynaflash <dynaflashtech@gmail.com>
Fri, 6 Mar 2009 16:32:59 +0000 (16:32 +0000)
committerdynaflash <dynaflashtech@gmail.com>
Fri, 6 Mar 2009 16:32:59 +0000 (16:32 +0000)
- Make sure the preview window stays within the parameters of the screen as it resizes, even on multiple monitor systems.
- Among other things fixes an issue where preview window being opened up at launch would push part of it off screen as it resized to a new source.

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2232 b64f7644-9d1e-0410-96f1-a4d463321fa5

macosx/HBPreviewController.mm

index 0eb6500fd417f1b49a994df4cee1abfca31f369b..cea2a1ee3f4bfee4be76a62073e2956d249d1873 100644 (file)
@@ -1314,6 +1314,26 @@ return YES;
     }
     else
     {
+        /* Since upon launch we can open up the preview window if it was open
+         * the last time we quit (and at the size it was) we want to make
+         * sure that upon resize we do not have the window off the screen
+         * So check the origin against the screen origin and adjust if
+         * necessary.
+         */
+        NSSize screenSize = [[[self window] screen] frame].size;
+        NSPoint screenOrigin = [[[self window] screen] frame].origin;
+        /* our origin is off the screen to the left*/
+        if (frame.origin.x < screenOrigin.x)
+        {
+            /* so shift our origin to the right */
+            frame.origin.x = screenOrigin.x;
+        }
+        else if ((frame.origin.x + frame.size.width) > (screenOrigin.x + screenSize.width))
+        {
+            /* the right side of the preview is off the screen, so shift to the left */
+            frame.origin.x = (screenOrigin.x + screenSize.width) - frame.size.width;
+        }
+        
         [[self window] setFrame:frame display:YES animate:YES];
     }