Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: ash/wm/window_state.h

Issue 24108003: [Cleanup] Rename WindowSettings to WindowState (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_WINDOW_SETTINGS_H_ 5 #ifndef ASH_WM_WINDOW_STATE_H_
6 #define ASH_WM_WINDOW_SETTINGS_H_ 6 #define ASH_WM_WINDOW_STATE_H_
7 7
8 #include "ash/ash_export.h" 8 #include "ash/ash_export.h"
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/memory/scoped_ptr.h"
10 #include "base/observer_list.h" 11 #include "base/observer_list.h"
12 #include "ui/base/ui_base_types.h"
11 13
12 namespace aura { 14 namespace aura {
13 class Window; 15 class Window;
14 } 16 }
15 17
18 namespace gfx {
19 class Rect;
20 }
21
16 namespace ash { 22 namespace ash {
17 namespace wm { 23 namespace wm {
18 24
19 // Per managed window information should be stored here 25 // WindowState manages and defines ash specific window state and
20 // instead of using plain aura window property. 26 // 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.
21 class ASH_EXPORT WindowSettings { 27 class ASH_EXPORT WindowState {
22 public: 28 public:
23 class ASH_EXPORT Observer { 29 class ASH_EXPORT Observer {
24 public: 30 public:
25 // Called when the tracked_by_workspace has changed. 31 // Called when the tracked_by_workspace has changed.
26 virtual void OnTrackedByWorkspaceChanged(aura::Window* window, 32 virtual void OnTrackedByWorkspaceChanged(aura::Window* window,
27 bool old_value) {} 33 bool old_value) {}
28 }; 34 };
29 35
30 explicit WindowSettings(aura::Window* window); 36 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
31 ~WindowSettings(); 37
38 explicit WindowState(aura::Window* window);
39 ~WindowState();
40
41 aura::Window* window() { return window_; }
42 const aura::Window* window() const { return window_; }
43
44 // Returns the window's current shows tate.
45 ui::WindowShowState GetShowState() const;
46
47 // Returns true if the window is minimized.
48 bool IsMinimized() const;
49
50 // 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 :)
51 bool IsMaximized() const;
52
53 // Returns true if the window is fullscreen.
54 bool IsFullscreen() const;
55
56 // Return true if the window is either maximized or fullscreen.
57 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
58
59 // Returns true if the window is normal or default.
60 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
61
62 // Returns true if the window is active.
63 bool IsActive() const;
64
65 // Returns true if the window can be maximized.
66 bool CanMaximize() const;
67
68 // Returns true if the window can be minimized.
69 bool CanMinimize() const;
70
71 // Returns true if the window can be resized.
72 bool CanResize() const;
73
74 // Returns true if the window can be snapped to the left or right.
75 bool CanSnap() const;
76
77 // Returns true if the window can be ativated.
78 bool CanActivate() const;
79
80 // Returns true if the window has restore bounds.
81 bool HasRestoreBounds() const;
82
83 void Maximize();
84 void Minimize();
85 void Unminimize();
86 void Activate();
87 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
88 void Deactivate();
89 void Restore();
90 void ToggleMaximized();
91
92 // Sets the window's bounds in screen coordinates.
93 void SetBoundsInScreen(const gfx::Rect& bounds_in_screen);
94
95 // Saves the current bounds to be used as a restore bounds.
96 void SaveCurrentBoundsForRestore();
97
98 // Same as |GetRestoreBoundsInScreen| except that it returns the
99 // bounds in the parent's coordinates.
100 gfx::Rect GetRestoreBoundsInParent() const;
101
102 // Returns the restore bounds property on the window in the virtual screen
103 // coordinates. The bounds can be NULL if the bounds property does not
104 // exist for the window. The window owns the bounds object.
105 gfx::Rect GetRestoreBoundsInScreen() const;
106
107 // Same as |SetRestoreBoundsInScreen| except that the bounds is in the
108 // parent's coordinates.
109 void SetRestoreBoundsInParent(const gfx::Rect& bounds_in_parent);
110
111 // Sets the restore bounds property on the window in the virtual screen
112 // coordinates. Deletes existing bounds value if exists.
113 void SetRestoreBoundsInScreen(const gfx::Rect& bounds_in_screen);
114
115 // Deletes and clears the restore bounds property on the window.
116 void ClearRestoreBounds();
117
118 // Sets whether the window should always be restored to the restore bounds
119 // (sometimes the workspace layout manager restores the window to its original
120 // bounds instead of the restore bounds. Setting this key overrides that
121 // behaviour). The flag is reset to the default value after the window is
122 // restored.
123 bool always_restores_to_restore_bounds() const {
124 return always_restores_to_restore_bounds_;
125 }
126 void set_always_restores_to_restore_bounds(bool value) {
127 always_restores_to_restore_bounds_ = value;
128 }
129
130 // Gets/Sets the bounds of the window before it was moved by the auto window
131 // management. As long as it was not auto-managed, it will return NULL.
132 const gfx::Rect* pre_auto_manage_window_bounds() const {
133 return pre_auto_manage_window_bounds_.get();
134 }
135 void SetPreAutoManageWindowBounds(const gfx::Rect& bounds);
136
137 // Layout related properties
32 138
33 void AddObserver(Observer* observer); 139 void AddObserver(Observer* observer);
34 void RemoveObserver(Observer* observer); 140 void RemoveObserver(Observer* observer);
35 141
36 // Whether the window is tracked by workspace code. Default is 142 // Whether the window is tracked by workspace code. Default is
37 // true. If set to false the workspace does not switch the current 143 // true. If set to false the workspace does not switch the current
38 // workspace, nor does it attempt to impose constraints on the 144 // workspace, nor does it attempt to impose constraints on the
39 // bounds of the window. This is intended for tab dragging. 145 // bounds of the window. This is intended for tab dragging.
40 bool tracked_by_workspace() const { return tracked_by_workspace_; } 146 bool tracked_by_workspace() const { return tracked_by_workspace_; }
41 void SetTrackedByWorkspace(bool tracked_by_workspace); 147 void SetTrackedByWorkspace(bool tracked_by_workspace);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 // The owner of this window settings. 187 // The owner of this window settings.
82 aura::Window* window_; 188 aura::Window* window_;
83 189
84 bool tracked_by_workspace_; 190 bool tracked_by_workspace_;
85 bool window_position_managed_; 191 bool window_position_managed_;
86 bool bounds_changed_by_user_; 192 bool bounds_changed_by_user_;
87 bool panel_attached_; 193 bool panel_attached_;
88 bool continue_drag_after_reparent_; 194 bool continue_drag_after_reparent_;
89 bool ignored_by_shelf_; 195 bool ignored_by_shelf_;
90 196
197 bool always_restores_to_restore_bounds_;
198
199 // A property to remember the window position which was set before the
200 // auto window position manager changed the window bounds, so that it can get
201 // restored when only this one window gets shown.
202 scoped_ptr<gfx::Rect> pre_auto_manage_window_bounds_;
203
91 ObserverList<Observer> observer_list_; 204 ObserverList<Observer> observer_list_;
92 205
93 DISALLOW_COPY_AND_ASSIGN(WindowSettings); 206 DISALLOW_COPY_AND_ASSIGN(WindowState);
94 }; 207 };
James Cook 2013/09/18 20:44:17 Overall, I like having all this information in one
95 208
96 // Returns the WindowSettings for |window|. Creates WindowSettings 209 // Returns the WindowState for active window. Returns |NULL|
210 // if there is no active window.
211 ASH_EXPORT WindowState* GetActiveWindowState();
212
213 // Returns the WindowState for |window|. Creates WindowState
97 // if it didn't exist. The settings object is owned by |window|. 214 // if it didn't exist. The settings object is owned by |window|.
98 ASH_EXPORT WindowSettings* GetWindowSettings(aura::Window* window); 215 ASH_EXPORT WindowState* GetWindowState(aura::Window* window);
99 216
100 // const version of GetWindowSettings. 217 // const version of GetWindowState.
101 ASH_EXPORT const WindowSettings* 218 ASH_EXPORT const WindowState*
102 GetWindowSettings(const aura::Window* window); 219 GetWindowState(const aura::Window* window);
103 220
104 } // namespace wm 221 } // namespace wm
105 } // namespace ash 222 } // namespace ash
106 223
107 #endif // ASH_WM_WINDOW_SETTINGS_H_ 224 #endif // ASH_WM_WINDOW_STATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698