OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_TREE_NODE_H_ | 5 #ifndef MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_TREE_NODE_H_ |
6 #define MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_TREE_NODE_H_ | 6 #define MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_TREE_NODE_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
12 #include "mojo/public/cpp/bindings/array.h" | 12 #include "mojo/public/cpp/bindings/array.h" |
13 #include "mojo/services/public/cpp/view_manager/view_manager_types.h" | 13 #include "mojo/services/public/cpp/view_manager/view_manager_types.h" |
| 14 #include "mojo/services/public/interfaces/view_manager/view_manager_constants.mo
jom.h" |
14 #include "ui/gfx/geometry/rect.h" | 15 #include "ui/gfx/geometry/rect.h" |
15 | 16 |
16 namespace mojo { | 17 namespace mojo { |
17 namespace view_manager { | 18 namespace view_manager { |
18 | 19 |
19 class View; | 20 class View; |
20 class ViewManager; | 21 class ViewManager; |
21 class ViewTreeNodeObserver; | 22 class ViewTreeNodeObserver; |
22 | 23 |
23 // ViewTreeNodes are owned by the ViewManager. | 24 // ViewTreeNodes are owned by the ViewManager. |
(...skipping 21 matching lines...) Expand all Loading... |
45 void RemoveObserver(ViewTreeNodeObserver* observer); | 46 void RemoveObserver(ViewTreeNodeObserver* observer); |
46 | 47 |
47 // Tree. | 48 // Tree. |
48 ViewTreeNode* parent() { return parent_; } | 49 ViewTreeNode* parent() { return parent_; } |
49 const ViewTreeNode* parent() const { return parent_; } | 50 const ViewTreeNode* parent() const { return parent_; } |
50 const Children& children() const { return children_; } | 51 const Children& children() const { return children_; } |
51 | 52 |
52 void AddChild(ViewTreeNode* child); | 53 void AddChild(ViewTreeNode* child); |
53 void RemoveChild(ViewTreeNode* child); | 54 void RemoveChild(ViewTreeNode* child); |
54 | 55 |
| 56 void Reorder(ViewTreeNode* relative, OrderDirection direction); |
| 57 void MoveToFront(); |
| 58 void MoveToBack(); |
| 59 |
55 bool Contains(ViewTreeNode* child) const; | 60 bool Contains(ViewTreeNode* child) const; |
56 | 61 |
57 ViewTreeNode* GetChildById(Id id); | 62 ViewTreeNode* GetChildById(Id id); |
58 | 63 |
59 // View. | 64 // View. |
60 void SetActiveView(View* view); | 65 void SetActiveView(View* view); |
61 View* active_view() { return active_view_; } | 66 View* active_view() { return active_view_; } |
62 | 67 |
63 // Embedding. | 68 // Embedding. |
64 void Embed(const String& url); | 69 void Embed(const String& url); |
65 | 70 |
66 protected: | 71 protected: |
67 // This class is subclassed only by test classes that provide a public ctor. | 72 // This class is subclassed only by test classes that provide a public ctor. |
68 ViewTreeNode(); | 73 ViewTreeNode(); |
69 ~ViewTreeNode(); | 74 ~ViewTreeNode(); |
70 | 75 |
71 private: | 76 private: |
72 friend class ViewTreeNodePrivate; | 77 friend class ViewTreeNodePrivate; |
73 | 78 |
74 explicit ViewTreeNode(ViewManager* manager); | 79 explicit ViewTreeNode(ViewManager* manager); |
75 | 80 |
76 void LocalDestroy(); | 81 void LocalDestroy(); |
77 void LocalAddChild(ViewTreeNode* child); | 82 void LocalAddChild(ViewTreeNode* child); |
78 void LocalRemoveChild(ViewTreeNode* child); | 83 void LocalRemoveChild(ViewTreeNode* child); |
| 84 // Returns true if the order actually changed. |
| 85 bool LocalReorder(ViewTreeNode* relative, OrderDirection direction); |
79 void LocalSetActiveView(View* view); | 86 void LocalSetActiveView(View* view); |
80 void LocalSetBounds(const gfx::Rect& old_bounds, const gfx::Rect& new_bounds); | 87 void LocalSetBounds(const gfx::Rect& old_bounds, const gfx::Rect& new_bounds); |
81 | 88 |
82 ViewManager* manager_; | 89 ViewManager* manager_; |
83 Id id_; | 90 Id id_; |
84 ViewTreeNode* parent_; | 91 ViewTreeNode* parent_; |
85 Children children_; | 92 Children children_; |
86 | 93 |
87 ObserverList<ViewTreeNodeObserver> observers_; | 94 ObserverList<ViewTreeNodeObserver> observers_; |
88 | 95 |
89 gfx::Rect bounds_; | 96 gfx::Rect bounds_; |
90 View* active_view_; | 97 View* active_view_; |
91 | 98 |
92 DISALLOW_COPY_AND_ASSIGN(ViewTreeNode); | 99 DISALLOW_COPY_AND_ASSIGN(ViewTreeNode); |
93 }; | 100 }; |
94 | 101 |
95 } // namespace view_manager | 102 } // namespace view_manager |
96 } // namespace mojo | 103 } // namespace mojo |
97 | 104 |
98 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_TREE_NODE_H_ | 105 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_TREE_NODE_H_ |
OLD | NEW |