OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 UI_AURA_WINDOW_H_ | 5 #ifndef UI_AURA_WINDOW_H_ |
6 #define UI_AURA_WINDOW_H_ | 6 #define UI_AURA_WINDOW_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
15 #include "base/string16.h" | 15 #include "base/string16.h" |
16 #include "ui/base/events.h" | 16 #include "ui/base/events.h" |
17 #include "ui/base/ui_base_types.h" | |
18 #include "ui/aura/aura_export.h" | 17 #include "ui/aura/aura_export.h" |
19 #include "ui/aura/window_types.h" | 18 #include "ui/aura/window_types.h" |
20 #include "ui/gfx/compositor/layer.h" | 19 #include "ui/gfx/compositor/layer.h" |
21 #include "ui/gfx/compositor/layer_animator.h" | 20 #include "ui/gfx/compositor/layer_animator.h" |
22 #include "ui/gfx/compositor/layer_delegate.h" | 21 #include "ui/gfx/compositor/layer_delegate.h" |
23 #include "ui/gfx/native_widget_types.h" | 22 #include "ui/gfx/native_widget_types.h" |
24 #include "ui/gfx/rect.h" | 23 #include "ui/gfx/rect.h" |
25 | 24 |
26 class SkCanvas; | 25 class SkCanvas; |
27 | 26 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 // The Window does not own this object. | 87 // The Window does not own this object. |
89 void set_user_data(void* user_data) { user_data_ = user_data; } | 88 void set_user_data(void* user_data) { user_data_ = user_data; } |
90 void* user_data() const { return user_data_; } | 89 void* user_data() const { return user_data_; } |
91 | 90 |
92 // Changes the visibility of the window. | 91 // Changes the visibility of the window. |
93 void Show(); | 92 void Show(); |
94 void Hide(); | 93 void Hide(); |
95 // Returns true if this window and all its ancestors are visible. | 94 // Returns true if this window and all its ancestors are visible. |
96 bool IsVisible() const; | 95 bool IsVisible() const; |
97 | 96 |
98 // Maximize the window. | |
99 void Maximize(); | |
100 | |
101 // Go into fullscreen mode. | |
102 void Fullscreen(); | |
103 | |
104 // Restore the window to its original bounds. | |
105 void Restore(); | |
106 | |
107 // Returns the window's bounds in screen coordinates. | 97 // Returns the window's bounds in screen coordinates. |
108 gfx::Rect GetScreenBounds() const; | 98 gfx::Rect GetScreenBounds() const; |
109 | 99 |
110 // Returns the window's show state. | |
111 ui::WindowShowState show_state() const { return show_state_; } | |
112 | |
113 // Activates this window. Only top level windows can be activated. Requests | 100 // Activates this window. Only top level windows can be activated. Requests |
114 // to activate a non-top level window are ignored. | 101 // to activate a non-top level window are ignored. |
115 void Activate(); | 102 void Activate(); |
116 | 103 |
117 // Deactivates this window. Only top level windows can be | 104 // Deactivates this window. Only top level windows can be |
118 // deactivated. Requests to deactivate a non-top level window are ignored. | 105 // deactivated. Requests to deactivate a non-top level window are ignored. |
119 void Deactivate(); | 106 void Deactivate(); |
120 | 107 |
121 // Returns true if this window is active. | 108 // Returns true if this window is active. |
122 bool IsActive() const; | 109 bool IsActive() const; |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 // Releases a mouse capture. | 244 // Releases a mouse capture. |
258 void ReleaseCapture(); | 245 void ReleaseCapture(); |
259 | 246 |
260 // Returns true if this window has a mouse capture. | 247 // Returns true if this window has a mouse capture. |
261 bool HasCapture(); | 248 bool HasCapture(); |
262 | 249 |
263 // Returns the first ancestor whose parent window returns true from | 250 // Returns the first ancestor whose parent window returns true from |
264 // IsToplevelWindowContainer. | 251 // IsToplevelWindowContainer. |
265 Window* GetToplevelWindow(); | 252 Window* GetToplevelWindow(); |
266 | 253 |
267 // Returns true if this window is fullscreen or contains a fullscreen window. | 254 // Sets the window property |value| for given |name|. Setting NULL or 0 |
268 bool IsOrContainsFullscreenWindow() const; | |
269 | |
270 // Sets the window property |value| for given |name|. Setting NULL | |
271 // removes the property. It uses |ui::ViewProp| to store the property. | 255 // removes the property. It uses |ui::ViewProp| to store the property. |
272 // Please see the description of |prop_map_| for more details. | 256 // Please see the description of |prop_map_| for more details. |
273 void SetProperty(const char* name, void* value); | 257 void SetProperty(const char* name, void* value); |
| 258 void SetIntProperty(const char* name, int value); |
274 | 259 |
275 // Returns the window property for given |name|. Returns NULL if | 260 // Returns the window property for given |name|. Returns NULL or 0 if |
276 // the property does not exist. | 261 // the property does not exist. |
| 262 // TODO(oshima): Returning 0 for non existing property is problematic. |
| 263 // Fix ViewProp to be able to tell if the property exists and |
| 264 // change it to -1. |
277 void* GetProperty(const char* name) const; | 265 void* GetProperty(const char* name) const; |
| 266 int GetIntProperty(const char* name) const; |
278 | 267 |
279 protected: | 268 protected: |
280 // Returns the desktop or NULL if we aren't yet attached to a desktop. | 269 // Returns the desktop or NULL if we aren't yet attached to a desktop. |
281 virtual Desktop* GetDesktop(); | 270 virtual Desktop* GetDesktop(); |
282 | 271 |
283 private: | 272 private: |
284 friend class LayoutManager; | 273 friend class LayoutManager; |
285 | 274 |
286 // Changes the bounds of the window without condition. | 275 // Changes the bounds of the window without condition. |
287 void SetBoundsInternal(const gfx::Rect& new_bounds); | 276 void SetBoundsInternal(const gfx::Rect& new_bounds); |
288 | 277 |
289 // Updates the visible state of the layer, but does not make visible-state | 278 // Updates the visible state of the layer, but does not make visible-state |
290 // specific changes. Called from Show()/Hide(). | 279 // specific changes. Called from Show()/Hide(). |
291 void SetVisible(bool visible); | 280 void SetVisible(bool visible); |
292 | 281 |
293 // Schedules a paint for the Window's entire bounds. | 282 // Schedules a paint for the Window's entire bounds. |
294 void SchedulePaint(); | 283 void SchedulePaint(); |
295 | 284 |
296 // This window is currently stopping event propagation for any windows behind | 285 // This window is currently stopping event propagation for any windows behind |
297 // it in the z-order. | 286 // it in the z-order. |
298 bool StopsEventPropagation() const; | 287 bool StopsEventPropagation() const; |
299 | 288 |
300 // Update the show state and restore bounds. Returns false | |
301 // if |new_show_state| is same as current show state. | |
302 bool UpdateShowStateAndRestoreBounds(ui::WindowShowState new_show_state); | |
303 | |
304 // Gets a Window (either this one or a subwindow) containing |local_point|. | 289 // Gets a Window (either this one or a subwindow) containing |local_point|. |
305 // If |return_tightest| is true, returns the tightest-containing (i.e. | 290 // If |return_tightest| is true, returns the tightest-containing (i.e. |
306 // furthest down the hierarchy) Window containing the point; otherwise, | 291 // furthest down the hierarchy) Window containing the point; otherwise, |
307 // returns the loosest. If |for_event_handling| is true, then hit-test masks | 292 // returns the loosest. If |for_event_handling| is true, then hit-test masks |
308 // and StopsEventPropagation() are honored; otherwise, only bounds checks are | 293 // and StopsEventPropagation() are honored; otherwise, only bounds checks are |
309 // performed. | 294 // performed. |
310 Window* GetWindowForPoint(const gfx::Point& local_point, | 295 Window* GetWindowForPoint(const gfx::Point& local_point, |
311 bool return_tightest, | 296 bool return_tightest, |
312 bool for_event_handling); | 297 bool for_event_handling); |
313 | 298 |
314 // Overridden from ui::LayerDelegate: | 299 // Overridden from ui::LayerDelegate: |
315 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE; | 300 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE; |
316 virtual void OnLayerAnimationEnded( | 301 virtual void OnLayerAnimationEnded( |
317 const ui::LayerAnimationSequence* animation) OVERRIDE; | 302 const ui::LayerAnimationSequence* animation) OVERRIDE; |
318 | 303 |
319 WindowType type_; | 304 WindowType type_; |
320 | 305 |
321 WindowDelegate* delegate_; | 306 WindowDelegate* delegate_; |
322 | 307 |
323 ui::WindowShowState show_state_; | |
324 | |
325 // The original bounds of a maximized/fullscreen window. | 308 // The original bounds of a maximized/fullscreen window. |
326 gfx::Rect restore_bounds_; | 309 gfx::Rect restore_bounds_; |
327 | 310 |
328 // The minimum size of the window a user can resize to. | 311 // The minimum size of the window a user can resize to. |
329 gfx::Size minimum_size_; | 312 gfx::Size minimum_size_; |
330 | 313 |
331 scoped_ptr<ui::Layer> layer_; | 314 scoped_ptr<ui::Layer> layer_; |
332 | 315 |
333 // The Window's parent. | 316 // The Window's parent. |
334 Window* parent_; | 317 Window* parent_; |
(...skipping 26 matching lines...) Expand all Loading... |
361 // TODO(oshima): Consolidcate ViewProp and aura::window property | 344 // TODO(oshima): Consolidcate ViewProp and aura::window property |
362 // implementation. | 345 // implementation. |
363 std::map<const char*, ui::ViewProp*> prop_map_; | 346 std::map<const char*, ui::ViewProp*> prop_map_; |
364 | 347 |
365 DISALLOW_COPY_AND_ASSIGN(Window); | 348 DISALLOW_COPY_AND_ASSIGN(Window); |
366 }; | 349 }; |
367 | 350 |
368 } // namespace aura | 351 } // namespace aura |
369 | 352 |
370 #endif // UI_AURA_WINDOW_H_ | 353 #endif // UI_AURA_WINDOW_H_ |
OLD | NEW |