| 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_ |
| 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/shell_observer.h" | 10 #include "ash/shell_observer.h" |
| 11 #include "ash/wm/shelf_types.h" | 11 #include "ash/wm/shelf_types.h" |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
| 15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
| 16 #include "base/timer.h" | 16 #include "base/timer.h" |
| 17 #include "ui/aura/client/activation_change_observer.h" | 17 #include "ui/aura/client/activation_change_observer.h" |
| 18 #include "ui/aura/layout_manager.h" | 18 #include "ui/aura/layout_manager.h" |
| 19 #include "ui/gfx/insets.h" | 19 #include "ui/gfx/insets.h" |
| 20 #include "ui/gfx/rect.h" | 20 #include "ui/gfx/rect.h" |
| 21 | 21 |
| 22 namespace aura { | 22 namespace aura { |
| 23 class RootWindow; | 23 class RootWindow; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace ui { | 26 namespace ui { |
| 27 class GestureEvent; | 27 class GestureEvent; |
| 28 } | 28 } |
| 29 | 29 |
| 30 namespace views { | |
| 31 class Widget; | |
| 32 } | |
| 33 | |
| 34 namespace ash { | 30 namespace ash { |
| 35 class ScreenAsh; | 31 class ScreenAsh; |
| 36 namespace internal { | 32 namespace internal { |
| 37 | 33 |
| 38 class ShelfLayoutManagerTest; | 34 class ShelfLayoutManagerTest; |
| 35 class StatusAreaWidget; |
| 39 class WorkspaceController; | 36 class WorkspaceController; |
| 40 | 37 |
| 41 // ShelfLayoutManager is the layout manager responsible for the launcher and | 38 // ShelfLayoutManager is the layout manager responsible for the launcher and |
| 42 // status widgets. The launcher is given the total available width and told the | 39 // status widgets. The launcher is given the total available width and told the |
| 43 // width of the status area. This allows the launcher to draw the background and | 40 // width of the status area. This allows the launcher to draw the background and |
| 44 // layout to the status area. | 41 // layout to the status area. |
| 45 // To respond to bounds changes in the status area StatusAreaLayoutManager works | 42 // To respond to bounds changes in the status area StatusAreaLayoutManager works |
| 46 // closely with ShelfLayoutManager. | 43 // closely with ShelfLayoutManager. |
| 47 class ASH_EXPORT ShelfLayoutManager : | 44 class ASH_EXPORT ShelfLayoutManager : |
| 48 public aura::LayoutManager, | 45 public aura::LayoutManager, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 // the bottom-of-window resize handle can be hit. | 78 // the bottom-of-window resize handle can be hit. |
| 82 // TODO(jamescook): Some day we may want the workspace area to be an even | 79 // TODO(jamescook): Some day we may want the workspace area to be an even |
| 83 // multiple of the size of the grid (currently 8 pixels), which will require | 80 // multiple of the size of the grid (currently 8 pixels), which will require |
| 84 // removing this and finding a way for hover and click events to pass through | 81 // removing this and finding a way for hover and click events to pass through |
| 85 // the invisible parts of the launcher. | 82 // the invisible parts of the launcher. |
| 86 static const int kWorkspaceAreaBottomInset; | 83 static const int kWorkspaceAreaBottomInset; |
| 87 | 84 |
| 88 // Size of the shelf when auto-hidden. | 85 // Size of the shelf when auto-hidden. |
| 89 static const int kAutoHideSize; | 86 static const int kAutoHideSize; |
| 90 | 87 |
| 91 explicit ShelfLayoutManager(views::Widget* status); | 88 explicit ShelfLayoutManager(StatusAreaWidget* status); |
| 92 virtual ~ShelfLayoutManager(); | 89 virtual ~ShelfLayoutManager(); |
| 93 | 90 |
| 94 // Sets the ShelfAutoHideBehavior. See enum description for details. | 91 // Sets the ShelfAutoHideBehavior. See enum description for details. |
| 95 void SetAutoHideBehavior(ShelfAutoHideBehavior behavior); | 92 void SetAutoHideBehavior(ShelfAutoHideBehavior behavior); |
| 96 ShelfAutoHideBehavior auto_hide_behavior() const { | 93 ShelfAutoHideBehavior auto_hide_behavior() const { |
| 97 return auto_hide_behavior_; | 94 return auto_hide_behavior_; |
| 98 } | 95 } |
| 99 | 96 |
| 100 // Sets the alignment. Returns true if the alignment is changed. Otherwise, | 97 // Sets the alignment. Returns true if the alignment is changed. Otherwise, |
| 101 // returns false. | 98 // returns false. |
| 102 bool SetAlignment(ShelfAlignment alignment); | 99 bool SetAlignment(ShelfAlignment alignment); |
| 103 ShelfAlignment alignment() const { return alignment_; } | 100 ShelfAlignment alignment() const { return alignment_; } |
| 104 | 101 |
| 105 void set_workspace_controller(WorkspaceController* controller) { | 102 void set_workspace_controller(WorkspaceController* controller) { |
| 106 workspace_controller_ = controller; | 103 workspace_controller_ = controller; |
| 107 } | 104 } |
| 108 | 105 |
| 109 views::Widget* launcher_widget() { | 106 views::Widget* launcher_widget() { |
| 110 return launcher_ ? launcher_->widget() : NULL; | 107 return launcher_ ? launcher_->widget() : NULL; |
| 111 } | 108 } |
| 112 const views::Widget* launcher_widget() const { | 109 const views::Widget* launcher_widget() const { |
| 113 return launcher_ ? launcher_->widget() : NULL; | 110 return launcher_ ? launcher_->widget() : NULL; |
| 114 } | 111 } |
| 115 views::Widget* status() { return status_; } | 112 StatusAreaWidget* status_area_widget() { return status_area_widget_; } |
| 116 | 113 |
| 117 bool in_layout() const { return in_layout_; } | 114 bool in_layout() const { return in_layout_; } |
| 118 | 115 |
| 119 // Returns whether the shelf and its contents (launcher, status) are visible | 116 // Returns whether the shelf and its contents (launcher, status) are visible |
| 120 // on the screen. | 117 // on the screen. |
| 121 bool IsVisible() const; | 118 bool IsVisible() const; |
| 122 | 119 |
| 123 // The launcher is typically created after the layout manager. | 120 // The launcher is typically created after the layout manager. |
| 124 void SetLauncher(Launcher* launcher); | 121 void SetLauncher(Launcher* launcher); |
| 125 Launcher* launcher() { return launcher_; } | 122 Launcher* launcher() { return launcher_; } |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 | 267 |
| 271 // See description above setter. | 268 // See description above setter. |
| 272 ShelfAutoHideBehavior auto_hide_behavior_; | 269 ShelfAutoHideBehavior auto_hide_behavior_; |
| 273 | 270 |
| 274 ShelfAlignment alignment_; | 271 ShelfAlignment alignment_; |
| 275 | 272 |
| 276 // Current state. | 273 // Current state. |
| 277 State state_; | 274 State state_; |
| 278 | 275 |
| 279 Launcher* launcher_; | 276 Launcher* launcher_; |
| 280 views::Widget* status_; | 277 StatusAreaWidget* status_area_widget_; |
| 281 | 278 |
| 282 WorkspaceController* workspace_controller_; | 279 WorkspaceController* workspace_controller_; |
| 283 | 280 |
| 284 // Do any windows overlap the shelf? This is maintained by WorkspaceManager. | 281 // Do any windows overlap the shelf? This is maintained by WorkspaceManager. |
| 285 bool window_overlaps_shelf_; | 282 bool window_overlaps_shelf_; |
| 286 | 283 |
| 287 base::OneShotTimer<ShelfLayoutManager> auto_hide_timer_; | 284 base::OneShotTimer<ShelfLayoutManager> auto_hide_timer_; |
| 288 | 285 |
| 289 // EventFilter used to detect when user moves the mouse over the launcher to | 286 // EventFilter used to detect when user moves the mouse over the launcher to |
| 290 // trigger showing the launcher. | 287 // trigger showing the launcher. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 313 // Used to delay updating shelf background. | 310 // Used to delay updating shelf background. |
| 314 UpdateShelfObserver* update_shelf_observer_; | 311 UpdateShelfObserver* update_shelf_observer_; |
| 315 | 312 |
| 316 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager); | 313 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager); |
| 317 }; | 314 }; |
| 318 | 315 |
| 319 } // namespace internal | 316 } // namespace internal |
| 320 } // namespace ash | 317 } // namespace ash |
| 321 | 318 |
| 322 #endif // ASH_WM_SHELF_LAYOUT_MANAGER_H_ | 319 #endif // ASH_WM_SHELF_LAYOUT_MANAGER_H_ |
| OLD | NEW |