OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 UI_MESSAGE_CENTER_VIEWS_TOAST_CONTENTS_VIEW_H_ | 5 #ifndef UI_MESSAGE_CENTER_VIEWS_TOAST_CONTENTS_VIEW_H_ |
6 #define UI_MESSAGE_CENTER_VIEWS_TOAST_CONTENTS_VIEW_H_ | 6 #define UI_MESSAGE_CENTER_VIEWS_TOAST_CONTENTS_VIEW_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "ui/gfx/animation/animation_delegate.h" | 11 #include "ui/gfx/animation/animation_delegate.h" |
12 #include "ui/gfx/geometry/point.h" | 12 #include "ui/gfx/geometry/point.h" |
13 #include "ui/gfx/geometry/rect.h" | 13 #include "ui/gfx/geometry/rect.h" |
14 #include "ui/gfx/geometry/size.h" | 14 #include "ui/gfx/geometry/size.h" |
15 #include "ui/gfx/native_widget_types.h" | |
16 #include "ui/message_center/views/message_center_controller.h" | 15 #include "ui/message_center/views/message_center_controller.h" |
17 #include "ui/views/widget/widget_delegate.h" | 16 #include "ui/views/widget/widget_delegate.h" |
18 | 17 |
19 namespace gfx { | 18 namespace gfx { |
20 class Animation; | 19 class Animation; |
21 class SlideAnimation; | 20 class SlideAnimation; |
22 } | 21 } |
23 | 22 |
24 namespace views { | 23 namespace views { |
25 class View; | 24 class View; |
26 } | 25 } |
27 | 26 |
28 namespace message_center { | 27 namespace message_center { |
29 | 28 |
30 namespace test { | 29 namespace test { |
31 class MessagePopupCollectionTest; | 30 class MessagePopupCollectionTest; |
32 } | 31 } |
33 | 32 |
34 class MessagePopupCollection; | 33 class MessagePopupCollection; |
35 class MessageView; | 34 class MessageView; |
36 class Notification; | 35 class Notification; |
| 36 class PopupAlignmentDelegate; |
37 | 37 |
38 // The widget host for a popup. Also implements MessageCenterController | 38 // The widget host for a popup. Also implements MessageCenterController |
39 // which delegates over to MessagePopupCollection, but takes care about | 39 // which delegates over to MessagePopupCollection, but takes care about |
40 // checking the weakref since MessagePopupCollection may disappear before | 40 // checking the weakref since MessagePopupCollection may disappear before |
41 // widget/views are closed/destructed. | 41 // widget/views are closed/destructed. |
42 class ToastContentsView : public views::WidgetDelegateView, | 42 class ToastContentsView : public views::WidgetDelegateView, |
43 public MessageCenterController, | 43 public MessageCenterController, |
44 public gfx::AnimationDelegate { | 44 public gfx::AnimationDelegate { |
45 public: | 45 public: |
46 // Computes the size of a toast assuming it will host the given view. | 46 // Computes the size of a toast assuming it will host the given view. |
47 static gfx::Size GetToastSizeForView(const views::View* view); | 47 static gfx::Size GetToastSizeForView(const views::View* view); |
48 | 48 |
49 ToastContentsView(const std::string& notification_id, | 49 ToastContentsView(const std::string& notification_id, |
| 50 PopupAlignmentDelegate* alignment_delegate, |
50 base::WeakPtr<MessagePopupCollection> collection); | 51 base::WeakPtr<MessagePopupCollection> collection); |
51 ~ToastContentsView() override; | 52 ~ToastContentsView() override; |
52 | 53 |
53 // Sets the inner view of the toast. If it has contents already, | 54 // Sets the inner view of the toast. If it has contents already, |
54 // |a11y_feedback_for_updates| causes the view to notify that the | 55 // |a11y_feedback_for_updates| causes the view to notify that the |
55 // accessibility message should be read after this update. | 56 // accessibility message should be read after this update. |
56 void SetContents(MessageView* view, bool a11y_feedback_for_updates); | 57 void SetContents(MessageView* view, bool a11y_feedback_for_updates); |
57 | 58 |
58 void UpdateContents(const Notification& notification, | 59 void UpdateContents(const Notification& notification, |
59 bool a11y_feedback_for_updates); | 60 bool a11y_feedback_for_updates); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 // Overridden from views::WidgetDelegate: | 106 // Overridden from views::WidgetDelegate: |
106 views::View* GetContentsView() override; | 107 views::View* GetContentsView() override; |
107 void WindowClosing() override; | 108 void WindowClosing() override; |
108 void OnDisplayChanged() override; | 109 void OnDisplayChanged() override; |
109 void OnWorkAreaChanged() override; | 110 void OnWorkAreaChanged() override; |
110 | 111 |
111 // Recalculates preferred size from underlying view and notifies about it. | 112 // Recalculates preferred size from underlying view and notifies about it. |
112 void UpdatePreferredSize(); | 113 void UpdatePreferredSize(); |
113 | 114 |
114 // Initialization and update. | 115 // Initialization and update. |
115 void CreateWidget(gfx::NativeView parent); | 116 void CreateWidget(PopupAlignmentDelegate* alignment_delegate); |
116 | 117 |
117 // Immediately moves the toast without any sort of delay or animation. | 118 // Immediately moves the toast without any sort of delay or animation. |
118 void SetBoundsInstantly(gfx::Rect new_bounds); | 119 void SetBoundsInstantly(gfx::Rect new_bounds); |
119 | 120 |
120 // Given the bounds of a toast on the screen, compute the bouds for that | 121 // Given the bounds of a toast on the screen, compute the bouds for that |
121 // toast in 'closed' state. The 'closed' state is used as origin/destination | 122 // toast in 'closed' state. The 'closed' state is used as origin/destination |
122 // in reveal/closing animations. | 123 // in reveal/closing animations. |
123 gfx::Rect GetClosedToastBounds(gfx::Rect bounds); | 124 gfx::Rect GetClosedToastBounds(gfx::Rect bounds); |
124 | 125 |
125 void StartFadeIn(); | 126 void StartFadeIn(); |
(...skipping 18 matching lines...) Expand all Loading... |
144 | 145 |
145 gfx::Point origin_; | 146 gfx::Point origin_; |
146 gfx::Size preferred_size_; | 147 gfx::Size preferred_size_; |
147 | 148 |
148 DISALLOW_COPY_AND_ASSIGN(ToastContentsView); | 149 DISALLOW_COPY_AND_ASSIGN(ToastContentsView); |
149 }; | 150 }; |
150 | 151 |
151 } // namespace message_center | 152 } // namespace message_center |
152 | 153 |
153 #endif // UI_MESSAGE_CENTER_VIEWS_TOAST_CONTENTS_VIEW_H_ | 154 #endif // UI_MESSAGE_CENTER_VIEWS_TOAST_CONTENTS_VIEW_H_ |
OLD | NEW |