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_UI_VIEWS_NOTIFICATIONS_BALLOON_VIEW_H_ | 7 #ifndef CHROME_BROWSER_UI_VIEWS_NOTIFICATIONS_BALLOON_VIEW_H_ |
8 #define CHROME_BROWSER_UI_VIEWS_NOTIFICATIONS_BALLOON_VIEW_H_ | 8 #define CHROME_BROWSER_UI_VIEWS_NOTIFICATIONS_BALLOON_VIEW_H_ |
9 #pragma once | 9 #pragma once |
10 | 10 |
11 #include "app/animation_delegate.h" | |
12 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
13 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
14 #include "base/task.h" | 13 #include "base/task.h" |
15 #include "chrome/browser/notifications/balloon.h" | 14 #include "chrome/browser/notifications/balloon.h" |
16 #include "chrome/browser/views/notifications/balloon_view_host.h" | 15 #include "chrome/browser/views/notifications/balloon_view_host.h" |
17 #include "chrome/common/notification_registrar.h" | 16 #include "chrome/common/notification_registrar.h" |
18 #include "gfx/path.h" | 17 #include "gfx/path.h" |
19 #include "gfx/point.h" | 18 #include "gfx/point.h" |
20 #include "gfx/rect.h" | 19 #include "gfx/rect.h" |
21 #include "gfx/size.h" | 20 #include "gfx/size.h" |
| 21 #include "ui/base/animation/animation_delegate.h" |
22 #include "views/controls/button/menu_button.h" | 22 #include "views/controls/button/menu_button.h" |
23 #include "views/controls/label.h" | 23 #include "views/controls/label.h" |
24 #include "views/controls/menu/view_menu_delegate.h" | 24 #include "views/controls/menu/view_menu_delegate.h" |
25 #include "views/view.h" | 25 #include "views/view.h" |
26 #include "views/widget/widget_delegate.h" | 26 #include "views/widget/widget_delegate.h" |
27 | 27 |
28 namespace views { | 28 namespace views { |
29 class ButtonListener; | 29 class ButtonListener; |
30 class ImageButton; | 30 class ImageButton; |
31 class ImagePainter; | 31 class ImagePainter; |
32 class TextButton; | 32 class TextButton; |
33 class WidgetWin; | 33 class WidgetWin; |
34 class Menu2; | 34 class Menu2; |
35 } // namespace views | 35 } // namespace views |
36 | 36 |
37 class BalloonCollection; | 37 class BalloonCollection; |
38 class NotificationDetails; | 38 class NotificationDetails; |
39 class NotificationOptionsMenuModel; | 39 class NotificationOptionsMenuModel; |
40 class NotificationSource; | 40 class NotificationSource; |
| 41 |
| 42 namespace ui { |
41 class SlideAnimation; | 43 class SlideAnimation; |
| 44 } |
42 | 45 |
43 // A balloon view is the UI component for a desktop notification toasts. | 46 // A balloon view is the UI component for a desktop notification toasts. |
44 // It draws a border, and within the border an HTML renderer. | 47 // It draws a border, and within the border an HTML renderer. |
45 class BalloonViewImpl : public BalloonView, | 48 class BalloonViewImpl : public BalloonView, |
46 public views::View, | 49 public views::View, |
47 public views::ViewMenuDelegate, | 50 public views::ViewMenuDelegate, |
48 public views::WidgetDelegate, | 51 public views::WidgetDelegate, |
49 public views::ButtonListener, | 52 public views::ButtonListener, |
50 public NotificationObserver, | 53 public NotificationObserver, |
51 public AnimationDelegate { | 54 public ui::AnimationDelegate { |
52 public: | 55 public: |
53 explicit BalloonViewImpl(BalloonCollection* collection); | 56 explicit BalloonViewImpl(BalloonCollection* collection); |
54 ~BalloonViewImpl(); | 57 ~BalloonViewImpl(); |
55 | 58 |
56 // BalloonView interface. | 59 // BalloonView interface. |
57 virtual void Show(Balloon* balloon); | 60 virtual void Show(Balloon* balloon); |
58 virtual void Update(); | 61 virtual void Update(); |
59 virtual void RepositionToBalloon(); | 62 virtual void RepositionToBalloon(); |
60 virtual void Close(bool by_user); | 63 virtual void Close(bool by_user); |
61 virtual gfx::Size GetSize() const; | 64 virtual gfx::Size GetSize() const; |
(...skipping 14 matching lines...) Expand all Loading... |
76 virtual void WorkAreaChanged(); | 79 virtual void WorkAreaChanged(); |
77 | 80 |
78 // views::ButtonListener interface. | 81 // views::ButtonListener interface. |
79 virtual void ButtonPressed(views::Button* sender, const views::Event&); | 82 virtual void ButtonPressed(views::Button* sender, const views::Event&); |
80 | 83 |
81 // NotificationObserver interface. | 84 // NotificationObserver interface. |
82 virtual void Observe(NotificationType type, | 85 virtual void Observe(NotificationType type, |
83 const NotificationSource& source, | 86 const NotificationSource& source, |
84 const NotificationDetails& details); | 87 const NotificationDetails& details); |
85 | 88 |
86 // AnimationDelegate interface. | 89 // ui::AnimationDelegate interface. |
87 virtual void AnimationProgressed(const Animation* animation); | 90 virtual void AnimationProgressed(const ui::Animation* animation); |
88 | 91 |
89 // Launches the options menu at screen coordinates |pt|. | 92 // Launches the options menu at screen coordinates |pt|. |
90 void RunOptionsMenu(const gfx::Point& pt); | 93 void RunOptionsMenu(const gfx::Point& pt); |
91 | 94 |
92 // Initializes the options menu. | 95 // Initializes the options menu. |
93 void CreateOptionsMenu(); | 96 void CreateOptionsMenu(); |
94 | 97 |
95 // Masks the contents to fit within the frame. | 98 // Masks the contents to fit within the frame. |
96 void GetContentsMask(const gfx::Rect& contents_rect, gfx::Path* path) const; | 99 void GetContentsMask(const gfx::Rect& contents_rect, gfx::Path* path) const; |
97 | 100 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 // The following factory is used to call methods at a later time. | 148 // The following factory is used to call methods at a later time. |
146 ScopedRunnableMethodFactory<BalloonViewImpl> method_factory_; | 149 ScopedRunnableMethodFactory<BalloonViewImpl> method_factory_; |
147 | 150 |
148 // Pointer to sub-view is owned by the View sub-class. | 151 // Pointer to sub-view is owned by the View sub-class. |
149 views::ImageButton* close_button_; | 152 views::ImageButton* close_button_; |
150 | 153 |
151 // Pointer to sub-view is owned by View class. | 154 // Pointer to sub-view is owned by View class. |
152 views::Label* source_label_; | 155 views::Label* source_label_; |
153 | 156 |
154 // An animation to move the balloon on the screen as its position changes. | 157 // An animation to move the balloon on the screen as its position changes. |
155 scoped_ptr<SlideAnimation> animation_; | 158 scoped_ptr<ui::SlideAnimation> animation_; |
156 gfx::Rect anim_frame_start_; | 159 gfx::Rect anim_frame_start_; |
157 gfx::Rect anim_frame_end_; | 160 gfx::Rect anim_frame_end_; |
158 | 161 |
159 // The options menu. | 162 // The options menu. |
160 scoped_ptr<NotificationOptionsMenuModel> options_menu_model_; | 163 scoped_ptr<NotificationOptionsMenuModel> options_menu_model_; |
161 scoped_ptr<views::Menu2> options_menu_menu_; | 164 scoped_ptr<views::Menu2> options_menu_menu_; |
162 views::MenuButton* options_menu_button_; | 165 views::MenuButton* options_menu_button_; |
163 | 166 |
164 NotificationRegistrar notification_registrar_; | 167 NotificationRegistrar notification_registrar_; |
165 | 168 |
166 DISALLOW_COPY_AND_ASSIGN(BalloonViewImpl); | 169 DISALLOW_COPY_AND_ASSIGN(BalloonViewImpl); |
167 }; | 170 }; |
168 | 171 |
169 #endif // CHROME_BROWSER_UI_VIEWS_NOTIFICATIONS_BALLOON_VIEW_H_ | 172 #endif // CHROME_BROWSER_UI_VIEWS_NOTIFICATIONS_BALLOON_VIEW_H_ |
OLD | NEW |