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

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

Issue 2721203003: Background correctly adapts to state in Chrome VR. (Closed)
Patch Set: 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 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) {
tiborg 2017/03/01 18:28:15 This method should probably be in some general uti
cjgrant 2017/03/01 22:30:48 Agreed.
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:
cjgrant 2017/03/01 22:30:48 For another change (possibly by me) - Mode used to
cjgrant 2017/03/01 22:30:48 I could be wrong, but this appears to be: if (men
tiborg 2017/03/02 20:39:29 I played around with it a bit and I agree that the
tiborg 2017/03/02 20:39:29 Regarding the mode boolean: sounds good to me.
638 ui.setBackgroundColor(this.FULLSCREEN_BACKGROUND_COLOR); 645 if (fullscreen) {
639 } else { 646 if (menuMode) {
640 ui.setBackgroundColor(this.HORIZON_COLOR); 647 this.setLightBackground();
648 } else {
649 this.setDarkBackground();
650 }
651 } else {
652 this.setLightBackground();
653 }
654 break;
655 case api.Mode.WEB_VR:
656 if (menuMode) {
657 this.setLightBackground();
658 } else {
659 this.setHiddenBackground();
660 }
661 break;
641 } 662 }
642 } 663 }
643 }; 664 };
644 665
645 class Omnibox { 666 class Omnibox {
646 constructor() { 667 constructor() {
647 this.enabled = false; 668 this.enabled = false;
648 669
649 this.domUiElement = new DomUiElement('#omnibox-ui-element'); 670 this.domUiElement = new DomUiElement('#omnibox-ui-element');
650 let root = this.domUiElement.domElement; 671 let root = this.domUiElement.domElement;
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 handleAppButtonClicked() { 913 handleAppButtonClicked() {
893 this.menuMode = !this.menuMode; 914 this.menuMode = !this.menuMode;
894 this.updateState(); 915 this.updateState();
895 } 916 }
896 917
897 updateState() { 918 updateState() {
898 /** @const */ var URL_INDICATOR_VISIBILITY_TIMEOUT_MS = 5000; 919 /** @const */ var URL_INDICATOR_VISIBILITY_TIMEOUT_MS = 5000;
899 920
900 let mode = this.mode; 921 let mode = this.mode;
901 let menuMode = this.menuMode; 922 let menuMode = this.menuMode;
923 let fullscreen = this.fullscreen;
902 924
903 api.doAction(api.Action.SET_CONTENT_PAUSED, {'paused': menuMode}); 925 api.doAction(api.Action.SET_CONTENT_PAUSED, {'paused': menuMode});
904 926
905 this.background.setEnabled(mode == api.Mode.STANDARD);
906 this.contentQuad.setEnabled(mode == api.Mode.STANDARD); 927 this.contentQuad.setEnabled(mode == api.Mode.STANDARD);
907 this.contentQuad.setFullscreen(this.fullscreen); 928 this.contentQuad.setFullscreen(fullscreen);
908 this.contentQuad.setMenuMode(menuMode); 929 this.contentQuad.setMenuMode(menuMode);
909 // TODO(crbug/643815): Set aspect ratio on content quad when available. 930 // TODO(crbug/643815): Set aspect ratio on content quad when available.
910 this.controls.setEnabled(menuMode); 931 this.controls.setEnabled(menuMode);
911 this.omnibox.setEnabled(menuMode); 932 this.omnibox.setEnabled(menuMode);
912 this.urlIndicator.setEnabled(mode == api.Mode.STANDARD && !menuMode); 933 this.urlIndicator.setEnabled(mode == api.Mode.STANDARD && !menuMode);
913 this.urlIndicator.setVisibilityTimeout( 934 this.urlIndicator.setVisibilityTimeout(
914 URL_INDICATOR_VISIBILITY_TIMEOUT_MS); 935 URL_INDICATOR_VISIBILITY_TIMEOUT_MS);
915 this.secureOriginWarnings.setEnabled( 936 this.secureOriginWarnings.setEnabled(
916 mode == api.Mode.WEB_VR && !menuMode); 937 mode == api.Mode.WEB_VR && !menuMode);
917 this.background.setEnabled(mode == api.Mode.STANDARD || menuMode); 938 this.background.setState(mode, menuMode, fullscreen);
918 this.background.setFullscreen(this.fullscreen);
919 this.tabContainer.setEnabled(mode == api.Mode.STANDARD && menuMode); 939 this.tabContainer.setEnabled(mode == api.Mode.STANDARD && menuMode);
920 940
921 this.reloadUiButton.setEnabled(mode == api.Mode.STANDARD); 941 this.reloadUiButton.setEnabled(mode == api.Mode.STANDARD);
922 942
923 api.setUiCssSize( 943 api.setUiCssSize(
924 uiRootElement.clientWidth, uiRootElement.clientHeight, UI_DPR); 944 uiRootElement.clientWidth, uiRootElement.clientHeight, UI_DPR);
925 } 945 }
926 946
927 setSecurityLevel(level) { 947 setSecurityLevel(level) {
928 this.urlIndicator.setSecurityLevel(level); 948 this.urlIndicator.setSecurityLevel(level);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 nativeCommandHandler.handleCommand(dict); 1047 nativeCommandHandler.handleCommand(dict);
1028 } 1048 }
1029 1049
1030 return { 1050 return {
1031 initialize: initialize, 1051 initialize: initialize,
1032 command: command, 1052 command: command,
1033 }; 1053 };
1034 })(); 1054 })();
1035 1055
1036 window.addEventListener('load', vrShellUi.initialize); 1056 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