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

Side by Side Diff: ui/keyboard/keyboard_controller.cc

Issue 13164002: Create and show the virtual keyboard. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix upstream Created 7 years, 8 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 | « ui/keyboard/keyboard_controller.h ('k') | ui/keyboard/keyboard_controller_proxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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/keyboard/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/keyboard/keyboard_controller_proxy.h"
11
12 namespace {
13
14 // LayoutManager for the virtual keyboard container. Manages a single window
15 // (the virtual keyboard) and keeps it positioned at the bottom of the
16 // container window.
17 class KeyboardLayoutManager : public aura::LayoutManager {
18 public:
19 KeyboardLayoutManager(aura::Window* owner, aura::Window* keyboard)
20 : owner_(owner), keyboard_(keyboard) {}
21
22 // Overridden from aura::LayoutManager
23 virtual void OnWindowResized() OVERRIDE {
24 gfx::Rect owner_bounds = owner_->bounds();
25 gfx::Rect keyboard_bounds = gfx::Rect(
26 owner_bounds.x(),
27 owner_bounds.y() + owner_bounds.height() * 0.7,
28 owner_bounds.width(),
29 owner_bounds.height() * 0.3);
30 SetChildBoundsDirect(keyboard_, keyboard_bounds);
31 }
32 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE {
33 CHECK(child == keyboard_);
34 }
35 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE {}
36 virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE {}
37 virtual void OnChildWindowVisibilityChanged(aura::Window* child,
38 bool visible) OVERRIDE {}
39 virtual void SetChildBounds(aura::Window* child,
40 const gfx::Rect& requested_bounds) OVERRIDE {
41 // Drop these: the size should only be set in OnWindowResized.
42 }
43
44 private:
45 aura::Window* owner_;
46 aura::Window* keyboard_;
47
48 DISALLOW_COPY_AND_ASSIGN(KeyboardLayoutManager);
49 };
50
51 } // namespace
52
53 namespace keyboard {
54
55 KeyboardController::KeyboardController(KeyboardControllerProxy* proxy)
56 : proxy_(proxy), container_(NULL) {
57 CHECK(proxy);
58 }
59
60 KeyboardController::~KeyboardController() {}
61
62 aura::Window* KeyboardController::GetContainerWindow() {
63 if (!container_) {
64 container_ = new aura::Window(NULL);
65 container_->SetName("KeyboardContainer");
66 container_->Init(ui::LAYER_NOT_DRAWN);
67
68 aura::Window* keyboard = proxy_->GetKeyboardWindow();
69 keyboard->Show();
70
71 container_->SetLayoutManager(
72 new KeyboardLayoutManager(container_, keyboard));
73 container_->AddChild(keyboard);
74 }
75 return container_;
76 }
77
78 } // namespace keyboard
OLDNEW
« no previous file with comments | « ui/keyboard/keyboard_controller.h ('k') | ui/keyboard/keyboard_controller_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698