| 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 let nativeCommandHandler; | 10 let nativeCommandHandler; |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 b: this.HORIZON_COLOR.b, | 602 b: this.HORIZON_COLOR.b, |
| 603 a: 0 | 603 a: 0 |
| 604 }; | 604 }; |
| 605 groundGrid.setFill(new api.GridGradient( | 605 groundGrid.setFill(new api.GridGradient( |
| 606 transparentHorizonColor, this.HORIZON_COLOR, this.GRIDLINE_COUNT)); | 606 transparentHorizonColor, this.HORIZON_COLOR, this.GRIDLINE_COUNT)); |
| 607 groundGrid.setTranslation(0, -this.SCENE_HEIGHT / 2 + 0.01, 0); | 607 groundGrid.setTranslation(0, -this.SCENE_HEIGHT / 2 + 0.01, 0); |
| 608 groundGrid.setRotation(1.0, 0.0, 0.0, -Math.PI / 2); | 608 groundGrid.setRotation(1.0, 0.0, 0.0, -Math.PI / 2); |
| 609 groundGrid.setDrawPhase(0); | 609 groundGrid.setDrawPhase(0); |
| 610 this.groundGridId = ui.addElement(groundGrid); | 610 this.groundGridId = ui.addElement(groundGrid); |
| 611 | 611 |
| 612 this.setHiddenBackground(); |
| 613 } |
| 614 |
| 615 setElementVisible(elementId, visible) { |
| 616 let update = new api.UiElementUpdate(); |
| 617 update.setVisible(visible); |
| 618 ui.updateElement(elementId, update); |
| 619 } |
| 620 |
| 621 setLightBackground() { |
| 622 this.setElementVisible(this.groundPlaneId, true); |
| 623 this.setElementVisible(this.ceilingPlaneId, true); |
| 624 this.setElementVisible(this.groundGridId, true); |
| 612 ui.setBackgroundColor(this.HORIZON_COLOR); | 625 ui.setBackgroundColor(this.HORIZON_COLOR); |
| 613 } | 626 } |
| 614 | 627 |
| 615 setEnabled(enabled) { | 628 setDarkBackground() { |
| 616 let groundPlaneUpdate = new api.UiElementUpdate(); | 629 this.setElementVisible(this.groundPlaneId, false); |
| 617 groundPlaneUpdate.setVisible(enabled); | 630 this.setElementVisible(this.ceilingPlaneId, false); |
| 618 ui.updateElement(this.groundPlaneId, groundPlaneUpdate); | 631 this.setElementVisible(this.groundGridId, true); |
| 619 let ceilingPlaneUpdate = new api.UiElementUpdate(); | 632 ui.setBackgroundColor(this.FULLSCREEN_BACKGROUND_COLOR); |
| 620 ceilingPlaneUpdate.setVisible(enabled); | |
| 621 ui.updateElement(this.ceilingPlaneId, ceilingPlaneUpdate); | |
| 622 let groundGridUpdate = new api.UiElementUpdate(); | |
| 623 groundGridUpdate.setVisible(enabled); | |
| 624 ui.updateElement(this.groundGridId, groundGridUpdate); | |
| 625 } | 633 } |
| 626 | 634 |
| 627 setFullscreen(fullscreen) { | 635 setHiddenBackground() { |
| 628 let groundPlaneUpdate = new api.UiElementUpdate(); | 636 this.setElementVisible(this.groundPlaneId, false); |
| 629 groundPlaneUpdate.setVisible(!fullscreen); | 637 this.setElementVisible(this.ceilingPlaneId, false); |
| 630 ui.updateElement(this.groundPlaneId, groundPlaneUpdate); | 638 this.setElementVisible(this.groundGridId, false); |
| 631 let ceilingPlaneUpdate = new api.UiElementUpdate(); | 639 ui.setBackgroundColor(this.FULLSCREEN_BACKGROUND_COLOR); |
| 632 ceilingPlaneUpdate.setVisible(!fullscreen); | 640 } |
| 633 ui.updateElement(this.ceilingPlaneId, ceilingPlaneUpdate); | |
| 634 | 641 |
| 635 // Set darker background color for fullscreen since the user might | 642 setState(mode, menuMode, fullscreen) { |
| 636 // potentially watch a video. | 643 switch (mode) { |
| 637 if (fullscreen) { | 644 case api.Mode.STANDARD: |
| 638 ui.setBackgroundColor(this.FULLSCREEN_BACKGROUND_COLOR); | 645 if (fullscreen) { |
| 639 } else { | 646 this.setDarkBackground(); |
| 640 ui.setBackgroundColor(this.HORIZON_COLOR); | 647 } else { |
| 648 this.setLightBackground(); |
| 649 } |
| 650 break; |
| 651 case api.Mode.WEB_VR: |
| 652 if (menuMode) { |
| 653 this.setLightBackground(); |
| 654 } else { |
| 655 this.setHiddenBackground(); |
| 656 } |
| 657 break; |
| 641 } | 658 } |
| 642 } | 659 } |
| 643 }; | 660 }; |
| 644 | 661 |
| 645 class Omnibox { | 662 class Omnibox { |
| 646 constructor() { | 663 constructor() { |
| 647 this.enabled = false; | 664 this.enabled = false; |
| 648 | 665 |
| 649 this.domUiElement = new DomUiElement('#omnibox-ui-element'); | 666 this.domUiElement = new DomUiElement('#omnibox-ui-element'); |
| 650 let root = this.domUiElement.domElement; | 667 let root = this.domUiElement.domElement; |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 handleAppButtonClicked() { | 929 handleAppButtonClicked() { |
| 913 this.menuMode = !this.menuMode; | 930 this.menuMode = !this.menuMode; |
| 914 this.updateState(); | 931 this.updateState(); |
| 915 } | 932 } |
| 916 | 933 |
| 917 updateState() { | 934 updateState() { |
| 918 /** @const */ var URL_INDICATOR_VISIBILITY_TIMEOUT_MS = 5000; | 935 /** @const */ var URL_INDICATOR_VISIBILITY_TIMEOUT_MS = 5000; |
| 919 | 936 |
| 920 let mode = this.mode; | 937 let mode = this.mode; |
| 921 let menuMode = this.menuMode; | 938 let menuMode = this.menuMode; |
| 939 let fullscreen = this.fullscreen; |
| 922 | 940 |
| 923 api.doAction(api.Action.SET_CONTENT_PAUSED, {'paused': menuMode}); | 941 api.doAction(api.Action.SET_CONTENT_PAUSED, {'paused': menuMode}); |
| 924 | 942 |
| 925 this.background.setEnabled(mode == api.Mode.STANDARD); | |
| 926 this.contentQuad.setEnabled(mode == api.Mode.STANDARD); | 943 this.contentQuad.setEnabled(mode == api.Mode.STANDARD); |
| 927 this.contentQuad.setFullscreen(this.fullscreen); | 944 this.contentQuad.setFullscreen(fullscreen); |
| 928 this.contentQuad.setMenuMode(menuMode); | 945 this.contentQuad.setMenuMode(menuMode); |
| 929 // TODO(crbug/643815): Set aspect ratio on content quad when available. | 946 // TODO(crbug/643815): Set aspect ratio on content quad when available. |
| 930 this.controls.setEnabled(menuMode); | 947 this.controls.setEnabled(menuMode); |
| 931 this.omnibox.setEnabled(menuMode); | 948 this.omnibox.setEnabled(menuMode); |
| 932 this.urlIndicator.setEnabled(mode == api.Mode.STANDARD && !menuMode); | 949 this.urlIndicator.setEnabled(mode == api.Mode.STANDARD && !menuMode); |
| 933 this.urlIndicator.setVisibilityTimeout( | 950 this.urlIndicator.setVisibilityTimeout( |
| 934 URL_INDICATOR_VISIBILITY_TIMEOUT_MS); | 951 URL_INDICATOR_VISIBILITY_TIMEOUT_MS); |
| 935 this.secureOriginWarnings.setEnabled( | 952 this.secureOriginWarnings.setEnabled( |
| 936 mode == api.Mode.WEB_VR && !menuMode); | 953 mode == api.Mode.WEB_VR && !menuMode); |
| 937 this.background.setEnabled(mode == api.Mode.STANDARD || menuMode); | 954 this.background.setState(mode, menuMode, fullscreen); |
| 938 this.background.setFullscreen(this.fullscreen); | |
| 939 this.tabContainer.setEnabled(mode == api.Mode.STANDARD && menuMode); | 955 this.tabContainer.setEnabled(mode == api.Mode.STANDARD && menuMode); |
| 940 | 956 |
| 941 this.reloadUiButton.setEnabled(mode == api.Mode.STANDARD); | 957 this.reloadUiButton.setEnabled(mode == api.Mode.STANDARD); |
| 942 this.keyboard.setEnabled(mode == api.Mode.STANDARD); | 958 this.keyboard.setEnabled(mode == api.Mode.STANDARD); |
| 943 | 959 |
| 944 api.setUiCssSize( | 960 api.setUiCssSize( |
| 945 uiRootElement.clientWidth, uiRootElement.clientHeight, UI_DPR); | 961 uiRootElement.clientWidth, uiRootElement.clientHeight, UI_DPR); |
| 946 } | 962 } |
| 947 | 963 |
| 948 setSecurityLevel(level) { | 964 setSecurityLevel(level) { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1048 nativeCommandHandler.handleCommand(dict); | 1064 nativeCommandHandler.handleCommand(dict); |
| 1049 } | 1065 } |
| 1050 | 1066 |
| 1051 return { | 1067 return { |
| 1052 initialize: initialize, | 1068 initialize: initialize, |
| 1053 command: command, | 1069 command: command, |
| 1054 }; | 1070 }; |
| 1055 })(); | 1071 })(); |
| 1056 | 1072 |
| 1057 window.addEventListener('load', vrShellUi.initialize); | 1073 window.addEventListener('load', vrShellUi.initialize); |
| OLD | NEW |