| 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_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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
| 11 #include "ash/launcher/launcher.h" | |
| 12 #include "ash/shelf/background_animator.h" | 11 #include "ash/shelf/background_animator.h" |
| 12 #include "ash/shelf/shelf.h" |
| 13 #include "ash/shelf/shelf_types.h" | 13 #include "ash/shelf/shelf_types.h" |
| 14 #include "ash/shell_observer.h" | 14 #include "ash/shell_observer.h" |
| 15 #include "ash/system/status_area_widget.h" | 15 #include "ash/system/status_area_widget.h" |
| 16 #include "ash/wm/dock/docked_window_layout_manager_observer.h" | 16 #include "ash/wm/dock/docked_window_layout_manager_observer.h" |
| 17 #include "ash/wm/lock_state_observer.h" | 17 #include "ash/wm/lock_state_observer.h" |
| 18 #include "ash/wm/workspace/workspace_types.h" | 18 #include "ash/wm/workspace/workspace_types.h" |
| 19 #include "base/basictypes.h" | 19 #include "base/basictypes.h" |
| 20 #include "base/compiler_specific.h" | 20 #include "base/compiler_specific.h" |
| 21 #include "base/logging.h" | 21 #include "base/logging.h" |
| 22 #include "base/observer_list.h" | 22 #include "base/observer_list.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 44 FORWARD_DECLARE_TEST(WebNotificationTrayTest, PopupAndFullscreen); | 44 FORWARD_DECLARE_TEST(WebNotificationTrayTest, PopupAndFullscreen); |
| 45 | 45 |
| 46 namespace internal { | 46 namespace internal { |
| 47 | 47 |
| 48 class PanelLayoutManagerTest; | 48 class PanelLayoutManagerTest; |
| 49 class ShelfBezelEventFilter; | 49 class ShelfBezelEventFilter; |
| 50 class ShelfLayoutManagerTest; | 50 class ShelfLayoutManagerTest; |
| 51 class StatusAreaWidget; | 51 class StatusAreaWidget; |
| 52 class WorkspaceController; | 52 class WorkspaceController; |
| 53 | 53 |
| 54 // ShelfLayoutManager is the layout manager responsible for the launcher and | 54 // ShelfLayoutManager is the layout manager responsible for the shelf and |
| 55 // status widgets. The launcher is given the total available width and told the | 55 // status widgets. The shelf is given the total available width and told the |
| 56 // width of the status area. This allows the launcher to draw the background and | 56 // width of the status area. This allows the shelf to draw the background and |
| 57 // layout to the status area. | 57 // layout to the status area. |
| 58 // To respond to bounds changes in the status area StatusAreaLayoutManager works | 58 // To respond to bounds changes in the status area StatusAreaLayoutManager works |
| 59 // closely with ShelfLayoutManager. | 59 // closely with ShelfLayoutManager. |
| 60 class ASH_EXPORT ShelfLayoutManager : | 60 class ASH_EXPORT ShelfLayoutManager : |
| 61 public aura::LayoutManager, | 61 public aura::LayoutManager, |
| 62 public ash::ShellObserver, | 62 public ash::ShellObserver, |
| 63 public aura::client::ActivationChangeObserver, | 63 public aura::client::ActivationChangeObserver, |
| 64 public DockedWindowLayoutManagerObserver, | 64 public DockedWindowLayoutManagerObserver, |
| 65 public keyboard::KeyboardControllerObserver, | 65 public keyboard::KeyboardControllerObserver, |
| 66 public LockStateObserver { | 66 public LockStateObserver { |
| 67 public: | 67 public: |
| 68 | 68 |
| 69 // We reserve a small area on the edge of the workspace area to ensure that | 69 // We reserve a small area on the edge of the workspace area to ensure that |
| 70 // the resize handle at the edge of the window can be hit. | 70 // the resize handle at the edge of the window can be hit. |
| 71 static const int kWorkspaceAreaVisibleInset; | 71 static const int kWorkspaceAreaVisibleInset; |
| 72 | 72 |
| 73 // When autohidden we extend the touch hit target onto the screen so that the | 73 // When autohidden we extend the touch hit target onto the screen so that the |
| 74 // user can drag the shelf out. | 74 // user can drag the shelf out. |
| 75 static const int kWorkspaceAreaAutoHideInset; | 75 static const int kWorkspaceAreaAutoHideInset; |
| 76 | 76 |
| 77 // Size of the shelf when auto-hidden. | 77 // Size of the shelf when auto-hidden. |
| 78 static const int kAutoHideSize; | 78 static const int kAutoHideSize; |
| 79 | 79 |
| 80 // The size of the shelf when shown (currently only used in alternate | 80 // The size of the shelf when shown (currently only used in alternate |
| 81 // settings see ash::switches::UseAlternateShelfLayout). | 81 // settings see ash::switches::UseAlternateShelfLayout). |
| 82 static const int kShelfSize; | 82 static const int kShelfSize; |
| 83 | 83 |
| 84 // Inset between the inner edge of the shelf (towards centre of screen), and | 84 // Inset between the inner edge of the shelf (towards centre of screen), and |
| 85 // the launcher items, notifications, status area etc. | 85 // the shelf items, notifications, status area etc. |
| 86 static const int kShelfItemInset; | 86 static const int kShelfItemInset; |
| 87 | 87 |
| 88 // Returns the preferred size for the shelf (either kLauncherPreferredSize or | 88 // Returns the preferred size for the shelf (either kLauncherPreferredSize or |
| 89 // kShelfSize). | 89 // kShelfSize). |
| 90 static int GetPreferredShelfSize(); | 90 static int GetPreferredShelfSize(); |
| 91 | 91 |
| 92 explicit ShelfLayoutManager(ShelfWidget* shelf); | 92 explicit ShelfLayoutManager(ShelfWidget* shelf); |
| 93 virtual ~ShelfLayoutManager(); | 93 virtual ~ShelfLayoutManager(); |
| 94 | 94 |
| 95 // Sets the ShelfAutoHideBehavior. See enum description for details. | 95 // Sets the ShelfAutoHideBehavior. See enum description for details. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 108 | 108 |
| 109 void set_workspace_controller(WorkspaceController* controller) { | 109 void set_workspace_controller(WorkspaceController* controller) { |
| 110 workspace_controller_ = controller; | 110 workspace_controller_ = controller; |
| 111 } | 111 } |
| 112 | 112 |
| 113 bool updating_bounds() const { return updating_bounds_; } | 113 bool updating_bounds() const { return updating_bounds_; } |
| 114 | 114 |
| 115 // Clears internal data for shutdown process. | 115 // Clears internal data for shutdown process. |
| 116 void PrepareForShutdown(); | 116 void PrepareForShutdown(); |
| 117 | 117 |
| 118 // Returns whether the shelf and its contents (launcher, status) are visible | 118 // Returns whether the shelf and its contents (shelf, status) are visible |
| 119 // on the screen. | 119 // on the screen. |
| 120 bool IsVisible() const; | 120 bool IsVisible() const; |
| 121 | 121 |
| 122 // Returns the ideal bounds of the shelf assuming it is visible. | 122 // Returns the ideal bounds of the shelf assuming it is visible. |
| 123 gfx::Rect GetIdealBounds(); | 123 gfx::Rect GetIdealBounds(); |
| 124 | 124 |
| 125 // Returns the docked area bounds. | 125 // Returns the docked area bounds. |
| 126 const gfx::Rect& dock_bounds() const { return dock_bounds_; } | 126 const gfx::Rect& dock_bounds() const { return dock_bounds_; } |
| 127 | 127 |
| 128 // Stops any animations and sets the bounds of the launcher and status | 128 // Stops any animations and sets the bounds of the shelf and status |
| 129 // widgets. | 129 // widgets. |
| 130 void LayoutShelf(); | 130 void LayoutShelf(); |
| 131 | 131 |
| 132 // Returns shelf visibility state based on current value of auto hide | 132 // Returns shelf visibility state based on current value of auto hide |
| 133 // behavior setting. | 133 // behavior setting. |
| 134 ShelfVisibilityState CalculateShelfVisibility(); | 134 ShelfVisibilityState CalculateShelfVisibility(); |
| 135 | 135 |
| 136 // Updates the visibility state. | 136 // Updates the visibility state. |
| 137 void UpdateVisibilityState(); | 137 void UpdateVisibilityState(); |
| 138 | 138 |
| 139 // Invoked by the shelf/launcher when the auto-hide state may have changed. | 139 // Invoked by the shelf when the auto-hide state may have changed. |
| 140 void UpdateAutoHideState(); | 140 void UpdateAutoHideState(); |
| 141 | 141 |
| 142 ShelfVisibilityState visibility_state() const { | 142 ShelfVisibilityState visibility_state() const { |
| 143 return state_.visibility_state; | 143 return state_.visibility_state; |
| 144 } | 144 } |
| 145 ShelfAutoHideState auto_hide_state() const { return state_.auto_hide_state; } | 145 ShelfAutoHideState auto_hide_state() const { return state_.auto_hide_state; } |
| 146 | 146 |
| 147 ShelfWidget* shelf_widget() { return shelf_; } | 147 ShelfWidget* shelf_widget() { return shelf_; } |
| 148 | 148 |
| 149 // Sets whether any windows overlap the shelf. If a window overlaps the shelf | 149 // Sets whether any windows overlap the shelf. If a window overlaps the shelf |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 } | 208 } |
| 209 | 209 |
| 210 template<typename T> | 210 template<typename T> |
| 211 T PrimaryAxisValue(T horizontal, T vertical) const { | 211 T PrimaryAxisValue(T horizontal, T vertical) const { |
| 212 return IsHorizontalAlignment() ? horizontal : vertical; | 212 return IsHorizontalAlignment() ? horizontal : vertical; |
| 213 } | 213 } |
| 214 | 214 |
| 215 // Is the shelf's alignment horizontal? | 215 // Is the shelf's alignment horizontal? |
| 216 bool IsHorizontalAlignment() const; | 216 bool IsHorizontalAlignment() const; |
| 217 | 217 |
| 218 // Returns a ShelfLayoutManager on the display which has a launcher for | 218 // Returns a ShelfLayoutManager on the display which has a shelf for |
| 219 // given |window|. See RootWindowController::ForLauncher for more info. | 219 // given |window|. See RootWindowController::ForShelf for more info. |
| 220 static ShelfLayoutManager* ForLauncher(aura::Window* window); | 220 static ShelfLayoutManager* ForShelf(aura::Window* window); |
| 221 | 221 |
| 222 private: | 222 private: |
| 223 class AutoHideEventFilter; | 223 class AutoHideEventFilter; |
| 224 class UpdateShelfObserver; | 224 class UpdateShelfObserver; |
| 225 friend class ash::ScreenAsh; | 225 friend class ash::ScreenAsh; |
| 226 friend class PanelLayoutManagerTest; | 226 friend class PanelLayoutManagerTest; |
| 227 friend class ShelfLayoutManagerTest; | 227 friend class ShelfLayoutManagerTest; |
| 228 FRIEND_TEST_ALL_PREFIXES(ash::WebNotificationTrayTest, PopupAndFullscreen); | 228 FRIEND_TEST_ALL_PREFIXES(ash::WebNotificationTrayTest, PopupAndFullscreen); |
| 229 | 229 |
| 230 struct TargetBounds { | 230 struct TargetBounds { |
| 231 TargetBounds(); | 231 TargetBounds(); |
| 232 ~TargetBounds(); | 232 ~TargetBounds(); |
| 233 | 233 |
| 234 float opacity; | 234 float opacity; |
| 235 float status_opacity; | 235 float status_opacity; |
| 236 gfx::Rect shelf_bounds_in_root; | 236 gfx::Rect shelf_bounds_in_root; |
| 237 gfx::Rect launcher_bounds_in_shelf; | 237 gfx::Rect shelf_bounds_in_shelf; |
| 238 gfx::Rect status_bounds_in_shelf; | 238 gfx::Rect status_bounds_in_shelf; |
| 239 gfx::Insets work_area_insets; | 239 gfx::Insets work_area_insets; |
| 240 }; | 240 }; |
| 241 | 241 |
| 242 struct State { | 242 struct State { |
| 243 State() : visibility_state(SHELF_VISIBLE), | 243 State() : visibility_state(SHELF_VISIBLE), |
| 244 auto_hide_state(SHELF_AUTO_HIDE_HIDDEN), | 244 auto_hide_state(SHELF_AUTO_HIDE_HIDDEN), |
| 245 window_state(WORKSPACE_WINDOW_STATE_DEFAULT), | 245 window_state(WORKSPACE_WINDOW_STATE_DEFAULT), |
| 246 is_screen_locked(false) {} | 246 is_screen_locked(false) {} |
| 247 | 247 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 259 | 259 |
| 260 ShelfVisibilityState visibility_state; | 260 ShelfVisibilityState visibility_state; |
| 261 ShelfAutoHideState auto_hide_state; | 261 ShelfAutoHideState auto_hide_state; |
| 262 WorkspaceWindowState window_state; | 262 WorkspaceWindowState window_state; |
| 263 bool is_screen_locked; | 263 bool is_screen_locked; |
| 264 }; | 264 }; |
| 265 | 265 |
| 266 // Sets the visibility of the shelf to |state|. | 266 // Sets the visibility of the shelf to |state|. |
| 267 void SetState(ShelfVisibilityState visibility_state); | 267 void SetState(ShelfVisibilityState visibility_state); |
| 268 | 268 |
| 269 // Updates the bounds and opacity of the launcher and status widgets. | 269 // Updates the bounds and opacity of the shelf and status widgets. |
| 270 // If |observer| is specified, it will be called back when the animations, if | 270 // If |observer| is specified, it will be called back when the animations, if |
| 271 // any, are complete. | 271 // any, are complete. |
| 272 void UpdateBoundsAndOpacity(const TargetBounds& target_bounds, | 272 void UpdateBoundsAndOpacity(const TargetBounds& target_bounds, |
| 273 bool animate, | 273 bool animate, |
| 274 ui::ImplicitAnimationObserver* observer); | 274 ui::ImplicitAnimationObserver* observer); |
| 275 | 275 |
| 276 // Stops any animations and progresses them to the end. | 276 // Stops any animations and progresses them to the end. |
| 277 void StopAnimating(); | 277 void StopAnimating(); |
| 278 | 278 |
| 279 // Returns the width (if aligned to the side) or height (if aligned to the | 279 // Returns the width (if aligned to the side) or height (if aligned to the |
| (...skipping 22 matching lines...) Expand all Loading... |
| 302 // Stops the auto hide timer and clears | 302 // Stops the auto hide timer and clears |
| 303 // |mouse_over_shelf_when_auto_hide_timer_started_|. | 303 // |mouse_over_shelf_when_auto_hide_timer_started_|. |
| 304 void StopAutoHideTimer(); | 304 void StopAutoHideTimer(); |
| 305 | 305 |
| 306 // Returns the bounds of an additional region which can trigger showing the | 306 // Returns the bounds of an additional region which can trigger showing the |
| 307 // shelf. This region exists to make it easier to trigger showing the shelf | 307 // shelf. This region exists to make it easier to trigger showing the shelf |
| 308 // when the shelf is auto hidden and the shelf is on the boundary between | 308 // when the shelf is auto hidden and the shelf is on the boundary between |
| 309 // two displays. | 309 // two displays. |
| 310 gfx::Rect GetAutoHideShowShelfRegionInScreen() const; | 310 gfx::Rect GetAutoHideShowShelfRegionInScreen() const; |
| 311 | 311 |
| 312 // Returns the AutoHideState. This value is determined from the launcher and | 312 // Returns the AutoHideState. This value is determined from the shelf and |
| 313 // tray. | 313 // tray. |
| 314 ShelfAutoHideState CalculateAutoHideState( | 314 ShelfAutoHideState CalculateAutoHideState( |
| 315 ShelfVisibilityState visibility_state) const; | 315 ShelfVisibilityState visibility_state) const; |
| 316 | 316 |
| 317 // Updates the hit test bounds override for launcher and status area. | 317 // Updates the hit test bounds override for shelf and status area. |
| 318 void UpdateHitTestBounds(); | 318 void UpdateHitTestBounds(); |
| 319 | 319 |
| 320 // Returns true if |window| is a descendant of the shelf. | 320 // Returns true if |window| is a descendant of the shelf. |
| 321 bool IsShelfWindow(aura::Window* window); | 321 bool IsShelfWindow(aura::Window* window); |
| 322 | 322 |
| 323 int GetWorkAreaSize(const State& state, int size) const; | 323 int GetWorkAreaSize(const State& state, int size) const; |
| 324 | 324 |
| 325 // Return the bounds available in the parent, taking into account the bounds | 325 // Return the bounds available in the parent, taking into account the bounds |
| 326 // of the keyboard if necessary. | 326 // of the keyboard if necessary. |
| 327 gfx::Rect GetAvailableBounds() const; | 327 gfx::Rect GetAvailableBounds() const; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 | 362 |
| 363 // Do any windows overlap the shelf? This is maintained by WorkspaceManager. | 363 // Do any windows overlap the shelf? This is maintained by WorkspaceManager. |
| 364 bool window_overlaps_shelf_; | 364 bool window_overlaps_shelf_; |
| 365 | 365 |
| 366 base::OneShotTimer<ShelfLayoutManager> auto_hide_timer_; | 366 base::OneShotTimer<ShelfLayoutManager> auto_hide_timer_; |
| 367 | 367 |
| 368 // Whether the mouse was over the shelf when the auto hide timer started. | 368 // Whether the mouse was over the shelf when the auto hide timer started. |
| 369 // False when neither the auto hide timer nor the timer task are running. | 369 // False when neither the auto hide timer nor the timer task are running. |
| 370 bool mouse_over_shelf_when_auto_hide_timer_started_; | 370 bool mouse_over_shelf_when_auto_hide_timer_started_; |
| 371 | 371 |
| 372 // EventFilter used to detect when user moves the mouse over the launcher to | 372 // EventFilter used to detect when user moves the mouse over the shelf to |
| 373 // trigger showing the launcher. | 373 // trigger showing the shelf. |
| 374 scoped_ptr<AutoHideEventFilter> auto_hide_event_filter_; | 374 scoped_ptr<AutoHideEventFilter> auto_hide_event_filter_; |
| 375 | 375 |
| 376 // EventFilter used to detect when user issues a gesture on a bezel sensor. | 376 // EventFilter used to detect when user issues a gesture on a bezel sensor. |
| 377 scoped_ptr<ShelfBezelEventFilter> bezel_event_filter_; | 377 scoped_ptr<ShelfBezelEventFilter> bezel_event_filter_; |
| 378 | 378 |
| 379 ObserverList<ShelfLayoutManagerObserver> observers_; | 379 ObserverList<ShelfLayoutManagerObserver> observers_; |
| 380 | 380 |
| 381 // The shelf reacts to gesture-drags, and can be set to auto-hide for certain | 381 // The shelf reacts to gesture-drags, and can be set to auto-hide for certain |
| 382 // gestures. Some shelf behaviour (e.g. visibility state, background color | 382 // gestures. Some shelf behaviour (e.g. visibility state, background color |
| 383 // etc.) are affected by various stages of the drag. The enum keeps track of | 383 // etc.) are affected by various stages of the drag. The enum keeps track of |
| (...skipping 22 matching lines...) Expand all Loading... |
| 406 // The bounds of the dock. | 406 // The bounds of the dock. |
| 407 gfx::Rect dock_bounds_; | 407 gfx::Rect dock_bounds_; |
| 408 | 408 |
| 409 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager); | 409 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager); |
| 410 }; | 410 }; |
| 411 | 411 |
| 412 } // namespace internal | 412 } // namespace internal |
| 413 } // namespace ash | 413 } // namespace ash |
| 414 | 414 |
| 415 #endif // ASH_SHELF_SHELF_LAYOUT_MANAGER_H_ | 415 #endif // ASH_SHELF_SHELF_LAYOUT_MANAGER_H_ |
| OLD | NEW |