Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: ash/system/tray/system_tray.h

Issue 2930123002: Tablet WM : Swiping on system tray bubble. (Closed)
Patch Set: Addressed xiyuan's comments. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ash/system/tray/system_tray.cc » ('j') | ash/system/tray/system_tray.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
tdanderson 2017/06/19 16:19:38 I see you are using bug 725977 to track many diffe
minch1 2017/06/20 16:45:34 Thanks for your suggestion Terry. I will split thi
tdanderson 2017/06/20 22:42:20 Acknowledged.
11 11
12 #include "ash/ash_export.h" 12 #include "ash/ash_export.h"
13 #include "ash/shell_observer.h"
13 #include "ash/system/tray/system_tray_bubble.h" 14 #include "ash/system/tray/system_tray_bubble.h"
14 #include "ash/system/tray/tray_background_view.h" 15 #include "ash/system/tray/tray_background_view.h"
15 #include "base/macros.h" 16 #include "base/macros.h"
16 #include "ui/views/bubble/tray_bubble_view.h" 17 #include "ui/views/bubble/tray_bubble_view.h"
17 #include "ui/views/view.h" 18 #include "ui/views/view.h"
18 19
19 namespace ash { 20 namespace ash {
20 21
21 class KeyEventWatcher; 22 class KeyEventWatcher;
22 enum class LoginStatus; 23 enum class LoginStatus;
(...skipping 14 matching lines...) Expand all
37 class TrayTiles; 38 class TrayTiles;
38 class TrayUpdate; 39 class TrayUpdate;
39 class WebNotificationTray; 40 class WebNotificationTray;
40 41
41 // There are different methods for creating bubble views. 42 // There are different methods for creating bubble views.
42 enum BubbleCreationType { 43 enum BubbleCreationType {
43 BUBBLE_CREATE_NEW, // Closes any existing bubble and creates a new one. 44 BUBBLE_CREATE_NEW, // Closes any existing bubble and creates a new one.
44 BUBBLE_USE_EXISTING, // Uses any existing bubble, or creates a new one. 45 BUBBLE_USE_EXISTING, // Uses any existing bubble, or creates a new one.
45 }; 46 };
46 47
47 class ASH_EXPORT SystemTray : public TrayBackgroundView, 48 class ASH_EXPORT SystemTray : public TrayBackgroundView,
tdanderson 2017/06/19 16:19:38 Note that I have left a comment here listing the o
minch1 2017/06/20 16:45:34 Yes, I think it will has some code reuse in the fo
tdanderson 2017/06/20 22:42:20 Acknowledged.
48 public views::TrayBubbleView::Delegate { 49 public views::TrayBubbleView::Delegate,
50 public ShellObserver {
xdai1 2017/06/19 19:01:30 You don't need observe Shell to get the maximize m
minch1 2017/06/20 16:45:34 Done.
49 public: 51 public:
50 explicit SystemTray(Shelf* shelf); 52 explicit SystemTray(Shelf* shelf);
51 ~SystemTray() override; 53 ~SystemTray() override;
52 54
53 TrayUpdate* tray_update() { return tray_update_; } 55 TrayUpdate* tray_update() { return tray_update_; }
54 56
55 TrayNightLight* tray_night_light() { return tray_night_light_; } 57 TrayNightLight* tray_night_light() { return tray_night_light_; }
56 58
57 // Calls TrayBackgroundView::Initialize(), creates the tray items, and 59 // Calls TrayBackgroundView::Initialize(), creates the tray items, and
58 // adds them to SystemTrayNotifier. 60 // adds them to SystemTrayNotifier.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 void HideBubbleWithView(const views::TrayBubbleView* bubble_view) override; 131 void HideBubbleWithView(const views::TrayBubbleView* bubble_view) override;
130 void ClickedOutsideBubble() override; 132 void ClickedOutsideBubble() override;
131 133
132 // views::TrayBubbleView::Delegate: 134 // views::TrayBubbleView::Delegate:
133 void BubbleViewDestroyed() override; 135 void BubbleViewDestroyed() override;
134 void OnMouseEnteredView() override; 136 void OnMouseEnteredView() override;
135 void OnMouseExitedView() override; 137 void OnMouseExitedView() override;
136 base::string16 GetAccessibleNameForBubble() override; 138 base::string16 GetAccessibleNameForBubble() override;
137 void HideBubble(const views::TrayBubbleView* bubble_view) override; 139 void HideBubble(const views::TrayBubbleView* bubble_view) override;
138 140
141 // ShellObserver:
142 void OnMaximizeModeStarted() override;
143 void OnMaximizeModeEnded() override;
144
139 ScreenTrayItem* GetScreenShareItem() { return screen_share_tray_item_; } 145 ScreenTrayItem* GetScreenShareItem() { return screen_share_tray_item_; }
140 ScreenTrayItem* GetScreenCaptureItem() { return screen_capture_tray_item_; } 146 ScreenTrayItem* GetScreenCaptureItem() { return screen_capture_tray_item_; }
141 147
142 // Activates the system tray bubble. 148 // Activates the system tray bubble.
143 void ActivateBubble(); 149 void ActivateBubble();
144 150
151 // Overridden from ui::EventHandler:
tdanderson 2017/06/19 16:19:38 nit: just "ui::EventHandler:"
minch1 2017/06/20 16:45:34 Done.
152 void OnGestureEvent(ui::GestureEvent* event) override;
153
154 gfx::Rect GetWorkAreaBoundsInScreen() const;
155
156 bool in_maximize_mode() { return in_maximize_mode_; }
157
145 private: 158 private:
146 friend class SystemTrayTestApi; 159 friend class SystemTrayTestApi;
147 class ActivationObserver; 160 class ActivationObserver;
148 161
149 // Closes the bubble. Used to bind as a KeyEventWatcher::KeyEventCallback. 162 // Closes the bubble. Used to bind as a KeyEventWatcher::KeyEventCallback.
150 void CloseBubble(const ui::KeyEvent& key_event); 163 void CloseBubble(const ui::KeyEvent& key_event);
151 164
152 // Activates the bubble and starts key navigation with the |key_event|. 165 // Activates the bubble and starts key navigation with the |key_event|.
153 void ActivateAndStartNavigation(const ui::KeyEvent& key_event); 166 void ActivateAndStartNavigation(const ui::KeyEvent& key_event);
154 167
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 // Deactivate the system tray in the shelf if it was active before. 199 // Deactivate the system tray in the shelf if it was active before.
187 void CloseSystemBubbleAndDeactivateSystemTray(); 200 void CloseSystemBubbleAndDeactivateSystemTray();
188 201
189 // Records UMA metrics for the number of user-visible rows in the system menu 202 // Records UMA metrics for the number of user-visible rows in the system menu
190 // and the percentage of the work area height covered by the system menu. 203 // and the percentage of the work area height covered by the system menu.
191 void RecordSystemMenuMetrics(); 204 void RecordSystemMenuMetrics();
192 205
193 // Overridden from ActionableView. 206 // Overridden from ActionableView.
194 bool PerformAction(const ui::Event& event) override; 207 bool PerformAction(const ui::Event& event) override;
195 208
209 // Gesture related functions:
210 bool ProcessGestureEvent(const ui::GestureEvent& event);
211 bool StartGestureDrag(const ui::GestureEvent& gesture);
212 void UpdateGestureDrag(const ui::GestureEvent& gesture);
213 void CompleteGestureDrag(const ui::GestureEvent& gesture);
214
215 // Returns true if swiping down triggered on the system tray area on the
216 // shelf.
217 bool IsDraggingDownOnShelf(const ui::GestureEvent& gesture);
218
219 // Update the bounds of the system tray bubble according to the location of
220 // the gesture drag.
221 void UpdateBoundsOnDragging(const ui::GestureEvent& gesture);
222
223 // Open the system tray bubble if the drag amount is larger than one third of
224 // the height of the bubble. Otherwise, close it.
225 bool ShouldShowSystemBubbleBasedOnDragAmount();
226
227 // Rules of opening / closing the system bubble for gesture dragging.
228 // |ET_GESTURE_SCROLL_END| considers only the position of the dragging.
229 // |ET_SCROLL_FLING_START| should consider both position and velocity of the
230 // dragging.
231 bool ShouldShowSystemBubbleForDragging(const ui::GestureEvent& gesture);
232
233 // Shelf the system tray is in.
234 Shelf* const shelf_;
235
236 // Swiping of the system tray bubble is only for maximize mode.
tdanderson 2017/06/19 16:19:38 Can you clarify why you want to restrict this func
minch1 2017/06/20 16:45:34 I think the touch gestures here is only for tablet
tdanderson 2017/06/20 22:42:20 OK as discussed in the other email thread, in a fo
minch1 2017/06/22 17:42:10 Done.
237 bool in_maximize_mode_ = false;
238
239 // The original bounds of the system tray bubble.
240 gfx::Rect system_tray_bubble_bounds_ = gfx::Rect();
xdai1 2017/06/19 19:01:30 nit: I don't think you need this initialization.
minch1 2017/06/20 16:45:34 Done.
241
242 // Tracks the amount of the drag.
243 float gesture_drag_amount_ = 0.f;
244
196 // The web notification tray view that appears adjacent to this view. 245 // The web notification tray view that appears adjacent to this view.
197 WebNotificationTray* web_notification_tray_ = nullptr; 246 WebNotificationTray* web_notification_tray_ = nullptr;
198 247
199 // Items. 248 // Items.
200 std::vector<std::unique_ptr<SystemTrayItem>> items_; 249 std::vector<std::unique_ptr<SystemTrayItem>> items_;
201 250
202 // Pointers to members of |items_|. 251 // Pointers to members of |items_|.
203 SystemTrayItem* detailed_item_ = nullptr; 252 SystemTrayItem* detailed_item_ = nullptr;
204 253
205 // Bubble for default and detailed views. 254 // Bubble for default and detailed views.
(...skipping 29 matching lines...) Expand all
235 std::unique_ptr<KeyEventWatcher> key_event_watcher_; 284 std::unique_ptr<KeyEventWatcher> key_event_watcher_;
236 285
237 std::unique_ptr<ActivationObserver> activation_observer_; 286 std::unique_ptr<ActivationObserver> activation_observer_;
238 287
239 DISALLOW_COPY_AND_ASSIGN(SystemTray); 288 DISALLOW_COPY_AND_ASSIGN(SystemTray);
240 }; 289 };
241 290
242 } // namespace ash 291 } // namespace ash
243 292
244 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ 293 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_
OLDNEW
« no previous file with comments | « no previous file | ash/system/tray/system_tray.cc » ('j') | ash/system/tray/system_tray.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698