OLD | NEW |
1 // Copyright (c) 2009 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 <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include "app/animation.h" | 9 #include "app/linear_animation.h" |
10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "chrome/browser/tab_contents/tab_contents.h" | 12 #include "chrome/browser/tab_contents/tab_contents.h" |
13 #include "chrome/common/notification_registrar.h" | 13 #include "chrome/common/notification_registrar.h" |
14 #include "chrome/common/notification_service.h" | 14 #include "chrome/common/notification_service.h" |
15 #include "gfx/rect.h" | 15 #include "gfx/rect.h" |
16 #include "grit/theme_resources.h" | 16 #include "grit/theme_resources.h" |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 // How long to spend moving downwards and fading out after waiting. | 20 // How long to spend moving downwards and fading out after waiting. |
21 const int kMoveTimeMs = 600; | 21 const int kMoveTimeMs = 600; |
22 | 22 |
23 // The animation framerate. | 23 // The animation framerate. |
24 const int kFrameRateHz = 60; | 24 const int kFrameRateHz = 60; |
25 | 25 |
26 // What fraction of the frame height to move downward from the frame center. | 26 // What fraction of the frame height to move downward from the frame center. |
27 // Note that setting this greater than 0.5 will mean moving past the bottom of | 27 // Note that setting this greater than 0.5 will mean moving past the bottom of |
28 // the frame. | 28 // the frame. |
29 const double kMoveFraction = 1.0 / 3.0; | 29 const double kMoveFraction = 1.0 / 3.0; |
30 | 30 |
31 class DownloadStartedAnimationGtk : public Animation, | 31 class DownloadStartedAnimationGtk : public LinearAnimation, |
32 public NotificationObserver { | 32 public NotificationObserver { |
33 public: | 33 public: |
34 explicit DownloadStartedAnimationGtk(TabContents* tab_contents); | 34 explicit DownloadStartedAnimationGtk(TabContents* tab_contents); |
35 | 35 |
36 // DownloadStartedAnimation will delete itself, but this is public so | 36 // DownloadStartedAnimation will delete itself, but this is public so |
37 // that we can use DeleteSoon(). | 37 // that we can use DeleteSoon(). |
38 virtual ~DownloadStartedAnimationGtk(); | 38 virtual ~DownloadStartedAnimationGtk(); |
39 | 39 |
40 private: | 40 private: |
41 // Move the arrow to wherever it should currently be. | 41 // Move the arrow to wherever it should currently be. |
(...skipping 29 matching lines...) Expand all Loading... |
71 gfx::Rect tab_contents_bounds_; | 71 gfx::Rect tab_contents_bounds_; |
72 | 72 |
73 // A scoped container for notification registries. | 73 // A scoped container for notification registries. |
74 NotificationRegistrar registrar_; | 74 NotificationRegistrar registrar_; |
75 | 75 |
76 DISALLOW_COPY_AND_ASSIGN(DownloadStartedAnimationGtk); | 76 DISALLOW_COPY_AND_ASSIGN(DownloadStartedAnimationGtk); |
77 }; | 77 }; |
78 | 78 |
79 DownloadStartedAnimationGtk::DownloadStartedAnimationGtk( | 79 DownloadStartedAnimationGtk::DownloadStartedAnimationGtk( |
80 TabContents* tab_contents) | 80 TabContents* tab_contents) |
81 : Animation(kMoveTimeMs, kFrameRateHz, NULL), | 81 : LinearAnimation(kMoveTimeMs, kFrameRateHz, NULL), |
82 tab_contents_(tab_contents) { | 82 tab_contents_(tab_contents) { |
83 static GdkPixbuf* kDownloadImage = NULL; | 83 static GdkPixbuf* kDownloadImage = NULL; |
84 if (!kDownloadImage) { | 84 if (!kDownloadImage) { |
85 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 85 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
86 kDownloadImage = rb.GetPixbufNamed(IDR_DOWNLOAD_ANIMATION_BEGIN); | 86 kDownloadImage = rb.GetPixbufNamed(IDR_DOWNLOAD_ANIMATION_BEGIN); |
87 } | 87 } |
88 | 88 |
89 width_ = gdk_pixbuf_get_width(kDownloadImage); | 89 width_ = gdk_pixbuf_get_width(kDownloadImage); |
90 height_ = gdk_pixbuf_get_height(kDownloadImage); | 90 height_ = gdk_pixbuf_get_height(kDownloadImage); |
91 | 91 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 Close(); | 185 Close(); |
186 } | 186 } |
187 | 187 |
188 } // namespace | 188 } // namespace |
189 | 189 |
190 // static | 190 // static |
191 void DownloadStartedAnimation::Show(TabContents* tab_contents) { | 191 void DownloadStartedAnimation::Show(TabContents* tab_contents) { |
192 // The animation will delete itself. | 192 // The animation will delete itself. |
193 new DownloadStartedAnimationGtk(tab_contents); | 193 new DownloadStartedAnimationGtk(tab_contents); |
194 } | 194 } |
OLD | NEW |