aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2009-10-30 18:35:16 +0000
committerGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2009-10-30 18:35:16 +0000
commite1c938bc73510d64b908408bf404eb10a419001e (patch)
tree0001b2d01f045c33f33fff7051fceddcc00971a4
parente1cbd4dc301f0f7e0a0fd7616a958bfaeb615b67 (diff)
[Author: thomasvl]
Add a helper for doing view resizing without resizing subviews. Fix the fixed width call to not change the width. Update the unittest to make sure the fixed width call doesn't change the width. R=stuartmorgan,dmaclach DELTA=41 (30 added, 0 deleted, 11 changed)
-rw-r--r--AppKit/GTMUILocalizerAndLayoutTweaker.h12
-rw-r--r--AppKit/GTMUILocalizerAndLayoutTweaker.m20
-rw-r--r--AppKit/GTMUILocalizerAndLayoutTweakerTest.m3
-rw-r--r--AppKit/GTMUILocalizerAndLayoutTweakerTest3.xib4
-rw-r--r--AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-0.tiffbin9234 -> 8652 bytes
-rw-r--r--AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-1.tiffbin15754 -> 9252 bytes
-rw-r--r--AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-2.tiffbin16292 -> 15768 bytes
-rw-r--r--AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-3.tiffbin19996 -> 16290 bytes
-rw-r--r--AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-4.tiffbin0 -> 20016 bytes
-rw-r--r--GTM.xcodeproj/project.pbxproj4
10 files changed, 36 insertions, 7 deletions
diff --git a/AppKit/GTMUILocalizerAndLayoutTweaker.h b/AppKit/GTMUILocalizerAndLayoutTweaker.h
index abcb758..3c5c864 100644
--- a/AppKit/GTMUILocalizerAndLayoutTweaker.h
+++ b/AppKit/GTMUILocalizerAndLayoutTweaker.h
@@ -42,7 +42,7 @@
// This checks to see if |view| implements @selector(sizeToFit) and calls it.
// It then checks the class of |view| and does some fixup for known issues
-// where sizeToFit doesn't product a view that meets UI guidelines.
+// where sizeToFit doesn't produce a view that meets UI guidelines.
// Returns the amount the view changed in size.
+ (NSSize)sizeToFitView:(NSView *)view;
@@ -60,13 +60,15 @@
+ (void)wrapButtonTitleForWidth:(NSButton *)button;
+ (void)wrapRadioGroupForWidth:(NSMatrix *)radioGroup;
-// Resizes |window| by |delta| without letting the subviews of |window| get
+// Resizes |window| or |view| by |delta| without letting the subviews get
// resized. Useful when you've done manual tweaking by things like
-// +sizeToFitFixedWidthTextField. The window's origin is not adjusted. Passes
-// |NO| to for -setFrame:display:'s |displayViews| flag on the assumptions
-// the caller is doing all the invals/updates needed.
+// +sizeToFitFixedWidthTextField. The origin is not adjusted. For windows,
+// passes |NO| to for -setFrame:display:'s |displayViews| flag on the
+// assumptions the caller is doing all the invals/updates needed.
+ (void)resizeWindowWithoutAutoResizingSubViews:(NSWindow*)window
delta:(NSSize)delta;
++ (void)resizeViewWithoutAutoResizingSubViews:(NSView*)view
+ delta:(NSSize)delta;
@end
diff --git a/AppKit/GTMUILocalizerAndLayoutTweaker.m b/AppKit/GTMUILocalizerAndLayoutTweaker.m
index dca167a..382871c 100644
--- a/AppKit/GTMUILocalizerAndLayoutTweaker.m
+++ b/AppKit/GTMUILocalizerAndLayoutTweaker.m
@@ -223,6 +223,7 @@ static BOOL IsRightAnchored(NSView *view);
NSRect initialFrame = [textField frame];
NSRect sizeRect = NSMakeRect(0, 0, NSWidth(initialFrame), CGFLOAT_MAX);
NSSize newSize = [[textField cell] cellSizeForBounds:sizeRect];
+ newSize.width = NSWidth(initialFrame);
[textField setFrameSize:newSize];
return newSize.height - NSHeight(initialFrame);
}
@@ -278,6 +279,25 @@ static BOOL IsRightAnchored(NSView *view);
}
}
++ (void)resizeViewWithoutAutoResizingSubViews:(NSView*)view
+ delta:(NSSize)delta {
+ // Clear autosizesSubviews (saving the state).
+ BOOL autoresizesSubviews = [view autoresizesSubviews];
+ if (autoresizesSubviews) {
+ [view setAutoresizesSubviews:NO];
+ }
+
+ NSRect rect = [view frame];
+ rect.size.width += delta.width;
+ rect.size.height += delta.height;
+ [view setFrame:rect];
+
+ // Restore autosizesSubviews.
+ if (autoresizesSubviews) {
+ [view setAutoresizesSubviews:YES];
+ }
+}
+
@end
@implementation GTMWidthBasedTweaker
diff --git a/AppKit/GTMUILocalizerAndLayoutTweakerTest.m b/AppKit/GTMUILocalizerAndLayoutTweakerTest.m
index 51dd9ff..5d2375f 100644
--- a/AppKit/GTMUILocalizerAndLayoutTweakerTest.m
+++ b/AppKit/GTMUILocalizerAndLayoutTweakerTest.m
@@ -63,7 +63,10 @@ static NSUInteger gTestPass = 0;
// In the xib, the one field is over sized, the other is undersized, this
// way we make sure the code handles both condions as there was a bahavior
// change between the 10.4 and 10.5 SDKs.
+ // The right field is also right aligned to make sure the width of the text
+ // field stays constant.
NSString *kTestStrings[] = {
+ @"The fox jumps the dog.",
@"The quick brown fox jumps over the lazy dog.",
@"The quick brown fox jumps over the lazy dog. The quick brown fox jumps "
@"over the lazy dog. The quick brown fox jumps over the lazy dog. "
diff --git a/AppKit/GTMUILocalizerAndLayoutTweakerTest3.xib b/AppKit/GTMUILocalizerAndLayoutTweakerTest3.xib
index d0e3e21..36a6fc5 100644
--- a/AppKit/GTMUILocalizerAndLayoutTweakerTest3.xib
+++ b/AppKit/GTMUILocalizerAndLayoutTweakerTest3.xib
@@ -8,7 +8,7 @@
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="1"/>
+ <integer value="2"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -93,7 +93,7 @@
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="847317034">
<int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">272891904</int>
+ <int key="NSCellFlags2">71565312</int>
<string key="NSContents">Multiline Label</string>
<reference key="NSSupport" ref="554297525"/>
<reference key="NSControlView" ref="958773035"/>
diff --git a/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-0.tiff b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-0.tiff
index 6ea28e6..30c2a89 100644
--- a/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-0.tiff
+++ b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-0.tiff
Binary files differ
diff --git a/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-1.tiff b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-1.tiff
index fb0826c..d949898 100644
--- a/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-1.tiff
+++ b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-1.tiff
Binary files differ
diff --git a/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-2.tiff b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-2.tiff
index a9640a0..2d51e31 100644
--- a/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-2.tiff
+++ b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-2.tiff
Binary files differ
diff --git a/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-3.tiff b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-3.tiff
index 7f2f0a9..eb7b8fa 100644
--- a/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-3.tiff
+++ b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-3.tiff
Binary files differ
diff --git a/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-4.tiff b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-4.tiff
new file mode 100644
index 0000000..041b683
--- /dev/null
+++ b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest3-4.tiff
Binary files differ
diff --git a/GTM.xcodeproj/project.pbxproj b/GTM.xcodeproj/project.pbxproj
index e1df5c4..b236943 100644
--- a/GTM.xcodeproj/project.pbxproj
+++ b/GTM.xcodeproj/project.pbxproj
@@ -315,6 +315,7 @@
F49FA88B0EEF303D00077669 /* GTMFileSystemKQueueTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F49FA88A0EEF303D00077669 /* GTMFileSystemKQueueTest.m */; };
F4A420EF0EDDF8E000397A11 /* GTMHotKeyTextField.h in Headers */ = {isa = PBXBuildFile; fileRef = F4A420EC0EDDF8E000397A11 /* GTMHotKeyTextField.h */; settings = {ATTRIBUTES = (Public, ); }; };
F4A420F00EDDF8E000397A11 /* GTMHotKeyTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = F4A420ED0EDDF8E000397A11 /* GTMHotKeyTextField.m */; };
+ F4AA2CB2109B37650025C956 /* GTMUILocalizerAndLayoutTweakerTest3-4.tiff in Resources */ = {isa = PBXBuildFile; fileRef = F4AA2CB1109B37650025C956 /* GTMUILocalizerAndLayoutTweakerTest3-4.tiff */; };
F4BC1C880DDDD45D00108B7D /* GTMHTTPServer.h in Headers */ = {isa = PBXBuildFile; fileRef = F4BC1C860DDDD45D00108B7D /* GTMHTTPServer.h */; settings = {ATTRIBUTES = (Public, ); }; };
F4BC1C890DDDD45D00108B7D /* GTMHTTPServer.m in Sources */ = {isa = PBXBuildFile; fileRef = F4BC1C870DDDD45D00108B7D /* GTMHTTPServer.m */; };
F4BC1E8D0DE1FC4A00108B7D /* GTMHTTPServerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F4BC1E8C0DE1FC4A00108B7D /* GTMHTTPServerTest.m */; };
@@ -715,6 +716,7 @@
F4A420EC0EDDF8E000397A11 /* GTMHotKeyTextField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GTMHotKeyTextField.h; sourceTree = "<group>"; };
F4A420ED0EDDF8E000397A11 /* GTMHotKeyTextField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTMHotKeyTextField.m; sourceTree = "<group>"; };
F4A420EE0EDDF8E000397A11 /* GTMHotKeyTextFieldTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTMHotKeyTextFieldTest.m; sourceTree = "<group>"; };
+ F4AA2CB1109B37650025C956 /* GTMUILocalizerAndLayoutTweakerTest3-4.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = "GTMUILocalizerAndLayoutTweakerTest3-4.tiff"; sourceTree = "<group>"; };
F4BC1C860DDDD45D00108B7D /* GTMHTTPServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GTMHTTPServer.h; sourceTree = "<group>"; };
F4BC1C870DDDD45D00108B7D /* GTMHTTPServer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTMHTTPServer.m; sourceTree = "<group>"; };
F4BC1E8C0DE1FC4A00108B7D /* GTMHTTPServerTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTMHTTPServerTest.m; sourceTree = "<group>"; };
@@ -994,6 +996,7 @@
F4FC16001046B581000AB7BC /* GTMUILocalizerAndLayoutTweakerTest3-1.tiff */,
F4FC16011046B581000AB7BC /* GTMUILocalizerAndLayoutTweakerTest3-2.tiff */,
F4FC16021046B581000AB7BC /* GTMUILocalizerAndLayoutTweakerTest3-3.tiff */,
+ F4AA2CB1109B37650025C956 /* GTMUILocalizerAndLayoutTweakerTest3-4.tiff */,
F4FC327A104EC6D5000AB7BC /* GTMUILocalizerAndLayoutTweakerTest4-0.tiff */,
F4FC327B104EC6D5000AB7BC /* GTMUILocalizerAndLayoutTweakerTest4-1.tiff */,
F4FC327C104EC6D5000AB7BC /* GTMUILocalizerAndLayoutTweakerTest4-2.tiff */,
@@ -1717,6 +1720,7 @@
F4C0B9DB108E3142002FC8E4 /* GTMUILocalizerAndLayoutTweakerTest5-1.tiff in Resources */,
F4C0B9DC108E3142002FC8E4 /* GTMUILocalizerAndLayoutTweakerTest5-2.tiff in Resources */,
F4C6248A109753960069CADD /* GTMIBArrayTest.xib in Resources */,
+ F4AA2CB2109B37650025C956 /* GTMUILocalizerAndLayoutTweakerTest3-4.tiff in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};