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