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 ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ | 5 #ifndef ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ |
6 #define ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ | 6 #define ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <vector> | 10 #include <vector> |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 | 145 |
146 ScreenTrayItem* GetScreenShareItem() { return screen_share_tray_item_; } | 146 ScreenTrayItem* GetScreenShareItem() { return screen_share_tray_item_; } |
147 ScreenTrayItem* GetScreenCaptureItem() { return screen_capture_tray_item_; } | 147 ScreenTrayItem* GetScreenCaptureItem() { return screen_capture_tray_item_; } |
148 | 148 |
149 // Activates the system tray bubble. | 149 // Activates the system tray bubble. |
150 void ActivateBubble(); | 150 void ActivateBubble(); |
151 | 151 |
152 // ui::EventHandler: | 152 // ui::EventHandler: |
153 void OnGestureEvent(ui::GestureEvent* event) override; | 153 void OnGestureEvent(ui::GestureEvent* event) override; |
154 | 154 |
| 155 // Process a gesture event and updates the dragging state of the bubble when |
| 156 // appropriate. Returns true if the gesture has been handled and it should not |
| 157 // be processed any further, false otherwise. |
| 158 bool ProcessGestureEvent(const ui::GestureEvent& event); |
| 159 |
155 gfx::Rect GetWorkAreaBoundsInScreen() const; | 160 gfx::Rect GetWorkAreaBoundsInScreen() const; |
156 | 161 |
| 162 void set_target_view(View* target_view) { target_view_ = target_view; } |
| 163 |
157 private: | 164 private: |
158 friend class SystemTrayTestApi; | 165 friend class SystemTrayTestApi; |
159 class ActivationObserver; | 166 class ActivationObserver; |
160 | 167 |
161 // Closes the bubble. Used to bind as a KeyEventWatcher::KeyEventCallback. | 168 // Closes the bubble. Used to bind as a KeyEventWatcher::KeyEventCallback. |
162 void CloseBubble(const ui::KeyEvent& key_event); | 169 void CloseBubble(const ui::KeyEvent& key_event); |
163 | 170 |
164 // Activates the bubble and starts key navigation with the |key_event|. | 171 // Activates the bubble and starts key navigation with the |key_event|. |
165 void ActivateAndStartNavigation(const ui::KeyEvent& key_event); | 172 void ActivateAndStartNavigation(const ui::KeyEvent& key_event); |
166 | 173 |
(...skipping 28 matching lines...) Expand all Loading... |
195 void CloseSystemBubbleAndDeactivateSystemTray(); | 202 void CloseSystemBubbleAndDeactivateSystemTray(); |
196 | 203 |
197 // Records UMA metrics for the number of user-visible rows in the system menu | 204 // Records UMA metrics for the number of user-visible rows in the system menu |
198 // and the percentage of the work area height covered by the system menu. | 205 // and the percentage of the work area height covered by the system menu. |
199 void RecordSystemMenuMetrics(); | 206 void RecordSystemMenuMetrics(); |
200 | 207 |
201 // Overridden from ActionableView. | 208 // Overridden from ActionableView. |
202 bool PerformAction(const ui::Event& event) override; | 209 bool PerformAction(const ui::Event& event) override; |
203 | 210 |
204 // Gesture related functions: | 211 // Gesture related functions: |
205 bool ProcessGestureEvent(const ui::GestureEvent& event); | |
206 bool StartGestureDrag(const ui::GestureEvent& gesture); | 212 bool StartGestureDrag(const ui::GestureEvent& gesture); |
207 void UpdateGestureDrag(const ui::GestureEvent& gesture); | 213 void UpdateGestureDrag(const ui::GestureEvent& gesture); |
208 void CompleteGestureDrag(const ui::GestureEvent& gesture); | 214 void CompleteGestureDrag(const ui::GestureEvent& gesture); |
209 | 215 |
210 // Update the bounds of the system tray bubble according to |location|. Note | 216 // Update the bounds of the system tray bubble according to |location|. Note |
211 // that |location| is in the local coordinate space of |this|. | 217 // that |location| is in the local coordinate space of |this|. |
212 void SetBubbleBounds(const gfx::Point& location); | 218 void SetBubbleBounds(const gfx::Point& location); |
213 | 219 |
214 // Return true if the system bubble should be shown (i.e., animated upward to | 220 // Return true if the system bubble should be shown (i.e., animated upward to |
215 // be made fully visible) after a sequence of scroll events terminated by | 221 // be made fully visible) after a sequence of scroll events terminated by |
216 // |sequence_end|. Otherwise return false, indicating that the | 222 // |sequence_end|. Otherwise return false, indicating that the |
217 // partially-visible system bubble should be animated downward and made fully | 223 // partially-visible system bubble should be animated downward and made fully |
218 // hidden. | 224 // hidden. |
219 bool ShouldShowSystemBubbleAfterScrollSequence( | 225 bool ShouldShowSystemBubbleAfterScrollSequence( |
220 const ui::GestureEvent& sequence_end); | 226 const ui::GestureEvent& sequence_end); |
221 | 227 |
222 // Shelf the system tray is in. | 228 // Shelf the system tray is in. |
223 Shelf* const shelf_; | 229 Shelf* const shelf_; |
224 | 230 |
225 // The original bounds of the system tray bubble. | 231 // The original bounds of the system tray bubble. |
226 gfx::Rect system_tray_bubble_bounds_; | 232 gfx::Rect system_tray_bubble_bounds_; |
227 | 233 |
228 // Tracks the amount of the drag. Only valid if |is_in_drag_| is true. | 234 // Tracks the amount of the drag. Only valid if |is_in_drag_| is true. |
229 float gesture_drag_amount_ = 0.f; | 235 float gesture_drag_amount_ = 0.f; |
230 | 236 |
231 // True if the user is in the process of gesture-dragging to open the system | 237 // True if the user is in the process of gesture-dragging to open the system |
232 // tray bubble, false otherwise. | 238 // tray bubble, false otherwise. |
233 bool is_in_drag_ = false; | 239 bool is_in_drag_ = false; |
234 | 240 |
| 241 // The view that the dragging triggered on (i.e, dragging can starts from |
| 242 // system tray or system tray bubble). |
| 243 View* target_view_; |
| 244 |
235 // The web notification tray view that appears adjacent to this view. | 245 // The web notification tray view that appears adjacent to this view. |
236 WebNotificationTray* web_notification_tray_ = nullptr; | 246 WebNotificationTray* web_notification_tray_ = nullptr; |
237 | 247 |
238 // Items. | 248 // Items. |
239 std::vector<std::unique_ptr<SystemTrayItem>> items_; | 249 std::vector<std::unique_ptr<SystemTrayItem>> items_; |
240 | 250 |
241 // Pointers to members of |items_|. | 251 // Pointers to members of |items_|. |
242 SystemTrayItem* detailed_item_ = nullptr; | 252 SystemTrayItem* detailed_item_ = nullptr; |
243 | 253 |
244 // Bubble for default and detailed views. | 254 // Bubble for default and detailed views. |
(...skipping 27 matching lines...) Expand all Loading... |
272 ScreenTrayItem* screen_share_tray_item_ = nullptr; // not owned | 282 ScreenTrayItem* screen_share_tray_item_ = nullptr; // not owned |
273 | 283 |
274 std::unique_ptr<ActivationObserver> activation_observer_; | 284 std::unique_ptr<ActivationObserver> activation_observer_; |
275 | 285 |
276 DISALLOW_COPY_AND_ASSIGN(SystemTray); | 286 DISALLOW_COPY_AND_ASSIGN(SystemTray); |
277 }; | 287 }; |
278 | 288 |
279 } // namespace ash | 289 } // namespace ash |
280 | 290 |
281 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ | 291 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ |
OLD | NEW |