Chromium Code Reviews| Index: ash/wm/window_state.h |
| diff --git a/ash/wm/window_settings.h b/ash/wm/window_state.h |
| similarity index 38% |
| rename from ash/wm/window_settings.h |
| rename to ash/wm/window_state.h |
| index 749ff2e5b003c92d4076b4d53ae8e11a00a6861b..f956016f45921e1b1557ad14fb2a07d4b6ff86d7 100644 |
| --- a/ash/wm/window_settings.h |
| +++ b/ash/wm/window_state.h |
| @@ -2,23 +2,29 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#ifndef ASH_WM_WINDOW_SETTINGS_H_ |
| -#define ASH_WM_WINDOW_SETTINGS_H_ |
| +#ifndef ASH_WM_WINDOW_STATE_H_ |
| +#define ASH_WM_WINDOW_STATE_H_ |
| #include "ash/ash_export.h" |
| #include "base/basictypes.h" |
| +#include "base/memory/scoped_ptr.h" |
| #include "base/observer_list.h" |
| +#include "ui/base/ui_base_types.h" |
| namespace aura { |
| class Window; |
| } |
| +namespace gfx { |
| +class Rect; |
| +} |
| + |
| namespace ash { |
| namespace wm { |
| -// Per managed window information should be stored here |
| -// instead of using plain aura window property. |
| -class ASH_EXPORT WindowSettings { |
| +// WindowState manages and defines ash specific window state and |
| +// behavior. |
|
James Cook
2013/09/18 20:44:17
Given that this class is going to be a core piece
oshima
2013/09/19 01:52:01
Done.
|
| +class ASH_EXPORT WindowState { |
| public: |
| class ASH_EXPORT Observer { |
| public: |
| @@ -27,8 +33,108 @@ class ASH_EXPORT WindowSettings { |
| bool old_value) {} |
| }; |
| - explicit WindowSettings(aura::Window* window); |
| - ~WindowSettings(); |
| + static bool IsMaximizedOrFullscreenState(ui::WindowShowState state); |
|
James Cook
2013/09/18 20:44:17
Does this need to be part of the API for this clas
oshima
2013/09/19 01:52:01
I added here because this class has IsMaximizedOrF
|
| + |
| + explicit WindowState(aura::Window* window); |
| + ~WindowState(); |
| + |
| + aura::Window* window() { return window_; } |
| + const aura::Window* window() const { return window_; } |
| + |
| + // Returns the window's current shows tate. |
| + ui::WindowShowState GetShowState() const; |
| + |
| + // Returns true if the window is minimized. |
| + bool IsMinimized() const; |
| + |
| + // Returns true if the window is maximzied. |
|
James Cook
2013/09/18 20:44:17
maximzied -> maximized. Or just delete all these
oshima
2013/09/19 01:52:01
I'm glad you wanted remove them. I agree :)
|
| + bool IsMaximized() const; |
| + |
| + // Returns true if the window is fullscreen. |
| + bool IsFullscreen() const; |
| + |
| + // Return true if the window is either maximized or fullscreen. |
| + bool IsMaximizedOrFullscreen() const; |
|
James Cook
2013/09/18 20:44:17
Do we really need this API? Callers can do an ||.
oshima
2013/09/19 01:52:01
I found that this condition is used many places (9
|
| + |
| + // Returns true if the window is normal or default. |
| + bool IsNormal() const; |
|
James Cook
2013/09/18 20:44:17
This probably needs more explanation or a better n
oshima
2013/09/19 01:52:01
Changed to NormalShowState. I'll look into if we c
|
| + |
| + // Returns true if the window is active. |
| + bool IsActive() const; |
| + |
| + // Returns true if the window can be maximized. |
| + bool CanMaximize() const; |
| + |
| + // Returns true if the window can be minimized. |
| + bool CanMinimize() const; |
| + |
| + // Returns true if the window can be resized. |
| + bool CanResize() const; |
| + |
| + // Returns true if the window can be snapped to the left or right. |
| + bool CanSnap() const; |
| + |
| + // Returns true if the window can be ativated. |
| + bool CanActivate() const; |
| + |
| + // Returns true if the window has restore bounds. |
| + bool HasRestoreBounds() const; |
| + |
| + void Maximize(); |
| + void Minimize(); |
| + void Unminimize(); |
| + void Activate(); |
| + void Normalize(); |
|
James Cook
2013/09/18 20:44:17
What does this do?
oshima
2013/09/19 01:52:01
Thank you for asking. This is same as Restore() an
|
| + void Deactivate(); |
| + void Restore(); |
| + void ToggleMaximized(); |
| + |
| + // Sets the window's bounds in screen coordinates. |
| + void SetBoundsInScreen(const gfx::Rect& bounds_in_screen); |
| + |
| + // Saves the current bounds to be used as a restore bounds. |
| + void SaveCurrentBoundsForRestore(); |
| + |
| + // Same as |GetRestoreBoundsInScreen| except that it returns the |
| + // bounds in the parent's coordinates. |
| + gfx::Rect GetRestoreBoundsInParent() const; |
| + |
| + // Returns the restore bounds property on the window in the virtual screen |
| + // coordinates. The bounds can be NULL if the bounds property does not |
| + // exist for the window. The window owns the bounds object. |
| + gfx::Rect GetRestoreBoundsInScreen() const; |
| + |
| + // Same as |SetRestoreBoundsInScreen| except that the bounds is in the |
| + // parent's coordinates. |
| + void SetRestoreBoundsInParent(const gfx::Rect& bounds_in_parent); |
| + |
| + // Sets the restore bounds property on the window in the virtual screen |
| + // coordinates. Deletes existing bounds value if exists. |
| + void SetRestoreBoundsInScreen(const gfx::Rect& bounds_in_screen); |
| + |
| + // Deletes and clears the restore bounds property on the window. |
| + void ClearRestoreBounds(); |
| + |
| + // Sets whether the window should always be restored to the restore bounds |
| + // (sometimes the workspace layout manager restores the window to its original |
| + // bounds instead of the restore bounds. Setting this key overrides that |
| + // behaviour). The flag is reset to the default value after the window is |
| + // restored. |
| + bool always_restores_to_restore_bounds() const { |
| + return always_restores_to_restore_bounds_; |
| + } |
| + void set_always_restores_to_restore_bounds(bool value) { |
| + always_restores_to_restore_bounds_ = value; |
| + } |
| + |
| + // Gets/Sets the bounds of the window before it was moved by the auto window |
| + // management. As long as it was not auto-managed, it will return NULL. |
| + const gfx::Rect* pre_auto_manage_window_bounds() const { |
| + return pre_auto_manage_window_bounds_.get(); |
| + } |
| + void SetPreAutoManageWindowBounds(const gfx::Rect& bounds); |
| + |
| + // Layout related properties |
| void AddObserver(Observer* observer); |
| void RemoveObserver(Observer* observer); |
| @@ -88,20 +194,31 @@ class ASH_EXPORT WindowSettings { |
| bool continue_drag_after_reparent_; |
| bool ignored_by_shelf_; |
| + bool always_restores_to_restore_bounds_; |
| + |
| + // A property to remember the window position which was set before the |
| + // auto window position manager changed the window bounds, so that it can get |
| + // restored when only this one window gets shown. |
| + scoped_ptr<gfx::Rect> pre_auto_manage_window_bounds_; |
| + |
| ObserverList<Observer> observer_list_; |
| - DISALLOW_COPY_AND_ASSIGN(WindowSettings); |
| + DISALLOW_COPY_AND_ASSIGN(WindowState); |
| }; |
|
James Cook
2013/09/18 20:44:17
Overall, I like having all this information in one
|
| -// Returns the WindowSettings for |window|. Creates WindowSettings |
| +// Returns the WindowState for active window. Returns |NULL| |
| +// if there is no active window. |
| +ASH_EXPORT WindowState* GetActiveWindowState(); |
| + |
| +// Returns the WindowState for |window|. Creates WindowState |
| // if it didn't exist. The settings object is owned by |window|. |
| -ASH_EXPORT WindowSettings* GetWindowSettings(aura::Window* window); |
| +ASH_EXPORT WindowState* GetWindowState(aura::Window* window); |
| -// const version of GetWindowSettings. |
| -ASH_EXPORT const WindowSettings* |
| -GetWindowSettings(const aura::Window* window); |
| +// const version of GetWindowState. |
| +ASH_EXPORT const WindowState* |
| +GetWindowState(const aura::Window* window); |
| } // namespace wm |
| } // namespace ash |
| -#endif // ASH_WM_WINDOW_SETTINGS_H_ |
| +#endif // ASH_WM_WINDOW_STATE_H_ |