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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/macros.h" | 6 #include "base/macros.h" |
7 #include "examples/keyboard/keyboard.mojom.h" | 7 #include "examples/keyboard/keyboard.mojom.h" |
8 #include "examples/window_manager/debug_panel.h" | 8 #include "examples/window_manager/debug_panel.h" |
9 #include "examples/window_manager/window_manager.mojom.h" | 9 #include "examples/window_manager/window_manager.mojom.h" |
10 #include "mojo/application/application_runner_chromium.h" | 10 #include "mojo/application/application_runner_chromium.h" |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 scoped_ptr<ServiceProvider> imported_services) override { | 353 scoped_ptr<ServiceProvider> imported_services) override { |
354 DCHECK(!view_manager_); | 354 DCHECK(!view_manager_); |
355 view_manager_ = view_manager; | 355 view_manager_ = view_manager; |
356 | 356 |
357 View* view = View::Create(view_manager_); | 357 View* view = View::Create(view_manager_); |
358 root->AddChild(view); | 358 root->AddChild(view); |
359 Rect rect; | 359 Rect rect; |
360 rect.width = root->bounds().width; | 360 rect.width = root->bounds().width; |
361 rect.height = root->bounds().height; | 361 rect.height = root->bounds().height; |
362 view->SetBounds(rect); | 362 view->SetBounds(rect); |
| 363 view->SetVisible(true); |
363 content_view_id_ = view->id(); | 364 content_view_id_ = view->id(); |
364 | 365 |
365 Id launcher_ui_id = CreateLauncherUI(); | 366 Id launcher_ui_id = CreateLauncherUI(); |
366 Id control_panel_id = CreateControlPanel(view); | 367 Id control_panel_id = CreateControlPanel(view); |
367 | 368 |
368 root_layout_manager_.reset( | 369 root_layout_manager_.reset( |
369 new RootLayoutManager(view_manager, root, | 370 new RootLayoutManager(view_manager, root, |
370 content_view_id_, | 371 content_view_id_, |
371 launcher_ui_id, | 372 launcher_ui_id, |
372 control_panel_id)); | 373 control_panel_id)); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 bounds.y = windows_.back()->view()->bounds().y + 35; | 461 bounds.y = windows_.back()->view()->bounds().y + 35; |
461 } | 462 } |
462 return CreateWindow(bounds); | 463 return CreateWindow(bounds); |
463 } | 464 } |
464 | 465 |
465 Window* CreateWindow(const Rect& bounds) { | 466 Window* CreateWindow(const Rect& bounds) { |
466 View* content = view_manager_->GetViewById(content_view_id_); | 467 View* content = view_manager_->GetViewById(content_view_id_); |
467 View* view = View::Create(view_manager_); | 468 View* view = View::Create(view_manager_); |
468 content->AddChild(view); | 469 content->AddChild(view); |
469 view->SetBounds(bounds); | 470 view->SetBounds(bounds); |
| 471 view->SetVisible(true); |
470 view->SetFocus(); | 472 view->SetFocus(); |
471 return new Window(this, view); | 473 return new Window(this, view); |
472 } | 474 } |
473 | 475 |
474 bool IsDescendantOfKeyboard(View* target) { | 476 bool IsDescendantOfKeyboard(View* target) { |
475 return keyboard_manager_.get() && | 477 return keyboard_manager_.get() && |
476 keyboard_manager_->view()->Contains(target); | 478 keyboard_manager_->view()->Contains(target); |
477 } | 479 } |
478 | 480 |
479 Id CreateControlPanel(View* root) { | 481 Id CreateControlPanel(View* root) { |
480 View* view = View::Create(view_manager_); | 482 View* view = View::Create(view_manager_); |
481 root->AddChild(view); | 483 root->AddChild(view); |
482 | 484 |
483 Rect bounds; | 485 Rect bounds; |
484 bounds.x = root->bounds().width - kControlPanelWidth - kBorderInset; | 486 bounds.x = root->bounds().width - kControlPanelWidth - kBorderInset; |
485 bounds.y = kBorderInset * 2 + kTextfieldHeight; | 487 bounds.y = kBorderInset * 2 + kTextfieldHeight; |
486 bounds.width = kControlPanelWidth; | 488 bounds.width = kControlPanelWidth; |
487 bounds.height = | 489 bounds.height = |
488 root->bounds().height - kBorderInset * 3 - kTextfieldHeight; | 490 root->bounds().height - kBorderInset * 3 - kTextfieldHeight; |
489 view->SetBounds(bounds); | 491 view->SetBounds(bounds); |
| 492 view->SetVisible(true); |
490 | 493 |
491 debug_panel_ = new DebugPanel(this, shell_, view); | 494 debug_panel_ = new DebugPanel(this, shell_, view); |
492 return view->id(); | 495 return view->id(); |
493 } | 496 } |
494 | 497 |
495 WindowVector::iterator GetWindowByViewId(Id view_id) { | 498 WindowVector::iterator GetWindowByViewId(Id view_id) { |
496 for (std::vector<Window*>::iterator iter = windows_.begin(); | 499 for (std::vector<Window*>::iterator iter = windows_.begin(); |
497 iter != windows_.end(); | 500 iter != windows_.end(); |
498 ++iter) { | 501 ++iter) { |
499 if ((*iter)->view()->id() == view_id) { | 502 if ((*iter)->view()->id() == view_id) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 window_manager_->RequestNavigate(view_id_, target, request.Pass()); | 549 window_manager_->RequestNavigate(view_id_, target, request.Pass()); |
547 } | 550 } |
548 | 551 |
549 } // namespace examples | 552 } // namespace examples |
550 } // namespace mojo | 553 } // namespace mojo |
551 | 554 |
552 MojoResult MojoMain(MojoHandle shell_handle) { | 555 MojoResult MojoMain(MojoHandle shell_handle) { |
553 mojo::ApplicationRunnerChromium runner(new mojo::examples::WindowManager); | 556 mojo::ApplicationRunnerChromium runner(new mojo::examples::WindowManager); |
554 return runner.Run(shell_handle); | 557 return runner.Run(shell_handle); |
555 } | 558 } |
OLD | NEW |