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