Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: mojo/services/view_manager/node.cc

Issue 267293004: Wires up view manager to an actual display (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « mojo/services/view_manager/node.h ('k') | mojo/services/view_manager/root_node_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "mojo/services/view_manager/node.h" 5 #include "mojo/services/view_manager/node.h"
6 6
7 #include "mojo/services/view_manager/node_delegate.h" 7 #include "mojo/services/view_manager/node_delegate.h"
8 #include "mojo/services/view_manager/view.h" 8 #include "mojo/services/view_manager/view.h"
9 #include "ui/aura/window_property.h" 9 #include "ui/aura/window_property.h"
10 #include "ui/base/cursor/cursor.h"
11 #include "ui/base/hit_test.h"
12 #include "ui/gfx/canvas.h"
13 #include "ui/gfx/image/image_skia.h"
14 #include "ui/gfx/native_widget_types.h"
10 15
11 DECLARE_WINDOW_PROPERTY_TYPE(mojo::services::view_manager::Node*); 16 DECLARE_WINDOW_PROPERTY_TYPE(mojo::services::view_manager::Node*);
12 17
13 namespace mojo { 18 namespace mojo {
14 namespace services { 19 namespace services {
15 namespace view_manager { 20 namespace view_manager {
16 21
17 DEFINE_WINDOW_PROPERTY_KEY(Node*, kNodeKey, NULL); 22 DEFINE_WINDOW_PROPERTY_KEY(Node*, kNodeKey, NULL);
18 23
19 Node::Node(NodeDelegate* delegate, const NodeId& id) 24 Node::Node(NodeDelegate* delegate, const NodeId& id)
20 : delegate_(delegate), 25 : delegate_(delegate),
21 id_(id), 26 id_(id),
22 view_(NULL), 27 view_(NULL),
23 window_(NULL) { 28 window_(this) {
24 DCHECK(delegate); // Must provide a delegate. 29 DCHECK(delegate); // Must provide a delegate.
25 window_.set_owned_by_parent(false); 30 window_.set_owned_by_parent(false);
26 window_.AddObserver(this); 31 window_.AddObserver(this);
27 window_.SetProperty(kNodeKey, this); 32 window_.SetProperty(kNodeKey, this);
33 window_.Init(aura::WINDOW_LAYER_TEXTURED);
34
35 // TODO(sky): this likely needs to be false and add a visibility API.
36 window_.Show();
28 } 37 }
29 38
30 Node::~Node() { 39 Node::~Node() {
31 SetView(NULL); 40 SetView(NULL);
32 } 41 }
33 42
34 Node* Node::GetParent() { 43 Node* Node::GetParent() {
35 if (!window_.parent()) 44 if (!window_.parent())
36 return NULL; 45 return NULL;
37 return window_.parent()->GetProperty(kNodeKey); 46 return window_.parent()->GetProperty(kNodeKey);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 view->set_node(this); 82 view->set_node(this);
74 } 83 }
75 delegate_->OnNodeViewReplaced(id_, view_id, old_view_id); 84 delegate_->OnNodeViewReplaced(id_, view_id, old_view_id);
76 } 85 }
77 86
78 void Node::OnWindowHierarchyChanged( 87 void Node::OnWindowHierarchyChanged(
79 const aura::WindowObserver::HierarchyChangeParams& params) { 88 const aura::WindowObserver::HierarchyChangeParams& params) {
80 if (params.target != &window_ || params.receiver != &window_) 89 if (params.target != &window_ || params.receiver != &window_)
81 return; 90 return;
82 NodeId new_parent_id; 91 NodeId new_parent_id;
83 if (params.new_parent) 92 if (params.new_parent && params.new_parent->GetProperty(kNodeKey))
84 new_parent_id = params.new_parent->GetProperty(kNodeKey)->id(); 93 new_parent_id = params.new_parent->GetProperty(kNodeKey)->id();
85 NodeId old_parent_id; 94 NodeId old_parent_id;
86 if (params.old_parent) 95 if (params.old_parent && params.old_parent->GetProperty(kNodeKey))
87 old_parent_id = params.old_parent->GetProperty(kNodeKey)->id(); 96 old_parent_id = params.old_parent->GetProperty(kNodeKey)->id();
88 delegate_->OnNodeHierarchyChanged(id_, new_parent_id, old_parent_id); 97 delegate_->OnNodeHierarchyChanged(id_, new_parent_id, old_parent_id);
89 } 98 }
90 99
100 gfx::Size Node::GetMinimumSize() const {
101 return gfx::Size();
102 }
103
104 gfx::Size Node::GetMaximumSize() const {
105 return gfx::Size();
106 }
107
108 void Node::OnBoundsChanged(const gfx::Rect& old_bounds,
109 const gfx::Rect& new_bounds) {
110 }
111
112 gfx::NativeCursor Node::GetCursor(const gfx::Point& point) {
113 return gfx::kNullCursor;
114 }
115
116 int Node::GetNonClientComponent(const gfx::Point& point) const {
117 return HTCAPTION;
118 }
119
120 bool Node::ShouldDescendIntoChildForEventHandling(
121 aura::Window* child,
122 const gfx::Point& location) {
123 return true;
124 }
125
126 bool Node::CanFocus() {
127 return true;
128 }
129
130 void Node::OnCaptureLost() {
131 }
132
133 void Node::OnPaint(gfx::Canvas* canvas) {
134 if (view_) {
135 canvas->DrawImageInt(
136 gfx::ImageSkia::CreateFrom1xBitmap(view_->bitmap()), 0, 0);
137 }
138 }
139
140 void Node::OnDeviceScaleFactorChanged(float device_scale_factor) {
141 }
142
143 void Node::OnWindowDestroying(aura::Window* window) {
144 }
145
146 void Node::OnWindowDestroyed(aura::Window* window) {
147 }
148
149 void Node::OnWindowTargetVisibilityChanged(bool visible) {
150 }
151
152 bool Node::HasHitTestMask() const {
153 return false;
154 }
155
156 void Node::GetHitTestMask(gfx::Path* mask) const {
157 }
158
91 } // namespace view_manager 159 } // namespace view_manager
92 } // namespace services 160 } // namespace services
93 } // namespace mojo 161 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/view_manager/node.h ('k') | mojo/services/view_manager/root_node_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698