| 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_VIEW_MANAGER_NODE_H_ | |
| 6 #define MOJO_SERVICES_VIEW_MANAGER_NODE_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/logging.h" | |
| 11 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" | |
| 12 #include "mojo/services/view_manager/ids.h" | |
| 13 #include "mojo/services/view_manager/view_manager_export.h" | |
| 14 #include "third_party/skia/include/core/SkBitmap.h" | |
| 15 #include "ui/gfx/geometry/rect.h" | |
| 16 | |
| 17 namespace mojo { | |
| 18 namespace service { | |
| 19 | |
| 20 class NodeDelegate; | |
| 21 | |
| 22 // Represents a node in the graph. Delegate is informed of interesting events. | |
| 23 // | |
| 24 // It is assumed that all functions that mutate the node tree have validated the | |
| 25 // value. For example, Reorder() assumes the supplied node is a child and not | |
| 26 // already in position. | |
| 27 class MOJO_VIEW_MANAGER_EXPORT Node { | |
| 28 public: | |
| 29 Node(NodeDelegate* delegate, const NodeId& id); | |
| 30 virtual ~Node(); | |
| 31 | |
| 32 const NodeId& id() const { return id_; } | |
| 33 | |
| 34 void Add(Node* child); | |
| 35 void Remove(Node* child); | |
| 36 void Reorder(Node* child, Node* relative, OrderDirection direction); | |
| 37 | |
| 38 const gfx::Rect& bounds() const { return bounds_; } | |
| 39 void SetBounds(const gfx::Rect& bounds); | |
| 40 | |
| 41 const Node* parent() const { return parent_; } | |
| 42 Node* parent() { return parent_; } | |
| 43 | |
| 44 const Node* GetRoot() const; | |
| 45 Node* GetRoot() { | |
| 46 return const_cast<Node*>(const_cast<const Node*>(this)->GetRoot()); | |
| 47 } | |
| 48 | |
| 49 std::vector<const Node*> GetChildren() const; | |
| 50 std::vector<Node*> GetChildren(); | |
| 51 | |
| 52 bool Contains(const Node* node) const; | |
| 53 | |
| 54 // Returns true if the window is visible. This does not consider visibility | |
| 55 // of any ancestors. | |
| 56 bool visible() const { return visible_; } | |
| 57 void SetVisible(bool value); | |
| 58 | |
| 59 void SetBitmap(const SkBitmap& contents); | |
| 60 const SkBitmap& bitmap() const { return bitmap_; } | |
| 61 | |
| 62 private: | |
| 63 typedef std::vector<Node*> Nodes; | |
| 64 | |
| 65 // Implementation of removing a node. Doesn't send any notification. | |
| 66 void RemoveImpl(Node* node); | |
| 67 | |
| 68 NodeDelegate* delegate_; | |
| 69 const NodeId id_; | |
| 70 Node* parent_; | |
| 71 Nodes children_; | |
| 72 bool visible_; | |
| 73 gfx::Rect bounds_; | |
| 74 SkBitmap bitmap_; | |
| 75 | |
| 76 DISALLOW_COPY_AND_ASSIGN(Node); | |
| 77 }; | |
| 78 | |
| 79 } // namespace service | |
| 80 } // namespace mojo | |
| 81 | |
| 82 #endif // MOJO_SERVICES_VIEW_MANAGER_NODE_H_ | |
| OLD | NEW |