aboutsummaryrefslogtreecommitdiff
path: root/Foundation/GTMGeometryUtils.m
diff options
context:
space:
mode:
authorGravatar thomasvl@gmail.com <thomasvl@gmail.com@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2008-09-10 21:04:47 +0000
committerGravatar thomasvl@gmail.com <thomasvl@gmail.com@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2008-09-10 21:04:47 +0000
commitbfaf8705cccb15c0c2a7704b17ba011ddba8242f (patch)
treeb48e104487ee5e29522da1bce6accafa007e29cf /Foundation/GTMGeometryUtils.m
parent0f0f40db85a2c295a9b6dc1623cd76106a4448a5 (diff)
- Added GTMExceptionalInlines for dealing with cases where you get
warning: variable 'r' might be clobbered by 'longjmp' or 'vfork' when using certain Apple inlined functions in @synchronized/@try blocks. - Updated to Xcode 3.1 so the GTM and iPhone project have the same baseline. The code should work in other version of xcode, but the projects and xcconfig files now use 3.1 features. - Added GTMABAddressBook which is a cocoa wrapper for the 'C' AddressBook APIs on the iPhone. - Added several set environment variable statements to RunIPhoneUnitTest.sh to encourage bugs to come out of the woodwork.
Diffstat (limited to 'Foundation/GTMGeometryUtils.m')
-rw-r--r--Foundation/GTMGeometryUtils.m8
1 files changed, 6 insertions, 2 deletions
diff --git a/Foundation/GTMGeometryUtils.m b/Foundation/GTMGeometryUtils.m
index 9ac2933..07de80c 100644
--- a/Foundation/GTMGeometryUtils.m
+++ b/Foundation/GTMGeometryUtils.m
@@ -78,6 +78,8 @@ CGRect GTMCGAlignRectangles(CGRect alignee, CGRect aligner, GTMRectAlignment ali
CGRect GTMCGScaleRectangleToSize(CGRect scalee, CGSize size, GTMScaling scaling) {
switch (scaling) {
+
+ case GTMScaleToFillProportionally:
case GTMScaleProportionally: {
CGFloat height = CGRectGetHeight(scalee);
CGFloat width = CGRectGetWidth(scalee);
@@ -85,12 +87,14 @@ CGRect GTMCGScaleRectangleToSize(CGRect scalee, CGSize size, GTMScaling scaling)
(height > size.height || width > size.width)) {
CGFloat horiz = size.width / width;
CGFloat vert = size.height / height;
- CGFloat newScale = horiz < vert ? horiz : vert;
+ BOOL expand = (scaling == GTMScaleToFillProportionally);
+ // We use the smaller scale unless expand is true. In that case, larger.
+ CGFloat newScale = ((horiz < vert) ^ expand) ? horiz : vert;
scalee = GTMCGRectScale(scalee, newScale, newScale);
}
break;
}
-
+
case GTMScaleToFit:
scalee.size = size;
break;