OLD | NEW |
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/gtk/translate/translate_infobar_base_gtk.h" | 5 #include "chrome/browser/gtk/translate/translate_infobar_base_gtk.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/slide_animation.h" | |
9 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/translate/options_menu_model.h" | 9 #include "chrome/browser/translate/options_menu_model.h" |
11 #include "chrome/browser/translate/translate_infobar_delegate.h" | 10 #include "chrome/browser/translate/translate_infobar_delegate.h" |
12 #include "chrome/browser/gtk/translate/after_translate_infobar_gtk.h" | 11 #include "chrome/browser/gtk/translate/after_translate_infobar_gtk.h" |
13 #include "chrome/browser/gtk/translate/before_translate_infobar_gtk.h" | 12 #include "chrome/browser/gtk/translate/before_translate_infobar_gtk.h" |
14 #include "chrome/browser/gtk/translate/translate_message_infobar_gtk.h" | 13 #include "chrome/browser/gtk/translate/translate_message_infobar_gtk.h" |
15 #include "chrome/browser/gtk/gtk_util.h" | 14 #include "chrome/browser/gtk/gtk_util.h" |
16 #include "chrome/browser/gtk/menu_gtk.h" | 15 #include "chrome/browser/gtk/menu_gtk.h" |
17 #include "gfx/canvas.h" | 16 #include "gfx/canvas.h" |
18 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
| 18 #include "ui/base/animation/slide_animation.h" |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 // To be able to map from language id <-> entry in the combo box, we | 22 // To be able to map from language id <-> entry in the combo box, we |
23 // store the language id in the combo box data model in addition to the | 23 // store the language id in the combo box data model in addition to the |
24 // displayed name. | 24 // displayed name. |
25 enum { | 25 enum { |
26 LANGUAGE_COMBO_COLUMN_ID, | 26 LANGUAGE_COMBO_COLUMN_ID, |
27 LANGUAGE_COMBO_COLUMN_NAME, | 27 LANGUAGE_COMBO_COLUMN_NAME, |
28 LANGUAGE_COMBO_COLUMN_COUNT | 28 LANGUAGE_COMBO_COLUMN_COUNT |
29 }; | 29 }; |
30 | 30 |
31 } // namespace | 31 } // namespace |
32 | 32 |
33 TranslateInfoBarBase::TranslateInfoBarBase(TranslateInfoBarDelegate* delegate) | 33 TranslateInfoBarBase::TranslateInfoBarBase(TranslateInfoBarDelegate* delegate) |
34 : InfoBar(delegate) { | 34 : InfoBar(delegate) { |
35 TranslateInfoBarDelegate::BackgroundAnimationType animation = | 35 TranslateInfoBarDelegate::BackgroundAnimationType animation = |
36 delegate->background_animation_type(); | 36 delegate->background_animation_type(); |
37 if (animation != TranslateInfoBarDelegate::NONE) { | 37 if (animation != TranslateInfoBarDelegate::NONE) { |
38 background_color_animation_.reset(new SlideAnimation(this)); | 38 background_color_animation_.reset(new ui::SlideAnimation(this)); |
39 background_color_animation_->SetTweenType(Tween::LINEAR); | 39 background_color_animation_->SetTweenType(ui::Tween::LINEAR); |
40 background_color_animation_->SetSlideDuration(500); | 40 background_color_animation_->SetSlideDuration(500); |
41 if (animation == TranslateInfoBarDelegate::NORMAL_TO_ERROR) { | 41 if (animation == TranslateInfoBarDelegate::NORMAL_TO_ERROR) { |
42 background_color_animation_->Show(); | 42 background_color_animation_->Show(); |
43 } else { | 43 } else { |
44 DCHECK_EQ(TranslateInfoBarDelegate::ERROR_TO_NORMAL, animation); | 44 DCHECK_EQ(TranslateInfoBarDelegate::ERROR_TO_NORMAL, animation); |
45 // Hide() runs the animation in reverse. | 45 // Hide() runs the animation in reverse. |
46 background_color_animation_->Reset(1.0); | 46 background_color_animation_->Reset(1.0); |
47 background_color_animation_->Hide(); | 47 background_color_animation_->Hide(); |
48 } | 48 } |
49 } else { | 49 } else { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 double offset_r = error_r - normal_r; | 110 double offset_r = error_r - normal_r; |
111 double offset_g = error_g - normal_g; | 111 double offset_g = error_g - normal_g; |
112 double offset_b = error_b - normal_b; | 112 double offset_b = error_b - normal_b; |
113 | 113 |
114 *r = normal_r + (background_error_percent_ * offset_r); | 114 *r = normal_r + (background_error_percent_ * offset_r); |
115 *g = normal_g + (background_error_percent_ * offset_g); | 115 *g = normal_g + (background_error_percent_ * offset_g); |
116 *b = normal_b + (background_error_percent_ * offset_b); | 116 *b = normal_b + (background_error_percent_ * offset_b); |
117 } | 117 } |
118 } | 118 } |
119 | 119 |
120 void TranslateInfoBarBase::AnimationProgressed(const Animation* animation) { | 120 void TranslateInfoBarBase::AnimationProgressed(const ui::Animation* animation) { |
121 DCHECK(animation == background_color_animation_.get()); | 121 DCHECK(animation == background_color_animation_.get()); |
122 background_error_percent_ = animation->GetCurrentValue(); | 122 background_error_percent_ = animation->GetCurrentValue(); |
123 // Queue the info bar widget for redisplay so it repaints its background. | 123 // Queue the info bar widget for redisplay so it repaints its background. |
124 gtk_widget_queue_draw(widget()); | 124 gtk_widget_queue_draw(widget()); |
125 } | 125 } |
126 | 126 |
127 bool TranslateInfoBarBase::ShowOptionsMenuButton() const { | 127 bool TranslateInfoBarBase::ShowOptionsMenuButton() const { |
128 return false; | 128 return false; |
129 } | 129 } |
130 | 130 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 break; | 232 break; |
233 default: | 233 default: |
234 NOTREACHED(); | 234 NOTREACHED(); |
235 } | 235 } |
236 infobar->Init(); | 236 infobar->Init(); |
237 // Set |infobar_view_| so that the model can notify the infobar when it | 237 // Set |infobar_view_| so that the model can notify the infobar when it |
238 // changes. | 238 // changes. |
239 infobar_view_ = infobar; | 239 infobar_view_ = infobar; |
240 return infobar; | 240 return infobar; |
241 } | 241 } |
OLD | NEW |