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/services/public/cpp/view_manager/view_manager_types.h" | 12 #include "mojo/services/public/cpp/view_manager/view_manager_types.h" |
13 | 13 |
14 namespace mojo { | 14 namespace mojo { |
15 namespace services { | 15 namespace services { |
16 namespace view_manager { | 16 namespace view_manager { |
17 | 17 |
| 18 class View; |
18 class ViewManager; | 19 class ViewManager; |
19 class ViewTreeNodeObserver; | 20 class ViewTreeNodeObserver; |
20 | 21 |
21 // ViewTreeNodes are owned by the ViewManager. | 22 // ViewTreeNodes are owned by the ViewManager. |
22 // TODO(beng): Right now, you'll have to implement a ViewTreeNodeObserver to | 23 // TODO(beng): Right now, you'll have to implement a ViewTreeNodeObserver to |
23 // track destruction and NULL any pointers you have. | 24 // track destruction and NULL any pointers you have. |
24 // Investigate some kind of smart pointer or weak pointer for these. | 25 // Investigate some kind of smart pointer or weak pointer for these. |
25 class ViewTreeNode { | 26 class ViewTreeNode { |
26 public: | 27 public: |
27 typedef std::vector<ViewTreeNode*> Children; | 28 typedef std::vector<ViewTreeNode*> Children; |
(...skipping 15 matching lines...) Expand all Loading... |
43 const ViewTreeNode* parent() const { return parent_; } | 44 const ViewTreeNode* parent() const { return parent_; } |
44 const Children& children() const { return children_; } | 45 const Children& children() const { return children_; } |
45 | 46 |
46 void AddChild(ViewTreeNode* child); | 47 void AddChild(ViewTreeNode* child); |
47 void RemoveChild(ViewTreeNode* child); | 48 void RemoveChild(ViewTreeNode* child); |
48 | 49 |
49 bool Contains(ViewTreeNode* child) const; | 50 bool Contains(ViewTreeNode* child) const; |
50 | 51 |
51 ViewTreeNode* GetChildById(TransportNodeId id); | 52 ViewTreeNode* GetChildById(TransportNodeId id); |
52 | 53 |
| 54 // View. |
| 55 void SetActiveView(View* view); |
| 56 View* active_view() { return active_view_; } |
| 57 |
53 protected: | 58 protected: |
54 // This class is subclassed only by test classes that provide a public ctor. | 59 // This class is subclassed only by test classes that provide a public ctor. |
55 ViewTreeNode(); | 60 ViewTreeNode(); |
56 ~ViewTreeNode(); | 61 ~ViewTreeNode(); |
57 | 62 |
58 private: | 63 private: |
59 friend class ViewTreeNodePrivate; | 64 friend class ViewTreeNodePrivate; |
60 | 65 |
61 explicit ViewTreeNode(ViewManager* manager); | 66 explicit ViewTreeNode(ViewManager* manager); |
62 | 67 |
63 void LocalDestroy(); | 68 void LocalDestroy(); |
64 void LocalAddChild(ViewTreeNode* child); | 69 void LocalAddChild(ViewTreeNode* child); |
65 void LocalRemoveChild(ViewTreeNode* child); | 70 void LocalRemoveChild(ViewTreeNode* child); |
| 71 void LocalSetActiveView(View* view); |
66 | 72 |
67 ViewManager* manager_; | 73 ViewManager* manager_; |
68 TransportNodeId id_; | 74 TransportNodeId id_; |
69 ViewTreeNode* parent_; | 75 ViewTreeNode* parent_; |
70 Children children_; | 76 Children children_; |
71 | 77 |
72 ObserverList<ViewTreeNodeObserver> observers_; | 78 ObserverList<ViewTreeNodeObserver> observers_; |
73 | 79 |
| 80 View* active_view_; |
| 81 |
74 DISALLOW_COPY_AND_ASSIGN(ViewTreeNode); | 82 DISALLOW_COPY_AND_ASSIGN(ViewTreeNode); |
75 }; | 83 }; |
76 | 84 |
77 } // namespace view_manager | 85 } // namespace view_manager |
78 } // namespace services | 86 } // namespace services |
79 } // namespace mojo | 87 } // namespace mojo |
80 | 88 |
81 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_TREE_NODE_H_ | 89 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_TREE_NODE_H_ |
OLD | NEW |