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