Chromium Code Reviews| 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_WM_SHELF_LAYOUT_MANAGER_H_ | 5 #ifndef ASH_WM_SHELF_LAYOUT_MANAGER_H_ |
| 6 #define ASH_WM_SHELF_LAYOUT_MANAGER_H_ | 6 #define ASH_WM_SHELF_LAYOUT_MANAGER_H_ |
|
Mr4D (OOO till 08-26)
2013/03/04 22:59:00
As before: "..WM_.." -> "..SHELF_.."
Harry McCleave
2013/03/05 05:59:19
Done.
| |
| 7 | 7 |
| 8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
| 9 #include "ash/launcher/launcher.h" | 9 #include "ash/launcher/launcher.h" |
| 10 #include "ash/shelf_types.h" | 10 #include "ash/shelf/background_animator.h" |
| 11 #include "ash/shelf/shelf_types.h" | |
| 11 #include "ash/shell_observer.h" | 12 #include "ash/shell_observer.h" |
| 13 #include "ash/system/status_area_widget.h" | |
| 12 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 13 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 14 #include "base/logging.h" | 16 #include "base/logging.h" |
| 15 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
| 16 #include "base/timer.h" | 18 #include "base/timer.h" |
| 17 #include "ui/aura/client/activation_change_observer.h" | 19 #include "ui/aura/client/activation_change_observer.h" |
| 18 #include "ui/aura/layout_manager.h" | 20 #include "ui/aura/layout_manager.h" |
| 19 #include "ui/gfx/insets.h" | 21 #include "ui/gfx/insets.h" |
| 20 #include "ui/gfx/rect.h" | 22 #include "ui/gfx/rect.h" |
| 21 | 23 |
| 22 namespace aura { | 24 namespace aura { |
| 23 class RootWindow; | 25 class RootWindow; |
| 24 } | 26 } |
| 25 | 27 |
| 26 namespace ui { | 28 namespace ui { |
| 27 class GestureEvent; | 29 class GestureEvent; |
| 28 } | 30 } |
| 29 | 31 |
| 30 namespace ash { | 32 namespace ash { |
| 31 class ScreenAsh; | 33 class ScreenAsh; |
| 34 class ShelfWidget; | |
| 32 namespace internal { | 35 namespace internal { |
| 33 | 36 |
| 34 class ShelfLayoutManagerTest; | 37 class ShelfLayoutManagerTest; |
| 35 class StatusAreaWidget; | 38 class StatusAreaWidget; |
| 36 class WorkspaceController; | 39 class WorkspaceController; |
| 37 | 40 |
| 38 // ShelfLayoutManager is the layout manager responsible for the launcher and | 41 // ShelfLayoutManager is the layout manager responsible for the launcher and |
| 39 // status widgets. The launcher is given the total available width and told the | 42 // status widgets. The launcher is given the total available width and told the |
| 40 // width of the status area. This allows the launcher to draw the background and | 43 // width of the status area. This allows the launcher to draw the background and |
| 41 // layout to the status area. | 44 // layout to the status area. |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 58 virtual void OnAutoHideStateChanged(ShelfAutoHideState new_state) {} | 61 virtual void OnAutoHideStateChanged(ShelfAutoHideState new_state) {} |
| 59 }; | 62 }; |
| 60 | 63 |
| 61 // We reserve a small area at the bottom of the workspace area to ensure that | 64 // We reserve a small area at the bottom of the workspace area to ensure that |
| 62 // the bottom-of-window resize handle can be hit. | 65 // the bottom-of-window resize handle can be hit. |
| 63 static const int kWorkspaceAreaBottomInset; | 66 static const int kWorkspaceAreaBottomInset; |
| 64 | 67 |
| 65 // Size of the shelf when auto-hidden. | 68 // Size of the shelf when auto-hidden. |
| 66 static const int kAutoHideSize; | 69 static const int kAutoHideSize; |
| 67 | 70 |
| 68 explicit ShelfLayoutManager(StatusAreaWidget* status); | 71 explicit ShelfLayoutManager(ShelfWidget* shelf); |
| 69 virtual ~ShelfLayoutManager(); | 72 virtual ~ShelfLayoutManager(); |
| 70 | 73 |
| 71 // Sets the ShelfAutoHideBehavior. See enum description for details. | 74 // Sets the ShelfAutoHideBehavior. See enum description for details. |
| 72 void SetAutoHideBehavior(ShelfAutoHideBehavior behavior); | 75 void SetAutoHideBehavior(ShelfAutoHideBehavior behavior); |
| 73 ShelfAutoHideBehavior auto_hide_behavior() const { | 76 ShelfAutoHideBehavior auto_hide_behavior() const { |
| 74 return auto_hide_behavior_; | 77 return auto_hide_behavior_; |
| 75 } | 78 } |
| 76 | 79 |
| 77 // Sets the alignment. Returns true if the alignment is changed. Otherwise, | 80 // Sets the alignment. Returns true if the alignment is changed. Otherwise, |
| 78 // returns false. | 81 // returns false. |
| 79 bool SetAlignment(ShelfAlignment alignment); | 82 bool SetAlignment(ShelfAlignment alignment); |
| 80 ShelfAlignment GetAlignment() const { return alignment_; } | 83 ShelfAlignment GetAlignment() const { return alignment_; } |
| 81 | 84 |
| 82 void set_workspace_controller(WorkspaceController* controller) { | 85 void set_workspace_controller(WorkspaceController* controller) { |
| 83 workspace_controller_ = controller; | 86 workspace_controller_ = controller; |
| 84 } | 87 } |
| 85 | 88 |
| 86 views::Widget* launcher_widget() { | |
| 87 return launcher_ ? launcher_->widget() : NULL; | |
| 88 } | |
| 89 const views::Widget* launcher_widget() const { | |
| 90 return launcher_ ? launcher_->widget() : NULL; | |
| 91 } | |
| 92 StatusAreaWidget* status_area_widget() { return status_area_widget_; } | |
| 93 | |
| 94 bool in_layout() const { return in_layout_; } | 89 bool in_layout() const { return in_layout_; } |
| 95 | 90 |
| 96 // Returns whether the shelf and its contents (launcher, status) are visible | 91 // Returns whether the shelf and its contents (launcher, status) are visible |
| 97 // on the screen. | 92 // on the screen. |
| 98 bool IsVisible() const; | 93 bool IsVisible() const; |
| 99 | 94 |
| 100 // The launcher is typically created after the layout manager. | |
| 101 void SetLauncher(Launcher* launcher); | |
| 102 Launcher* launcher() { return launcher_; } | |
| 103 | |
| 104 // Returns the ideal bounds of the shelf assuming it is visible. | 95 // Returns the ideal bounds of the shelf assuming it is visible. |
| 105 gfx::Rect GetIdealBounds(); | 96 gfx::Rect GetIdealBounds(); |
| 106 | 97 |
| 107 // Stops any animations and sets the bounds of the launcher and status | 98 // Stops any animations and sets the bounds of the launcher and status |
| 108 // widgets. | 99 // widgets. |
| 109 void LayoutShelf(); | 100 void LayoutShelf(); |
| 110 | 101 |
| 111 // Returns shelf visibility state based on current value of auto hide | 102 // Returns shelf visibility state based on current value of auto hide |
| 112 // behavior setting. | 103 // behavior setting. |
| 113 ShelfVisibilityState CalculateShelfVisibility(); | 104 ShelfVisibilityState CalculateShelfVisibility(); |
| 114 | 105 |
| 115 // Returns shelf visibility state based on current value of auto hide | 106 // Returns shelf visibility state based on current value of auto hide |
| 116 // behavior setting. | 107 // behavior setting. |
| 117 ShelfVisibilityState CalculateShelfVisibilityWhileDragging(); | 108 ShelfVisibilityState CalculateShelfVisibilityWhileDragging(); |
| 118 | 109 |
| 119 // Updates the visibility state. | 110 // Updates the visibility state. |
| 120 void UpdateVisibilityState(); | 111 void UpdateVisibilityState(); |
| 121 | 112 |
| 122 // Invoked by the shelf/launcher when the auto-hide state may have changed. | 113 // Invoked by the shelf/launcher when the auto-hide state may have changed. |
| 123 void UpdateAutoHideState(); | 114 void UpdateAutoHideState(); |
| 124 | 115 |
| 125 ShelfVisibilityState visibility_state() const { | 116 ShelfVisibilityState visibility_state() const { |
| 126 return state_.visibility_state; | 117 return state_.visibility_state; |
| 127 } | 118 } |
| 128 ShelfAutoHideState auto_hide_state() const { return state_.auto_hide_state; } | 119 ShelfAutoHideState auto_hide_state() const { return state_.auto_hide_state; } |
| 129 | 120 |
| 121 ShelfWidget* shelf_widget() const { return shelf_; } | |
| 122 | |
| 130 // Sets whether any windows overlap the shelf. If a window overlaps the shelf | 123 // Sets whether any windows overlap the shelf. If a window overlaps the shelf |
| 131 // the shelf renders slightly differently. | 124 // the shelf renders slightly differently. |
| 132 void SetWindowOverlapsShelf(bool value); | 125 void SetWindowOverlapsShelf(bool value); |
| 133 bool window_overlaps_shelf() const { return window_overlaps_shelf_; } | 126 bool window_overlaps_shelf() const { return window_overlaps_shelf_; } |
| 134 | 127 |
| 135 void AddObserver(Observer* observer); | 128 void AddObserver(Observer* observer); |
| 136 void RemoveObserver(Observer* observer); | 129 void RemoveObserver(Observer* observer); |
| 137 | 130 |
| 138 // Gesture dragging related functions: | 131 // Gesture dragging related functions: |
| 139 void StartGestureDrag(const ui::GestureEvent& gesture); | 132 void StartGestureDrag(const ui::GestureEvent& gesture); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 private: | 193 private: |
| 201 class AutoHideEventFilter; | 194 class AutoHideEventFilter; |
| 202 class UpdateShelfObserver; | 195 class UpdateShelfObserver; |
| 203 friend class ash::ScreenAsh; | 196 friend class ash::ScreenAsh; |
| 204 friend class ShelfLayoutManagerTest; | 197 friend class ShelfLayoutManagerTest; |
| 205 | 198 |
| 206 struct TargetBounds { | 199 struct TargetBounds { |
| 207 TargetBounds(); | 200 TargetBounds(); |
| 208 | 201 |
| 209 float opacity; | 202 float opacity; |
| 210 gfx::Rect launcher_bounds_in_root; | 203 gfx::Rect shelf_bounds_in_root; |
| 211 gfx::Rect status_bounds_in_root; | 204 gfx::Rect launcher_bounds_in_shelf; |
| 205 gfx::Rect status_bounds_in_shelf; | |
| 212 gfx::Insets work_area_insets; | 206 gfx::Insets work_area_insets; |
| 213 }; | 207 }; |
| 214 | 208 |
| 215 struct State { | 209 struct State { |
| 216 State() : visibility_state(SHELF_VISIBLE), | 210 State() : visibility_state(SHELF_VISIBLE), |
| 217 auto_hide_state(SHELF_AUTO_HIDE_HIDDEN), | 211 auto_hide_state(SHELF_AUTO_HIDE_HIDDEN), |
| 218 is_screen_locked(false) {} | 212 is_screen_locked(false) {} |
| 219 | 213 |
| 220 // Returns true if the two states are considered equal. As | 214 // Returns true if the two states are considered equal. As |
| 221 // |auto_hide_state| only matters if |visibility_state| is | 215 // |auto_hide_state| only matters if |visibility_state| is |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 bool in_layout_; | 279 bool in_layout_; |
| 286 | 280 |
| 287 // See description above setter. | 281 // See description above setter. |
| 288 ShelfAutoHideBehavior auto_hide_behavior_; | 282 ShelfAutoHideBehavior auto_hide_behavior_; |
| 289 | 283 |
| 290 ShelfAlignment alignment_; | 284 ShelfAlignment alignment_; |
| 291 | 285 |
| 292 // Current state. | 286 // Current state. |
| 293 State state_; | 287 State state_; |
| 294 | 288 |
| 295 Launcher* launcher_; | 289 ShelfWidget* shelf_; |
| 296 StatusAreaWidget* status_area_widget_; | |
| 297 | 290 |
| 298 WorkspaceController* workspace_controller_; | 291 WorkspaceController* workspace_controller_; |
| 299 | 292 |
| 300 // Do any windows overlap the shelf? This is maintained by WorkspaceManager. | 293 // Do any windows overlap the shelf? This is maintained by WorkspaceManager. |
| 301 bool window_overlaps_shelf_; | 294 bool window_overlaps_shelf_; |
| 302 | 295 |
| 303 base::OneShotTimer<ShelfLayoutManager> auto_hide_timer_; | 296 base::OneShotTimer<ShelfLayoutManager> auto_hide_timer_; |
| 304 | 297 |
| 305 // EventFilter used to detect when user moves the mouse over the launcher to | 298 // EventFilter used to detect when user moves the mouse over the launcher to |
| 306 // trigger showing the launcher. | 299 // trigger showing the launcher. |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 329 // Used to delay updating shelf background. | 322 // Used to delay updating shelf background. |
| 330 UpdateShelfObserver* update_shelf_observer_; | 323 UpdateShelfObserver* update_shelf_observer_; |
| 331 | 324 |
| 332 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager); | 325 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager); |
| 333 }; | 326 }; |
| 334 | 327 |
| 335 } // namespace internal | 328 } // namespace internal |
| 336 } // namespace ash | 329 } // namespace ash |
| 337 | 330 |
| 338 #endif // ASH_WM_SHELF_LAYOUT_MANAGER_H_ | 331 #endif // ASH_WM_SHELF_LAYOUT_MANAGER_H_ |
| OLD | NEW |