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_ |
|
Mr4D (OOO till 08-26)
2013/03/04 19:18:04
"WM_" -> "SHELF_"
Mr4D (OOO till 08-26)
2013/03/04 22:59:00
I think you have missed this one.
| |
| 6 #define ASH_WM_SHELF_LAYOUT_MANAGER_H_ | 6 #define ASH_WM_SHELF_LAYOUT_MANAGER_H_ |
| 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(); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 190 return IsHorizontalAlignment() ? horizontal : vertical; | 181 return IsHorizontalAlignment() ? horizontal : vertical; |
| 191 } | 182 } |
| 192 | 183 |
| 193 // Is the shelf's alignment horizontal? | 184 // Is the shelf's alignment horizontal? |
| 194 bool IsHorizontalAlignment() const; | 185 bool IsHorizontalAlignment() const; |
| 195 | 186 |
| 196 // Returns a ShelfLayoutManager on the display which has a launcher for | 187 // Returns a ShelfLayoutManager on the display which has a launcher for |
| 197 // given |window|. See RootWindowController::ForLauncher for more info. | 188 // given |window|. See RootWindowController::ForLauncher for more info. |
| 198 static ShelfLayoutManager* ForLauncher(aura::Window* window); | 189 static ShelfLayoutManager* ForLauncher(aura::Window* window); |
| 199 | 190 |
| 191 ShelfWidget* shelf_widget() const { return shelf_; } | |
|
Mr4D (OOO till 08-26)
2013/03/04 19:18:04
New line. Or better: Move up to the other accessor
Harry McCleave
2013/03/04 20:29:24
Done.
| |
| 200 private: | 192 private: |
| 201 class AutoHideEventFilter; | 193 class AutoHideEventFilter; |
| 202 class UpdateShelfObserver; | 194 class UpdateShelfObserver; |
| 203 friend class ash::ScreenAsh; | 195 friend class ash::ScreenAsh; |
| 204 friend class ShelfLayoutManagerTest; | 196 friend class ShelfLayoutManagerTest; |
| 205 | 197 |
| 206 struct TargetBounds { | 198 struct TargetBounds { |
| 207 TargetBounds(); | 199 TargetBounds(); |
| 208 | 200 |
| 209 float opacity; | 201 float opacity; |
| 210 gfx::Rect launcher_bounds_in_root; | 202 gfx::Rect shelf_bounds_in_root; |
| 211 gfx::Rect status_bounds_in_root; | 203 gfx::Rect launcher_bounds_in_shelf; |
| 204 gfx::Rect status_bounds_in_shelf; | |
| 212 gfx::Insets work_area_insets; | 205 gfx::Insets work_area_insets; |
| 213 }; | 206 }; |
| 214 | 207 |
| 215 struct State { | 208 struct State { |
| 216 State() : visibility_state(SHELF_VISIBLE), | 209 State() : visibility_state(SHELF_VISIBLE), |
| 217 auto_hide_state(SHELF_AUTO_HIDE_HIDDEN), | 210 auto_hide_state(SHELF_AUTO_HIDE_HIDDEN), |
| 218 is_screen_locked(false) {} | 211 is_screen_locked(false) {} |
| 219 | 212 |
| 220 // Returns true if the two states are considered equal. As | 213 // Returns true if the two states are considered equal. As |
| 221 // |auto_hide_state| only matters if |visibility_state| is | 214 // |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_; | 278 bool in_layout_; |
| 286 | 279 |
| 287 // See description above setter. | 280 // See description above setter. |
| 288 ShelfAutoHideBehavior auto_hide_behavior_; | 281 ShelfAutoHideBehavior auto_hide_behavior_; |
| 289 | 282 |
| 290 ShelfAlignment alignment_; | 283 ShelfAlignment alignment_; |
| 291 | 284 |
| 292 // Current state. | 285 // Current state. |
| 293 State state_; | 286 State state_; |
| 294 | 287 |
| 295 Launcher* launcher_; | 288 ShelfWidget* shelf_; |
| 296 StatusAreaWidget* status_area_widget_; | |
| 297 | 289 |
| 298 WorkspaceController* workspace_controller_; | 290 WorkspaceController* workspace_controller_; |
| 299 | 291 |
| 300 // Do any windows overlap the shelf? This is maintained by WorkspaceManager. | 292 // Do any windows overlap the shelf? This is maintained by WorkspaceManager. |
| 301 bool window_overlaps_shelf_; | 293 bool window_overlaps_shelf_; |
| 302 | 294 |
| 303 base::OneShotTimer<ShelfLayoutManager> auto_hide_timer_; | 295 base::OneShotTimer<ShelfLayoutManager> auto_hide_timer_; |
| 304 | 296 |
| 305 // EventFilter used to detect when user moves the mouse over the launcher to | 297 // EventFilter used to detect when user moves the mouse over the launcher to |
| 306 // trigger showing the launcher. | 298 // trigger showing the launcher. |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 329 // Used to delay updating shelf background. | 321 // Used to delay updating shelf background. |
| 330 UpdateShelfObserver* update_shelf_observer_; | 322 UpdateShelfObserver* update_shelf_observer_; |
| 331 | 323 |
| 332 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager); | 324 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager); |
| 333 }; | 325 }; |
| 334 | 326 |
| 335 } // namespace internal | 327 } // namespace internal |
| 336 } // namespace ash | 328 } // namespace ash |
| 337 | 329 |
| 338 #endif // ASH_WM_SHELF_LAYOUT_MANAGER_H_ | 330 #endif // ASH_WM_SHELF_LAYOUT_MANAGER_H_ |
| OLD | NEW |