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

Side by Side Diff: chrome/browser/resources/vr_shell/vr_shell_ui.js

Issue 2733103002: Adjust HTML VKB positioning. (Closed)
Patch Set: Fix search-and-replace typo. Created 3 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 var vrShellUi = (function() { 5 var vrShellUi = (function() {
6 'use strict'; 6 'use strict';
7 7
8 let ui = new scene.Scene(); 8 let ui = new scene.Scene();
9 let uiManager; 9 let uiManager;
10 let nativeCommandHandler; 10 let nativeCommandHandler;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 element.setSize(this.sizeX, this.sizeY); 144 element.setSize(this.sizeX, this.sizeY);
145 145
146 // Pull additional custom properties from CSS. 146 // Pull additional custom properties from CSS.
147 let style = window.getComputedStyle(domElement); 147 let style = window.getComputedStyle(domElement);
148 this.translationX = getStyleFloat(style, '--tranX'); 148 this.translationX = getStyleFloat(style, '--tranX');
149 this.translationY = getStyleFloat(style, '--tranY'); 149 this.translationY = getStyleFloat(style, '--tranY');
150 this.translationZ = getStyleFloat(style, '--tranZ'); 150 this.translationZ = getStyleFloat(style, '--tranZ');
151 element.setTranslation( 151 element.setTranslation(
152 this.translationX, this.translationY, this.translationZ); 152 this.translationX, this.translationY, this.translationZ);
153 153
154 this.uiElementId = ui.addElement(element); 154 this.id = ui.addElement(element);
155 this.domElement = domElement; 155 this.domElement = domElement;
156 } 156 }
157 }; 157 };
158 158
159 class Button { 159 class Button {
160 constructor(domId, callback, parentId) { 160 constructor(domId, callback, parentId) {
161 let captionId = domId + '-caption'; 161 let captionId = domId + '-caption';
162 this.button = document.querySelector(domId); 162 this.button = document.querySelector(domId);
163 this.caption = document.querySelector(captionId); 163 this.caption = document.querySelector(captionId);
164 164
165 // Create an invisible parent, from which the button will hover. 165 // Create an invisible parent, from which the button will hover.
166 let backing = new api.UiElement(0, 0, 0, 0); 166 let backing = new api.UiElement(0, 0, 0, 0);
167 backing.setParentId(parentId); 167 backing.setParentId(parentId);
168 backing.setVisible(false); 168 backing.setVisible(false);
169 this.backingElementId = ui.addElement(backing); 169 this.backingElementId = ui.addElement(backing);
170 170
171 this.buttonElement = new DomUiElement(domId); 171 this.buttonElement = new DomUiElement(domId);
172 let update = new api.UiElementUpdate(); 172 let update = new api.UiElementUpdate();
173 update.setParentId(this.backingElementId); 173 update.setParentId(this.backingElementId);
174 ui.updateElement(this.buttonElement.uiElementId, update); 174 ui.updateElement(this.buttonElement.id, update);
175 175
176 this.captionElement = new DomUiElement(captionId); 176 this.captionElement = new DomUiElement(captionId);
177 update = new api.UiElementUpdate(); 177 update = new api.UiElementUpdate();
178 update.setParentId(this.buttonElement.uiElementId); 178 update.setParentId(this.buttonElement.id);
179 update.setTranslation(0, -this.captionElement.sizeY / 2, 0); 179 update.setTranslation(0, -this.captionElement.sizeY / 2, 0);
180 update.setAnchoring(api.XAnchoring.XNONE, api.YAnchoring.YBOTTOM); 180 update.setAnchoring(api.XAnchoring.XNONE, api.YAnchoring.YBOTTOM);
181 ui.updateElement(this.captionElement.uiElementId, update); 181 ui.updateElement(this.captionElement.id, update);
182 182
183 this.button.addEventListener('mouseenter', this.onMouseEnter.bind(this)); 183 this.button.addEventListener('mouseenter', this.onMouseEnter.bind(this));
184 this.button.addEventListener('mouseleave', this.onMouseLeave.bind(this)); 184 this.button.addEventListener('mouseleave', this.onMouseLeave.bind(this));
185 this.button.addEventListener('click', callback); 185 this.button.addEventListener('click', callback);
186 } 186 }
187 187
188 setTranslation(x, y, z) { 188 setTranslation(x, y, z) {
189 let update = new api.UiElementUpdate(); 189 let update = new api.UiElementUpdate();
190 update.setTranslation(x, y, z); 190 update.setTranslation(x, y, z);
191 ui.updateElement(this.backingElementId, update); 191 ui.updateElement(this.backingElementId, update);
192 } 192 }
193 193
194 setVisible(visible) { 194 setVisible(visible) {
195 let update = new api.UiElementUpdate(); 195 let update = new api.UiElementUpdate();
196 update.setVisible(visible); 196 update.setVisible(visible);
197 ui.updateElement(this.buttonElement.uiElementId, update); 197 ui.updateElement(this.buttonElement.id, update);
198 update = new api.UiElementUpdate(); 198 update = new api.UiElementUpdate();
199 update.setVisible(visible); 199 update.setVisible(visible);
200 ui.updateElement(this.captionElement.uiElementId, update); 200 ui.updateElement(this.captionElement.id, update);
201 } 201 }
202 202
203 configure(buttonOpacity, captionOpacity, distanceForward) { 203 configure(buttonOpacity, captionOpacity, distanceForward) {
204 this.button.style.opacity = buttonOpacity; 204 this.button.style.opacity = buttonOpacity;
205 this.caption.style.opacity = captionOpacity; 205 this.caption.style.opacity = captionOpacity;
206 206
207 let anim = 207 let anim = new api.Animation(this.buttonElement.id, ANIM_DURATION);
208 new api.Animation(this.buttonElement.uiElementId, ANIM_DURATION);
209 anim.setTranslation(0, 0, distanceForward); 208 anim.setTranslation(0, 0, distanceForward);
210 ui.addAnimation(anim); 209 ui.addAnimation(anim);
211 ui.flush(); 210 ui.flush();
212 } 211 }
213 212
214 onMouseEnter() { 213 onMouseEnter() {
215 this.configure(1, 1, 0.015); 214 this.configure(1, 1, 0.015);
216 } 215 }
217 216
218 onMouseLeave() { 217 onMouseLeave() {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 this.uiElement.domElement.addEventListener('click', function() { 289 this.uiElement.domElement.addEventListener('click', function() {
291 ui.purge(); 290 ui.purge();
292 api.doAction(api.Action.RELOAD_UI, {}); 291 api.doAction(api.Action.RELOAD_UI, {});
293 }); 292 });
294 293
295 let update = new api.UiElementUpdate(); 294 let update = new api.UiElementUpdate();
296 update.setVisible(false); 295 update.setVisible(false);
297 update.setSize(0.25, 0.1); 296 update.setSize(0.25, 0.1);
298 update.setTranslation(0, -1.0, -1.0); 297 update.setTranslation(0, -1.0, -1.0);
299 update.setRotation(1, 0, 0, -0.8); 298 update.setRotation(1, 0, 0, -0.8);
300 ui.updateElement(this.uiElement.uiElementId, update); 299 ui.updateElement(this.uiElement.id, update);
301 } 300 }
302 301
303 setEnabled(enabled) { 302 setEnabled(enabled) {
304 this.enabled = enabled; 303 this.enabled = enabled;
305 this.updateState(); 304 this.updateState();
306 } 305 }
307 306
308 setDevMode(enabled) { 307 setDevMode(enabled) {
309 this.devMode = enabled; 308 this.devMode = enabled;
310 this.updateState(); 309 this.updateState();
311 } 310 }
312 311
313 updateState() { 312 updateState() {
314 let update = new api.UiElementUpdate(); 313 let update = new api.UiElementUpdate();
315 update.setVisible(this.enabled && this.devMode); 314 update.setVisible(this.enabled && this.devMode);
316 ui.updateElement(this.uiElement.uiElementId, update); 315 ui.updateElement(this.uiElement.id, update);
317 } 316 }
318 }; 317 };
319 318
320 class SecureOriginWarnings { 319 class SecureOriginWarnings {
321 constructor() { 320 constructor() {
322 /** @const */ var DISTANCE = 0.7; 321 /** @const */ var DISTANCE = 0.7;
323 /** @const */ var ANGLE_UP = 16.3 * Math.PI / 180.0; 322 /** @const */ var ANGLE_UP = 16.3 * Math.PI / 180.0;
324 323
325 this.enabled = false; 324 this.enabled = false;
326 this.secure = false; 325 this.secure = false;
327 this.secureOriginTimer = null; 326 this.secureOriginTimer = null;
328 327
329 // Permanent WebVR security warning. This warning is shown near the top of 328 // Permanent WebVR security warning. This warning is shown near the top of
330 // the field of view. 329 // the field of view.
331 this.webVrSecureWarning = new DomUiElement('#webvr-not-secure-permanent'); 330 this.webVrSecureWarning = new DomUiElement('#webvr-not-secure-permanent');
332 let update = new api.UiElementUpdate(); 331 let update = new api.UiElementUpdate();
333 update.setScale(DISTANCE, DISTANCE, 1); 332 update.setScale(DISTANCE, DISTANCE, 1);
334 update.setTranslation( 333 update.setTranslation(
335 0, DISTANCE * Math.sin(ANGLE_UP), -DISTANCE * Math.cos(ANGLE_UP)); 334 0, DISTANCE * Math.sin(ANGLE_UP), -DISTANCE * Math.cos(ANGLE_UP));
336 update.setRotation(1.0, 0.0, 0.0, ANGLE_UP); 335 update.setRotation(1.0, 0.0, 0.0, ANGLE_UP);
337 update.setHitTestable(false); 336 update.setHitTestable(false);
338 update.setVisible(false); 337 update.setVisible(false);
339 update.setLockToFieldOfView(true); 338 update.setLockToFieldOfView(true);
340 ui.updateElement(this.webVrSecureWarning.uiElementId, update); 339 ui.updateElement(this.webVrSecureWarning.id, update);
341 340
342 // Temporary WebVR security warning. This warning is shown in the center 341 // Temporary WebVR security warning. This warning is shown in the center
343 // of the field of view, for a limited period of time. 342 // of the field of view, for a limited period of time.
344 this.transientWarning = new DomUiElement('#webvr-not-secure-transient'); 343 this.transientWarning = new DomUiElement('#webvr-not-secure-transient');
345 update = new api.UiElementUpdate(); 344 update = new api.UiElementUpdate();
346 update.setScale(DISTANCE, DISTANCE, 1); 345 update.setScale(DISTANCE, DISTANCE, 1);
347 update.setTranslation(0, 0, -DISTANCE); 346 update.setTranslation(0, 0, -DISTANCE);
348 update.setHitTestable(false); 347 update.setHitTestable(false);
349 update.setVisible(false); 348 update.setVisible(false);
350 update.setLockToFieldOfView(true); 349 update.setLockToFieldOfView(true);
351 ui.updateElement(this.transientWarning.uiElementId, update); 350 ui.updateElement(this.transientWarning.id, update);
352 } 351 }
353 352
354 setEnabled(enabled) { 353 setEnabled(enabled) {
355 this.enabled = enabled; 354 this.enabled = enabled;
356 this.updateState(); 355 this.updateState();
357 } 356 }
358 357
359 setSecure(secure) { 358 setSecure(secure) {
360 this.secure = secure; 359 this.secure = secure;
361 this.updateState(); 360 this.updateState();
(...skipping 10 matching lines...) Expand all
372 if (visible) { 371 if (visible) {
373 this.secureOriginTimer = 372 this.secureOriginTimer =
374 setTimeout(this.onTransientTimer.bind(this), TRANSIENT_TIMEOUT_MS); 373 setTimeout(this.onTransientTimer.bind(this), TRANSIENT_TIMEOUT_MS);
375 } 374 }
376 this.showOrHideWarnings(visible); 375 this.showOrHideWarnings(visible);
377 } 376 }
378 377
379 showOrHideWarnings(visible) { 378 showOrHideWarnings(visible) {
380 let update = new api.UiElementUpdate(); 379 let update = new api.UiElementUpdate();
381 update.setVisible(visible); 380 update.setVisible(visible);
382 ui.updateElement(this.webVrSecureWarning.uiElementId, update); 381 ui.updateElement(this.webVrSecureWarning.id, update);
383 update = new api.UiElementUpdate(); 382 update = new api.UiElementUpdate();
384 update.setVisible(visible); 383 update.setVisible(visible);
385 ui.updateElement(this.transientWarning.uiElementId, update); 384 ui.updateElement(this.transientWarning.id, update);
386 } 385 }
387 386
388 onTransientTimer() { 387 onTransientTimer() {
389 let update = new api.UiElementUpdate(); 388 let update = new api.UiElementUpdate();
390 update.setVisible(false); 389 update.setVisible(false);
391 ui.updateElement(this.transientWarning.uiElementId, update); 390 ui.updateElement(this.transientWarning.id, update);
392 this.secureOriginTimer = null; 391 this.secureOriginTimer = null;
393 ui.flush(); 392 ui.flush();
394 } 393 }
395 }; 394 };
396 395
397 class UrlIndicator { 396 class UrlIndicator {
398 constructor() { 397 constructor() {
399 this.domUiElement = new DomUiElement('#url-indicator-container'); 398 this.domUiElement = new DomUiElement('#url-indicator-container');
400 this.enabled = false; 399 this.enabled = false;
401 this.hidden = false; 400 this.hidden = false;
402 this.loading = false; 401 this.loading = false;
403 this.loadProgress = 0; 402 this.loadProgress = 0;
404 this.level = 0; 403 this.level = 0;
405 this.visibilityTimeout = 0; 404 this.visibilityTimeout = 0;
406 this.visibilityTimer = null; 405 this.visibilityTimer = null;
407 this.nativeState = {}; 406 this.nativeState = {};
408 407
409 // Initially invisible. 408 // Initially invisible.
410 let update = new api.UiElementUpdate(); 409 let update = new api.UiElementUpdate();
411 update.setVisible(false); 410 update.setVisible(false);
412 ui.updateElement(this.domUiElement.uiElementId, update); 411 ui.updateElement(this.domUiElement.id, update);
413 this.nativeState.visible = false; 412 this.nativeState.visible = false;
414 413
415 // Pull some CSS properties so that Javascript can reconfigure the 414 // Pull some CSS properties so that Javascript can reconfigure the
416 // indicator programmatically. 415 // indicator programmatically.
417 let border = 416 let border =
418 this.domUiElement.domElement.querySelector('#url-indicator-border'); 417 this.domUiElement.domElement.querySelector('#url-indicator-border');
419 let style = window.getComputedStyle(border); 418 let style = window.getComputedStyle(border);
420 this.statusBarColor = getStyleString(style, '--statusBarColor'); 419 this.statusBarColor = getStyleString(style, '--statusBarColor');
421 this.backgroundColor = style.backgroundColor; 420 this.backgroundColor = style.backgroundColor;
422 this.fadeTimeMs = getStyleFloat(style, '--fadeTimeMs'); 421 this.fadeTimeMs = getStyleFloat(style, '--fadeTimeMs');
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 } 522 }
524 523
525 let shouldBeHidden = 524 let shouldBeHidden =
526 !this.loading && this.visibilityTimeout > 0 && !this.visibilityTimer; 525 !this.loading && this.visibilityTimeout > 0 && !this.visibilityTimer;
527 if (shouldBeHidden != this.hidden) { 526 if (shouldBeHidden != this.hidden) {
528 // Make the box fade away if it's disappearing. 527 // Make the box fade away if it's disappearing.
529 this.hidden = shouldBeHidden; 528 this.hidden = shouldBeHidden;
530 529
531 // Fade-out or fade-in the box. 530 // Fade-out or fade-in the box.
532 let opacityAnimation = 531 let opacityAnimation =
533 new api.Animation(this.domUiElement.uiElementId, this.fadeTimeMs); 532 new api.Animation(this.domUiElement.id, this.fadeTimeMs);
534 opacityAnimation.setOpacity(this.hidden ? 0.0 : this.opacity); 533 opacityAnimation.setOpacity(this.hidden ? 0.0 : this.opacity);
535 ui.addAnimation(opacityAnimation); 534 ui.addAnimation(opacityAnimation);
536 535
537 // Drop the position as it fades, or raise the position if appearing. 536 // Drop the position as it fades, or raise the position if appearing.
538 let yOffset = this.hidden ? this.fadeYOffset : 0; 537 let yOffset = this.hidden ? this.fadeYOffset : 0;
539 let positionAnimation = 538 let positionAnimation =
540 new api.Animation(this.domUiElement.uiElementId, this.fadeTimeMs); 539 new api.Animation(this.domUiElement.id, this.fadeTimeMs);
541 positionAnimation.setTranslation( 540 positionAnimation.setTranslation(
542 this.domUiElement.translationX, 541 this.domUiElement.translationX,
543 this.domUiElement.translationY + yOffset, 542 this.domUiElement.translationY + yOffset,
544 this.domUiElement.translationZ); 543 this.domUiElement.translationZ);
545 ui.addAnimation(positionAnimation); 544 ui.addAnimation(positionAnimation);
546 } 545 }
547 546
548 ui.flush(); 547 ui.flush();
549 } 548 }
550 549
551 setNativeVisibility(visible) { 550 setNativeVisibility(visible) {
552 if (visible == this.nativeState.visible) { 551 if (visible == this.nativeState.visible) {
553 return; 552 return;
554 } 553 }
555 this.nativeState.visible = visible; 554 this.nativeState.visible = visible;
556 let update = new api.UiElementUpdate(); 555 let update = new api.UiElementUpdate();
557 update.setVisible(visible); 556 update.setVisible(visible);
558 ui.updateElement(this.domUiElement.uiElementId, update); 557 ui.updateElement(this.domUiElement.id, update);
559 ui.flush(); 558 ui.flush();
560 } 559 }
561 }; 560 };
562 561
563 class Background { 562 class Background {
564 constructor() { 563 constructor() {
565 /** @const */ this.SCENE_GROUND_SIZE = 25.0; 564 /** @const */ this.SCENE_GROUND_SIZE = 25.0;
566 /** @const */ this.SCENE_HEIGHT = 4.0; 565 /** @const */ this.SCENE_HEIGHT = 4.0;
567 /** @const */ this.GRIDLINE_COUNT = 10; 566 /** @const */ this.GRIDLINE_COUNT = 10;
568 /** @const */ this.HORIZON_COLOR = {r: 0.57, g: 0.57, b: 0.57, a: 1.0}; 567 /** @const */ this.HORIZON_COLOR = {r: 0.57, g: 0.57, b: 0.57, a: 1.0};
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 constructor() { 662 constructor() {
664 this.enabled = false; 663 this.enabled = false;
665 664
666 this.domUiElement = new DomUiElement('#omnibox-ui-element'); 665 this.domUiElement = new DomUiElement('#omnibox-ui-element');
667 let root = this.domUiElement.domElement; 666 let root = this.domUiElement.domElement;
668 this.inputField = root.querySelector('#omnibox-input-field'); 667 this.inputField = root.querySelector('#omnibox-input-field');
669 668
670 // Initially invisible. 669 // Initially invisible.
671 let update = new api.UiElementUpdate(); 670 let update = new api.UiElementUpdate();
672 update.setVisible(true); 671 update.setVisible(true);
673 ui.updateElement(this.domUiElement.uiElementId, update); 672 ui.updateElement(this.domUiElement.id, update);
674 673
675 // Field-clearing button. 674 // Field-clearing button.
676 let clearButton = root.querySelector('#omnibox-clear-button'); 675 let clearButton = root.querySelector('#omnibox-clear-button');
677 clearButton.addEventListener('click', function() { 676 clearButton.addEventListener('click', function() {
678 this.inputField.value = ''; 677 this.inputField.value = '';
679 api.doAction(api.Action.OMNIBOX_CONTENT, {'text': ''}); 678 api.doAction(api.Action.OMNIBOX_CONTENT, {'text': ''});
680 }.bind(this)); 679 }.bind(this));
681 680
682 // Watch for the enter key to trigger navigation. 681 // Watch for the enter key to trigger navigation.
683 this.inputField.addEventListener('keypress', function(e) { 682 this.inputField.addEventListener('keypress', function(e) {
(...skipping 20 matching lines...) Expand all
704 this.setSuggestions([]); 703 this.setSuggestions([]);
705 } 704 }
706 }.bind(this, i)); 705 }.bind(this, i));
707 } 706 }
708 } 707 }
709 708
710 setEnabled(enabled) { 709 setEnabled(enabled) {
711 this.enabled = enabled; 710 this.enabled = enabled;
712 let update = new api.UiElementUpdate(); 711 let update = new api.UiElementUpdate();
713 update.setVisible(enabled); 712 update.setVisible(enabled);
714 ui.updateElement(this.domUiElement.uiElementId, update); 713 ui.updateElement(this.domUiElement.id, update);
715 } 714 }
716 715
717 setURL(url) { 716 setURL(url) {
718 this.inputField.value = url; 717 this.inputField.value = url;
719 } 718 }
720 719
721 setSuggestions(suggestions) { 720 setSuggestions(suggestions) {
722 for (var i = 0; i < this.maxSuggestions; i++) { 721 for (var i = 0; i < this.maxSuggestions; i++) {
723 let element = document.querySelector('#suggestion-' + i); 722 let element = document.querySelector('#suggestion-' + i);
724 if (i >= suggestions.length) { 723 if (i >= suggestions.length) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 this.domTabTemplate = document.querySelector(DOM_TAB_TEMPLATE_SELECTOR); 761 this.domTabTemplate = document.querySelector(DOM_TAB_TEMPLATE_SELECTOR);
763 this.domTabContainer = document.querySelector(DOM_TAB_CONTAINER_SELECTOR); 762 this.domTabContainer = document.querySelector(DOM_TAB_CONTAINER_SELECTOR);
764 this.domTabClip = document.querySelector(DOM_TAB_CLIP_SELECTOR); 763 this.domTabClip = document.querySelector(DOM_TAB_CLIP_SELECTOR);
765 764
766 // Add tab container to native scene. 765 // Add tab container to native scene.
767 this.tabContainerElement = new DomUiElement(DOM_TAB_CONTAINER_SELECTOR); 766 this.tabContainerElement = new DomUiElement(DOM_TAB_CONTAINER_SELECTOR);
768 let positionUpdate = new api.UiElementUpdate(); 767 let positionUpdate = new api.UiElementUpdate();
769 positionUpdate.setTranslation( 768 positionUpdate.setTranslation(
770 0, TAB_CONTAINER_Y_OFFSET, TAB_CONTAINER_Z_OFFSET); 769 0, TAB_CONTAINER_Y_OFFSET, TAB_CONTAINER_Z_OFFSET);
771 positionUpdate.setVisible(false); 770 positionUpdate.setVisible(false);
772 ui.updateElement(this.tabContainerElement.uiElementId, positionUpdate); 771 ui.updateElement(this.tabContainerElement.id, positionUpdate);
773 772
774 // Add the new tab buttons to the native scene. 773 // Add the new tab buttons to the native scene.
775 let buttonConfigs = [ 774 let buttonConfigs = [
776 { 775 {
777 selector: DOM_NEW_TAB_BUTTON_SELECTOR, x: -0.2, incognito: false 776 selector: DOM_NEW_TAB_BUTTON_SELECTOR, x: -0.2, incognito: false
778 }, { 777 }, {
779 selector: DOM_NEW_INCOGNITO_TAB_BUTTON_SELECTOR, 778 selector: DOM_NEW_INCOGNITO_TAB_BUTTON_SELECTOR,
780 x: 0.2, 779 x: 0.2,
781 incognito: true 780 incognito: true
782 } 781 }
783 ]; 782 ];
784 this.buttonElements = []; 783 this.buttonElements = [];
785 buttonConfigs.forEach(function(buttonConfig) { 784 buttonConfigs.forEach(function(buttonConfig) {
786 let buttonElement = new DomUiElement(buttonConfig.selector); 785 let buttonElement = new DomUiElement(buttonConfig.selector);
787 let update = new api.UiElementUpdate(); 786 let update = new api.UiElementUpdate();
788 update.setTranslation(buttonConfig.x, 0.1, 0); 787 update.setTranslation(buttonConfig.x, 0.1, 0);
789 update.setVisible(false); 788 update.setVisible(false);
790 update.setAnchoring(api.XAnchoring.XNONE, api.YAnchoring.YTOP); 789 update.setAnchoring(api.XAnchoring.XNONE, api.YAnchoring.YTOP);
791 update.setParentId(this.tabContainerElement.uiElementId); 790 update.setParentId(this.tabContainerElement.id);
792 ui.updateElement(buttonElement.uiElementId, update); 791 ui.updateElement(buttonElement.id, update);
793 buttonElement.domElement.addEventListener('click', function() { 792 buttonElement.domElement.addEventListener('click', function() {
794 api.doAction( 793 api.doAction(
795 api.Action.OPEN_NEW_TAB, {'incognito': buttonConfig.incognito}); 794 api.Action.OPEN_NEW_TAB, {'incognito': buttonConfig.incognito});
796 }); 795 });
797 this.buttonElements.push(buttonElement); 796 this.buttonElements.push(buttonElement);
798 }, this); 797 }, this);
799 798
800 // Calculate the width of one tab so that we can properly set the clip 799 // Calculate the width of one tab so that we can properly set the clip
801 // element's width. 800 // element's width.
802 this.domTabWidth = this.domTabTemplate.offsetWidth; 801 this.domTabWidth = this.domTabTemplate.offsetWidth;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 let qualifiedTabId = tab.id; 860 let qualifiedTabId = tab.id;
862 let domTab = this.domTabs[qualifiedTabId]; 861 let domTab = this.domTabs[qualifiedTabId];
863 delete this.domTabs[qualifiedTabId]; 862 delete this.domTabs[qualifiedTabId];
864 this.domTabClip.removeChild(domTab); 863 this.domTabClip.removeChild(domTab);
865 this.resizeClipElement(); 864 this.resizeClipElement();
866 } 865 }
867 866
868 setEnabled(enabled) { 867 setEnabled(enabled) {
869 let update = new api.UiElementUpdate(); 868 let update = new api.UiElementUpdate();
870 update.setVisible(enabled); 869 update.setVisible(enabled);
871 ui.updateElement(this.tabContainerElement.uiElementId, update); 870 ui.updateElement(this.tabContainerElement.id, update);
872 this.buttonElements.forEach(function(buttonElement) { 871 this.buttonElements.forEach(function(buttonElement) {
873 let update = new api.UiElementUpdate(); 872 let update = new api.UiElementUpdate();
874 update.setVisible(enabled); 873 update.setVisible(enabled);
875 ui.updateElement(buttonElement.uiElementId, update); 874 ui.updateElement(buttonElement.id, update);
876 }, this); 875 }, this);
877 } 876 }
878 }; 877 };
879 878
880 class VirtualKeyboard { 879 class VirtualKeyboard {
881 constructor(contentQuadId) { 880 constructor(contentQuadId) {
882 this.domUiElement = new DomUiElement('#vkb'); 881 /** @const */ this.SCENE_GROUND_SIZE = 25.0;
882 /** @const */ this.SCALE = 1.8;
883 /** @const */ this.ANGLE_UP = Math.PI / 6;
884 /** @const */ this.Y_OFFSET = -1.0;
885 /** @const */ this.Z_OFFSET = -1.8;
886
887 this.element = new DomUiElement('#vkb');
883 let update = new api.UiElementUpdate(); 888 let update = new api.UiElementUpdate();
884 update.setParentId(contentQuadId); 889 update.setVisible(true);
885 update.setVisible(false); 890 update.setOpacity(0);
886 update.setRotation(1.0, 0.0, 0.0, -0.9); 891 update.setRotation(1, 0, 0, -this.ANGLE_UP);
887 update.setScale(1.8, 1.8, 1.8); 892 update.setScale(this.SCALE, this.SCALE, this.SCALE);
888 update.setTranslation(0, -1.2, 0.1); 893 update.setTranslation(0, this.Y_OFFSET, this.Z_OFFSET);
889 update.setAnchoring(api.XAnchoring.XNONE, api.YAnchoring.YBOTTOM); 894 ui.updateElement(this.element.id, update);
890 ui.updateElement(this.domUiElement.uiElementId, update);
891 } 895 }
892 896
893 setEnabled(enabled) { 897 setEnabled(enabled) {
894 let update = new api.UiElementUpdate(); 898 let anim = new api.Animation(this.element.id, ANIM_DURATION);
895 update.setVisible(enabled); 899 anim.setOpacity(enabled ? 1 : 0);
896 ui.updateElement(this.domUiElement.uiElementId, update); 900 ui.addAnimation(anim);
901 anim = new api.Animation(this.element.id, ANIM_DURATION);
902 let scale = enabled ? this.SCALE : 0;
903 anim.setScale(scale, scale, scale);
904 ui.addAnimation(anim);
897 } 905 }
898 }; 906 };
899 907
900 class UiManager { 908 class UiManager {
901 constructor() { 909 constructor() {
902 this.mode = api.Mode.UNKNOWN; 910 this.mode = api.Mode.UNKNOWN;
903 this.menuMode = false; 911 this.menuMode = false;
904 this.fullscreen = false; 912 this.fullscreen = false;
905 913
906 this.background = new Background(); 914 this.background = new Background();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 this.omnibox.setEnabled(menuMode); 956 this.omnibox.setEnabled(menuMode);
949 this.urlIndicator.setEnabled(mode == api.Mode.STANDARD && !menuMode); 957 this.urlIndicator.setEnabled(mode == api.Mode.STANDARD && !menuMode);
950 this.urlIndicator.setVisibilityTimeout( 958 this.urlIndicator.setVisibilityTimeout(
951 URL_INDICATOR_VISIBILITY_TIMEOUT_MS); 959 URL_INDICATOR_VISIBILITY_TIMEOUT_MS);
952 this.secureOriginWarnings.setEnabled( 960 this.secureOriginWarnings.setEnabled(
953 mode == api.Mode.WEB_VR && !menuMode); 961 mode == api.Mode.WEB_VR && !menuMode);
954 this.background.setState(mode, menuMode, fullscreen); 962 this.background.setState(mode, menuMode, fullscreen);
955 this.tabContainer.setEnabled(mode == api.Mode.STANDARD && menuMode); 963 this.tabContainer.setEnabled(mode == api.Mode.STANDARD && menuMode);
956 964
957 this.reloadUiButton.setEnabled(mode == api.Mode.STANDARD); 965 this.reloadUiButton.setEnabled(mode == api.Mode.STANDARD);
958 this.keyboard.setEnabled(mode == api.Mode.STANDARD); 966 this.keyboard.setEnabled(mode == api.Mode.STANDARD && menuMode);
959 967
960 api.setUiCssSize( 968 api.setUiCssSize(
961 uiRootElement.clientWidth, uiRootElement.clientHeight, UI_DPR); 969 uiRootElement.clientWidth, uiRootElement.clientHeight, UI_DPR);
962 } 970 }
963 971
964 setSecurityLevel(level) { 972 setSecurityLevel(level) {
965 this.urlIndicator.setSecurityLevel(level); 973 this.urlIndicator.setSecurityLevel(level);
966 } 974 }
967 975
968 setWebVRSecureOrigin(secure) { 976 setWebVRSecureOrigin(secure) {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 nativeCommandHandler.handleCommand(dict); 1072 nativeCommandHandler.handleCommand(dict);
1065 } 1073 }
1066 1074
1067 return { 1075 return {
1068 initialize: initialize, 1076 initialize: initialize,
1069 command: command, 1077 command: command,
1070 }; 1078 };
1071 })(); 1079 })();
1072 1080
1073 window.addEventListener('load', vrShellUi.initialize); 1081 window.addEventListener('load', vrShellUi.initialize);
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698