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

Side by Side Diff: chrome/browser/resources/keyboard/ime.js

Issue 7058046: Adjust virtual keyboard size base on input method candidates. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Rebase on trunk Created 9 years, 6 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 /** 5 /**
6 * @fileoverview An input method UI implementation 6 * @fileoverview An input method UI implementation
7 */ 7 */
8 8
9 /** 9 /**
10 * Const variables 10 * Const variables
11 */ 11 */
12 const IME_KEYBOARD_HEIGHT = 300;
12 const IME_HEIGHT = 48; 13 const IME_HEIGHT = 48;
13 const IME_VMARGIN = 12; 14 const IME_VMARGIN = 12;
14 const IME_HMARGIN = 16; 15 const IME_HMARGIN = 16;
15 const IME_FONTSIZE = IME_HEIGHT - IME_VMARGIN * 2; 16 const IME_FONTSIZE = IME_HEIGHT - IME_VMARGIN * 2;
16 const IME_MAX_CANDIDATES = 20; 17 const IME_MAX_CANDIDATES = 20;
17 18
18 /** 19 /**
19 * Creates a new button element. 20 * Creates a new button element.
20 * @param {Object=} opt_propertyBag Optional properties. 21 * @param {Object=} opt_propertyBag Optional properties.
21 * @constructor 22 * @constructor
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 that.appendChild(candidate); 117 that.appendChild(candidate);
117 candidate.onclick = function() { 118 candidate.onclick = function() {
118 that.candidateClicked(index); 119 that.candidateClicked(index);
119 }; 120 };
120 } 121 }
121 for (var i = 0; i < IME_MAX_CANDIDATES; i++) { 122 for (var i = 0; i < IME_MAX_CANDIDATES; i++) {
122 createCandidateButton(i); 123 createCandidateButton(i);
123 } 124 }
124 125
125 this.appendChild(this.pageDown_); 126 this.appendChild(this.pageDown_);
127 this.update();
126 }, 128 },
127 129
128 /** 130 /**
131 * Returns true if Ime Ui is visible.
132 * @return {boolean}
133 */
134 get visible() {
135 return this.style.display != 'none';
136 },
137
138 /**
129 * Sets the input cursor location. 139 * Sets the input cursor location.
130 * @param {number} x The x of the input cursor coordinates. 140 * @param {number} x The x of the input cursor coordinates.
131 * @param {number} y The y of the input cursor coordinates. 141 * @param {number} y The y of the input cursor coordinates.
132 * @param {number} w The width of the input cursor. 142 * @param {number} w The width of the input cursor.
133 * @param {number} h The height of the input cursor. 143 * @param {number} h The height of the input cursor.
134 * @return {void} 144 * @return {void}
135 */ 145 */
136 setCursorLocation: function(x, y, w, h) { 146 setCursorLocation: function(x, y, w, h) {
137 // Currently we do nothing. 147 // Currently we do nothing.
138 }, 148 },
(...skipping 25 matching lines...) Expand all
164 } else { 174 } else {
165 for (var i = 0; i < this.candidates_.length; i++) { 175 for (var i = 0; i < this.candidates_.length; i++) {
166 this.candidates_[i].text = ''; 176 this.candidates_[i].text = '';
167 } 177 }
168 } 178 }
169 this.table_ = table; 179 this.table_ = table;
170 this.update(); 180 this.update();
171 }, 181 },
172 182
173 update : function() { 183 update : function() {
174 // TODO(penghuang) Add API for show and hide ImeUI. 184 var visible =
175 // Currently, ImeUi is always visible. 185 (this.table_ && this.table_.visible) || this.auxiliary_.text_;
176 if (true || (this.table_ && this.table_.visible) || this.auxiliary_.text_) { 186
177 this.style.display = 'block'; 187 if (visible == this.visible) {
188 return;
189 }
190
191 if (visible) {
192 chrome.experimental.input.setKeyboardHeight(
193 IME_KEYBOARD_HEIGHT + IME_HEIGHT);
194 this.style.display = 'inline-block';
178 } else { 195 } else {
179 this.style.display = 'none'; 196 this.style.display = 'none';
197 chrome.experimental.input.setKeyboardHeight(IME_KEYBOARD_HEIGHT);
180 } 198 }
181
182 // TODO(penghuang) Adjust the width of all items in ImeUi to fill the width 199 // TODO(penghuang) Adjust the width of all items in ImeUi to fill the width
183 // of keyboard. 200 // of keyboard.
184 }, 201 },
185 202
186 /** 203 /**
187 * Candidate is clicked. 204 * Candidate is clicked.
188 * @param {number} index The index of the candidate. 205 * @param {number} index The index of the candidate.
189 * @return {void} 206 * @return {void}
190 */ 207 */
191 candidateClicked: function(index) { 208 candidateClicked: function(index) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 273
257 /** 274 /**
258 * Updates Ime Ui. It should be called when window is resized. 275 * Updates Ime Ui. It should be called when window is resized.
259 * @return {void} 276 * @return {void}
260 */ 277 */
261 function updateIme() { 278 function updateIme() {
262 if (imeui) { 279 if (imeui) {
263 imeui.update(); 280 imeui.update();
264 } 281 }
265 } 282 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_input_api.cc ('k') | chrome/browser/resources/keyboard/main.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698