Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 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 #include "ui/virtual_keyboard/virtual_keyboard_controller.h" | |
| 6 | |
| 7 #include "ui/aura/layout_manager.h" | |
| 8 #include "ui/aura/window.h" | |
| 9 #include "ui/gfx/rect.h" | |
| 10 #include "ui/virtual_keyboard/virtual_keyboard_controller_proxy.h" | |
| 11 | |
| 12 namespace { | |
| 13 | |
| 14 class VirtualKeyboardLayoutManager : public aura::LayoutManager { | |
|
sadrul
2013/03/28 19:17:00
doc
bryeung
2013/04/02 15:56:53
Done.
| |
| 15 public: | |
| 16 VirtualKeyboardLayoutManager(aura::Window* owner, aura::Window* keyboard) | |
| 17 : owner_(owner), keyboard_(keyboard) {} | |
| 18 | |
| 19 void OnWindowResized() OVERRIDE { | |
|
sadrul
2013/03/28 19:17:00
virtual (and other overrides too)
bryeung
2013/04/02 15:56:53
Done.
| |
| 20 gfx::Rect owner_bounds = owner_->bounds(); | |
| 21 gfx::Rect keyboard_bounds = gfx::Rect( | |
| 22 owner_bounds.x(), | |
| 23 owner_bounds.y() + owner_bounds.height() * 0.7, | |
| 24 owner_bounds.width(), | |
| 25 owner_bounds.height() * 0.3); | |
| 26 SetChildBoundsDirect(keyboard_, keyboard_bounds); | |
| 27 } | |
| 28 | |
| 29 void OnWindowAddedToLayout(aura::Window* child) OVERRIDE { | |
| 30 CHECK(child == keyboard_); | |
| 31 } | |
| 32 | |
| 33 void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE {} | |
| 34 | |
| 35 void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE {} | |
| 36 | |
| 37 void OnChildWindowVisibilityChanged(aura::Window* child, | |
| 38 bool visible) OVERRIDE {} | |
| 39 | |
| 40 void SetChildBounds(aura::Window* child, | |
| 41 const gfx::Rect& requested_bounds) OVERRIDE { | |
| 42 // Drop these: the size should only be set in OnWindowResized. | |
| 43 } | |
| 44 | |
| 45 private: | |
| 46 aura::Window* owner_; | |
| 47 aura::Window* keyboard_; | |
| 48 | |
| 49 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardLayoutManager); | |
| 50 }; | |
| 51 | |
| 52 } // namespace | |
| 53 | |
| 54 namespace virtual_keyboard { | |
| 55 | |
| 56 VirtualKeyboardController::VirtualKeyboardController( | |
| 57 VirtualKeyboardControllerProxy* proxy) | |
| 58 : proxy_(proxy) { | |
| 59 CHECK(proxy); | |
| 60 } | |
| 61 | |
| 62 VirtualKeyboardController::~VirtualKeyboardController() {} | |
| 63 | |
| 64 aura::Window* VirtualKeyboardController::Init() { | |
| 65 aura::Window* keyboard = proxy_->GetVirtualKeyboard(); | |
| 66 | |
| 67 container_.reset(new aura::Window(NULL)); | |
| 68 container_->SetName("VirtualKeyboardContainer"); | |
| 69 container_->Init(ui::LAYER_NOT_DRAWN); | |
| 70 container_->SetLayoutManager( | |
| 71 new VirtualKeyboardLayoutManager(container_.get(), keyboard)); | |
| 72 container_->AddChild(keyboard); | |
| 73 container_->Show(); | |
| 74 | |
| 75 return container_.get(); | |
| 76 } | |
| 77 | |
| 78 } // namespace virtual_keyboard | |
| OLD | NEW |