Index: ui/virtual_keyboard/virtual_keyboard_controller.cc |
diff --git a/ui/virtual_keyboard/virtual_keyboard_controller.cc b/ui/virtual_keyboard/virtual_keyboard_controller.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0b53f8b2e3b54722c5d56c1b8fa073f98eb1c282 |
--- /dev/null |
+++ b/ui/virtual_keyboard/virtual_keyboard_controller.cc |
@@ -0,0 +1,78 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "ui/virtual_keyboard/virtual_keyboard_controller.h" |
+ |
+#include "ui/aura/layout_manager.h" |
+#include "ui/aura/window.h" |
+#include "ui/gfx/rect.h" |
+#include "ui/virtual_keyboard/virtual_keyboard_controller_proxy.h" |
+ |
+namespace { |
+ |
+class VirtualKeyboardLayoutManager : public aura::LayoutManager { |
sadrul
2013/03/28 19:17:00
doc
bryeung
2013/04/02 15:56:53
Done.
|
+ public: |
+ VirtualKeyboardLayoutManager(aura::Window* owner, aura::Window* keyboard) |
+ : owner_(owner), keyboard_(keyboard) {} |
+ |
+ void OnWindowResized() OVERRIDE { |
sadrul
2013/03/28 19:17:00
virtual (and other overrides too)
bryeung
2013/04/02 15:56:53
Done.
|
+ gfx::Rect owner_bounds = owner_->bounds(); |
+ gfx::Rect keyboard_bounds = gfx::Rect( |
+ owner_bounds.x(), |
+ owner_bounds.y() + owner_bounds.height() * 0.7, |
+ owner_bounds.width(), |
+ owner_bounds.height() * 0.3); |
+ SetChildBoundsDirect(keyboard_, keyboard_bounds); |
+ } |
+ |
+ void OnWindowAddedToLayout(aura::Window* child) OVERRIDE { |
+ CHECK(child == keyboard_); |
+ } |
+ |
+ void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE {} |
+ |
+ void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE {} |
+ |
+ void OnChildWindowVisibilityChanged(aura::Window* child, |
+ bool visible) OVERRIDE {} |
+ |
+ void SetChildBounds(aura::Window* child, |
+ const gfx::Rect& requested_bounds) OVERRIDE { |
+ // Drop these: the size should only be set in OnWindowResized. |
+ } |
+ |
+ private: |
+ aura::Window* owner_; |
+ aura::Window* keyboard_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardLayoutManager); |
+}; |
+ |
+} // namespace |
+ |
+namespace virtual_keyboard { |
+ |
+VirtualKeyboardController::VirtualKeyboardController( |
+ VirtualKeyboardControllerProxy* proxy) |
+ : proxy_(proxy) { |
+ CHECK(proxy); |
+} |
+ |
+VirtualKeyboardController::~VirtualKeyboardController() {} |
+ |
+aura::Window* VirtualKeyboardController::Init() { |
+ aura::Window* keyboard = proxy_->GetVirtualKeyboard(); |
+ |
+ container_.reset(new aura::Window(NULL)); |
+ container_->SetName("VirtualKeyboardContainer"); |
+ container_->Init(ui::LAYER_NOT_DRAWN); |
+ container_->SetLayoutManager( |
+ new VirtualKeyboardLayoutManager(container_.get(), keyboard)); |
+ container_->AddChild(keyboard); |
+ container_->Show(); |
+ |
+ return container_.get(); |
+} |
+ |
+} // namespace virtual_keyboard |