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_MESSAGE_POPUP_COLLECTION_H_ | 5 #ifndef UI_MESSAGE_CENTER_VIEWS_MESSAGE_POPUP_COLLECTION_H_ |
6 #define UI_MESSAGE_CENTER_VIEWS_MESSAGE_POPUP_COLLECTION_H_ | 6 #define UI_MESSAGE_CENTER_VIEWS_MESSAGE_POPUP_COLLECTION_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 public: | 51 public: |
52 // |parent| specifies the parent widget of the toast windows. The default | 52 // |parent| specifies the parent widget of the toast windows. The default |
53 // parent will be used for NULL. | 53 // parent will be used for NULL. |
54 MessagePopupCollection(gfx::NativeView parent, | 54 MessagePopupCollection(gfx::NativeView parent, |
55 MessageCenter* message_center); | 55 MessageCenter* message_center); |
56 virtual ~MessagePopupCollection(); | 56 virtual ~MessagePopupCollection(); |
57 | 57 |
58 // Called by ToastContentsView when its window is closed. | 58 // Called by ToastContentsView when its window is closed. |
59 void RemoveToast(ToastContentsView* toast); | 59 void RemoveToast(ToastContentsView* toast); |
60 | 60 |
61 void OnMouseEntered(); | 61 // Since these events are really coming from individual toast widgets, |
62 void OnMouseExited(); | 62 // it helps to be able to keep track of the sender. |
| 63 void OnMouseEntered(ToastContentsView* toast_entered); |
| 64 void OnMouseExited(ToastContentsView* toast_exited); |
63 | 65 |
64 // Invoked by toasts when they start/finish their animations. | 66 // Invoked by toasts when they start/finish their animations. |
65 // While "defer counter" is greater then zero, the popup collection does | 67 // While "defer counter" is greater then zero, the popup collection does |
66 // not perform updates. It is used to wait for various animations and user | 68 // not perform updates. It is used to wait for various animations and user |
67 // actions like serial closing of the toasts, when the remaining toasts "flow | 69 // actions like serial closing of the toasts, when the remaining toasts "flow |
68 // under the mouse". | 70 // under the mouse". |
69 void IncrementDeferCounter(); | 71 void IncrementDeferCounter(); |
70 void DecrementDeferCounter(); | 72 void DecrementDeferCounter(); |
71 | 73 |
72 // Runs the next step in update/animate sequence, if the defer counter is not | 74 // Runs the next step in update/animate sequence, if the defer counter is not |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 void RunLoopForTest(); | 124 void RunLoopForTest(); |
123 gfx::Rect GetToastRectAt(size_t index); | 125 gfx::Rect GetToastRectAt(size_t index); |
124 | 126 |
125 gfx::NativeView parent_; | 127 gfx::NativeView parent_; |
126 MessageCenter* message_center_; | 128 MessageCenter* message_center_; |
127 Toasts toasts_; | 129 Toasts toasts_; |
128 gfx::Rect work_area_; | 130 gfx::Rect work_area_; |
129 | 131 |
130 int defer_counter_; | 132 int defer_counter_; |
131 | 133 |
| 134 // This is only used to compare with incoming events, do not assume that |
| 135 // the toast will be valid if this pointer is non-NULL. |
| 136 ToastContentsView* latest_toast_entered_; |
| 137 |
132 // Denotes a mode when user is clicking the Close button of toasts in a | 138 // Denotes a mode when user is clicking the Close button of toasts in a |
133 // sequence, w/o moving the mouse. We reposition the toasts so the next one | 139 // sequence, w/o moving the mouse. We reposition the toasts so the next one |
134 // happens to be right under the mouse, and the user can just dispose of | 140 // happens to be right under the mouse, and the user can just dispose of |
135 // multipel toasts by clicking. The mode ends when defer_timer_ expires. | 141 // multipel toasts by clicking. The mode ends when defer_timer_ expires. |
136 bool user_is_closing_toasts_by_clicking_; | 142 bool user_is_closing_toasts_by_clicking_; |
137 scoped_ptr<base::OneShotTimer<MessagePopupCollection> > defer_timer_; | 143 scoped_ptr<base::OneShotTimer<MessagePopupCollection> > defer_timer_; |
138 // The top edge to align the position of the next toast during 'close by | 144 // The top edge to align the position of the next toast during 'close by |
139 // clicking" mode. | 145 // clicking" mode. |
140 // Only to be used when user_is_closing_toasts_by_clicking_ is true. | 146 // Only to be used when user_is_closing_toasts_by_clicking_ is true. |
141 int target_top_edge_; | 147 int target_top_edge_; |
142 | 148 |
143 // Weak, only exists temporarily in tests. | 149 // Weak, only exists temporarily in tests. |
144 scoped_ptr<base::RunLoop> run_loop_for_test_; | 150 scoped_ptr<base::RunLoop> run_loop_for_test_; |
145 | 151 |
146 DISALLOW_COPY_AND_ASSIGN(MessagePopupCollection); | 152 DISALLOW_COPY_AND_ASSIGN(MessagePopupCollection); |
147 }; | 153 }; |
148 | 154 |
149 } // namespace message_center | 155 } // namespace message_center |
150 | 156 |
151 #endif // UI_MESSAGE_CENTER_VIEWS_MESSAGE_POPUP_COLLECTION_H_ | 157 #endif // UI_MESSAGE_CENTER_VIEWS_MESSAGE_POPUP_COLLECTION_H_ |
OLD | NEW |