From 57a6b925ab37059f9f601cba1e2ea8a13f333a67 Mon Sep 17 00:00:00 2001 From: "thomasvl@chromium.org" Date: Tue, 3 Nov 2009 21:52:05 +0000 Subject: [Mac] Prefs window sizing/spacing: - Make some vertical spacing in basics more consistent - Make some vertical spacing in personal stuff more consistent - Make the views a bit wider to avoid some clipping and wrapping in a few languages. - A little code cleanup, no longer allow the pref views to be different widths, this resulted in some really odd looks, so we want to mange the layout ourselves up front (things not always being as wide as the window, etc). TEST=window looks ok (given our strings it won't always look great, but shoot for ok). BUG=26586 Review URL: http://codereview.chromium.org/351027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30871 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/app/nibs/Preferences.xib | 132 ++++++++++----------- .../browser/cocoa/preferences_window_controller.mm | 46 ++++--- 2 files changed, 88 insertions(+), 90 deletions(-) diff --git a/chrome/app/nibs/Preferences.xib b/chrome/app/nibs/Preferences.xib index 20a1ddf..0209ca0 100644 --- a/chrome/app/nibs/Preferences.xib +++ b/chrome/app/nibs/Preferences.xib @@ -728,7 +728,7 @@ 268 - {{17, 310}, {148, 150}} + {{17, 302}, {128, 150}} YES @@ -743,8 +743,8 @@ - 268 - {{172, 402}, {378, 58}} + 266 + {{152, 394}, {358, 58}} YES 3 @@ -1004,7 +1004,7 @@ rwAAAAAAAAAAAAAAAAAAAAAAdGV4dAAAAABDb3B5cmlnaHQgQXBwbGUsIEluYy4sIDIwMDkAA75 - {378, 18} + {358, 18} {4, 2} 1151868928 NSActionCell @@ -1070,8 +1070,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 268 - {{274, 309}, {205, 23}} + 266 + {{295, 301}, {215, 23}} YES @@ -1091,7 +1091,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 - {{223, 309}, {52, 23}} + {{244, 301}, {52, 23}} YES @@ -1115,7 +1115,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 - {{172, 309}, {52, 23}} + {{193, 301}, {52, 23}} YES @@ -1138,7 +1138,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 268 + 266 YES @@ -1149,7 +1149,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 256 - {305, 63} + {315, 63} YES @@ -1160,7 +1160,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA YES - 3.020000e+02 + 3.120000e+02 4.000000e+01 1.000000e+03 @@ -1223,9 +1223,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA YES - {{1, 1}, {305, 63}} + {{1, 1}, {315, 63}} - 4 @@ -1251,9 +1250,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 5.714286e-01 - {{172, 329}, {307, 65}} + {{193, 321}, {317, 65}} - 530 @@ -1263,7 +1261,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 - {{17, 219}, {148, 63}} + {{17, 211}, {128, 63}} YES @@ -1278,8 +1276,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 268 - {{199, 219}, {280, 22}} + 266 + {{193, 211}, {317, 22}} YES @@ -1305,8 +1303,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 268 - {{172, 244}, {307, 38}} + 266 + {{152, 236}, {358, 38}} YES 2 @@ -1434,7 +1432,7 @@ QXBwbGUgQ29tcHV0ZXIsIEluYy4sIDIwMDUAAAAAA 75 - {307, 18} + {358, 18} {4, 2} 1151868928 NSActionCell @@ -1498,7 +1496,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 - {{17, 147}, {148, 39}} + {{17, 144}, {128, 39}} YES @@ -1513,8 +1511,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 268 - {{170, 145}, {311, 18}} + 266 + {{150, 142}, {362, 18}} YES @@ -1535,8 +1533,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 268 - {{170, 168}, {311, 18}} + 266 + {{150, 165}, {362, 18}} YES @@ -1557,8 +1555,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 268 - {{390, 85}, {95, 32}} + 265 + {{421, 85}, {95, 32}} YES @@ -1579,7 +1577,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 - {{17, 93}, {148, 19}} + {{17, 93}, {128, 19}} YES @@ -1594,8 +1592,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 268 - {{169, 89}, {222, 26}} + 266 + {{149, 89}, {273, 26}} YES @@ -1638,7 +1636,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 - {{166, 34}, {212, 32}} + {{146, 34}, {212, 32}} YES @@ -1657,8 +1655,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 268 - {{169, 20}, {313, 14}} + 266 + {{149, 20}, {364, 14}} YES @@ -1681,7 +1679,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 - {{17, 20}, {148, 42}} + {{17, 20}, {128, 42}} YES @@ -1695,7 +1693,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - {499, 480} + {530, 472} NSView @@ -1706,7 +1704,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 - {{17, 238}, {148, 72}} + {{17, 233}, {128, 68}} YES @@ -1721,8 +1719,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 268 - {{176, 272}, {300, 38}} + 266 + {{152, 263}, {358, 38}} YES 2 @@ -1850,7 +1848,7 @@ QXBwbGUgQ29tcHV0ZXIsIEluYy4sIDIwMDUAAAAAA 75 - {300, 18} + {358, 18} {4, 2} 1151868928 NSActionCell @@ -1914,7 +1912,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 - {{170, 230}, {184, 32}} + {{146, 225}, {184, 32}} YES @@ -1934,7 +1932,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 - {{17, 21}, {148, 17}} + {{17, 21}, {128, 17}} YES @@ -1950,7 +1948,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 - {{17, 172}, {148, 38}} + {{17, 168}, {128, 38}} YES @@ -1966,7 +1964,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 - {{17, 67}, {148, 74}} + {{17, 67}, {128, 74}} YES @@ -1981,8 +1979,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 268 - {{173, 67}, {309, 14}} + 266 + {{149, 67}, {364, 14}} YES @@ -1998,7 +1996,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 - {{170, 113}, {118, 32}} + {{146, 113}, {118, 32}} YES @@ -2018,7 +2016,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 - {{170, 81}, {153, 32}} + {{146, 82}, {153, 32}} YES @@ -2037,8 +2035,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 268 - {{176, 172}, {300, 38}} + 266 + {{152, 168}, {358, 38}} YES 2 @@ -2166,7 +2164,7 @@ QXBwbGUgQ29tcHV0ZXIsIEluYy4sIDIwMDUAAAAAA 75 - {300, 18} + {358, 18} {4, 2} 1151868928 NSActionCell @@ -2230,7 +2228,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 - {{290, 22}, {82, 16}} + {{266, 22}, {82, 16}} YES @@ -2250,7 +2248,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 268 - {{170, 12}, {118, 32}} + {{146, 12}, {118, 32}} YES @@ -2268,7 +2266,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - {499, 330} + {530, 321} NSView @@ -2289,13 +2287,14 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 274 - {484, 402} + {515, 402} NSView - {{1, 1}, {484, 402}} + {{1, 1}, {515, 402}} + 3 @@ -2306,7 +2305,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 256 - {{485, 1}, {15, 402}} + {{516, 1}, {15, 402}} _doScroller: @@ -2324,8 +2323,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 5.060241e-01 - {{-1, 60}, {501, 404}} + {{-1, 60}, {532, 404}} + 18 @@ -2357,12 +2357,12 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - {{386, 0}, {113, 52}} + {{417, 0}, {113, 52}} GTMWidthBasedTweaker - {499, 463} + {530, 463} NSView @@ -3906,8 +3906,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - - @@ -3915,12 +3913,14 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - + + + Basics View @@ -4927,14 +4927,14 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{85, 1019}, {499, 480}} + {{85, 1027}, {530, 472}} com.apple.InterfaceBuilder.CocoaPlugin YES - {{86, 655}, {499, 330}} + {{86, 664}, {530, 321}} com.apple.InterfaceBuilder.CocoaPlugin - {{81, 525}, {499, 463}} + {{87, 136}, {530, 463}} com.apple.InterfaceBuilder.CocoaPlugin {{682, 562}, {616, 0}} com.apple.InterfaceBuilder.CocoaPlugin diff --git a/chrome/browser/cocoa/preferences_window_controller.mm b/chrome/browser/cocoa/preferences_window_controller.mm index 42d4a0c..3296a3b 100644 --- a/chrome/browser/cocoa/preferences_window_controller.mm +++ b/chrome/browser/cocoa/preferences_window_controller.mm @@ -50,13 +50,6 @@ std::wstring GetNewTabUIURLString() { return URLFixerUpper::FixupURL(temp, std::wstring()); } -// Adjusts the views origin so it will be centered if in a given width parent. -void CenterViewForWidth(NSView* view, CGFloat width) { - NSRect frame = [view frame]; - frame.origin.x = (width - NSWidth(frame)) / 2.0; - [view setFrame:frame]; -} - // Helper to remove all but the last view from the view heirarchy. void RemoveAllButLastView(NSArray* views) { NSArray* toRemove = [views subarrayWithRange:NSMakeRange(0, [views count]-1)]; @@ -425,22 +418,32 @@ class PrefObserverBridge : public NotificationObserver { resizeViewWithoutAutoResizingSubViews:personalStuffView_ delta:NSMakeSize(0.0, verticalShift)]; - // Make sure the window is wide enough to fit the the widest view - NSRect underTheHoodFrame = [underTheHoodView_ frame]; - CGFloat widest = std::max(NSWidth([basicsView_ frame]), - NSWidth([personalStuffView_ frame])); - widest = std::max(widest, NSWidth(underTheHoodFrame)); +#ifndef NDEBUG + // Validate some assumptions in debug builds. + + // "Basics", "Personal Stuff", and "Under the Hood" views should be the same + // width. They should be the same width so they are laid out to look as good + // as possible at that width with controls just having to wrap if their text + // is too long. + DCHECK_EQ(NSWidth([basicsView_ frame]), NSWidth([personalStuffView_ frame])) + << "Basics and Personal Stuff should be the same widths"; + DCHECK_EQ(NSWidth([basicsView_ frame]), NSWidth([underTheHoodView_ frame])) + << "Basics and Under the Hood should be the same widths"; + // "Under the Hood" content should always be skinnier than the scroller it + // goes into (we resize it). + DCHECK_LE(NSWidth([underTheHoodContentView_ frame]), + [underTheHoodScroller_ contentSize].width) + << "The Under the Hood content should be narrower than the content " + "of the scroller it goes into"; +#endif // NDEBUG + + // Make the window as wide as the views NSWindow* prefsWindow = [self window]; NSRect frame = [prefsWindow frame]; - frame.size.width = widest; + frame.size.width = NSWidth([basicsView_ frame]); [prefsWindow setFrame:frame display:NO]; - // The Under the Hood prefs is a scroller, it shouldn't get any border, so it - // 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 to the full width + // 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]; @@ -455,11 +458,6 @@ class PrefObserverBridge : public NotificationObserver { 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 Under the Hood content view into the scroller and scroll it to the // top. [underTheHoodScroller_ setDocumentView:underTheHoodContentView_]; -- cgit v1.1