| 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/logging.h" |
| 15 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
| 16 #include "base/timer.h" | 17 #include "base/timer.h" |
| 17 #include "ui/aura/layout_manager.h" | 18 #include "ui/aura/layout_manager.h" |
| 18 #include "ui/gfx/insets.h" | 19 #include "ui/gfx/insets.h" |
| 19 #include "ui/gfx/rect.h" | 20 #include "ui/gfx/rect.h" |
| 20 #include "ui/views/corewm/activation_change_shim.h" | 21 #include "ui/views/corewm/activation_change_shim.h" |
| 21 | 22 |
| 22 namespace aura { | 23 namespace aura { |
| 23 class RootWindow; | 24 class RootWindow; |
| 24 } | 25 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 87 |
| 87 // Sets the ShelfAutoHideBehavior. See enum description for details. | 88 // Sets the ShelfAutoHideBehavior. See enum description for details. |
| 88 void SetAutoHideBehavior(ShelfAutoHideBehavior behavior); | 89 void SetAutoHideBehavior(ShelfAutoHideBehavior behavior); |
| 89 ShelfAutoHideBehavior auto_hide_behavior() const { | 90 ShelfAutoHideBehavior auto_hide_behavior() const { |
| 90 return auto_hide_behavior_; | 91 return auto_hide_behavior_; |
| 91 } | 92 } |
| 92 | 93 |
| 93 // Sets the alignment. Returns true if the alignment is changed. Otherwise, | 94 // Sets the alignment. Returns true if the alignment is changed. Otherwise, |
| 94 // returns false. | 95 // returns false. |
| 95 bool SetAlignment(ShelfAlignment alignment); | 96 bool SetAlignment(ShelfAlignment alignment); |
| 96 ShelfAlignment alignment() const { return alignment_; } | 97 ShelfAlignment GetAlignment() const { return alignment_; } |
| 97 | 98 |
| 98 void set_workspace_controller(WorkspaceController* controller) { | 99 void set_workspace_controller(WorkspaceController* controller) { |
| 99 workspace_controller_ = controller; | 100 workspace_controller_ = controller; |
| 100 } | 101 } |
| 101 | 102 |
| 102 views::Widget* launcher_widget() { | 103 views::Widget* launcher_widget() { |
| 103 return launcher_ ? launcher_->widget() : NULL; | 104 return launcher_ ? launcher_->widget() : NULL; |
| 104 } | 105 } |
| 105 const views::Widget* launcher_widget() const { | 106 const views::Widget* launcher_widget() const { |
| 106 return launcher_ ? launcher_->widget() : NULL; | 107 return launcher_ ? launcher_->widget() : NULL; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 virtual void SetChildBounds(aura::Window* child, | 165 virtual void SetChildBounds(aura::Window* child, |
| 165 const gfx::Rect& requested_bounds) OVERRIDE; | 166 const gfx::Rect& requested_bounds) OVERRIDE; |
| 166 | 167 |
| 167 // Overridden from ash::ShellObserver: | 168 // Overridden from ash::ShellObserver: |
| 168 virtual void OnLockStateChanged(bool locked) OVERRIDE; | 169 virtual void OnLockStateChanged(bool locked) OVERRIDE; |
| 169 | 170 |
| 170 // Overriden from aura::client::ActivationChangeObserver: | 171 // Overriden from aura::client::ActivationChangeObserver: |
| 171 virtual void OnWindowActivated(aura::Window* active, | 172 virtual void OnWindowActivated(aura::Window* active, |
| 172 aura::Window* old_active) OVERRIDE; | 173 aura::Window* old_active) OVERRIDE; |
| 173 | 174 |
| 175 // TODO(harrym|oshima): These templates will be moved to |
| 176 // new Shelf class. |
| 177 // A helper function that provides a shortcut for choosing |
| 178 // values specific to a shelf alignment. |
| 179 template<typename T> |
| 180 T SelectValueForShelfAlignment(T bottom, T left, T right) const { |
| 181 switch (alignment_) { |
| 182 case SHELF_ALIGNMENT_BOTTOM: |
| 183 return bottom; |
| 184 case SHELF_ALIGNMENT_LEFT: |
| 185 return left; |
| 186 case SHELF_ALIGNMENT_RIGHT: |
| 187 return right; |
| 188 } |
| 189 NOTREACHED(); |
| 190 return right; |
| 191 } |
| 192 |
| 193 template<typename T> |
| 194 T PrimaryAxisValue(T horizontal, T vertical) const { |
| 195 return IsHorizontalAlignment() ? horizontal : vertical; |
| 196 } |
| 197 |
| 198 // Is the shelf's alignment horizontal? |
| 199 bool IsHorizontalAlignment() const; |
| 200 |
| 201 // Returns a ShelfLayoutManager on the display which has a launcher for |
| 202 // given |window|. See RootWindowController::ForLauncher for more info. |
| 203 static ShelfLayoutManager* ForLauncher(aura::Window* window); |
| 204 |
| 174 private: | 205 private: |
| 175 class AutoHideEventFilter; | 206 class AutoHideEventFilter; |
| 176 class UpdateShelfObserver; | 207 class UpdateShelfObserver; |
| 177 friend class ash::ScreenAsh; | 208 friend class ash::ScreenAsh; |
| 178 friend class ShelfLayoutManagerTest; | 209 friend class ShelfLayoutManagerTest; |
| 179 FRIEND_TEST_ALL_PREFIXES(ShelfLayoutManagerTest, SetAutoHideBehavior); | 210 FRIEND_TEST_ALL_PREFIXES(ShelfLayoutManagerTest, SetAutoHideBehavior); |
| 180 | 211 |
| 181 struct TargetBounds { | 212 struct TargetBounds { |
| 182 TargetBounds(); | 213 TargetBounds(); |
| 183 | 214 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 AutoHideState CalculateAutoHideState(VisibilityState visibility_state) const; | 272 AutoHideState CalculateAutoHideState(VisibilityState visibility_state) const; |
| 242 | 273 |
| 243 // Updates the hit test bounds override for launcher and status area. | 274 // Updates the hit test bounds override for launcher and status area. |
| 244 void UpdateHitTestBounds(); | 275 void UpdateHitTestBounds(); |
| 245 | 276 |
| 246 // Returns true if |window| is a descendant of the shelf. | 277 // Returns true if |window| is a descendant of the shelf. |
| 247 bool IsShelfWindow(aura::Window* window); | 278 bool IsShelfWindow(aura::Window* window); |
| 248 | 279 |
| 249 int GetWorkAreaSize(const State& state, int size) const; | 280 int GetWorkAreaSize(const State& state, int size) const; |
| 250 | 281 |
| 251 int axis_position(int x, int y) const { | |
| 252 return alignment_ == SHELF_ALIGNMENT_BOTTOM ? y : x; | |
| 253 } | |
| 254 | |
| 255 // The RootWindow is cached so that we don't invoke Shell::GetInstance() from | 282 // The RootWindow is cached so that we don't invoke Shell::GetInstance() from |
| 256 // our destructor. We avoid that as at the time we're deleted Shell is being | 283 // our destructor. We avoid that as at the time we're deleted Shell is being |
| 257 // deleted too. | 284 // deleted too. |
| 258 aura::RootWindow* root_window_; | 285 aura::RootWindow* root_window_; |
| 259 | 286 |
| 260 // True when inside LayoutShelf method. Used to prevent calling LayoutShelf | 287 // True when inside LayoutShelf method. Used to prevent calling LayoutShelf |
| 261 // again from SetChildBounds(). | 288 // again from SetChildBounds(). |
| 262 bool in_layout_; | 289 bool in_layout_; |
| 263 | 290 |
| 264 // See description above setter. | 291 // See description above setter. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 // Used to delay updating shelf background. | 333 // Used to delay updating shelf background. |
| 307 UpdateShelfObserver* update_shelf_observer_; | 334 UpdateShelfObserver* update_shelf_observer_; |
| 308 | 335 |
| 309 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager); | 336 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager); |
| 310 }; | 337 }; |
| 311 | 338 |
| 312 } // namespace internal | 339 } // namespace internal |
| 313 } // namespace ash | 340 } // namespace ash |
| 314 | 341 |
| 315 #endif // ASH_WM_SHELF_LAYOUT_MANAGER_H_ | 342 #endif // ASH_WM_SHELF_LAYOUT_MANAGER_H_ |
| OLD | NEW |