| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_COMMON_WINDOW_STATE_H_ | 5 #ifndef ASH_WM_COMMON_WINDOW_STATE_H_ |
| 6 #define ASH_WM_COMMON_WINDOW_STATE_H_ | 6 #define ASH_WM_COMMON_WINDOW_STATE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "ash/ash_export.h" | 10 #include "ash/wm/common/ash_wm_common_export.h" |
| 11 #include "ash/wm/common/drag_details.h" | 11 #include "ash/wm/common/drag_details.h" |
| 12 #include "ash/wm/common/wm_types.h" | 12 #include "ash/wm/common/wm_types.h" |
| 13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
| 16 #include "ui/base/ui_base_types.h" | 16 #include "ui/base/ui_base_types.h" |
| 17 | 17 |
| 18 namespace aura { | 18 namespace aura { |
| 19 class Window; | 19 class Window; |
| 20 } | 20 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 37 // behavior. Ash specific per-window state (such as ones that controls | 37 // behavior. Ash specific per-window state (such as ones that controls |
| 38 // window manager behavior) and ash specific window behavior (such as | 38 // window manager behavior) and ash specific window behavior (such as |
| 39 // maximize, minimize, snap sizing etc) should be added here instead | 39 // maximize, minimize, snap sizing etc) should be added here instead |
| 40 // of defining separate functions (like |MaximizeWindow(aura::Window* | 40 // of defining separate functions (like |MaximizeWindow(aura::Window* |
| 41 // window)|) or using aura Window property. | 41 // window)|) or using aura Window property. |
| 42 // The WindowState gets created when first accessed by | 42 // The WindowState gets created when first accessed by |
| 43 // |wm::GetWindowState|, and deleted when the window is deleted. | 43 // |wm::GetWindowState|, and deleted when the window is deleted. |
| 44 // Prefer using this class instead of passing aura::Window* around in | 44 // Prefer using this class instead of passing aura::Window* around in |
| 45 // ash code as this is often what you need to interact with, and | 45 // ash code as this is often what you need to interact with, and |
| 46 // accessing the window using |window()| is cheap. | 46 // accessing the window using |window()| is cheap. |
| 47 class ASH_EXPORT WindowState { | 47 class ASH_WM_COMMON_EXPORT WindowState { |
| 48 public: | 48 public: |
| 49 // A subclass of State class represents one of the window's states | 49 // A subclass of State class represents one of the window's states |
| 50 // that corresponds to WindowStateType in Ash environment, e.g. | 50 // that corresponds to WindowStateType in Ash environment, e.g. |
| 51 // maximized, minimized or side snapped, as subclass. | 51 // maximized, minimized or side snapped, as subclass. |
| 52 // Each subclass defines its own behavior and transition for each WMEvent. | 52 // Each subclass defines its own behavior and transition for each WMEvent. |
| 53 class State { | 53 class State { |
| 54 public: | 54 public: |
| 55 State() {} | 55 State() {} |
| 56 virtual ~State() {} | 56 virtual ~State() {} |
| 57 | 57 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 71 // Gets called before the state objects gets deactivated / detached from the | 71 // Gets called before the state objects gets deactivated / detached from the |
| 72 // window, so that it can save the various states it is interested in. | 72 // window, so that it can save the various states it is interested in. |
| 73 // Note: This only gets called when the state object gets changed. | 73 // Note: This only gets called when the state object gets changed. |
| 74 virtual void DetachState(WindowState* window_state) = 0; | 74 virtual void DetachState(WindowState* window_state) = 0; |
| 75 | 75 |
| 76 private: | 76 private: |
| 77 DISALLOW_COPY_AND_ASSIGN(State); | 77 DISALLOW_COPY_AND_ASSIGN(State); |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 // Call GetWindowState() to instantiate this class. | 80 // Call GetWindowState() to instantiate this class. |
| 81 ~WindowState(); | 81 virtual ~WindowState(); |
| 82 | 82 |
| 83 WmWindow* window() { return window_; } | 83 WmWindow* window() { return window_; } |
| 84 const WmWindow* window() const { return window_; } | 84 const WmWindow* window() const { return window_; } |
| 85 | 85 |
| 86 bool HasDelegate() const; | 86 bool HasDelegate() const; |
| 87 void SetDelegate(std::unique_ptr<WindowStateDelegate> delegate); | 87 void SetDelegate(std::unique_ptr<WindowStateDelegate> delegate); |
| 88 | 88 |
| 89 // Returns the window's current ash state type. | 89 // Returns the window's current ash state type. |
| 90 // Refer to WindowStateType definition in wm_types.h as for why Ash | 90 // Refer to WindowStateType definition in wm_types.h as for why Ash |
| 91 // has its own state type. | 91 // has its own state type. |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 // Sets the currently stored restore bounds and clears the restore bounds. | 291 // Sets the currently stored restore bounds and clears the restore bounds. |
| 292 void SetAndClearRestoreBounds(); | 292 void SetAndClearRestoreBounds(); |
| 293 | 293 |
| 294 // Returns a pointer to DragDetails during drag operations. | 294 // Returns a pointer to DragDetails during drag operations. |
| 295 const DragDetails* drag_details() const { return drag_details_.get(); } | 295 const DragDetails* drag_details() const { return drag_details_.get(); } |
| 296 DragDetails* drag_details() { return drag_details_.get(); } | 296 DragDetails* drag_details() { return drag_details_.get(); } |
| 297 | 297 |
| 298 // Called from the associated WmWindow once the show state changes. | 298 // Called from the associated WmWindow once the show state changes. |
| 299 void OnWindowShowStateChanged(); | 299 void OnWindowShowStateChanged(); |
| 300 | 300 |
| 301 protected: |
| 302 explicit WindowState(WmWindow* window); |
| 303 |
| 301 private: | 304 private: |
| 302 friend class DefaultState; | 305 friend class DefaultState; |
| 303 friend class ash::LockWindowState; | 306 friend class ash::LockWindowState; |
| 304 friend class ash::MaximizeModeWindowState; | 307 friend class ash::MaximizeModeWindowState; |
| 305 friend ASH_EXPORT WindowState* GetWindowState(aura::Window*); | |
| 306 FRIEND_TEST_ALL_PREFIXES(WindowAnimationsTest, CrossFadeToBounds); | 308 FRIEND_TEST_ALL_PREFIXES(WindowAnimationsTest, CrossFadeToBounds); |
| 307 FRIEND_TEST_ALL_PREFIXES(WindowAnimationsTest, | 309 FRIEND_TEST_ALL_PREFIXES(WindowAnimationsTest, |
| 308 CrossFadeToBoundsFromTransform); | 310 CrossFadeToBoundsFromTransform); |
| 309 | 311 |
| 310 explicit WindowState(WmWindow* window); | |
| 311 | |
| 312 WindowStateDelegate* delegate() { return delegate_.get(); } | 312 WindowStateDelegate* delegate() { return delegate_.get(); } |
| 313 | 313 |
| 314 // Returns the window's current always_on_top state. | 314 // Returns the window's current always_on_top state. |
| 315 bool GetAlwaysOnTop() const; | 315 bool GetAlwaysOnTop() const; |
| 316 | 316 |
| 317 // Returns the window's current show state. | 317 // Returns the window's current show state. |
| 318 ui::WindowShowState GetShowState() const; | 318 ui::WindowShowState GetShowState() const; |
| 319 | 319 |
| 320 // Sets the window's bounds in screen coordinates. | 320 // Sets the window's bounds in screen coordinates. |
| 321 void SetBoundsInScreen(const gfx::Rect& bounds_in_screen); | 321 void SetBoundsInScreen(const gfx::Rect& bounds_in_screen); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 | 378 |
| 379 std::unique_ptr<State> current_state_; | 379 std::unique_ptr<State> current_state_; |
| 380 | 380 |
| 381 DISALLOW_COPY_AND_ASSIGN(WindowState); | 381 DISALLOW_COPY_AND_ASSIGN(WindowState); |
| 382 }; | 382 }; |
| 383 | 383 |
| 384 } // namespace wm | 384 } // namespace wm |
| 385 } // namespace ash | 385 } // namespace ash |
| 386 | 386 |
| 387 #endif // ASH_WM_COMMON_WINDOW_STATE_H_ | 387 #endif // ASH_WM_COMMON_WINDOW_STATE_H_ |
| OLD | NEW |