| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 #import "chrome/browser/ui/cocoa/translate/translate_infobar_base.h" | 6 #import "chrome/browser/ui/cocoa/translate/translate_infobar_base.h" |
| 7 | 7 |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 // Removes all controls so that layout can add in only the controls | 148 // Removes all controls so that layout can add in only the controls |
| 149 // required. | 149 // required. |
| 150 - (void)clearAllControls; | 150 - (void)clearAllControls; |
| 151 | 151 |
| 152 // Create all the various controls we need for the toolbar. | 152 // Create all the various controls we need for the toolbar. |
| 153 - (void)constructViews; | 153 - (void)constructViews; |
| 154 | 154 |
| 155 // Reloads text for all labels for the current state. | 155 // Reloads text for all labels for the current state. |
| 156 - (void)loadLabelText:(TranslateErrors::Type)error; | 156 - (void)loadLabelText:(TranslateErrors::Type)error; |
| 157 | 157 |
| 158 // Set the infobar background gradient. | |
| 159 - (void)setInfoBarGradientColor; | |
| 160 | |
| 161 // Main function to update the toolbar graphic state and data model after | 158 // Main function to update the toolbar graphic state and data model after |
| 162 // the state has changed. | 159 // the state has changed. |
| 163 // Controls are moved around as needed and visibility changed to match the | 160 // Controls are moved around as needed and visibility changed to match the |
| 164 // current state. | 161 // current state. |
| 165 - (void)updateState; | 162 - (void)updateState; |
| 166 | 163 |
| 167 // Called when the source or target language selection changes in a menu. | 164 // Called when the source or target language selection changes in a menu. |
| 168 // |newLanguageIdx| is the index of the newly selected item in the appropriate | 165 // |newLanguageIdx| is the index of the newly selected item in the appropriate |
| 169 // menu. | 166 // menu. |
| 170 - (void)sourceLanguageModified:(NSInteger)newLanguageIdx; | 167 - (void)sourceLanguageModified:(NSInteger)newLanguageIdx; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 - (void)updateState { | 241 - (void)updateState { |
| 245 [self loadLabelText]; | 242 [self loadLabelText]; |
| 246 [self clearAllControls]; | 243 [self clearAllControls]; |
| 247 [self showVisibleControls:[self visibleControls]]; | 244 [self showVisibleControls:[self visibleControls]]; |
| 248 [optionsPopUp_ setHidden:![self shouldShowOptionsPopUp]]; | 245 [optionsPopUp_ setHidden:![self shouldShowOptionsPopUp]]; |
| 249 [self layout]; | 246 [self layout]; |
| 250 [self adjustOptionsButtonSizeAndVisibilityForView: | 247 [self adjustOptionsButtonSizeAndVisibilityForView: |
| 251 [[self visibleControls] lastObject]]; | 248 [[self visibleControls] lastObject]]; |
| 252 } | 249 } |
| 253 | 250 |
| 254 - (void)setInfoBarGradientColor { | |
| 255 NSColor* startingColor = [NSColor colorWithCalibratedWhite:0.93 alpha:1.0]; | |
| 256 NSColor* endingColor = [NSColor colorWithCalibratedWhite:0.85 alpha:1.0]; | |
| 257 NSGradient* translateInfoBarGradient = | |
| 258 [[[NSGradient alloc] initWithStartingColor:startingColor | |
| 259 endingColor:endingColor] autorelease]; | |
| 260 | |
| 261 [infoBarView_ setGradient:translateInfoBarGradient]; | |
| 262 [infoBarView_ | |
| 263 setStrokeColor:[NSColor colorWithCalibratedWhite:0.75 alpha:1.0]]; | |
| 264 } | |
| 265 | |
| 266 - (void)removeOkCancelButtons { | 251 - (void)removeOkCancelButtons { |
| 267 // Removing okButton_ & cancelButton_ from the view may cause them | 252 // Removing okButton_ & cancelButton_ from the view may cause them |
| 268 // to be released and since we can still access them from other areas | 253 // to be released and since we can still access them from other areas |
| 269 // in the code later, we need them to be nil when this happens. | 254 // in the code later, we need them to be nil when this happens. |
| 270 [okButton_ removeFromSuperview]; | 255 [okButton_ removeFromSuperview]; |
| 271 okButton_ = nil; | 256 okButton_ = nil; |
| 272 [cancelButton_ removeFromSuperview]; | 257 [cancelButton_ removeFromSuperview]; |
| 273 cancelButton_ = nil; | 258 cancelButton_ = nil; |
| 274 } | 259 } |
| 275 | 260 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 | 388 |
| 404 - (void)addAdditionalControls { | 389 - (void)addAdditionalControls { |
| 405 using l10n_util::GetNSString; | 390 using l10n_util::GetNSString; |
| 406 using l10n_util::GetNSStringWithFixup; | 391 using l10n_util::GetNSStringWithFixup; |
| 407 | 392 |
| 408 // Get layout information from the NIB. | 393 // Get layout information from the NIB. |
| 409 NSRect okButtonFrame = [okButton_ frame]; | 394 NSRect okButtonFrame = [okButton_ frame]; |
| 410 NSRect cancelButtonFrame = [cancelButton_ frame]; | 395 NSRect cancelButtonFrame = [cancelButton_ frame]; |
| 411 spaceBetweenControls_ = NSMinX(cancelButtonFrame) - NSMaxX(okButtonFrame); | 396 spaceBetweenControls_ = NSMinX(cancelButtonFrame) - NSMaxX(okButtonFrame); |
| 412 | 397 |
| 413 // Set infobar background color. | |
| 414 [self setInfoBarGradientColor]; | |
| 415 | |
| 416 // Instantiate additional controls. | 398 // Instantiate additional controls. |
| 417 [self constructViews]; | 399 [self constructViews]; |
| 418 | 400 |
| 419 // Set ourselves as the delegate for the options menu so we can populate it | 401 // Set ourselves as the delegate for the options menu so we can populate it |
| 420 // dynamically. | 402 // dynamically. |
| 421 [[optionsPopUp_ menu] setDelegate:self]; | 403 [[optionsPopUp_ menu] setDelegate:self]; |
| 422 | 404 |
| 423 // Replace label_ with label1_ so we get a consistent look between all the | 405 // Replace label_ with label1_ so we get a consistent look between all the |
| 424 // labels we display in the translate view. | 406 // labels we display in the translate view. |
| 425 [[label_ superview] replaceSubview:label_ with:label1_.get()]; | 407 [[label_ superview] replaceSubview:label_ with:label1_.get()]; |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 return false; | 628 return false; |
| 647 } | 629 } |
| 648 previousControl = control; | 630 previousControl = control; |
| 649 } | 631 } |
| 650 | 632 |
| 651 return true; | 633 return true; |
| 652 } | 634 } |
| 653 | 635 |
| 654 @end // TranslateInfoBarControllerBase (TestingAPI) | 636 @end // TranslateInfoBarControllerBase (TestingAPI) |
| 655 | 637 |
| OLD | NEW |