| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_TREE_NODE_H_ | |
| 6 #define MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_TREE_NODE_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/observer_list.h" | |
| 12 #include "mojo/public/cpp/bindings/array.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" | |
| 15 #include "ui/gfx/geometry/rect.h" | |
| 16 | |
| 17 namespace mojo { | |
| 18 namespace view_manager { | |
| 19 | |
| 20 class View; | |
| 21 class ViewManager; | |
| 22 class ViewTreeNodeObserver; | |
| 23 | |
| 24 // ViewTreeNodes are owned by the ViewManager. | |
| 25 // TODO(beng): Right now, you'll have to implement a ViewTreeNodeObserver to | |
| 26 // track destruction and NULL any pointers you have. | |
| 27 // Investigate some kind of smart pointer or weak pointer for these. | |
| 28 class ViewTreeNode { | |
| 29 public: | |
| 30 typedef std::vector<ViewTreeNode*> Children; | |
| 31 | |
| 32 static ViewTreeNode* Create(ViewManager* view_manager); | |
| 33 | |
| 34 // Destroys this node and all its children. | |
| 35 void Destroy(); | |
| 36 | |
| 37 // Configuration. | |
| 38 Id id() const { return id_; } | |
| 39 | |
| 40 // Geometric disposition. | |
| 41 const gfx::Rect& bounds() { return bounds_; } | |
| 42 void SetBounds(const gfx::Rect& bounds); | |
| 43 | |
| 44 // Observation. | |
| 45 void AddObserver(ViewTreeNodeObserver* observer); | |
| 46 void RemoveObserver(ViewTreeNodeObserver* observer); | |
| 47 | |
| 48 // Tree. | |
| 49 ViewTreeNode* parent() { return parent_; } | |
| 50 const ViewTreeNode* parent() const { return parent_; } | |
| 51 const Children& children() const { return children_; } | |
| 52 | |
| 53 void AddChild(ViewTreeNode* child); | |
| 54 void RemoveChild(ViewTreeNode* child); | |
| 55 | |
| 56 void Reorder(ViewTreeNode* relative, OrderDirection direction); | |
| 57 void MoveToFront(); | |
| 58 void MoveToBack(); | |
| 59 | |
| 60 bool Contains(ViewTreeNode* child) const; | |
| 61 | |
| 62 ViewTreeNode* GetChildById(Id id); | |
| 63 | |
| 64 // View. | |
| 65 void SetActiveView(View* view); | |
| 66 View* active_view() { return active_view_; } | |
| 67 | |
| 68 // Focus. | |
| 69 void SetFocus(); | |
| 70 | |
| 71 // Embedding. | |
| 72 void Embed(const String& url); | |
| 73 | |
| 74 protected: | |
| 75 // This class is subclassed only by test classes that provide a public ctor. | |
| 76 ViewTreeNode(); | |
| 77 ~ViewTreeNode(); | |
| 78 | |
| 79 private: | |
| 80 friend class ViewTreeNodePrivate; | |
| 81 | |
| 82 explicit ViewTreeNode(ViewManager* manager); | |
| 83 | |
| 84 void LocalDestroy(); | |
| 85 void LocalAddChild(ViewTreeNode* child); | |
| 86 void LocalRemoveChild(ViewTreeNode* child); | |
| 87 // Returns true if the order actually changed. | |
| 88 bool LocalReorder(ViewTreeNode* relative, OrderDirection direction); | |
| 89 void LocalSetActiveView(View* view); | |
| 90 void LocalSetBounds(const gfx::Rect& old_bounds, const gfx::Rect& new_bounds); | |
| 91 | |
| 92 ViewManager* manager_; | |
| 93 Id id_; | |
| 94 ViewTreeNode* parent_; | |
| 95 Children children_; | |
| 96 | |
| 97 ObserverList<ViewTreeNodeObserver> observers_; | |
| 98 | |
| 99 gfx::Rect bounds_; | |
| 100 View* active_view_; | |
| 101 | |
| 102 DISALLOW_COPY_AND_ASSIGN(ViewTreeNode); | |
| 103 }; | |
| 104 | |
| 105 } // namespace view_manager | |
| 106 } // namespace mojo | |
| 107 | |
| 108 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_TREE_NODE_H_ | |
| OLD | NEW |