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 #ifndef CHROME_BROWSER_UI_GTK_THROBBER_GTK_H_ | 5 #ifndef CHROME_BROWSER_UI_GTK_THROBBER_GTK_H_ |
6 #define CHROME_BROWSER_UI_GTK_THROBBER_GTK_H_ | 6 #define CHROME_BROWSER_UI_GTK_THROBBER_GTK_H_ |
7 | 7 |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "content/public/browser/notification_observer.h" | 11 #include "content/public/browser/notification_observer.h" |
12 #include "content/public/browser/notification_registrar.h" | 12 #include "content/public/browser/notification_registrar.h" |
13 #include "ui/base/animation/animation_delegate.h" | |
14 #include "ui/base/animation/slide_animation.h" | |
15 #include "ui/base/gtk/gtk_signal.h" | 13 #include "ui/base/gtk/gtk_signal.h" |
16 #include "ui/base/gtk/owned_widget_gtk.h" | 14 #include "ui/base/gtk/owned_widget_gtk.h" |
| 15 #include "ui/gfx/animation/animation_delegate.h" |
| 16 #include "ui/gfx/animation/slide_animation.h" |
17 #include "ui/gfx/image/image.h" | 17 #include "ui/gfx/image/image.h" |
18 | 18 |
19 class GtkThemeService; | 19 class GtkThemeService; |
20 class SkBitmap; | 20 class SkBitmap; |
21 | 21 |
22 // An animating throbber. | 22 // An animating throbber. |
23 class ThrobberGtk : public ui::AnimationDelegate, | 23 class ThrobberGtk : public gfx::AnimationDelegate, |
24 public content::NotificationObserver { | 24 public content::NotificationObserver { |
25 public: | 25 public: |
26 // |theme_service| must not be NULL. | 26 // |theme_service| must not be NULL. |
27 explicit ThrobberGtk(GtkThemeService* theme_service); | 27 explicit ThrobberGtk(GtkThemeService* theme_service); |
28 virtual ~ThrobberGtk(); | 28 virtual ~ThrobberGtk(); |
29 | 29 |
30 // Start or stop the throbbing animation. | 30 // Start or stop the throbbing animation. |
31 void Start(); | 31 void Start(); |
32 void Stop(); | 32 void Stop(); |
33 | 33 |
34 GtkWidget* widget() const { return widget_.get(); } | 34 GtkWidget* widget() const { return widget_.get(); } |
35 | 35 |
36 // ui::AnimationDelegate implementation. | 36 // gfx::AnimationDelegate implementation. |
37 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; | 37 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; |
38 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | 38 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; |
39 | 39 |
40 // content::NotificationObserver implementation. | 40 // content::NotificationObserver implementation. |
41 virtual void Observe(int type, | 41 virtual void Observe(int type, |
42 const content::NotificationSource& source, | 42 const content::NotificationSource& source, |
43 const content::NotificationDetails& details) OVERRIDE; | 43 const content::NotificationDetails& details) OVERRIDE; |
44 | 44 |
45 private: | 45 private: |
46 CHROMEGTK_CALLBACK_1(ThrobberGtk, gboolean, OnExpose, GdkEventExpose*); | 46 CHROMEGTK_CALLBACK_1(ThrobberGtk, gboolean, OnExpose, GdkEventExpose*); |
47 | 47 |
48 // Initialize the widget. | 48 // Initialize the widget. |
49 void Init(); | 49 void Init(); |
50 | 50 |
51 // Load the animation frames from IDR_THROBBER. | 51 // Load the animation frames from IDR_THROBBER. |
52 void LoadFrames(); | 52 void LoadFrames(); |
53 | 53 |
54 content::NotificationRegistrar registrar_; | 54 content::NotificationRegistrar registrar_; |
55 | 55 |
56 // The theme service. Weak pointer. | 56 // The theme service. Weak pointer. |
57 GtkThemeService* theme_service_; | 57 GtkThemeService* theme_service_; |
58 | 58 |
59 // The actual GtkWidget. | 59 // The actual GtkWidget. |
60 ui::OwnedWidgetGtk widget_; | 60 ui::OwnedWidgetGtk widget_; |
61 | 61 |
62 // A linear animation over the loaded frames. | 62 // A linear animation over the loaded frames. |
63 ui::SlideAnimation animation_; | 63 gfx::SlideAnimation animation_; |
64 | 64 |
65 // The image containing the throbber frames. | 65 // The image containing the throbber frames. |
66 gfx::Image frames_; | 66 gfx::Image frames_; |
67 | 67 |
68 // The number of frames in |frames_|. | 68 // The number of frames in |frames_|. |
69 int num_frames_; | 69 int num_frames_; |
70 | 70 |
71 DISALLOW_COPY_AND_ASSIGN(ThrobberGtk); | 71 DISALLOW_COPY_AND_ASSIGN(ThrobberGtk); |
72 }; | 72 }; |
73 | 73 |
74 #endif // CHROME_BROWSER_UI_GTK_THROBBER_GTK_H_ | 74 #endif // CHROME_BROWSER_UI_GTK_THROBBER_GTK_H_ |
OLD | NEW |