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

Side by Side Diff: ash/shelf/shelf_layout_manager.h

Issue 2007003002: mash: Preliminary support for shelf auto-hide (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shutdown
Patch Set: cleanup Created 4 years, 7 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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_SHELF_SHELF_LAYOUT_MANAGER_H_ 5 #ifndef ASH_SHELF_SHELF_LAYOUT_MANAGER_H_
6 #define ASH_SHELF_SHELF_LAYOUT_MANAGER_H_ 6 #define ASH_SHELF_SHELF_LAYOUT_MANAGER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
11 #include "ash/ash_export.h" 11 #include "ash/ash_export.h"
12 #include "ash/session/session_state_observer.h" 12 #include "ash/session/session_state_observer.h"
13 #include "ash/shelf/shelf.h" 13 #include "ash/shelf/shelf.h"
14 #include "ash/shelf/shelf_types.h" 14 #include "ash/shelf/shelf_types.h"
15 #include "ash/shell_observer.h" 15 #include "ash/shell_observer.h"
16 #include "ash/snap_to_pixel_layout_manager.h" 16 #include "ash/snap_to_pixel_layout_manager.h"
17 #include "ash/system/status_area_widget.h" 17 #include "ash/system/status_area_widget.h"
18 #include "ash/wm/common/background_animator.h" 18 #include "ash/wm/common/background_animator.h"
19 #include "ash/wm/common/dock/docked_window_layout_manager_observer.h" 19 #include "ash/wm/common/dock/docked_window_layout_manager_observer.h"
20 #include "ash/wm/common/workspace/workspace_types.h" 20 #include "ash/wm/common/workspace/workspace_types.h"
21 #include "ash/wm/gestures/shelf_gesture_handler.h"
21 #include "ash/wm/lock_state_observer.h" 22 #include "ash/wm/lock_state_observer.h"
22 #include "base/compiler_specific.h" 23 #include "base/compiler_specific.h"
23 #include "base/gtest_prod_util.h" 24 #include "base/gtest_prod_util.h"
24 #include "base/logging.h" 25 #include "base/logging.h"
25 #include "base/macros.h" 26 #include "base/macros.h"
26 #include "base/observer_list.h" 27 #include "base/observer_list.h"
27 #include "base/timer/timer.h" 28 #include "base/timer/timer.h"
28 #include "ui/gfx/geometry/insets.h" 29 #include "ui/gfx/geometry/insets.h"
29 #include "ui/gfx/geometry/rect.h" 30 #include "ui/gfx/geometry/rect.h"
30 #include "ui/keyboard/keyboard_controller.h" 31 #include "ui/keyboard/keyboard_controller.h"
(...skipping 20 matching lines...) Expand all
51 class WorkspaceController; 52 class WorkspaceController;
52 FORWARD_DECLARE_TEST(AshPopupAlignmentDelegateTest, AutoHide); 53 FORWARD_DECLARE_TEST(AshPopupAlignmentDelegateTest, AutoHide);
53 FORWARD_DECLARE_TEST(WebNotificationTrayTest, PopupAndFullscreen); 54 FORWARD_DECLARE_TEST(WebNotificationTrayTest, PopupAndFullscreen);
54 55
55 // ShelfLayoutManager is the layout manager responsible for the shelf and 56 // ShelfLayoutManager is the layout manager responsible for the shelf and
56 // status widgets. The shelf is given the total available width and told the 57 // status widgets. The shelf is given the total available width and told the
57 // width of the status area. This allows the shelf to draw the background and 58 // width of the status area. This allows the shelf to draw the background and
58 // layout to the status area. 59 // layout to the status area.
59 // To respond to bounds changes in the status area StatusAreaLayoutManager works 60 // To respond to bounds changes in the status area StatusAreaLayoutManager works
60 // closely with ShelfLayoutManager. 61 // closely with ShelfLayoutManager.
62 // On mus, widget bounds management is handled by the window manager.
61 class ASH_EXPORT ShelfLayoutManager 63 class ASH_EXPORT ShelfLayoutManager
62 : public ash::ShellObserver, 64 : public ash::ShellObserver,
63 public aura::client::ActivationChangeObserver, 65 public aura::client::ActivationChangeObserver,
64 public DockedWindowLayoutManagerObserver, 66 public DockedWindowLayoutManagerObserver,
65 public keyboard::KeyboardControllerObserver, 67 public keyboard::KeyboardControllerObserver,
66 public LockStateObserver, 68 public LockStateObserver,
67 public SnapToPixelLayoutManager, 69 public SnapToPixelLayoutManager,
68 public SessionStateObserver { 70 public SessionStateObserver {
69 public: 71 public:
70 // We reserve a small area on the edge of the workspace area to ensure that 72 // We reserve a small area on the edge of the workspace area to ensure that
(...skipping 23 matching lines...) Expand all
94 // Clears internal data for shutdown process. 96 // Clears internal data for shutdown process.
95 void PrepareForShutdown(); 97 void PrepareForShutdown();
96 98
97 // Returns whether the shelf and its contents (shelf, status) are visible 99 // Returns whether the shelf and its contents (shelf, status) are visible
98 // on the screen. 100 // on the screen.
99 bool IsVisible() const; 101 bool IsVisible() const;
100 102
101 // Returns the ideal bounds of the shelf assuming it is visible. 103 // Returns the ideal bounds of the shelf assuming it is visible.
102 gfx::Rect GetIdealBounds(); 104 gfx::Rect GetIdealBounds();
103 105
106 // Returns the preferred size of the shelf for the target visibility state.
107 gfx::Size GetPreferredSize();
108
104 // Returns the docked area bounds. 109 // Returns the docked area bounds.
105 const gfx::Rect& dock_bounds() const { return dock_bounds_; } 110 const gfx::Rect& dock_bounds() const { return dock_bounds_; }
106 111
107 // Returns the bounds within the root window not occupied by the shelf nor the 112 // Returns the bounds within the root window not occupied by the shelf nor the
108 // virtual keyboard. 113 // virtual keyboard.
109 const gfx::Rect& user_work_area_bounds() const { 114 const gfx::Rect& user_work_area_bounds() const {
110 return user_work_area_bounds_; 115 return user_work_area_bounds_;
111 } 116 }
112 117
113 // Stops any animations and sets the bounds of the shelf and status widgets. 118 // Stops any animations and sets the bounds of the shelf and status widgets.
114 void LayoutShelf(); 119 void LayoutShelf();
115 120
116 // Returns shelf visibility state based on current value of auto hide 121 // Returns shelf visibility state based on current value of auto hide
117 // behavior setting. 122 // behavior setting.
118 ShelfVisibilityState CalculateShelfVisibility(); 123 ShelfVisibilityState CalculateShelfVisibility();
119 124
120 // Updates the visibility state. 125 // Updates the visibility state.
121 void UpdateVisibilityState(); 126 void UpdateVisibilityState();
122 127
123 // Invoked by the shelf when the auto-hide state may have changed. 128 // Invoked by the shelf when the auto-hide state may have changed.
124 void UpdateAutoHideState(); 129 void UpdateAutoHideState();
125 130
131 // Updates the auto-hide state for certain events. In classic ash these come
132 // from an EventHandler. In mash these come from events that hit the shelf
msw 2016/05/24 20:46:55 Could we always forward shelf/status events and re
James Cook 2016/05/25 00:25:43 I'd like to do that, but I don't think I can do it
133 // widget and status tray widget.
134 void UpdateAutoHideForMouseEvent(ui::MouseEvent* event);
135 void UpdateAutoHideForGestureEvent(ui::GestureEvent* event);
136
126 ShelfVisibilityState visibility_state() const { 137 ShelfVisibilityState visibility_state() const {
127 return state_.visibility_state; 138 return state_.visibility_state;
128 } 139 }
129 ShelfAutoHideState auto_hide_state() const { return state_.auto_hide_state; } 140 ShelfAutoHideState auto_hide_state() const { return state_.auto_hide_state; }
130 141
131 ShelfWidget* shelf_widget() { return shelf_; } 142 ShelfWidget* shelf_widget() { return shelf_; }
132 143
133 // Sets whether any windows overlap the shelf. If a window overlaps the shelf 144 // Sets whether any windows overlap the shelf. If a window overlaps the shelf
134 // the shelf renders slightly differently. 145 // the shelf renders slightly differently.
135 void SetWindowOverlapsShelf(bool value); 146 void SetWindowOverlapsShelf(bool value);
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 // Do any windows overlap the shelf? This is maintained by WorkspaceManager. 358 // Do any windows overlap the shelf? This is maintained by WorkspaceManager.
348 bool window_overlaps_shelf_; 359 bool window_overlaps_shelf_;
349 360
350 base::OneShotTimer auto_hide_timer_; 361 base::OneShotTimer auto_hide_timer_;
351 362
352 // Whether the mouse was over the shelf when the auto hide timer started. 363 // Whether the mouse was over the shelf when the auto hide timer started.
353 // False when neither the auto hide timer nor the timer task are running. 364 // False when neither the auto hide timer nor the timer task are running.
354 bool mouse_over_shelf_when_auto_hide_timer_started_; 365 bool mouse_over_shelf_when_auto_hide_timer_started_;
355 366
356 // EventFilter used to detect when user moves the mouse over the shelf to 367 // EventFilter used to detect when user moves the mouse over the shelf to
357 // trigger showing the shelf. 368 // trigger showing the shelf. Used in classic ash.
358 std::unique_ptr<AutoHideEventFilter> auto_hide_event_filter_; 369 std::unique_ptr<AutoHideEventFilter> auto_hide_event_filter_;
359 370
360 // EventFilter used to detect when user issues a gesture on a bezel sensor. 371 // EventFilter used to detect when user issues a gesture on a bezel sensor.
361 std::unique_ptr<ShelfBezelEventFilter> bezel_event_filter_; 372 std::unique_ptr<ShelfBezelEventFilter> bezel_event_filter_;
362 373
363 base::ObserverList<ShelfLayoutManagerObserver> observers_; 374 base::ObserverList<ShelfLayoutManagerObserver> observers_;
364 375
376 ShelfGestureHandler gesture_handler_;
377
365 // The shelf reacts to gesture-drags, and can be set to auto-hide for certain 378 // The shelf reacts to gesture-drags, and can be set to auto-hide for certain
366 // gestures. Some shelf behaviour (e.g. visibility state, background color 379 // gestures. Some shelf behaviour (e.g. visibility state, background color
367 // etc.) are affected by various stages of the drag. The enum keeps track of 380 // etc.) are affected by various stages of the drag. The enum keeps track of
368 // the present status of the gesture drag. 381 // the present status of the gesture drag.
369 enum GestureDragStatus { 382 enum GestureDragStatus {
370 GESTURE_DRAG_NONE, 383 GESTURE_DRAG_NONE,
371 GESTURE_DRAG_IN_PROGRESS, 384 GESTURE_DRAG_IN_PROGRESS,
372 GESTURE_DRAG_CANCEL_IN_PROGRESS, 385 GESTURE_DRAG_CANCEL_IN_PROGRESS,
373 GESTURE_DRAG_COMPLETE_IN_PROGRESS 386 GESTURE_DRAG_COMPLETE_IN_PROGRESS
374 }; 387 };
(...skipping 28 matching lines...) Expand all
403 416
404 std::unique_ptr<RootWindowControllerObserverImpl> 417 std::unique_ptr<RootWindowControllerObserverImpl>
405 root_window_controller_observer_; 418 root_window_controller_observer_;
406 419
407 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager); 420 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager);
408 }; 421 };
409 422
410 } // namespace ash 423 } // namespace ash
411 424
412 #endif // ASH_SHELF_SHELF_LAYOUT_MANAGER_H_ 425 #endif // ASH_SHELF_SHELF_LAYOUT_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698