Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Side by Side Diff: chrome/browser/views/download_started_animation_win.cc

Issue 1961001: Refactors animation to allow for cleaner subclassing. I'm doing this (Closed)
Patch Set: Incorporated review feedback Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/views/download_shelf_view.cc ('k') | chrome/browser/views/dropdown_bar_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "app/animation.h" 7 #include "app/linear_animation.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "chrome/browser/tab_contents/tab_contents.h" 9 #include "chrome/browser/tab_contents/tab_contents.h"
10 #include "chrome/common/notification_registrar.h" 10 #include "chrome/common/notification_registrar.h"
11 #include "chrome/common/notification_service.h" 11 #include "chrome/common/notification_service.h"
12 #include "gfx/rect.h" 12 #include "gfx/rect.h"
13 #include "grit/theme_resources.h" 13 #include "grit/theme_resources.h"
14 #include "views/controls/image_view.h" 14 #include "views/controls/image_view.h"
15 #include "views/widget/widget_win.h" 15 #include "views/widget/widget_win.h"
16 16
17 // How long to spend moving downwards and fading out after waiting. 17 // How long to spend moving downwards and fading out after waiting.
18 static const int kMoveTimeMs = 600; 18 static const int kMoveTimeMs = 600;
19 19
20 // The animation framerate. 20 // The animation framerate.
21 static const int kFrameRateHz = 60; 21 static const int kFrameRateHz = 60;
22 22
23 // What fraction of the frame height to move downward from the frame center. 23 // What fraction of the frame height to move downward from the frame center.
24 // Note that setting this greater than 0.5 will mean moving past the bottom of 24 // Note that setting this greater than 0.5 will mean moving past the bottom of
25 // the frame. 25 // the frame.
26 static const double kMoveFraction = 1.0 / 3.0; 26 static const double kMoveFraction = 1.0 / 3.0;
27 27
28 namespace { 28 namespace {
29 29
30 // DownloadStartAnimation creates an animation (which begins running 30 // DownloadStartAnimation creates an animation (which begins running
31 // immediately) that animates an image downward from the center of the frame 31 // immediately) that animates an image downward from the center of the frame
32 // provided on the constructor, while simultaneously fading it out. To use, 32 // provided on the constructor, while simultaneously fading it out. To use,
33 // simply call "new DownloadStartAnimation"; the class cleans itself up when it 33 // simply call "new DownloadStartAnimation"; the class cleans itself up when it
34 // finishes animating. 34 // finishes animating.
35 class DownloadStartedAnimationWin : public Animation, 35 class DownloadStartedAnimationWin : public LinearAnimation,
36 public NotificationObserver, 36 public NotificationObserver,
37 public views::ImageView { 37 public views::ImageView {
38 public: 38 public:
39 explicit DownloadStartedAnimationWin(TabContents* tab_contents); 39 explicit DownloadStartedAnimationWin(TabContents* tab_contents);
40 40
41 private: 41 private:
42 // Move the animation to wherever it should currently be. 42 // Move the animation to wherever it should currently be.
43 void Reposition(); 43 void Reposition();
44 44
45 // Shut down the animation cleanly. 45 // Shut down the animation cleanly.
(...skipping 21 matching lines...) Expand all
67 gfx::Rect tab_contents_bounds_; 67 gfx::Rect tab_contents_bounds_;
68 68
69 // A scoped container for notification registries. 69 // A scoped container for notification registries.
70 NotificationRegistrar registrar_; 70 NotificationRegistrar registrar_;
71 71
72 DISALLOW_COPY_AND_ASSIGN(DownloadStartedAnimationWin); 72 DISALLOW_COPY_AND_ASSIGN(DownloadStartedAnimationWin);
73 }; 73 };
74 74
75 DownloadStartedAnimationWin::DownloadStartedAnimationWin( 75 DownloadStartedAnimationWin::DownloadStartedAnimationWin(
76 TabContents* tab_contents) 76 TabContents* tab_contents)
77 : Animation(kMoveTimeMs, kFrameRateHz, NULL), 77 : LinearAnimation(kMoveTimeMs, kFrameRateHz, NULL),
78 popup_(NULL), 78 popup_(NULL),
79 tab_contents_(tab_contents) { 79 tab_contents_(tab_contents) {
80 static SkBitmap* kDownloadImage = NULL; 80 static SkBitmap* kDownloadImage = NULL;
81 if (!kDownloadImage) { 81 if (!kDownloadImage) {
82 kDownloadImage = ResourceBundle::GetSharedInstance().GetBitmapNamed( 82 kDownloadImage = ResourceBundle::GetSharedInstance().GetBitmapNamed(
83 IDR_DOWNLOAD_ANIMATION_BEGIN); 83 IDR_DOWNLOAD_ANIMATION_BEGIN);
84 } 84 }
85 85
86 // If we're too small to show the download image, then don't bother - 86 // If we're too small to show the download image, then don't bother -
87 // the shelf will be enough. 87 // the shelf will be enough.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 171 }
172 172
173 } // namespace 173 } // namespace
174 174
175 // static 175 // static
176 void DownloadStartedAnimation::Show(TabContents* tab_contents) { 176 void DownloadStartedAnimation::Show(TabContents* tab_contents) {
177 // The animation will delete itself when it's finished or when the tab 177 // The animation will delete itself when it's finished or when the tab
178 // contents is hidden or destroyed. 178 // contents is hidden or destroyed.
179 new DownloadStartedAnimationWin(tab_contents); 179 new DownloadStartedAnimationWin(tab_contents);
180 } 180 }
OLDNEW
« no previous file with comments | « chrome/browser/views/download_shelf_view.cc ('k') | chrome/browser/views/dropdown_bar_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698