Chromium Code Reviews

Side by Side Diff: chrome/browser/views/infobars/translate_infobars.cc

Issue 1961001: Refactors animation to allow for cleaner subclassing. I'm doing this (Closed)
Patch Set: Incorporated review feedback Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « chrome/browser/views/infobars/infobars.cc ('k') | chrome/browser/views/status_bubble_views.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "chrome/browser/views/infobars/translate_infobars.h" 5 #include "chrome/browser/views/infobars/translate_infobars.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
(...skipping 243 matching lines...)
254 set_background(NULL); 254 set_background(NULL);
255 255
256 // Initialize backgrounds. 256 // Initialize backgrounds.
257 normal_background_.reset( 257 normal_background_.reset(
258 new InfoBarBackground(InfoBarDelegate::PAGE_ACTION_TYPE)); 258 new InfoBarBackground(InfoBarDelegate::PAGE_ACTION_TYPE));
259 error_background_.reset( 259 error_background_.reset(
260 new InfoBarBackground(InfoBarDelegate::ERROR_TYPE)); 260 new InfoBarBackground(InfoBarDelegate::ERROR_TYPE));
261 261
262 // Initialize slide animation for transitioning to and from error state. 262 // Initialize slide animation for transitioning to and from error state.
263 error_animation_.reset(new SlideAnimation(this)); 263 error_animation_.reset(new SlideAnimation(this));
264 error_animation_->SetTweenType(SlideAnimation::NONE); 264 error_animation_->SetTweenType(Tween::LINEAR);
265 error_animation_->SetSlideDuration(500); 265 error_animation_->SetSlideDuration(500);
266 266
267 // Initialize icon. 267 // Initialize icon.
268 icon_ = new views::ImageView; 268 icon_ = new views::ImageView;
269 SkBitmap* image = delegate->GetIcon(); 269 SkBitmap* image = delegate->GetIcon();
270 if (image) 270 if (image)
271 icon_->SetImage(image); 271 icon_->SetImage(image);
272 AddChildView(icon_); 272 AddChildView(icon_);
273 273
274 // Create original language menu button. 274 // Create original language menu button.
(...skipping 282 matching lines...)
557 if (translation_pending_) { 557 if (translation_pending_) {
558 translating_label_->SetBounds( 558 translating_label_->SetBounds(
559 prev_right + InfoBar::kEndOfLabelSpacing, 559 prev_right + InfoBar::kEndOfLabelSpacing,
560 InfoBar::OffsetY(this, translating_ps), 560 InfoBar::OffsetY(this, translating_ps),
561 translating_width, translating_ps.height()); 561 translating_width, translating_ps.height());
562 } 562 }
563 } 563 }
564 564
565 void TranslateInfoBar::PaintBackground(gfx::Canvas* canvas) { 565 void TranslateInfoBar::PaintBackground(gfx::Canvas* canvas) {
566 // If we're not animating, simply paint background for current state. 566 // If we're not animating, simply paint background for current state.
567 if (!error_animation_->IsAnimating()) { 567 if (!error_animation_->is_animating()) {
568 GetBackground(state_)->Paint(canvas, this); 568 GetBackground(state_)->Paint(canvas, this);
569 return; 569 return;
570 } 570 }
571 571
572 // Animate cross-fading between error and normal states; 572 // Animate cross-fading between error and normal states;
573 // since all normal states use the same background, just use kAfterTranslate. 573 // since all normal states use the same background, just use kAfterTranslate.
574 if (error_animation_->IsShowing()) { // Transitioning to error state. 574 if (error_animation_->IsShowing()) { // Transitioning to error state.
575 // Fade out normal state. 575 // Fade out normal state.
576 FadeBackground(canvas, 1.0 - error_animation_->GetCurrentValue(), 576 FadeBackground(canvas, 1.0 - error_animation_->GetCurrentValue(),
577 TranslateInfoBarDelegate::kAfterTranslate); 577 TranslateInfoBarDelegate::kAfterTranslate);
(...skipping 394 matching lines...)
972 inline int TranslateInfoBar::GetSpacingAfterFirstLanguageButton() const { 972 inline int TranslateInfoBar::GetSpacingAfterFirstLanguageButton() const {
973 return (state_ == TranslateInfoBarDelegate::kAfterTranslate ? 973 return (state_ == TranslateInfoBarDelegate::kAfterTranslate ?
974 kButtonInLabelSpacing : 10); 974 kButtonInLabelSpacing : 10);
975 } 975 }
976 976
977 // TranslateInfoBarDelegate, InfoBarDelegate overrides: ------------------ 977 // TranslateInfoBarDelegate, InfoBarDelegate overrides: ------------------
978 978
979 InfoBar* TranslateInfoBarDelegate::CreateInfoBar() { 979 InfoBar* TranslateInfoBarDelegate::CreateInfoBar() {
980 return new TranslateInfoBar(this); 980 return new TranslateInfoBar(this);
981 } 981 }
OLDNEW
« no previous file with comments | « chrome/browser/views/infobars/infobars.cc ('k') | chrome/browser/views/status_bubble_views.cc » ('j') | no next file with comments »

Powered by Google App Engine