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/ui/views/location_bar/suggested_text_view.h" | 5 #include "chrome/browser/ui/views/location_bar/suggested_text_view.h" |
6 | 6 |
7 #include "app/multi_animation.h" | |
8 #include "chrome/browser/instant/instant_controller.h" | 7 #include "chrome/browser/instant/instant_controller.h" |
9 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
10 #include "gfx/canvas.h" | 9 #include "gfx/canvas.h" |
11 #include "gfx/color_utils.h" | 10 #include "gfx/color_utils.h" |
| 11 #include "ui/base/animation/multi_animation.h" |
12 | 12 |
13 SuggestedTextView::SuggestedTextView(LocationBarView* location_bar) | 13 SuggestedTextView::SuggestedTextView(LocationBarView* location_bar) |
14 : location_bar_(location_bar), | 14 : location_bar_(location_bar), |
15 bg_color_(0) { | 15 bg_color_(0) { |
16 } | 16 } |
17 | 17 |
18 SuggestedTextView::~SuggestedTextView() { | 18 SuggestedTextView::~SuggestedTextView() { |
19 } | 19 } |
20 | 20 |
21 void SuggestedTextView::StartAnimation() { | 21 void SuggestedTextView::StartAnimation() { |
(...skipping 20 matching lines...) Expand all Loading... |
42 } | 42 } |
43 | 43 |
44 void SuggestedTextView::PaintBackground(gfx::Canvas* canvas) { | 44 void SuggestedTextView::PaintBackground(gfx::Canvas* canvas) { |
45 if (!animation_.get() || animation_->GetCurrentValue() == 0) | 45 if (!animation_.get() || animation_->GetCurrentValue() == 0) |
46 return; | 46 return; |
47 | 47 |
48 // TODO(sky): these numbers need to come from the edit. | 48 // TODO(sky): these numbers need to come from the edit. |
49 canvas->FillRectInt(bg_color_, 0, 2, width(), height() - 5); | 49 canvas->FillRectInt(bg_color_, 0, 2, width(), height() - 5); |
50 } | 50 } |
51 | 51 |
52 void SuggestedTextView::AnimationEnded(const Animation* animation) { | 52 void SuggestedTextView::AnimationEnded(const ui::Animation* animation) { |
53 location_bar_->OnCommitSuggestedText(); | 53 location_bar_->OnCommitSuggestedText(); |
54 } | 54 } |
55 | 55 |
56 void SuggestedTextView::AnimationProgressed(const Animation* animation) { | 56 void SuggestedTextView::AnimationProgressed(const ui::Animation* animation) { |
57 UpdateBackgroundColor(); | 57 UpdateBackgroundColor(); |
58 | 58 |
59 SkColor fg_color = LocationBarView::GetColor( | 59 SkColor fg_color = LocationBarView::GetColor( |
60 ToolbarModel::NONE, LocationBarView::DEEMPHASIZED_TEXT); | 60 ToolbarModel::NONE, LocationBarView::DEEMPHASIZED_TEXT); |
61 SkColor sel_fg_color = LocationBarView::GetColor( | 61 SkColor sel_fg_color = LocationBarView::GetColor( |
62 ToolbarModel::NONE, LocationBarView::SELECTED_TEXT); | 62 ToolbarModel::NONE, LocationBarView::SELECTED_TEXT); |
63 SetColor(color_utils::AlphaBlend( | 63 SetColor(color_utils::AlphaBlend( |
64 sel_fg_color, fg_color, | 64 sel_fg_color, fg_color, |
65 Tween::ValueBetween(animation->GetCurrentValue(), 0, 255))); | 65 ui::Tween::ValueBetween(animation->GetCurrentValue(), 0, 255))); |
66 | 66 |
67 SchedulePaint(); | 67 SchedulePaint(); |
68 } | 68 } |
69 | 69 |
70 void SuggestedTextView::AnimationCanceled(const Animation* animation) { | 70 void SuggestedTextView::AnimationCanceled(const ui::Animation* animation) { |
71 } | 71 } |
72 | 72 |
73 Animation* SuggestedTextView::CreateAnimation() { | 73 ui::Animation* SuggestedTextView::CreateAnimation() { |
74 MultiAnimation::Parts parts; | 74 ui::MultiAnimation::Parts parts; |
75 parts.push_back(MultiAnimation::Part( | 75 parts.push_back(ui::MultiAnimation::Part( |
76 InstantController::kAutoCommitPauseTimeMS, Tween::ZERO)); | 76 InstantController::kAutoCommitPauseTimeMS, ui::Tween::ZERO)); |
77 parts.push_back(MultiAnimation::Part( | 77 parts.push_back(ui::MultiAnimation::Part( |
78 InstantController::kAutoCommitFadeInTimeMS, Tween::EASE_IN)); | 78 InstantController::kAutoCommitFadeInTimeMS, ui::Tween::EASE_IN)); |
79 MultiAnimation* animation = new MultiAnimation(parts); | 79 ui::MultiAnimation* animation = new ui::MultiAnimation(parts); |
80 animation->set_delegate(this); | 80 animation->set_delegate(this); |
81 animation->set_continuous(false); | 81 animation->set_continuous(false); |
82 return animation; | 82 return animation; |
83 } | 83 } |
84 | 84 |
85 void SuggestedTextView::UpdateBackgroundColor() { | 85 void SuggestedTextView::UpdateBackgroundColor() { |
86 if (!animation_.get()) { | 86 if (!animation_.get()) { |
87 // Background only painted while animating. | 87 // Background only painted while animating. |
88 return; | 88 return; |
89 } | 89 } |
90 | 90 |
91 double value = animation_->GetCurrentValue(); | 91 double value = animation_->GetCurrentValue(); |
92 SkColor bg_color = LocationBarView::GetColor(ToolbarModel::NONE, | 92 SkColor bg_color = LocationBarView::GetColor(ToolbarModel::NONE, |
93 LocationBarView::BACKGROUND); | 93 LocationBarView::BACKGROUND); |
94 #if defined(OS_WIN) | 94 #if defined(OS_WIN) |
95 SkColor s_color = color_utils::GetSysSkColor(COLOR_HIGHLIGHT); | 95 SkColor s_color = color_utils::GetSysSkColor(COLOR_HIGHLIGHT); |
96 #else | 96 #else |
97 // TODO(sky): fix me. | 97 // TODO(sky): fix me. |
98 NOTIMPLEMENTED(); | 98 NOTIMPLEMENTED(); |
99 SkColor s_color = SK_ColorLTGRAY; | 99 SkColor s_color = SK_ColorLTGRAY; |
100 #endif | 100 #endif |
101 bg_color_ = color_utils::AlphaBlend(s_color, bg_color, | 101 bg_color_ = color_utils::AlphaBlend(s_color, bg_color, |
102 Tween::ValueBetween(value, 0, 255)); | 102 ui::Tween::ValueBetween(value, 0, 255)); |
103 } | 103 } |
OLD | NEW |