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

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

Issue 6154001: Move animation code to new ui/base/animation directory.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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 | Annotate | Revision Log
OLDNEW
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/download/download_started_animation.h" 5 #include "chrome/browser/download/download_started_animation.h"
6 6
7 #include "app/linear_animation.h"
8 #include "app/resource_bundle.h" 7 #include "app/resource_bundle.h"
9 #include "chrome/browser/tab_contents/tab_contents.h" 8 #include "chrome/browser/tab_contents/tab_contents.h"
10 #include "chrome/common/notification_details.h" 9 #include "chrome/common/notification_details.h"
11 #include "chrome/common/notification_registrar.h" 10 #include "chrome/common/notification_registrar.h"
12 #include "chrome/common/notification_source.h" 11 #include "chrome/common/notification_source.h"
13 #include "gfx/rect.h" 12 #include "gfx/rect.h"
14 #include "grit/theme_resources.h" 13 #include "grit/theme_resources.h"
14 #include "ui/base/animation/linear_animation.h"
15 #include "views/controls/image_view.h" 15 #include "views/controls/image_view.h"
16 #include "views/widget/widget_win.h" 16 #include "views/widget/widget_win.h"
17 17
18 // How long to spend moving downwards and fading out after waiting. 18 // How long to spend moving downwards and fading out after waiting.
19 static const int kMoveTimeMs = 600; 19 static const int kMoveTimeMs = 600;
20 20
21 // The animation framerate. 21 // The animation framerate.
22 static const int kFrameRateHz = 60; 22 static const int kFrameRateHz = 60;
23 23
24 // What fraction of the frame height to move downward from the frame center. 24 // What fraction of the frame height to move downward from the frame center.
25 // Note that setting this greater than 0.5 will mean moving past the bottom of 25 // Note that setting this greater than 0.5 will mean moving past the bottom of
26 // the frame. 26 // the frame.
27 static const double kMoveFraction = 1.0 / 3.0; 27 static const double kMoveFraction = 1.0 / 3.0;
28 28
29 namespace { 29 namespace {
30 30
31 // DownloadStartAnimation creates an animation (which begins running 31 // DownloadStartAnimation creates an animation (which begins running
32 // 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
33 // provided on the constructor, while simultaneously fading it out. To use, 33 // provided on the constructor, while simultaneously fading it out. To use,
34 // simply call "new DownloadStartAnimation"; the class cleans itself up when it 34 // simply call "new DownloadStartAnimation"; the class cleans itself up when it
35 // finishes animating. 35 // finishes animating.
36 class DownloadStartedAnimationWin : public LinearAnimation, 36 class DownloadStartedAnimationWin : public ui::LinearAnimation,
37 public NotificationObserver, 37 public NotificationObserver,
38 public views::ImageView { 38 public views::ImageView {
39 public: 39 public:
40 explicit DownloadStartedAnimationWin(TabContents* tab_contents); 40 explicit DownloadStartedAnimationWin(TabContents* tab_contents);
41 41
42 private: 42 private:
43 // Move the animation to wherever it should currently be. 43 // Move the animation to wherever it should currently be.
44 void Reposition(); 44 void Reposition();
45 45
46 // Shut down the animation cleanly. 46 // Shut down the animation cleanly.
(...skipping 21 matching lines...) Expand all
68 gfx::Rect tab_contents_bounds_; 68 gfx::Rect tab_contents_bounds_;
69 69
70 // A scoped container for notification registries. 70 // A scoped container for notification registries.
71 NotificationRegistrar registrar_; 71 NotificationRegistrar registrar_;
72 72
73 DISALLOW_COPY_AND_ASSIGN(DownloadStartedAnimationWin); 73 DISALLOW_COPY_AND_ASSIGN(DownloadStartedAnimationWin);
74 }; 74 };
75 75
76 DownloadStartedAnimationWin::DownloadStartedAnimationWin( 76 DownloadStartedAnimationWin::DownloadStartedAnimationWin(
77 TabContents* tab_contents) 77 TabContents* tab_contents)
78 : LinearAnimation(kMoveTimeMs, kFrameRateHz, NULL), 78 : ui::LinearAnimation(kMoveTimeMs, kFrameRateHz, NULL),
79 popup_(NULL), 79 popup_(NULL),
80 tab_contents_(tab_contents) { 80 tab_contents_(tab_contents) {
81 static SkBitmap* kDownloadImage = NULL; 81 static SkBitmap* kDownloadImage = NULL;
82 if (!kDownloadImage) { 82 if (!kDownloadImage) {
83 kDownloadImage = ResourceBundle::GetSharedInstance().GetBitmapNamed( 83 kDownloadImage = ResourceBundle::GetSharedInstance().GetBitmapNamed(
84 IDR_DOWNLOAD_ANIMATION_BEGIN); 84 IDR_DOWNLOAD_ANIMATION_BEGIN);
85 } 85 }
86 86
87 // If we're too small to show the download image, then don't bother - 87 // If we're too small to show the download image, then don't bother -
88 // the shelf will be enough. 88 // the shelf will be enough.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 } 172 }
173 173
174 } // namespace 174 } // namespace
175 175
176 // static 176 // static
177 void DownloadStartedAnimation::Show(TabContents* tab_contents) { 177 void DownloadStartedAnimation::Show(TabContents* tab_contents) {
178 // The animation will delete itself when it's finished or when the tab 178 // The animation will delete itself when it's finished or when the tab
179 // contents is hidden or destroyed. 179 // contents is hidden or destroyed.
180 new DownloadStartedAnimationWin(tab_contents); 180 new DownloadStartedAnimationWin(tab_contents);
181 } 181 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/download_shelf_view.cc ('k') | chrome/browser/ui/views/dropdown_bar_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698