OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
16 #include "base/string16.h" | 16 #include "base/string16.h" |
17 #include "ui/aura/aura_export.h" | 17 #include "ui/aura/aura_export.h" |
18 #include "ui/aura/client/window_types.h" | 18 #include "ui/aura/client/window_types.h" |
19 #include "ui/base/events.h" | 19 #include "ui/base/events.h" |
20 #include "ui/base/gestures/gesture_types.h" | 20 #include "ui/base/gestures/gesture_types.h" |
21 #include "ui/compositor/layer_animator.h" | 21 #include "ui/compositor/layer_animator.h" |
22 #include "ui/compositor/layer_delegate.h" | 22 #include "ui/compositor/layer_delegate.h" |
| 23 #include "ui/compositor/layer_owner.h" |
23 #include "ui/compositor/layer_type.h" | 24 #include "ui/compositor/layer_type.h" |
24 #include "ui/gfx/insets.h" | 25 #include "ui/gfx/insets.h" |
25 #include "ui/gfx/native_widget_types.h" | 26 #include "ui/gfx/native_widget_types.h" |
26 #include "ui/gfx/rect.h" | 27 #include "ui/gfx/rect.h" |
27 | 28 |
28 class SkCanvas; | 29 class SkCanvas; |
29 | 30 |
30 namespace ui { | 31 namespace ui { |
31 class Layer; | 32 class Layer; |
32 class Texture; | 33 class Texture; |
(...skipping 13 matching lines...) Expand all Loading... |
46 } | 47 } |
47 | 48 |
48 // Defined in window_property.h (which we do not include) | 49 // Defined in window_property.h (which we do not include) |
49 template<typename T> | 50 template<typename T> |
50 struct WindowProperty; | 51 struct WindowProperty; |
51 | 52 |
52 // Aura window implementation. Interesting events are sent to the | 53 // Aura window implementation. Interesting events are sent to the |
53 // WindowDelegate. | 54 // WindowDelegate. |
54 // TODO(beng): resolve ownership. | 55 // TODO(beng): resolve ownership. |
55 class AURA_EXPORT Window : public ui::LayerDelegate, | 56 class AURA_EXPORT Window : public ui::LayerDelegate, |
| 57 public ui::LayerOwner, |
56 public ui::GestureConsumer { | 58 public ui::GestureConsumer { |
57 public: | 59 public: |
58 typedef std::vector<Window*> Windows; | 60 typedef std::vector<Window*> Windows; |
59 | 61 |
60 class AURA_EXPORT TestApi { | 62 class AURA_EXPORT TestApi { |
61 public: | 63 public: |
62 explicit TestApi(Window* window); | 64 explicit TestApi(Window* window); |
63 | 65 |
64 bool OwnsLayer() const; | 66 bool OwnsLayer() const; |
65 | 67 |
(...skipping 26 matching lines...) Expand all Loading... |
92 | 94 |
93 const std::string& name() const { return name_; } | 95 const std::string& name() const { return name_; } |
94 void SetName(const std::string& name); | 96 void SetName(const std::string& name); |
95 | 97 |
96 const string16 title() const { return title_; } | 98 const string16 title() const { return title_; } |
97 void set_title(const string16& title) { title_ = title; } | 99 void set_title(const string16& title) { title_ = title; } |
98 | 100 |
99 bool transparent() const { return transparent_; } | 101 bool transparent() const { return transparent_; } |
100 void SetTransparent(bool transparent); | 102 void SetTransparent(bool transparent); |
101 | 103 |
102 ui::Layer* layer() { return layer_; } | |
103 const ui::Layer* layer() const { return layer_; } | |
104 | |
105 // Releases the Window's owning reference to its layer, and returns it. | |
106 // This is used when you need to animate the presentation of the Window just | |
107 // prior to destroying it. The window can be destroyed soon after calling this | |
108 // function, and the caller is then responsible for disposing of the layer | |
109 // once any animation completes. Note that layer() will remain valid until the | |
110 // end of ~Window(). | |
111 ui::Layer* AcquireLayer(); | |
112 | |
113 WindowDelegate* delegate() { return delegate_; } | 104 WindowDelegate* delegate() { return delegate_; } |
114 | 105 |
115 const gfx::Rect& bounds() const; | 106 const gfx::Rect& bounds() const; |
116 | 107 |
117 Window* parent() { return parent_; } | 108 Window* parent() { return parent_; } |
118 const Window* parent() const { return parent_; } | 109 const Window* parent() const { return parent_; } |
119 | 110 |
120 // Returns the RootWindow that contains this Window or NULL if the Window is | 111 // Returns the RootWindow that contains this Window or NULL if the Window is |
121 // not contained by a RootWindow. | 112 // not contained by a RootWindow. |
122 virtual RootWindow* GetRootWindow(); | 113 virtual RootWindow* GetRootWindow(); |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 #endif | 398 #endif |
408 | 399 |
409 client::WindowType type_; | 400 client::WindowType type_; |
410 | 401 |
411 // True if the Window is owned by its parent - i.e. it will be deleted by its | 402 // True if the Window is owned by its parent - i.e. it will be deleted by its |
412 // parent during its parents destruction. True is the default. | 403 // parent during its parents destruction. True is the default. |
413 bool owned_by_parent_; | 404 bool owned_by_parent_; |
414 | 405 |
415 WindowDelegate* delegate_; | 406 WindowDelegate* delegate_; |
416 | 407 |
417 // The Window will own its layer unless ownership is relinquished via a call | |
418 // to AcquireLayer(). After that moment |layer_| will still be valid but | |
419 // |layer_owner_| will be NULL. The reason for releasing ownership is that | |
420 // the client may wish to animate the window's layer beyond the lifetime of | |
421 // the window, e.g. fading it out when it is destroyed. | |
422 scoped_ptr<ui::Layer> layer_owner_; | |
423 ui::Layer* layer_; | |
424 | |
425 // The Window's parent. | 408 // The Window's parent. |
426 Window* parent_; | 409 Window* parent_; |
427 | 410 |
428 // Child windows. Topmost is last. | 411 // Child windows. Topmost is last. |
429 Windows children_; | 412 Windows children_; |
430 | 413 |
431 // Transient windows. | 414 // Transient windows. |
432 Windows transient_children_; | 415 Windows transient_children_; |
433 | 416 |
434 Window* transient_parent_; | 417 Window* transient_parent_; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 }; | 453 }; |
471 | 454 |
472 std::map<const void*, Value> prop_map_; | 455 std::map<const void*, Value> prop_map_; |
473 | 456 |
474 DISALLOW_COPY_AND_ASSIGN(Window); | 457 DISALLOW_COPY_AND_ASSIGN(Window); |
475 }; | 458 }; |
476 | 459 |
477 } // namespace aura | 460 } // namespace aura |
478 | 461 |
479 #endif // UI_AURA_WINDOW_H_ | 462 #endif // UI_AURA_WINDOW_H_ |
OLD | NEW |