summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authordynaflash <[email protected]>2010-02-11 17:23:00 +0000
committerdynaflash <[email protected]>2010-02-11 17:23:00 +0000
commit5212b9a80b24015b8c638d49e789d253ddc70eb5 (patch)
treefd9a35bdb2d99e835560bf2177bcf807e5d397cb /macosx
parent15c7c717f1f1ccf195b4e2fb356774a5dfe072d6 (diff)
MacGui: Preview Window resizing bug fixes. Patch from BradleyS.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3112 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx')
-rw-r--r--macosx/HBPreviewController.m64
1 files changed, 33 insertions, 31 deletions
diff --git a/macosx/HBPreviewController.m b/macosx/HBPreviewController.m
index 5397fe5d6..750a68c4e 100644
--- a/macosx/HBPreviewController.m
+++ b/macosx/HBPreviewController.m
@@ -1145,39 +1145,15 @@
}
NSSize resultSize = imageSize;
-
- // Its better to have a view that's too small than a view that's too big, so
- // apply the maximum constraints last.
- if( resultSize.width < minWidth )
- {
- resultSize.height *= (minWidth / resultSize.width);
- resultSize.width = minWidth;
- }
- if( resultSize.height < minHeight )
- {
- resultSize.width *= (minHeight / resultSize.height);
- resultSize.height = minHeight;
- }
- if( resultSize.width > maxWidth )
- {
- resultSize.height *= (maxWidth / resultSize.width);
- resultSize.width = maxWidth;
- }
- if( resultSize.height > maxHeight )
- {
- resultSize.width *= (maxHeight / resultSize.height);
- resultSize.height = maxHeight;
- }
-
+ CGFloat resultPar = resultSize.width / resultSize.height;
+
+ //note, a mbp 15" at 1440 x 900 is a 1.6 ar
+ CGFloat screenAspect = screenSize.width / screenSize.height;
+ // Note, a standard dvd will use 720 x 480 which is a 1.5
+ CGFloat viewAreaAspect = viewAreaSize.width / viewAreaSize.height;
+
if (scaleToScreen == YES)
{
- CGFloat screenAspect;
- CGFloat viewAreaAspect;
- //note, a mbp 15" at 1440 x 900 is a 1.6 ar
- screenAspect = screenSize.width / screenSize.height;
-
- // Note, a standard dvd will use 720 x 480 which is a 1.5
- viewAreaAspect = viewAreaSize.width / viewAreaSize.height;
if (screenAspect < viewAreaAspect)
{
@@ -1191,6 +1167,32 @@
}
}
+ else if ( resultSize.width > maxWidth || resultSize.height > maxHeight )
+ {
+ // Source is larger than screen in one or more dimensions
+ if ( resultPar > screenAspect )
+ {
+ // Source aspect wider than screen aspect, snap to max width and vary height
+ resultSize.width = maxWidth;
+ resultSize.height = (maxWidth / resultPar);
+ }
+ else
+ {
+ // Source aspect narrower than screen aspect, snap to max height vary width
+ resultSize.height = maxHeight;
+ resultSize.width = (maxHeight * resultPar);
+ }
+ }
+
+ // If necessary, grow to minimum dimensions to ensure controls overlay is not obstructed
+ if ( resultSize.width < minWidth )
+ {
+ resultSize.width = minWidth;
+ }
+ if ( resultSize.height < minHeight )
+ {
+ resultSize.height = minHeight;
+ }
return resultSize;