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

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: make test compile 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 virtual void OnWindowResized() OVERRIDE {
23 gfx::Rect owner_bounds = owner_->bounds();
24 gfx::Rect keyboard_bounds = gfx::Rect(
25 owner_bounds.x(),
26 owner_bounds.y() + owner_bounds.height() * 0.7,
27 owner_bounds.width(),
28 owner_bounds.height() * 0.3);
29 SetChildBoundsDirect(keyboard_, keyboard_bounds);
30 }
31
32 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE {
33 CHECK(child == keyboard_);
34 }
35
36 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE {}
37
38 virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE {}
39
40 virtual void OnChildWindowVisibilityChanged(aura::Window* child,
41 bool visible) OVERRIDE {}
42
43 virtual void SetChildBounds(aura::Window* child,
44 const gfx::Rect& requested_bounds) OVERRIDE {
45 // Drop these: the size should only be set in OnWindowResized.
46 }
47
48 private:
49 aura::Window* owner_;
50 aura::Window* keyboard_;
51
52 DISALLOW_COPY_AND_ASSIGN(KeyboardLayoutManager);
53 };
54
55 } // namespace
56
57 namespace keyboard {
58
59 KeyboardController::KeyboardController(
60 KeyboardControllerProxy* proxy)
61 : proxy_(proxy) {
62 CHECK(proxy);
63 }
64
65 KeyboardController::~KeyboardController() {}
66
67 aura::Window* KeyboardController::GetContainerWindow() {
68 if (!container_) {
69 container_.reset(new aura::Window(NULL));
70 container_->set_owned_by_parent(false);
71 container_->SetName("KeyboardContainer");
72 container_->Init(ui::LAYER_NOT_DRAWN);
73
74 aura::Window* keyboard = proxy_->GetKeyboardWindow();
sadrul 2013/04/02 20:55:27 I think it makes sense to keyboard->Show() here.
bryeung 2013/04/03 14:46:03 Done.
75
76 container_->SetLayoutManager(
77 new KeyboardLayoutManager(container_.get(), keyboard));
78 container_->AddChild(keyboard);
79 container_->Show();
sadrul 2013/04/02 20:55:27 The caller might want to set the window up in some
bryeung 2013/04/03 14:46:03 Done.
80 }
81 return container_.get();
82 }
83
84 } // 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