| OLD | NEW |
| 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/download/download_started_animation.h" | 5 #include "chrome/browser/download/download_started_animation.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "content/public/browser/web_contents.h" | 8 #include "content/public/browser/web_contents.h" |
| 9 #include "grit/theme_resources.h" | 9 #include "grit/theme_resources.h" |
| 10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 popup_->Close(); | 106 popup_->Close(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 void DownloadStartedAnimationViews::AnimateToState(double state) { | 109 void DownloadStartedAnimationViews::AnimateToState(double state) { |
| 110 if (state >= 1.0) { | 110 if (state >= 1.0) { |
| 111 Close(); | 111 Close(); |
| 112 } else { | 112 } else { |
| 113 Reposition(); | 113 Reposition(); |
| 114 | 114 |
| 115 // Start at zero, peak halfway and end at zero. | 115 // Start at zero, peak halfway and end at zero. |
| 116 double opacity = std::min(1.0 - pow(GetCurrentValue() - 0.5, 2) * 4.0, | 116 popup_->SetOpacity(static_cast<float>( |
| 117 static_cast<double>(1.0)); | 117 std::min(1.0 - pow(GetCurrentValue() - 0.5, 2) * 4.0, 1.0))); |
| 118 | |
| 119 popup_->SetOpacity(static_cast<unsigned char>(opacity * 255.0)); | |
| 120 } | 118 } |
| 121 } | 119 } |
| 122 | 120 |
| 123 } // namespace | 121 } // namespace |
| 124 | 122 |
| 125 // static | 123 // static |
| 126 void DownloadStartedAnimation::Show(content::WebContents* web_contents) { | 124 void DownloadStartedAnimation::Show(content::WebContents* web_contents) { |
| 127 // The animation will delete itself when it's finished. | 125 // The animation will delete itself when it's finished. |
| 128 new DownloadStartedAnimationViews(web_contents); | 126 new DownloadStartedAnimationViews(web_contents); |
| 129 } | 127 } |
| OLD | NEW |