| OLD | NEW |
| 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 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 constructor() { | 29 constructor() { |
| 30 /** @const */ this.SCREEN_HEIGHT = 1.6; | 30 /** @const */ this.SCREEN_HEIGHT = 1.6; |
| 31 /** @const */ this.SCREEN_RATIO = 16 / 9; | 31 /** @const */ this.SCREEN_RATIO = 16 / 9; |
| 32 /** @const */ this.BROWSING_SCREEN_DISTANCE = 2.0; | 32 /** @const */ this.BROWSING_SCREEN_DISTANCE = 2.0; |
| 33 /** @const */ this.FULLSCREEN_DISTANCE = 3.0; | 33 /** @const */ this.FULLSCREEN_DISTANCE = 3.0; |
| 34 /** @const */ this.CSS_WIDTH_PIXELS = 960.0; | 34 /** @const */ this.CSS_WIDTH_PIXELS = 960.0; |
| 35 /** @const */ this.CSS_HEIGHT_PIXELS = 640.0; | 35 /** @const */ this.CSS_HEIGHT_PIXELS = 640.0; |
| 36 /** @const */ this.DPR = 1.2; | 36 /** @const */ this.DPR = 1.2; |
| 37 | 37 |
| 38 let element = new api.UiElement(0, 0, 0, 0); | 38 let element = new api.UiElement(0, 0, 0, 0); |
| 39 element.setIsContentQuad(); | 39 element.setFill(new api.Content()); |
| 40 element.setVisible(false); | 40 element.setVisible(false); |
| 41 element.setSize( | 41 element.setSize( |
| 42 this.SCREEN_HEIGHT * this.SCREEN_RATIO, this.SCREEN_HEIGHT); | 42 this.SCREEN_HEIGHT * this.SCREEN_RATIO, this.SCREEN_HEIGHT); |
| 43 element.setTranslation(0, 0, -this.BROWSING_SCREEN_DISTANCE); | 43 element.setTranslation(0, 0, -this.BROWSING_SCREEN_DISTANCE); |
| 44 this.elementId = ui.addElement(element); | 44 this.elementId = ui.addElement(element); |
| 45 } | 45 } |
| 46 | 46 |
| 47 setEnabled(enabled) { | 47 setEnabled(enabled) { |
| 48 let update = new api.UiElementUpdate(); | 48 let update = new api.UiElementUpdate(); |
| 49 update.setVisible(enabled); | 49 update.setVisible(enabled); |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 return; | 476 return; |
| 477 } | 477 } |
| 478 this.nativeState.visible = visible; | 478 this.nativeState.visible = visible; |
| 479 let update = new api.UiElementUpdate(); | 479 let update = new api.UiElementUpdate(); |
| 480 update.setVisible(visible); | 480 update.setVisible(visible); |
| 481 ui.updateElement(this.domUiElement.uiElementId, update); | 481 ui.updateElement(this.domUiElement.uiElementId, update); |
| 482 ui.flush(); | 482 ui.flush(); |
| 483 } | 483 } |
| 484 }; | 484 }; |
| 485 | 485 |
| 486 class Background { |
| 487 constructor() { |
| 488 /** @const */ var GRADIENT_LIGHER_GRAY = |
| 489 {r: 0.57, g: 0.57, b: 0.57, a: 1.0}; |
| 490 /** @const */ var GRADIENT_DARKER_GRAY = |
| 491 {r: 0.48, g: 0.48, b: 0.48, a: 1.0}; |
| 492 /** @const */ var SCENE_GROUND_SIZE = 25.0; |
| 493 /** @const */ var SCENE_HEIGHT = 4.0; |
| 494 /** @const */ var GRIDLINE_COUNT = 10; |
| 495 |
| 496 // Make ground plane. |
| 497 let groundPlane = new api.UiElementUpdate(); |
| 498 groundPlane.setVisible(true); |
| 499 groundPlane.setSize(SCENE_GROUND_SIZE, SCENE_GROUND_SIZE); |
| 500 groundPlane.setFill( |
| 501 new api.OpaqueGradient(GRADIENT_LIGHER_GRAY, GRADIENT_DARKER_GRAY)); |
| 502 groundPlane.setTranslation(0, -SCENE_HEIGHT / 2, 0); |
| 503 groundPlane.setRotation(1.0, 0.0, 0.0, -Math.PI / 2); |
| 504 this.groundPlaneId = ui.addElement(groundPlane); |
| 505 |
| 506 // Make ceiling plane. |
| 507 let ceilingPlane = new api.UiElementUpdate(); |
| 508 ceilingPlane.setVisible(true); |
| 509 ceilingPlane.setSize(SCENE_GROUND_SIZE, SCENE_GROUND_SIZE); |
| 510 ceilingPlane.setFill( |
| 511 new api.OpaqueGradient(GRADIENT_LIGHER_GRAY, GRADIENT_DARKER_GRAY)); |
| 512 ceilingPlane.setTranslation(0, SCENE_HEIGHT / 2, 0); |
| 513 ceilingPlane.setRotation(1.0, 0.0, 0.0, Math.PI / 2); |
| 514 this.ceilingPlaneId = ui.addElement(ceilingPlane); |
| 515 |
| 516 // Ground grid. |
| 517 let groundGrid = new api.UiElementUpdate(); |
| 518 groundGrid.setVisible(true); |
| 519 groundGrid.setSize(SCENE_GROUND_SIZE, SCENE_GROUND_SIZE); |
| 520 groundGrid.setFill(new api.GridGradient( |
| 521 GRADIENT_LIGHER_GRAY, GRADIENT_LIGHER_GRAY, GRIDLINE_COUNT)); |
| 522 groundGrid.setTranslation(0, -SCENE_HEIGHT / 2 + 0.01, 0); |
| 523 groundGrid.setRotation(1.0, 0.0, 0.0, -Math.PI / 2); |
| 524 this.groundGridId = ui.addElement(groundGrid); |
| 525 } |
| 526 |
| 527 setEnabled(enabled) { |
| 528 let groundPlaneUpdate = new api.UiElementUpdate(); |
| 529 groundPlaneUpdate.setVisible(enabled); |
| 530 ui.updateElement(this.groundPlaneId, groundPlaneUpdate); |
| 531 let ceilingPlaneUpdate = new api.UiElementUpdate(); |
| 532 ceilingPlaneUpdate.setVisible(enabled); |
| 533 ui.updateElement(this.ceilingPlaneId, ceilingPlaneUpdate); |
| 534 let groundGridUpdate = new api.UiElementUpdate(); |
| 535 groundGridUpdate.setVisible(enabled); |
| 536 ui.updateElement(this.groundGridId, groundGridUpdate); |
| 537 } |
| 538 }; |
| 539 |
| 486 class Omnibox { | 540 class Omnibox { |
| 487 constructor() { | 541 constructor() { |
| 488 this.enabled = false; | 542 this.enabled = false; |
| 489 | 543 |
| 490 this.domUiElement = new DomUiElement('#omnibox-ui-element'); | 544 this.domUiElement = new DomUiElement('#omnibox-ui-element'); |
| 491 let root = this.domUiElement.domElement; | 545 let root = this.domUiElement.domElement; |
| 492 this.inputField = root.querySelector('#omnibox-input-field'); | 546 this.inputField = root.querySelector('#omnibox-input-field'); |
| 493 | 547 |
| 494 // Initially invisible. | 548 // Initially invisible. |
| 495 let update = new api.UiElementUpdate(); | 549 let update = new api.UiElementUpdate(); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 } | 610 } |
| 557 } | 611 } |
| 558 }; | 612 }; |
| 559 | 613 |
| 560 class UiManager { | 614 class UiManager { |
| 561 constructor() { | 615 constructor() { |
| 562 this.mode = api.Mode.UNKNOWN; | 616 this.mode = api.Mode.UNKNOWN; |
| 563 this.menuMode = false; | 617 this.menuMode = false; |
| 564 this.fullscreen = false; | 618 this.fullscreen = false; |
| 565 | 619 |
| 620 this.background = new Background(); |
| 566 this.contentQuad = new ContentQuad(); | 621 this.contentQuad = new ContentQuad(); |
| 567 let contentId = this.contentQuad.getElementId(); | 622 let contentId = this.contentQuad.getElementId(); |
| 568 | 623 |
| 569 this.controls = new Controls(contentId); | 624 this.controls = new Controls(contentId); |
| 570 this.secureOriginWarnings = new SecureOriginWarnings(); | 625 this.secureOriginWarnings = new SecureOriginWarnings(); |
| 571 this.urlIndicator = new UrlIndicator(); | 626 this.urlIndicator = new UrlIndicator(); |
| 572 this.omnibox = new Omnibox(); | 627 this.omnibox = new Omnibox(); |
| 573 this.reloadUiButton = new ReloadUiButton(); | 628 this.reloadUiButton = new ReloadUiButton(); |
| 574 } | 629 } |
| 575 | 630 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 597 // TODO(crbug/643815): Set aspect ratio on content quad when available. | 652 // TODO(crbug/643815): Set aspect ratio on content quad when available. |
| 598 this.controls.setEnabled(menuMode); | 653 this.controls.setEnabled(menuMode); |
| 599 this.omnibox.setEnabled(menuMode); | 654 this.omnibox.setEnabled(menuMode); |
| 600 this.urlIndicator.setEnabled(mode == api.Mode.STANDARD && !menuMode); | 655 this.urlIndicator.setEnabled(mode == api.Mode.STANDARD && !menuMode); |
| 601 this.urlIndicator.setVisibilityTimeout( | 656 this.urlIndicator.setVisibilityTimeout( |
| 602 URL_INDICATOR_VISIBILITY_TIMEOUT_MS); | 657 URL_INDICATOR_VISIBILITY_TIMEOUT_MS); |
| 603 this.secureOriginWarnings.setEnabled( | 658 this.secureOriginWarnings.setEnabled( |
| 604 mode == api.Mode.WEB_VR && !menuMode); | 659 mode == api.Mode.WEB_VR && !menuMode); |
| 605 | 660 |
| 606 this.reloadUiButton.setEnabled(mode == api.Mode.STANDARD); | 661 this.reloadUiButton.setEnabled(mode == api.Mode.STANDARD); |
| 662 this.background.setEnabled(mode == api.Mode.STANDARD && !menuMode); |
| 607 | 663 |
| 608 api.setUiCssSize( | 664 api.setUiCssSize( |
| 609 uiRootElement.clientWidth, uiRootElement.clientHeight, UI_DPR); | 665 uiRootElement.clientWidth, uiRootElement.clientHeight, UI_DPR); |
| 610 } | 666 } |
| 611 | 667 |
| 612 setSecurityLevel(level) { | 668 setSecurityLevel(level) { |
| 613 this.urlIndicator.setSecurityLevel(level); | 669 this.urlIndicator.setSecurityLevel(level); |
| 614 } | 670 } |
| 615 | 671 |
| 616 setWebVRSecureOrigin(secure) { | 672 setWebVRSecureOrigin(secure) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 ui.flush(); | 723 ui.flush(); |
| 668 } | 724 } |
| 669 | 725 |
| 670 return { | 726 return { |
| 671 initialize: initialize, | 727 initialize: initialize, |
| 672 command: command, | 728 command: command, |
| 673 }; | 729 }; |
| 674 })(); | 730 })(); |
| 675 | 731 |
| 676 window.addEventListener('load', vrShellUi.initialize); | 732 window.addEventListener('load', vrShellUi.initialize); |
| OLD | NEW |