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

Side by Side Diff: chrome/browser/ui/gtk/infobars/translate_infobar_base_gtk.cc

Issue 23531053: ui/base/animation -> ui/gfx/animation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge 2 trunk Created 7 years, 3 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/gtk/infobars/translate_infobar_base_gtk.h" 5 #include "chrome/browser/ui/gtk/infobars/translate_infobar_base_gtk.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/translate/options_menu_model.h" 8 #include "chrome/browser/translate/options_menu_model.h"
9 #include "chrome/browser/translate/translate_infobar_delegate.h" 9 #include "chrome/browser/translate/translate_infobar_delegate.h"
10 #include "chrome/browser/ui/gtk/gtk_util.h" 10 #include "chrome/browser/ui/gtk/gtk_util.h"
11 #include "chrome/browser/ui/gtk/infobars/after_translate_infobar_gtk.h" 11 #include "chrome/browser/ui/gtk/infobars/after_translate_infobar_gtk.h"
12 #include "chrome/browser/ui/gtk/infobars/before_translate_infobar_gtk.h" 12 #include "chrome/browser/ui/gtk/infobars/before_translate_infobar_gtk.h"
13 #include "chrome/browser/ui/gtk/infobars/translate_message_infobar_gtk.h" 13 #include "chrome/browser/ui/gtk/infobars/translate_message_infobar_gtk.h"
14 #include "chrome/browser/ui/gtk/menu_gtk.h" 14 #include "chrome/browser/ui/gtk/menu_gtk.h"
15 #include "grit/generated_resources.h" 15 #include "grit/generated_resources.h"
16 #include "ui/base/animation/slide_animation.h"
17 #include "ui/base/gtk/gtk_signal_registrar.h" 16 #include "ui/base/gtk/gtk_signal_registrar.h"
18 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
18 #include "ui/gfx/animation/slide_animation.h"
19 #include "ui/gfx/canvas.h" 19 #include "ui/gfx/canvas.h"
20 20
21 21
22 // TranslateInfoBarDelegate --------------------------------------------------- 22 // TranslateInfoBarDelegate ---------------------------------------------------
23 23
24 InfoBar* TranslateInfoBarDelegate::CreateInfoBar(InfoBarService* owner) { 24 InfoBar* TranslateInfoBarDelegate::CreateInfoBar(InfoBarService* owner) {
25 if (infobar_type_ == BEFORE_TRANSLATE) 25 if (infobar_type_ == BEFORE_TRANSLATE)
26 return new BeforeTranslateInfoBar(owner, this); 26 return new BeforeTranslateInfoBar(owner, this);
27 if (infobar_type_ == AFTER_TRANSLATE) 27 if (infobar_type_ == AFTER_TRANSLATE)
28 return new AfterTranslateInfoBar(owner, this); 28 return new AfterTranslateInfoBar(owner, this);
29 return new TranslateMessageInfoBar(owner, this); 29 return new TranslateMessageInfoBar(owner, this);
30 } 30 }
31 31
32 32
33 // TranslateInfoBarBase ------------------------------------------------------- 33 // TranslateInfoBarBase -------------------------------------------------------
34 34
35 TranslateInfoBarBase::TranslateInfoBarBase(InfoBarService* owner, 35 TranslateInfoBarBase::TranslateInfoBarBase(InfoBarService* owner,
36 TranslateInfoBarDelegate* delegate) 36 TranslateInfoBarDelegate* delegate)
37 : InfoBarGtk(owner, delegate), 37 : InfoBarGtk(owner, delegate),
38 background_error_percent_(0) { 38 background_error_percent_(0) {
39 DCHECK(delegate); 39 DCHECK(delegate);
40 TranslateInfoBarDelegate::BackgroundAnimationType animation = 40 TranslateInfoBarDelegate::BackgroundAnimationType animation =
41 delegate->background_animation_type(); 41 delegate->background_animation_type();
42 if (animation != TranslateInfoBarDelegate::NONE) { 42 if (animation != TranslateInfoBarDelegate::NONE) {
43 background_color_animation_.reset(new ui::SlideAnimation(this)); 43 background_color_animation_.reset(new gfx::SlideAnimation(this));
44 background_color_animation_->SetTweenType(ui::Tween::LINEAR); 44 background_color_animation_->SetTweenType(gfx::Tween::LINEAR);
45 background_color_animation_->SetSlideDuration(500); 45 background_color_animation_->SetSlideDuration(500);
46 if (animation == TranslateInfoBarDelegate::NORMAL_TO_ERROR) { 46 if (animation == TranslateInfoBarDelegate::NORMAL_TO_ERROR) {
47 background_color_animation_->Show(); 47 background_color_animation_->Show();
48 } else { 48 } else {
49 DCHECK_EQ(TranslateInfoBarDelegate::ERROR_TO_NORMAL, animation); 49 DCHECK_EQ(TranslateInfoBarDelegate::ERROR_TO_NORMAL, animation);
50 // Hide() runs the animation in reverse. 50 // Hide() runs the animation in reverse.
51 background_color_animation_->Reset(1.0); 51 background_color_animation_->Reset(1.0);
52 background_color_animation_->Hide(); 52 background_color_animation_->Hide();
53 } 53 }
54 } else { 54 } else {
55 background_error_percent_ = delegate->is_error() ? 1 : 0; 55 background_error_percent_ = delegate->is_error() ? 1 : 0;
56 } 56 }
57 } 57 }
58 58
59 TranslateInfoBarBase::~TranslateInfoBarBase() { 59 TranslateInfoBarBase::~TranslateInfoBarBase() {
60 } 60 }
61 61
62 void TranslateInfoBarBase::AnimationProgressed(const ui::Animation* animation) { 62 void TranslateInfoBarBase::AnimationProgressed(
63 const gfx::Animation* animation) {
63 DCHECK(widget()); 64 DCHECK(widget());
64 if (animation == background_color_animation_.get()) { 65 if (animation == background_color_animation_.get()) {
65 background_error_percent_ = animation->GetCurrentValue(); 66 background_error_percent_ = animation->GetCurrentValue();
66 // Queue the info bar widget for redisplay so it repaints its background. 67 // Queue the info bar widget for redisplay so it repaints its background.
67 gtk_widget_queue_draw(widget()); 68 gtk_widget_queue_draw(widget());
68 } else { 69 } else {
69 InfoBar::AnimationProgressed(animation); 70 InfoBar::AnimationProgressed(animation);
70 } 71 }
71 } 72 }
72 73
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 } 194 }
194 195
195 TranslateInfoBarDelegate* TranslateInfoBarBase::GetDelegate() { 196 TranslateInfoBarDelegate* TranslateInfoBarBase::GetDelegate() {
196 return static_cast<TranslateInfoBarDelegate*>(delegate()); 197 return static_cast<TranslateInfoBarDelegate*>(delegate());
197 } 198 }
198 199
199 void TranslateInfoBarBase::OnOptionsClicked(GtkWidget* sender) { 200 void TranslateInfoBarBase::OnOptionsClicked(GtkWidget* sender) {
200 menu_model_.reset(new OptionsMenuModel(GetDelegate())); 201 menu_model_.reset(new OptionsMenuModel(GetDelegate()));
201 ShowMenuWithModel(sender, NULL, menu_model_.get()); 202 ShowMenuWithModel(sender, NULL, menu_model_.get());
202 } 203 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/infobars/translate_infobar_base_gtk.h ('k') | chrome/browser/ui/gtk/location_bar_view_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698