| 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 #include "view_manager/public/cpp/lib/view_manager_client_impl.h" | 5 #include "view_manager/public/cpp/lib/view_manager_client_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "mojo/public/cpp/application/application_impl.h" | 10 #include "mojo/public/cpp/application/application_impl.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 View* parent, | 29 View* parent, |
| 30 const ViewDataPtr& view_data) { | 30 const ViewDataPtr& view_data) { |
| 31 // We don't use the ctor that takes a ViewManager here, since it will call | 31 // We don't use the ctor that takes a ViewManager here, since it will call |
| 32 // back to the service and attempt to create a new view. | 32 // back to the service and attempt to create a new view. |
| 33 View* view = ViewPrivate::LocalCreate(); | 33 View* view = ViewPrivate::LocalCreate(); |
| 34 ViewPrivate private_view(view); | 34 ViewPrivate private_view(view); |
| 35 private_view.set_view_manager(client); | 35 private_view.set_view_manager(client); |
| 36 private_view.set_id(view_data->view_id); | 36 private_view.set_id(view_data->view_id); |
| 37 private_view.set_visible(view_data->visible); | 37 private_view.set_visible(view_data->visible); |
| 38 private_view.set_drawn(view_data->drawn); | 38 private_view.set_drawn(view_data->drawn); |
| 39 private_view.set_viewport_metrics(view_data->viewport_metrics.Pass()); | 39 private_view.LocalSetViewportMetrics(ViewportMetrics(), |
| 40 *view_data->viewport_metrics); |
| 40 private_view.set_properties( | 41 private_view.set_properties( |
| 41 view_data->properties.To<std::map<std::string, std::vector<uint8_t>>>()); | 42 view_data->properties.To<std::map<std::string, std::vector<uint8_t>>>()); |
| 42 client->AddView(view); | 43 client->AddView(view); |
| 43 private_view.LocalSetBounds(Rect(), *view_data->bounds); | 44 private_view.LocalSetBounds(Rect(), *view_data->bounds); |
| 44 if (parent) | 45 if (parent) |
| 45 ViewPrivate(parent).LocalAddChild(view); | 46 ViewPrivate(parent).LocalAddChild(view); |
| 46 return view; | 47 return view; |
| 47 } | 48 } |
| 48 | 49 |
| 49 View* BuildViewTree(ViewManagerClientImpl* client, | 50 View* BuildViewTree(ViewManagerClientImpl* client, |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 } | 290 } |
| 290 } | 291 } |
| 291 | 292 |
| 292 void ViewManagerClientImpl::OnViewBoundsChanged(Id view_id, | 293 void ViewManagerClientImpl::OnViewBoundsChanged(Id view_id, |
| 293 RectPtr old_bounds, | 294 RectPtr old_bounds, |
| 294 RectPtr new_bounds) { | 295 RectPtr new_bounds) { |
| 295 View* view = GetViewById(view_id); | 296 View* view = GetViewById(view_id); |
| 296 ViewPrivate(view).LocalSetBounds(*old_bounds, *new_bounds); | 297 ViewPrivate(view).LocalSetBounds(*old_bounds, *new_bounds); |
| 297 } | 298 } |
| 298 | 299 |
| 300 namespace { |
| 301 |
| 302 void SetViewportMetricsOnDecendents(View* root, |
| 303 const ViewportMetrics& old_metrics, |
| 304 const ViewportMetrics& new_metrics) { |
| 305 ViewPrivate(root).LocalSetViewportMetrics(old_metrics, new_metrics); |
| 306 const View::Children& children = root->children(); |
| 307 for (size_t i = 0; i < children.size(); ++i) |
| 308 SetViewportMetricsOnDecendants(children[i], old_metrics, new_metrics); |
| 309 } |
| 310 } |
| 311 |
| 312 void ViewManagerClientImpl::OnViewViewportMetricsChanged( |
| 313 ViewportMetricsPtr old_metrics, |
| 314 ViewportMetricsPtr new_metrics) { |
| 315 View* view = GetRoot(); |
| 316 if (view) |
| 317 SetViewportMetricsOnDecendants(view, *old_metrics, *new_metrics); |
| 318 } |
| 319 |
| 299 void ViewManagerClientImpl::OnViewHierarchyChanged( | 320 void ViewManagerClientImpl::OnViewHierarchyChanged( |
| 300 Id view_id, | 321 Id view_id, |
| 301 Id new_parent_id, | 322 Id new_parent_id, |
| 302 Id old_parent_id, | 323 Id old_parent_id, |
| 303 mojo::Array<ViewDataPtr> views) { | 324 mojo::Array<ViewDataPtr> views) { |
| 304 View* initial_parent = views.size() ? | 325 View* initial_parent = views.size() ? |
| 305 GetViewById(views[0]->parent_id) : NULL; | 326 GetViewById(views[0]->parent_id) : NULL; |
| 306 | 327 |
| 307 BuildViewTree(this, views, initial_parent); | 328 BuildViewTree(this, views, initial_parent); |
| 308 | 329 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 uint32 active_view_id) { | 489 uint32 active_view_id) { |
| 469 if (GetViewById(focused_view_id) != focused_view_) | 490 if (GetViewById(focused_view_id) != focused_view_) |
| 470 OnFocusChanged(focused_view_ ? focused_view_->id() : 0, focused_view_id); | 491 OnFocusChanged(focused_view_ ? focused_view_->id() : 0, focused_view_id); |
| 471 if (GetViewById(active_view_id) != activated_view_) { | 492 if (GetViewById(active_view_id) != activated_view_) { |
| 472 OnActiveWindowChanged(activated_view_ ? activated_view_->id() : 0, | 493 OnActiveWindowChanged(activated_view_ ? activated_view_->id() : 0, |
| 473 active_view_id); | 494 active_view_id); |
| 474 } | 495 } |
| 475 } | 496 } |
| 476 | 497 |
| 477 } // namespace mojo | 498 } // namespace mojo |
| OLD | NEW |