diff options
author | thomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-23 20:26:05 +0000 |
---|---|---|
committer | thomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-23 20:26:05 +0000 |
commit | ee493dd767b64b3e6510eae81fc0f78135d2518f (patch) | |
tree | b37af6c72b4f0cb5e3e1db28adfedb7b5aec2e3d /chrome/browser/cocoa | |
parent | e4cc398588dc6a109ce7322dfa50a2f92e78a1e2 (diff) | |
download | chromium_src-ee493dd767b64b3e6510eae81fc0f78135d2518f.zip chromium_src-ee493dd767b64b3e6510eae81fc0f78135d2518f.tar.gz chromium_src-ee493dd767b64b3e6510eae81fc0f78135d2518f.tar.bz2 |
Make the search engine prefs relayout based on their localized strings.
Move the instant experiment into a spot where it won't cause l10n issues.
BUG=64090
TEST=instant pref UI handles l10n correctly
Review URL: http://codereview.chromium.org/5359001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67146 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r-- | chrome/browser/cocoa/preferences_window_controller.h | 1 | ||||
-rw-r--r-- | chrome/browser/cocoa/preferences_window_controller.mm | 67 |
2 files changed, 63 insertions, 5 deletions
diff --git a/chrome/browser/cocoa/preferences_window_controller.h b/chrome/browser/cocoa/preferences_window_controller.h index 1f5a295..51aa79b 100644 --- a/chrome/browser/cocoa/preferences_window_controller.h +++ b/chrome/browser/cocoa/preferences_window_controller.h @@ -91,6 +91,7 @@ class ProfileSyncService; BooleanPrefMember showHomeButton_; BooleanPrefMember instantEnabled_; IBOutlet NSButton* instantCheckbox_; + IBOutlet NSTextField* instantExperiment_; scoped_nsobject<SearchEngineListModel> searchEngineModel_; // Used when creating a new home page url to make the new cell editable. BOOL pendingSelectForEdit_; diff --git a/chrome/browser/cocoa/preferences_window_controller.mm b/chrome/browser/cocoa/preferences_window_controller.mm index cf06527..fb59ff1 100644 --- a/chrome/browser/cocoa/preferences_window_controller.mm +++ b/chrome/browser/cocoa/preferences_window_controller.mm @@ -108,7 +108,8 @@ enum AutoSizeGroupBehavior { kAutoSizeGroupBehaviorVerticalToFit, kAutoSizeGroupBehaviorVerticalFirstToFit, kAutoSizeGroupBehaviorHorizontalToFit, - kAutoSizeGroupBehaviorHorizontalFirstGrows + kAutoSizeGroupBehaviorHorizontalFirstGrows, + kAutoSizeGroupBehaviorFirstTwoAsRowVerticalToFit }; // Helper to tweak the layout of the "pref groups" and also ripple any height @@ -195,6 +196,50 @@ CGFloat AutoSizeGroup(NSArray* views, AutoSizeGroupBehavior behavior, } break; } + case kAutoSizeGroupBehaviorFirstTwoAsRowVerticalToFit: { + // Start out like kAutoSizeGroupBehaviorVerticalToFit but don't do + // the first two. Then handle the two as a row, but apply any + // vertical shift. + // All but the first two (in the row); walk bottom up. + for (NSUInteger index = [views count] - 1; index > 2; --index) { + NSView* view = [views objectAtIndex:index]; + NSSize delta = cocoa_l10n_util::WrapOrSizeToFit(view); + DCHECK_GE(delta.height, 0.0) << "Should NOT shrink in height"; + if (localVerticalShift) { + NSPoint origin = [view frame].origin; + origin.y += localVerticalShift; + [view setFrameOrigin:origin]; + } + localVerticalShift += delta.height; + } + // Deal with the two for the horizontal row. Size the second one. + CGFloat horizontalShift = 0.0; + NSView* view = [views objectAtIndex:2]; + NSSize delta = cocoa_l10n_util::WrapOrSizeToFit(view); + DCHECK_GE(delta.height, 0.0) << "Should NOT shrink in height"; + horizontalShift -= delta.width; + NSPoint origin = [view frame].origin; + origin.x += horizontalShift; + if (localVerticalShift) { + origin.y += localVerticalShift; + } + [view setFrameOrigin:origin]; + // Now expand the first item in the row to consume the space opened up. + view = [views objectAtIndex:1]; + if (horizontalShift) { + NSSize delta = NSMakeSize(horizontalShift, 0.0); + [GTMUILocalizerAndLayoutTweaker + resizeViewWithoutAutoResizingSubViews:view + delta:delta]; + } + // And move it up by any amount needed from the previous items. + if (localVerticalShift) { + NSPoint origin = [view frame].origin; + origin.y += localVerticalShift; + [view setFrameOrigin:origin]; + } + break; + } default: NOTREACHED(); break; @@ -639,8 +684,20 @@ class ManagedPrefsBannerState : public policy::ManagedPrefsBannerBase { verticalShift += AutoSizeGroup(basicsGroupDefaultBrowser_, kAutoSizeGroupBehaviorVerticalFirstToFit, verticalShift); + // TODO(rsesek/rohitrao): This is ugly, when the instant experiement is no + // longer displayed, please remove this code, the NSTextField and IBOutlet + // needed. + DCHECK(instantExperiment_ != nil); + if (verticalShift) { + // If the default browser moved things up, move the experiment field up + // also, it is not in the SearchEngine group due to its position on screen. + NSPoint origin = [instantExperiment_ frame].origin; + origin.y += verticalShift; + [instantExperiment_ setFrameOrigin:origin]; + } + // End TODO verticalShift += AutoSizeGroup(basicsGroupSearchEngine_, - kAutoSizeGroupBehaviorHorizontalFirstGrows, + kAutoSizeGroupBehaviorFirstTwoAsRowVerticalToFit, verticalShift); verticalShift += AutoSizeGroup(basicsGroupToolbar_, kAutoSizeGroupBehaviorVerticalToFit, @@ -1210,12 +1267,12 @@ enum { kHomepageNewTabPage, kHomepageURL }; NSInteger state = enabled ? NSOnState : NSOffState; [instantCheckbox_ setState:state]; - NSString* title = l10n_util::GetNSStringWithFixup(IDS_INSTANT_PREF); + NSString* title = @""; if (enabled) { - title = [NSString stringWithFormat:@"%@ [%d]", title, + title = [NSString stringWithFormat:@"[%d]", prefs_->GetInteger(prefs::kInstantType)]; } - [instantCheckbox_ setTitle:title]; + [instantExperiment_ setStringValue:title]; } - (IBAction)learnMoreAboutInstant:(id)sender { |