OLD | NEW |
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 // Draws the view for the balloons. | 5 // Draws the view for the balloons. |
6 | 6 |
7 #ifndef CHROME_BROWSER_GTK_NOTIFICATIONS_BALLOON_VIEW_GTK_H_ | 7 #ifndef CHROME_BROWSER_GTK_NOTIFICATIONS_BALLOON_VIEW_GTK_H_ |
8 #define CHROME_BROWSER_GTK_NOTIFICATIONS_BALLOON_VIEW_GTK_H_ | 8 #define CHROME_BROWSER_GTK_NOTIFICATIONS_BALLOON_VIEW_GTK_H_ |
9 #pragma once | 9 #pragma once |
10 | 10 |
11 #include "app/animation_delegate.h" | |
12 #include "app/gtk_signal.h" | 11 #include "app/gtk_signal.h" |
13 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
14 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
15 #include "chrome/browser/gtk/menu_gtk.h" | 14 #include "chrome/browser/gtk/menu_gtk.h" |
16 #include "chrome/browser/gtk/notifications/balloon_view_host_gtk.h" | 15 #include "chrome/browser/gtk/notifications/balloon_view_host_gtk.h" |
17 #include "chrome/browser/notifications/balloon.h" | 16 #include "chrome/browser/notifications/balloon.h" |
18 #include "chrome/common/notification_observer.h" | 17 #include "chrome/common/notification_observer.h" |
19 #include "chrome/common/notification_registrar.h" | 18 #include "chrome/common/notification_registrar.h" |
20 #include "gfx/point.h" | 19 #include "gfx/point.h" |
21 #include "gfx/rect.h" | 20 #include "gfx/rect.h" |
22 #include "gfx/size.h" | 21 #include "gfx/size.h" |
| 22 #include "ui/base/animation/animation_delegate.h" |
23 | 23 |
24 class BalloonCollection; | 24 class BalloonCollection; |
25 class CustomDrawButton; | 25 class CustomDrawButton; |
26 class GtkThemeProvider; | 26 class GtkThemeProvider; |
27 class MenuGtk; | 27 class MenuGtk; |
28 class NotificationDetails; | 28 class NotificationDetails; |
29 class NotificationOptionsMenuModel; | 29 class NotificationOptionsMenuModel; |
30 class NotificationSource; | 30 class NotificationSource; |
| 31 |
| 32 namespace ui { |
31 class SlideAnimation; | 33 class SlideAnimation; |
| 34 } |
32 | 35 |
33 // A balloon view is the UI component for desktop notification toasts. | 36 // A balloon view is the UI component for desktop notification toasts. |
34 // It draws a border, and within the border an HTML renderer. | 37 // It draws a border, and within the border an HTML renderer. |
35 class BalloonViewImpl : public BalloonView, | 38 class BalloonViewImpl : public BalloonView, |
36 public MenuGtk::Delegate, | 39 public MenuGtk::Delegate, |
37 public NotificationObserver, | 40 public NotificationObserver, |
38 public AnimationDelegate { | 41 public ui::AnimationDelegate { |
39 public: | 42 public: |
40 explicit BalloonViewImpl(BalloonCollection* collection); | 43 explicit BalloonViewImpl(BalloonCollection* collection); |
41 ~BalloonViewImpl(); | 44 ~BalloonViewImpl(); |
42 | 45 |
43 // BalloonView interface. | 46 // BalloonView interface. |
44 virtual void Show(Balloon* balloon); | 47 virtual void Show(Balloon* balloon); |
45 virtual void Update(); | 48 virtual void Update(); |
46 virtual void RepositionToBalloon(); | 49 virtual void RepositionToBalloon(); |
47 virtual void Close(bool by_user); | 50 virtual void Close(bool by_user); |
48 virtual gfx::Size GetSize() const; | 51 virtual gfx::Size GetSize() const; |
49 virtual BalloonHost* GetHost() const; | 52 virtual BalloonHost* GetHost() const; |
50 | 53 |
51 private: | 54 private: |
52 // NotificationObserver interface. | 55 // NotificationObserver interface. |
53 virtual void Observe(NotificationType type, | 56 virtual void Observe(NotificationType type, |
54 const NotificationSource& source, | 57 const NotificationSource& source, |
55 const NotificationDetails& details); | 58 const NotificationDetails& details); |
56 | 59 |
57 // AnimationDelegate interface. | 60 // ui::AnimationDelegate interface. |
58 virtual void AnimationProgressed(const Animation* animation); | 61 virtual void AnimationProgressed(const ui::Animation* animation); |
59 | 62 |
60 // Do the delayed close work. | 63 // Do the delayed close work. |
61 void DelayedClose(bool by_user); | 64 void DelayedClose(bool by_user); |
62 | 65 |
63 // The height of the balloon's shelf. | 66 // The height of the balloon's shelf. |
64 // The shelf is where is close button is located. | 67 // The shelf is where is close button is located. |
65 int GetShelfHeight() const; | 68 int GetShelfHeight() const; |
66 | 69 |
67 // The width and height that the frame should be. If the balloon inside | 70 // The width and height that the frame should be. If the balloon inside |
68 // changes size, this will not be the same as the actual frame size until | 71 // changes size, this will not be the same as the actual frame size until |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 // The renderer of the HTML contents. | 105 // The renderer of the HTML contents. |
103 scoped_ptr<BalloonViewHost> html_contents_; | 106 scoped_ptr<BalloonViewHost> html_contents_; |
104 | 107 |
105 // The following factory is used to call methods at a later time. | 108 // The following factory is used to call methods at a later time. |
106 ScopedRunnableMethodFactory<BalloonViewImpl> method_factory_; | 109 ScopedRunnableMethodFactory<BalloonViewImpl> method_factory_; |
107 | 110 |
108 // Close button. | 111 // Close button. |
109 scoped_ptr<CustomDrawButton> close_button_; | 112 scoped_ptr<CustomDrawButton> close_button_; |
110 | 113 |
111 // An animation to move the balloon on the screen as its position changes. | 114 // An animation to move the balloon on the screen as its position changes. |
112 scoped_ptr<SlideAnimation> animation_; | 115 scoped_ptr<ui::SlideAnimation> animation_; |
113 gfx::Rect anim_frame_start_; | 116 gfx::Rect anim_frame_start_; |
114 gfx::Rect anim_frame_end_; | 117 gfx::Rect anim_frame_end_; |
115 | 118 |
116 // The options menu. | 119 // The options menu. |
117 scoped_ptr<MenuGtk> options_menu_; | 120 scoped_ptr<MenuGtk> options_menu_; |
118 scoped_ptr<NotificationOptionsMenuModel> options_menu_model_; | 121 scoped_ptr<NotificationOptionsMenuModel> options_menu_model_; |
119 // The button to open the options menu. | 122 // The button to open the options menu. |
120 scoped_ptr<CustomDrawButton> options_menu_button_; | 123 scoped_ptr<CustomDrawButton> options_menu_button_; |
121 | 124 |
122 NotificationRegistrar notification_registrar_; | 125 NotificationRegistrar notification_registrar_; |
123 | 126 |
124 DISALLOW_COPY_AND_ASSIGN(BalloonViewImpl); | 127 DISALLOW_COPY_AND_ASSIGN(BalloonViewImpl); |
125 }; | 128 }; |
126 | 129 |
127 #endif // CHROME_BROWSER_GTK_NOTIFICATIONS_BALLOON_VIEW_GTK_H_ | 130 #endif // CHROME_BROWSER_GTK_NOTIFICATIONS_BALLOON_VIEW_GTK_H_ |
OLD | NEW |