| 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" | 7 #include "app/multi_animation.h" |
| 8 #include "chrome/browser/instant/instant_controller.h" | 8 #include "chrome/browser/instant/instant_controller.h" |
| 9 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 9 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 10 #include "gfx/canvas.h" | 10 #include "gfx/canvas.h" |
| 11 #include "gfx/color_utils.h" | 11 #include "gfx/color_utils.h" |
| 12 | 12 |
| 13 // Amount of time to wait before starting the animation. | |
| 14 static const int kPauseTimeMS = 1000; | |
| 15 | |
| 16 // Duration of the animation in which the colors change. | |
| 17 static const int kFadeInTimeMS = 300; | |
| 18 | |
| 19 SuggestedTextView::SuggestedTextView(LocationBarView* location_bar) | 13 SuggestedTextView::SuggestedTextView(LocationBarView* location_bar) |
| 20 : location_bar_(location_bar), | 14 : location_bar_(location_bar), |
| 21 bg_color_(0) { | 15 bg_color_(0) { |
| 22 } | 16 } |
| 23 | 17 |
| 24 SuggestedTextView::~SuggestedTextView() { | 18 SuggestedTextView::~SuggestedTextView() { |
| 25 } | 19 } |
| 26 | 20 |
| 27 void SuggestedTextView::StartAnimation() { | 21 void SuggestedTextView::StartAnimation() { |
| 28 if (!InstantController::IsEnabled(location_bar_->profile(), | 22 if (!InstantController::IsEnabled(location_bar_->profile(), |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 Tween::ValueBetween(animation->GetCurrentValue(), 0, 255))); | 65 Tween::ValueBetween(animation->GetCurrentValue(), 0, 255))); |
| 72 | 66 |
| 73 SchedulePaint(); | 67 SchedulePaint(); |
| 74 } | 68 } |
| 75 | 69 |
| 76 void SuggestedTextView::AnimationCanceled(const Animation* animation) { | 70 void SuggestedTextView::AnimationCanceled(const Animation* animation) { |
| 77 } | 71 } |
| 78 | 72 |
| 79 Animation* SuggestedTextView::CreateAnimation() { | 73 Animation* SuggestedTextView::CreateAnimation() { |
| 80 MultiAnimation::Parts parts; | 74 MultiAnimation::Parts parts; |
| 81 parts.push_back(MultiAnimation::Part(kPauseTimeMS, Tween::ZERO)); | 75 parts.push_back(MultiAnimation::Part( |
| 82 parts.push_back(MultiAnimation::Part(kFadeInTimeMS, Tween::EASE_IN)); | 76 InstantController::kAutoCommitPauseTimeMS, Tween::ZERO)); |
| 77 parts.push_back(MultiAnimation::Part( |
| 78 InstantController::kAutoCommitFadeInTimeMS, Tween::EASE_IN)); |
| 83 MultiAnimation* animation = new MultiAnimation(parts); | 79 MultiAnimation* animation = new MultiAnimation(parts); |
| 84 animation->set_delegate(this); | 80 animation->set_delegate(this); |
| 85 animation->set_continuous(false); | 81 animation->set_continuous(false); |
| 86 return animation; | 82 return animation; |
| 87 } | 83 } |
| 88 | 84 |
| 89 void SuggestedTextView::UpdateBackgroundColor() { | 85 void SuggestedTextView::UpdateBackgroundColor() { |
| 90 if (!animation_.get()) { | 86 if (!animation_.get()) { |
| 91 // Background only painted while animating. | 87 // Background only painted while animating. |
| 92 return; | 88 return; |
| 93 } | 89 } |
| 94 | 90 |
| 95 double value = animation_->GetCurrentValue(); | 91 double value = animation_->GetCurrentValue(); |
| 96 SkColor bg_color = LocationBarView::GetColor(ToolbarModel::NONE, | 92 SkColor bg_color = LocationBarView::GetColor(ToolbarModel::NONE, |
| 97 LocationBarView::BACKGROUND); | 93 LocationBarView::BACKGROUND); |
| 98 #if defined(OS_WIN) | 94 #if defined(OS_WIN) |
| 99 SkColor s_color = color_utils::GetSysSkColor(COLOR_HIGHLIGHT); | 95 SkColor s_color = color_utils::GetSysSkColor(COLOR_HIGHLIGHT); |
| 100 #else | 96 #else |
| 101 // TODO(sky): fix me. | 97 // TODO(sky): fix me. |
| 102 NOTIMPLEMENTED(); | 98 NOTIMPLEMENTED(); |
| 103 SkColor s_color = SK_ColorLTGRAY; | 99 SkColor s_color = SK_ColorLTGRAY; |
| 104 #endif | 100 #endif |
| 105 bg_color_ = color_utils::AlphaBlend(s_color, bg_color, | 101 bg_color_ = color_utils::AlphaBlend(s_color, bg_color, |
| 106 Tween::ValueBetween(value, 0, 255)); | 102 Tween::ValueBetween(value, 0, 255)); |
| 107 } | 103 } |
| OLD | NEW |