Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(778)

Unified Diff: chrome/browser/cocoa/preferences_window_controller.mm

Issue 355011: [Mac] Prefs under the hood work:... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/cocoa/preferences_window_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/preferences_window_controller.mm
===================================================================
--- chrome/browser/cocoa/preferences_window_controller.mm (revision 30819)
+++ chrome/browser/cocoa/preferences_window_controller.mm (working copy)
@@ -220,6 +220,54 @@
return localVerticalShift + nonLabelShift;
}
+// Compare function for -[NSArray sortedArrayUsingFunction:context:] that
+// sorts the views in Y order bottom up.
+NSInteger CompareFrameY(id view1, id view2, void* context) {
+ CGFloat y1 = NSMinY([view1 frame]);
+ CGFloat y2 = NSMinY([view2 frame]);
+ if (y1 < y2)
+ return NSOrderedAscending;
+ else if (y1 > y2)
+ return NSOrderedDescending;
+ else
+ return NSOrderedSame;
+}
+
+// Helper to tweak the layout of the "Under the Hood" content by autosizing all
+// the views and moving things up vertically. Special case the two controls for
+// download location as they are horizontal, and should fill the row.
+CGFloat AutoSizeUnderTheHoodContent(NSView* view,
+ NSPathControl* downloadLocationControl,
+ NSButton* downloadLocationButton) {
+ CGFloat verticalShift = 0.0;
+
+ // Loop bottom up through the views sizing and shifting.
+ NSArray* views = [view subviews];
+ views = [views sortedArrayUsingFunction:CompareFrameY context:NULL];
Mark Mentovai 2009/11/03 17:35:44 Rather than assigning the same crap into the same
+ for (NSView* view in views) {
+ NSSize delta = WrapOrSizeToFit(view);
+ DCHECK_GE(delta.height, 0.0) << "Should NOT shrink in height";
+ if (verticalShift) {
+ NSPoint origin = [view frame].origin;
+ origin.y += verticalShift;
+ [view setFrameOrigin:origin];
+ }
+ verticalShift += delta.height;
+ // The Download Location controls go in a row with the button aligned to the
Mark Mentovai 2009/11/03 17:35:44 blank before?
+ // right edge and the path control using all the rest of the space.
+ if (view == downloadLocationButton) {
+ NSPoint origin = [downloadLocationButton frame].origin;
+ origin.x -= delta.width;
+ [downloadLocationButton setFrameOrigin:origin];
+ NSSize controlSize = [downloadLocationControl frame].size;
+ controlSize.width -= delta.width;
+ [downloadLocationControl setFrameSize:controlSize];
+ }
+ }
+
+ return verticalShift;
+}
+
} // namespace
//-------------------------------------------------------------------------
@@ -390,19 +438,32 @@
// gets resized to the as wide as the window ends up.
underTheHoodFrame.size.width = widest;
[underTheHoodView_ setFrame:underTheHoodFrame];
- // Widen the Under the Hood content so things can rewrap
- NSSize advancedContentSize = [advancedView_ frame].size;
- advancedContentSize.width = [advancedScroller_ contentSize].width;
- [advancedView_ setFrameSize:advancedContentSize];
+ // Widen the Under the Hood content so things can rewrap to the full width
+ NSSize underTheHoodContentSize = [underTheHoodContentView_ frame].size;
+ underTheHoodContentSize.width = [underTheHoodScroller_ contentSize].width;
+ [underTheHoodContentView_ setFrameSize:underTheHoodContentSize];
+
+ // Now that Under the Hood is the right wide, spin through auto sizing things
Mark Mentovai 2009/11/03 17:35:44 hahaha Now that Under the Hood is the right width
+ // to that new width to get teh final height.
+ verticalShift = AutoSizeUnderTheHoodContent(underTheHoodContentView_,
+ downloadLocationControl_,
+ downloadLocationButton_);
+ [GTMUILocalizerAndLayoutTweaker
+ resizeViewWithoutAutoResizingSubViews:underTheHoodContentView_
+ delta:NSMakeSize(0.0, verticalShift)];
+ underTheHoodContentSize = [underTheHoodContentView_ frame].size;
+
// Adjust the view origins so they show up centered.
CenterViewForWidth(basicsView_, widest);
CenterViewForWidth(personalStuffView_, widest);
CenterViewForWidth(underTheHoodView_, widest);
- // Put the advanced view into the scroller and scroll it to the top.
- [advancedScroller_ setDocumentView:advancedView_];
- [advancedView_ scrollPoint:NSMakePoint(0, advancedContentSize.height)];
+ // Put the Under the Hood content view into the scroller and scroll it to the
+ // top.
+ [underTheHoodScroller_ setDocumentView:underTheHoodContentView_];
+ [underTheHoodContentView_ scrollPoint:
+ NSMakePoint(0, underTheHoodContentSize.height)];
// Get the last visited page from local state.
OptionsPage page = static_cast<OptionsPage>(lastSelectedPage_.GetValue());
« no previous file with comments | « chrome/browser/cocoa/preferences_window_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698