aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AppKit/GTMUILocalizerAndLayoutTweaker.h8
-rw-r--r--AppKit/GTMUILocalizerAndLayoutTweaker.m24
2 files changed, 32 insertions, 0 deletions
diff --git a/AppKit/GTMUILocalizerAndLayoutTweaker.h b/AppKit/GTMUILocalizerAndLayoutTweaker.h
index 0ef0763..4f08525 100644
--- a/AppKit/GTMUILocalizerAndLayoutTweaker.h
+++ b/AppKit/GTMUILocalizerAndLayoutTweaker.h
@@ -52,6 +52,14 @@
// Returns the amount the field changed height.
+ (CGFloat)sizeToFitFixedWidthTextField:(NSTextField *)textField;
+// Resizes |window| by |delta| without letting the subviews of |window| 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.
++ (void)resizeWindowWithoutAutoResizingSubViews:(NSWindow*)window
+ delta:(NSSize)delta;
+
@end
// This is a Tweaker that will call sizeToFit on everything within it (that
diff --git a/AppKit/GTMUILocalizerAndLayoutTweaker.m b/AppKit/GTMUILocalizerAndLayoutTweaker.m
index cae8a02..c79bfa1 100644
--- a/AppKit/GTMUILocalizerAndLayoutTweaker.m
+++ b/AppKit/GTMUILocalizerAndLayoutTweaker.m
@@ -104,6 +104,30 @@ static BOOL IsRightAnchored(NSView *view);
return newSize.height - NSHeight(initialFrame);
}
++ (void)resizeWindowWithoutAutoResizingSubViews:(NSWindow*)window
+ delta:(NSSize)delta {
+ NSView *contentView = [window contentView];
+
+ // Clear autosizesSubviews (saving the state).
+ BOOL autoresizesSubviews = [contentView autoresizesSubviews];
+ if (autoresizesSubviews) {
+ [contentView setAutoresizesSubviews:NO];
+ }
+
+ NSRect rect = [window frame];
+ rect.size.width += delta.width;
+ rect.size.height += delta.height;
+ [window setFrame:rect display:NO];
+ // For some reason the content view is resizing, but some times not adjusting
+ // its origin, so correct it manually.
+ [contentView setFrameOrigin:NSMakePoint(0, 0)];
+
+ // Restore autosizesSubviews.
+ if (autoresizesSubviews) {
+ [contentView setAutoresizesSubviews:YES];
+ }
+}
+
@end
@implementation GTMWidthBasedTweaker