| 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_VIEW_MANAGER_NODE_H_ | 5 #ifndef MOJO_SERVICES_VIEW_MANAGER_NODE_H_ |
| 6 #define MOJO_SERVICES_VIEW_MANAGER_NODE_H_ | 6 #define MOJO_SERVICES_VIEW_MANAGER_NODE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "mojo/services/view_manager/ids.h" | 11 #include "mojo/services/view_manager/ids.h" |
| 12 #include "mojo/services/view_manager/view_manager_export.h" | 12 #include "mojo/services/view_manager/view_manager_export.h" |
| 13 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
| 14 #include "ui/aura/window_delegate.h" | |
| 15 #include "ui/aura/window_observer.h" | 14 #include "ui/aura/window_observer.h" |
| 16 | 15 |
| 17 namespace mojo { | 16 namespace mojo { |
| 18 namespace services { | 17 namespace services { |
| 19 namespace view_manager { | 18 namespace view_manager { |
| 20 | 19 |
| 21 class NodeDelegate; | 20 class NodeDelegate; |
| 22 class View; | 21 class View; |
| 23 | 22 |
| 24 // Represents a node in the graph. Delegate is informed of interesting events. | 23 // Represents a node in the graph. Delegate is informed of interesting events. |
| 25 class MOJO_VIEW_MANAGER_EXPORT Node | 24 class MOJO_VIEW_MANAGER_EXPORT Node : public aura::WindowObserver { |
| 26 : public aura::WindowObserver, | |
| 27 public aura::WindowDelegate { | |
| 28 public: | 25 public: |
| 29 Node(NodeDelegate* delegate, const NodeId& id); | 26 Node(NodeDelegate* delegate, const NodeId& id); |
| 30 virtual ~Node(); | 27 virtual ~Node(); |
| 31 | 28 |
| 32 void set_view_id(const ViewId& view_id) { view_id_ = view_id; } | 29 void set_view_id(const ViewId& view_id) { view_id_ = view_id; } |
| 33 const ViewId& view_id() const { return view_id_; } | 30 const ViewId& view_id() const { return view_id_; } |
| 34 | 31 |
| 35 const NodeId& id() const { return id_; } | 32 const NodeId& id() const { return id_; } |
| 36 | 33 |
| 37 void Add(Node* child); | 34 void Add(Node* child); |
| 38 void Remove(Node* child); | 35 void Remove(Node* child); |
| 39 | 36 |
| 40 aura::Window* window() { return &window_; } | |
| 41 | |
| 42 Node* GetParent(); | 37 Node* GetParent(); |
| 43 | 38 |
| 44 std::vector<Node*> GetChildren(); | 39 std::vector<Node*> GetChildren(); |
| 45 | 40 |
| 46 // Sets the view associated with this node. Node does not own its View. | 41 // Sets the view associated with this node. Node does not own its View. |
| 47 void SetView(View* view); | 42 void SetView(View* view); |
| 48 View* view() { return view_; } | 43 View* view() { return view_; } |
| 49 | 44 |
| 50 private: | 45 private: |
| 51 // WindowObserver overrides: | 46 // WindowObserver overrides: |
| 52 virtual void OnWindowHierarchyChanged( | 47 virtual void OnWindowHierarchyChanged( |
| 53 const aura::WindowObserver::HierarchyChangeParams& params) OVERRIDE; | 48 const aura::WindowObserver::HierarchyChangeParams& params) OVERRIDE; |
| 54 | 49 |
| 55 // WindowDelegate overrides: | |
| 56 virtual gfx::Size GetMinimumSize() const OVERRIDE; | |
| 57 virtual gfx::Size GetMaximumSize() const OVERRIDE; | |
| 58 virtual void OnBoundsChanged(const gfx::Rect& old_bounds, | |
| 59 const gfx::Rect& new_bounds) OVERRIDE; | |
| 60 virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE; | |
| 61 virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE; | |
| 62 virtual bool ShouldDescendIntoChildForEventHandling( | |
| 63 aura::Window* child, | |
| 64 const gfx::Point& location) OVERRIDE; | |
| 65 virtual bool CanFocus() OVERRIDE; | |
| 66 virtual void OnCaptureLost() OVERRIDE; | |
| 67 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | |
| 68 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; | |
| 69 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; | |
| 70 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; | |
| 71 virtual void OnWindowTargetVisibilityChanged(bool visible) OVERRIDE; | |
| 72 virtual bool HasHitTestMask() const OVERRIDE; | |
| 73 virtual void GetHitTestMask(gfx::Path* mask) const OVERRIDE; | |
| 74 | |
| 75 NodeDelegate* delegate_; | 50 NodeDelegate* delegate_; |
| 76 const NodeId id_; | 51 const NodeId id_; |
| 77 | 52 |
| 78 // Weak pointer to view associated with this node. | 53 // Weak pointer to view associated with this node. |
| 79 View* view_; | 54 View* view_; |
| 80 | 55 |
| 81 ViewId view_id_; | 56 ViewId view_id_; |
| 82 | 57 |
| 83 aura::Window window_; | 58 aura::Window window_; |
| 84 | 59 |
| 85 DISALLOW_COPY_AND_ASSIGN(Node); | 60 DISALLOW_COPY_AND_ASSIGN(Node); |
| 86 }; | 61 }; |
| 87 | 62 |
| 88 } // namespace view_manager | 63 } // namespace view_manager |
| 89 } // namespace services | 64 } // namespace services |
| 90 } // namespace mojo | 65 } // namespace mojo |
| 91 | 66 |
| 92 #endif // MOJO_SERVICES_VIEW_MANAGER_NODE_H_ | 67 #endif // MOJO_SERVICES_VIEW_MANAGER_NODE_H_ |
| OLD | NEW |