| 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" |
| 14 #include "ui/aura/window_observer.h" | 15 #include "ui/aura/window_observer.h" |
| 15 | 16 |
| 16 namespace mojo { | 17 namespace mojo { |
| 17 namespace services { | 18 namespace services { |
| 18 namespace view_manager { | 19 namespace view_manager { |
| 19 | 20 |
| 20 class NodeDelegate; | 21 class NodeDelegate; |
| 21 class View; | 22 class View; |
| 22 | 23 |
| 23 // Represents a node in the graph. Delegate is informed of interesting events. | 24 // Represents a node in the graph. Delegate is informed of interesting events. |
| 24 class MOJO_VIEW_MANAGER_EXPORT Node : public aura::WindowObserver { | 25 class MOJO_VIEW_MANAGER_EXPORT Node |
| 26 : public aura::WindowObserver, |
| 27 public aura::WindowDelegate { |
| 25 public: | 28 public: |
| 26 Node(NodeDelegate* delegate, const NodeId& id); | 29 Node(NodeDelegate* delegate, const NodeId& id); |
| 27 virtual ~Node(); | 30 virtual ~Node(); |
| 28 | 31 |
| 29 void set_view_id(const ViewId& view_id) { view_id_ = view_id; } | 32 void set_view_id(const ViewId& view_id) { view_id_ = view_id; } |
| 30 const ViewId& view_id() const { return view_id_; } | 33 const ViewId& view_id() const { return view_id_; } |
| 31 | 34 |
| 32 const NodeId& id() const { return id_; } | 35 const NodeId& id() const { return id_; } |
| 33 | 36 |
| 34 void Add(Node* child); | 37 void Add(Node* child); |
| 35 void Remove(Node* child); | 38 void Remove(Node* child); |
| 36 | 39 |
| 40 aura::Window* window() { return &window_; } |
| 41 |
| 37 Node* GetParent(); | 42 Node* GetParent(); |
| 38 | 43 |
| 39 std::vector<Node*> GetChildren(); | 44 std::vector<Node*> GetChildren(); |
| 40 | 45 |
| 41 // Sets the view associated with this node. Node does not own its View. | 46 // Sets the view associated with this node. Node does not own its View. |
| 42 void SetView(View* view); | 47 void SetView(View* view); |
| 43 View* view() { return view_; } | 48 View* view() { return view_; } |
| 44 | 49 |
| 45 private: | 50 private: |
| 46 // WindowObserver overrides: | 51 // WindowObserver overrides: |
| 47 virtual void OnWindowHierarchyChanged( | 52 virtual void OnWindowHierarchyChanged( |
| 48 const aura::WindowObserver::HierarchyChangeParams& params) OVERRIDE; | 53 const aura::WindowObserver::HierarchyChangeParams& params) OVERRIDE; |
| 49 | 54 |
| 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 |
| 50 NodeDelegate* delegate_; | 75 NodeDelegate* delegate_; |
| 51 const NodeId id_; | 76 const NodeId id_; |
| 52 | 77 |
| 53 // Weak pointer to view associated with this node. | 78 // Weak pointer to view associated with this node. |
| 54 View* view_; | 79 View* view_; |
| 55 | 80 |
| 56 ViewId view_id_; | 81 ViewId view_id_; |
| 57 | 82 |
| 58 aura::Window window_; | 83 aura::Window window_; |
| 59 | 84 |
| 60 DISALLOW_COPY_AND_ASSIGN(Node); | 85 DISALLOW_COPY_AND_ASSIGN(Node); |
| 61 }; | 86 }; |
| 62 | 87 |
| 63 } // namespace view_manager | 88 } // namespace view_manager |
| 64 } // namespace services | 89 } // namespace services |
| 65 } // namespace mojo | 90 } // namespace mojo |
| 66 | 91 |
| 67 #endif // MOJO_SERVICES_VIEW_MANAGER_NODE_H_ | 92 #endif // MOJO_SERVICES_VIEW_MANAGER_NODE_H_ |
| OLD | NEW |