| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 | 339 |
| 329 // The RootWindow is cached so that we don't invoke Shell::GetInstance() from | 340 // The RootWindow is cached so that we don't invoke Shell::GetInstance() from |
| 330 // our destructor. We avoid that as at the time we're deleted Shell is being | 341 // our destructor. We avoid that as at the time we're deleted Shell is being |
| 331 // deleted too. | 342 // deleted too. |
| 332 aura::Window* root_window_; | 343 aura::Window* root_window_; |
| 333 | 344 |
| 334 // True when inside UpdateBoundsAndOpacity() method. Used to prevent calling | 345 // True when inside UpdateBoundsAndOpacity() method. Used to prevent calling |
| 335 // UpdateBoundsAndOpacity() again from SetChildBounds(). | 346 // UpdateBoundsAndOpacity() again from SetChildBounds(). |
| 336 bool updating_bounds_; | 347 bool updating_bounds_; |
| 337 | 348 |
| 349 bool in_shutdown_ = false; |
| 350 |
| 338 // Current state. | 351 // Current state. |
| 339 State state_; | 352 State state_; |
| 340 | 353 |
| 341 ShelfWidget* shelf_; | 354 ShelfWidget* shelf_; |
| 342 | 355 |
| 343 WorkspaceController* workspace_controller_; | 356 WorkspaceController* workspace_controller_; |
| 344 | 357 |
| 345 // Do any windows overlap the shelf? This is maintained by WorkspaceManager. | 358 // Do any windows overlap the shelf? This is maintained by WorkspaceManager. |
| 346 bool window_overlaps_shelf_; | 359 bool window_overlaps_shelf_; |
| 347 | 360 |
| 348 base::OneShotTimer auto_hide_timer_; | 361 base::OneShotTimer auto_hide_timer_; |
| 349 | 362 |
| 350 // 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. |
| 351 // 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. |
| 352 bool mouse_over_shelf_when_auto_hide_timer_started_; | 365 bool mouse_over_shelf_when_auto_hide_timer_started_; |
| 353 | 366 |
| 354 // 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 |
| 355 // trigger showing the shelf. | 368 // trigger showing the shelf. Used in classic ash. |
| 356 std::unique_ptr<AutoHideEventFilter> auto_hide_event_filter_; | 369 std::unique_ptr<AutoHideEventFilter> auto_hide_event_filter_; |
| 357 | 370 |
| 358 // 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. |
| 359 std::unique_ptr<ShelfBezelEventFilter> bezel_event_filter_; | 372 std::unique_ptr<ShelfBezelEventFilter> bezel_event_filter_; |
| 360 | 373 |
| 361 base::ObserverList<ShelfLayoutManagerObserver> observers_; | 374 base::ObserverList<ShelfLayoutManagerObserver> observers_; |
| 362 | 375 |
| 376 ShelfGestureHandler gesture_handler_; |
| 377 |
| 363 // 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 |
| 364 // gestures. Some shelf behaviour (e.g. visibility state, background color | 379 // gestures. Some shelf behaviour (e.g. visibility state, background color |
| 365 // 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 |
| 366 // the present status of the gesture drag. | 381 // the present status of the gesture drag. |
| 367 enum GestureDragStatus { | 382 enum GestureDragStatus { |
| 368 GESTURE_DRAG_NONE, | 383 GESTURE_DRAG_NONE, |
| 369 GESTURE_DRAG_IN_PROGRESS, | 384 GESTURE_DRAG_IN_PROGRESS, |
| 370 GESTURE_DRAG_CANCEL_IN_PROGRESS, | 385 GESTURE_DRAG_CANCEL_IN_PROGRESS, |
| 371 GESTURE_DRAG_COMPLETE_IN_PROGRESS | 386 GESTURE_DRAG_COMPLETE_IN_PROGRESS |
| 372 }; | 387 }; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 401 | 416 |
| 402 std::unique_ptr<RootWindowControllerObserverImpl> | 417 std::unique_ptr<RootWindowControllerObserverImpl> |
| 403 root_window_controller_observer_; | 418 root_window_controller_observer_; |
| 404 | 419 |
| 405 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager); | 420 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager); |
| 406 }; | 421 }; |
| 407 | 422 |
| 408 } // namespace ash | 423 } // namespace ash |
| 409 | 424 |
| 410 #endif // ASH_SHELF_SHELF_LAYOUT_MANAGER_H_ | 425 #endif // ASH_SHELF_SHELF_LAYOUT_MANAGER_H_ |
| OLD | NEW |