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 "content/public/browser/notification_details.h" | 7 #include "content/public/browser/notification_details.h" |
8 #include "content/public/browser/notification_observer.h" | 8 #include "content/public/browser/notification_observer.h" |
9 #include "content/public/browser/notification_registrar.h" | 9 #include "content/public/browser/notification_registrar.h" |
10 #include "content/public/browser/notification_source.h" | 10 #include "content/public/browser/notification_source.h" |
11 #include "content/public/browser/notification_types.h" | 11 #include "content/public/browser/notification_types.h" |
12 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
13 #include "content/public/browser/web_contents_view.h" | 13 #include "content/public/browser/web_contents_view.h" |
14 #include "grit/theme_resources.h" | 14 #include "grit/theme_resources.h" |
15 #include "ui/base/resource/resource_bundle.h" | 15 #include "ui/base/resource/resource_bundle.h" |
16 #include "ui/gfx/animation/linear_animation.h" | 16 #include "ui/gfx/animation/linear_animation.h" |
17 #include "ui/gfx/rect.h" | 17 #include "ui/gfx/rect.h" |
18 #include "ui/views/controls/image_view.h" | 18 #include "ui/views/controls/image_view.h" |
19 #include "ui/views/widget/widget.h" | 19 #include "ui/views/widget/widget.h" |
20 | 20 |
21 using content::WebContents; | 21 using content::WebContents; |
22 | 22 |
23 // How long to spend moving downwards and fading out after waiting. | 23 // How long to spend moving downwards and fading out after waiting. |
24 static const int kMoveTimeMs = 600; | 24 const int kMoveTimeMs = 600; |
25 | 25 |
26 // The animation framerate. | 26 // The animation framerate. |
27 static const int kFrameRateHz = 60; | 27 const int kFrameRateHz = 60; |
28 | |
29 // What fraction of the frame height to move downward from the frame center. | |
30 // Note that setting this greater than 0.5 will mean moving past the bottom of | |
31 // the frame. | |
32 static const double kMoveFraction = 1.0 / 3.0; | |
33 | 28 |
34 namespace { | 29 namespace { |
35 | 30 |
36 // DownloadStartAnimation creates an animation (which begins running | 31 // DownloadStartAnimation creates an animation (which begins running |
37 // immediately) that animates an image downward from the center of the frame | 32 // immediately) that animates an image downward from the center of the frame |
38 // provided on the constructor, while simultaneously fading it out. To use, | 33 // provided on the constructor, while simultaneously fading it out. To use, |
39 // simply call "new DownloadStartAnimation"; the class cleans itself up when it | 34 // simply call "new DownloadStartAnimation"; the class cleans itself up when it |
40 // finishes animating. | 35 // finishes animating. |
41 class DownloadStartedAnimationWin : public gfx::LinearAnimation, | 36 class DownloadStartedAnimationWin : public gfx::LinearAnimation, |
42 public content::NotificationObserver, | 37 public content::NotificationObserver, |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 } | 176 } |
182 | 177 |
183 } // namespace | 178 } // namespace |
184 | 179 |
185 // static | 180 // static |
186 void DownloadStartedAnimation::Show(WebContents* web_contents) { | 181 void DownloadStartedAnimation::Show(WebContents* web_contents) { |
187 // The animation will delete itself when it's finished or when the tab | 182 // The animation will delete itself when it's finished or when the tab |
188 // contents is hidden or destroyed. | 183 // contents is hidden or destroyed. |
189 new DownloadStartedAnimationWin(web_contents); | 184 new DownloadStartedAnimationWin(web_contents); |
190 } | 185 } |
OLD | NEW |