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_WINDOW_STATE_H_ | 5 #ifndef ASH_WM_WINDOW_STATE_H_ |
6 #define ASH_WM_WINDOW_STATE_H_ | 6 #define ASH_WM_WINDOW_STATE_H_ |
7 | 7 |
8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
9 #include "ash/wm/window_state_delegate.h" | |
James Cook
2013/10/29 16:13:04
nit: Do you need this include? It doesn't look li
oshima
2013/10/29 17:45:54
Done.
| |
9 #include "ash/wm/wm_types.h" | 10 #include "ash/wm/wm_types.h" |
10 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
12 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
13 #include "ui/aura/window_observer.h" | 14 #include "ui/aura/window_observer.h" |
14 #include "ui/base/ui_base_types.h" | 15 #include "ui/base/ui_base_types.h" |
15 | 16 |
16 namespace aura { | 17 namespace aura { |
17 class Window; | 18 class Window; |
18 } | 19 } |
19 | 20 |
20 namespace gfx { | 21 namespace gfx { |
21 class Rect; | 22 class Rect; |
22 } | 23 } |
23 | 24 |
24 namespace ash { | 25 namespace ash { |
25 class WindowResizer; | 26 class WindowResizer; |
26 | 27 |
27 namespace wm { | 28 namespace wm { |
29 class WindowStateDelegate; | |
28 class WindowStateObserver; | 30 class WindowStateObserver; |
29 | 31 |
30 // WindowState manages and defines ash specific window state and | 32 // WindowState manages and defines ash specific window state and |
31 // behavior. Ash specific per-window state (such as ones that controls | 33 // behavior. Ash specific per-window state (such as ones that controls |
32 // window manager behavior) and ash specific window behavior (such as | 34 // window manager behavior) and ash specific window behavior (such as |
33 // maximize, minimize, snap sizing etc) should be added here instead | 35 // maximize, minimize, snap sizing etc) should be added here instead |
34 // of defining separate functions (like |MaximizeWindow(aura::Window* | 36 // of defining separate functions (like |MaximizeWindow(aura::Window* |
35 // window)|) or using aura Window property. | 37 // window)|) or using aura Window property. |
36 // The WindowState gets created when first accessed by | 38 // The WindowState gets created when first accessed by |
37 // |wm::GetWindowState|, and deleted when the window is deleted. | 39 // |wm::GetWindowState|, and deleted when the window is deleted. |
38 // Prefer using this class instead of passing aura::Window* around in | 40 // Prefer using this class instead of passing aura::Window* around in |
39 // ash code as this is often what you need to interact with, and | 41 // ash code as this is often what you need to interact with, and |
40 // accessing the window using |window()| is cheap. | 42 // accessing the window using |window()| is cheap. |
41 class ASH_EXPORT WindowState : public aura::WindowObserver { | 43 class ASH_EXPORT WindowState : public aura::WindowObserver { |
42 public: | 44 public: |
43 static bool IsMaximizedOrFullscreenState(ui::WindowShowState state); | 45 static bool IsMaximizedOrFullscreenState(ui::WindowShowState state); |
44 | 46 |
45 explicit WindowState(aura::Window* window); | 47 explicit WindowState(aura::Window* window); |
46 virtual ~WindowState(); | 48 virtual ~WindowState(); |
47 | 49 |
48 aura::Window* window() { return window_; } | 50 aura::Window* window() { return window_; } |
49 const aura::Window* window() const { return window_; } | 51 const aura::Window* window() const { return window_; } |
50 | 52 |
53 void SetDelegate(WindowStateDelegate* delegate); | |
54 | |
51 // Returns the window's current show state. | 55 // Returns the window's current show state. |
52 ui::WindowShowState GetShowState() const; | 56 ui::WindowShowState GetShowState() const; |
53 | 57 |
54 // Returns the window's current ash show type. | 58 // Returns the window's current ash show type. |
55 // Refer to WindowShowType definition in wm_types.h as for why Ash | 59 // Refer to WindowShowType definition in wm_types.h as for why Ash |
56 // has its own show type. | 60 // has its own show type. |
57 WindowShowType window_show_type() const { return window_show_type_; } | 61 WindowShowType window_show_type() const { return window_show_type_; } |
58 | 62 |
59 // Predicates to check window state. | 63 // Predicates to check window state. |
60 bool IsMinimized() const; | 64 bool IsMinimized() const; |
(...skipping 15 matching lines...) Expand all Loading... | |
76 // Returns true if the window has restore bounds. | 80 // Returns true if the window has restore bounds. |
77 bool HasRestoreBounds() const; | 81 bool HasRestoreBounds() const; |
78 | 82 |
79 void Maximize(); | 83 void Maximize(); |
80 void Minimize(); | 84 void Minimize(); |
81 void Unminimize(); | 85 void Unminimize(); |
82 void Activate(); | 86 void Activate(); |
83 void Deactivate(); | 87 void Deactivate(); |
84 void Restore(); | 88 void Restore(); |
85 void ToggleMaximized(); | 89 void ToggleMaximized(); |
90 void ToggleFullscreen(); | |
86 void SnapLeft(const gfx::Rect& bounds); | 91 void SnapLeft(const gfx::Rect& bounds); |
87 void SnapRight(const gfx::Rect& bounds); | 92 void SnapRight(const gfx::Rect& bounds); |
88 | 93 |
89 // Sets the window's bounds in screen coordinates. | 94 // Sets the window's bounds in screen coordinates. |
90 void SetBoundsInScreen(const gfx::Rect& bounds_in_screen); | 95 void SetBoundsInScreen(const gfx::Rect& bounds_in_screen); |
91 | 96 |
92 // Saves the current bounds to be used as a restore bounds. | 97 // Saves the current bounds to be used as a restore bounds. |
93 void SaveCurrentBoundsForRestore(); | 98 void SaveCurrentBoundsForRestore(); |
94 | 99 |
95 // Same as |GetRestoreBoundsInScreen| except that it returns the | 100 // Same as |GetRestoreBoundsInScreen| except that it returns the |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 // Gets/sets whether the shelf should be hidden when this window is | 132 // Gets/sets whether the shelf should be hidden when this window is |
128 // fullscreen. | 133 // fullscreen. |
129 bool hide_shelf_when_fullscreen() const { | 134 bool hide_shelf_when_fullscreen() const { |
130 return hide_shelf_when_fullscreen_; | 135 return hide_shelf_when_fullscreen_; |
131 } | 136 } |
132 | 137 |
133 void set_hide_shelf_when_fullscreen(bool value) { | 138 void set_hide_shelf_when_fullscreen(bool value) { |
134 hide_shelf_when_fullscreen_ = value; | 139 hide_shelf_when_fullscreen_ = value; |
135 } | 140 } |
136 | 141 |
142 // Sets/gets the flag to suppress the cross-fade animation for | |
143 // the transition to the fullscreen state. | |
144 bool animate_to_fullscreen() const { | |
145 return animate_to_fullscreen_; | |
146 } | |
147 void set_animate_to_fullscreen(bool value) { | |
148 animate_to_fullscreen_ = value; | |
149 } | |
150 | |
137 // Gets/Sets the bounds of the window before it was moved by the auto window | 151 // Gets/Sets the bounds of the window before it was moved by the auto window |
138 // management. As long as it was not auto-managed, it will return NULL. | 152 // management. As long as it was not auto-managed, it will return NULL. |
139 const gfx::Rect* pre_auto_manage_window_bounds() const { | 153 const gfx::Rect* pre_auto_manage_window_bounds() const { |
140 return pre_auto_manage_window_bounds_.get(); | 154 return pre_auto_manage_window_bounds_.get(); |
141 } | 155 } |
142 void SetPreAutoManageWindowBounds(const gfx::Rect& bounds); | 156 void SetPreAutoManageWindowBounds(const gfx::Rect& bounds); |
143 | 157 |
144 // Layout related properties | 158 // Layout related properties |
145 | 159 |
146 void AddObserver(WindowStateObserver* observer); | 160 void AddObserver(WindowStateObserver* observer); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
226 intptr_t old) OVERRIDE; | 240 intptr_t old) OVERRIDE; |
227 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; | 241 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; |
228 | 242 |
229 private: | 243 private: |
230 // Snaps the window to left or right of the desktop with given bounds. | 244 // Snaps the window to left or right of the desktop with given bounds. |
231 void SnapWindow(WindowShowType left_or_right, | 245 void SnapWindow(WindowShowType left_or_right, |
232 const gfx::Rect& bounds); | 246 const gfx::Rect& bounds); |
233 | 247 |
234 // The owner of this window settings. | 248 // The owner of this window settings. |
235 aura::Window* window_; | 249 aura::Window* window_; |
250 scoped_ptr<WindowStateDelegate> delegate_; | |
236 | 251 |
237 bool tracked_by_workspace_; | 252 bool tracked_by_workspace_; |
238 bool window_position_managed_; | 253 bool window_position_managed_; |
239 bool bounds_changed_by_user_; | 254 bool bounds_changed_by_user_; |
240 bool panel_attached_; | 255 bool panel_attached_; |
241 bool continue_drag_after_reparent_; | 256 bool continue_drag_after_reparent_; |
242 bool ignored_by_shelf_; | 257 bool ignored_by_shelf_; |
243 bool can_consume_system_keys_; | 258 bool can_consume_system_keys_; |
244 bool top_row_keys_are_function_keys_; | 259 bool top_row_keys_are_function_keys_; |
245 WindowResizer* window_resizer_; | 260 WindowResizer* window_resizer_; |
246 | 261 |
247 bool always_restores_to_restore_bounds_; | 262 bool always_restores_to_restore_bounds_; |
248 bool hide_shelf_when_fullscreen_; | 263 bool hide_shelf_when_fullscreen_; |
264 bool animate_to_fullscreen_; | |
249 | 265 |
250 // A property to remember the window position which was set before the | 266 // A property to remember the window position which was set before the |
251 // auto window position manager changed the window bounds, so that it can get | 267 // auto window position manager changed the window bounds, so that it can get |
252 // restored when only this one window gets shown. | 268 // restored when only this one window gets shown. |
253 scoped_ptr<gfx::Rect> pre_auto_manage_window_bounds_; | 269 scoped_ptr<gfx::Rect> pre_auto_manage_window_bounds_; |
254 | 270 |
255 ObserverList<WindowStateObserver> observer_list_; | 271 ObserverList<WindowStateObserver> observer_list_; |
256 | 272 |
257 WindowShowType window_show_type_; | 273 WindowShowType window_show_type_; |
258 | 274 |
259 DISALLOW_COPY_AND_ASSIGN(WindowState); | 275 DISALLOW_COPY_AND_ASSIGN(WindowState); |
260 }; | 276 }; |
261 | 277 |
262 // Returns the WindowState for active window. Returns |NULL| | 278 // Returns the WindowState for active window. Returns |NULL| |
263 // if there is no active window. | 279 // if there is no active window. |
264 ASH_EXPORT WindowState* GetActiveWindowState(); | 280 ASH_EXPORT WindowState* GetActiveWindowState(); |
265 | 281 |
266 // Returns the WindowState for |window|. Creates WindowState | 282 // Returns the WindowState for |window|. Creates WindowState |
267 // if it didn't exist. The settings object is owned by |window|. | 283 // if it didn't exist. The settings object is owned by |window|. |
268 ASH_EXPORT WindowState* GetWindowState(aura::Window* window); | 284 ASH_EXPORT WindowState* GetWindowState(aura::Window* window); |
269 | 285 |
270 // const version of GetWindowState. | 286 // const version of GetWindowState. |
271 ASH_EXPORT const WindowState* | 287 ASH_EXPORT const WindowState* |
272 GetWindowState(const aura::Window* window); | 288 GetWindowState(const aura::Window* window); |
273 | 289 |
274 } // namespace wm | 290 } // namespace wm |
275 } // namespace ash | 291 } // namespace ash |
276 | 292 |
277 #endif // ASH_WM_WINDOW_STATE_H_ | 293 #endif // ASH_WM_WINDOW_STATE_H_ |
OLD | NEW |