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

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

Issue 2740013003: Exiting menu mode when content preview is clicked (Closed)
Patch Set: Resolving conflict 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 | « chrome/browser/resources/vr_shell/vr_shell_ui.html ('k') | 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 21 matching lines...) Expand all
32 /** @const */ this.SCREEN_RATIO = 16 / 9; 32 /** @const */ this.SCREEN_RATIO = 16 / 9;
33 /** @const */ this.BROWSING_SCREEN_DISTANCE = 2.0; 33 /** @const */ this.BROWSING_SCREEN_DISTANCE = 2.0;
34 /** @const */ this.FULLSCREEN_DISTANCE = 3.0; 34 /** @const */ this.FULLSCREEN_DISTANCE = 3.0;
35 /** @const */ this.CSS_WIDTH_PIXELS = 960.0; 35 /** @const */ this.CSS_WIDTH_PIXELS = 960.0;
36 /** @const */ this.CSS_HEIGHT_PIXELS = 640.0; 36 /** @const */ this.CSS_HEIGHT_PIXELS = 640.0;
37 /** @const */ this.DPR = 1.2; 37 /** @const */ this.DPR = 1.2;
38 /** @const */ this.MENU_MODE_SCREEN_DISTANCE = 2.0; 38 /** @const */ this.MENU_MODE_SCREEN_DISTANCE = 2.0;
39 /** @const */ this.MENU_MODE_SCREEN_HEIGHT = 0.8; 39 /** @const */ this.MENU_MODE_SCREEN_HEIGHT = 0.8;
40 /** @const */ this.MENU_MODE_SCREEN_ELEVATION = 0.2; 40 /** @const */ this.MENU_MODE_SCREEN_ELEVATION = 0.2;
41 /** @const */ this.BACKGROUND_DISTANCE_MULTIPLIER = 1.414; 41 /** @const */ this.BACKGROUND_DISTANCE_MULTIPLIER = 1.414;
42 /** @const */ this.DOM_INTERCEPTOR_SELECTOR = '#content-interceptor';
43 /** @const */ this.DOM_INTERCEPTOR_ELEVATION = 0.01;
42 44
43 this.menuMode = false; 45 this.menuMode = false;
44 this.fullscreen = false; 46 this.fullscreen = false;
45 47
46 let element = new api.UiElement(0, 0, 0, 0); 48 let element = new api.UiElement(0, 0, 0, 0);
47 element.setFill(new api.Content()); 49 element.setFill(new api.Content());
48 element.setVisible(false); 50 element.setVisible(false);
49 element.setSize( 51 element.setSize(
50 this.SCREEN_HEIGHT * this.SCREEN_RATIO, this.SCREEN_HEIGHT); 52 this.SCREEN_HEIGHT * this.SCREEN_RATIO, this.SCREEN_HEIGHT);
51 element.setTranslation(0, 0, -this.BROWSING_SCREEN_DISTANCE); 53 element.setTranslation(0, 0, -this.BROWSING_SCREEN_DISTANCE);
52 this.elementId = ui.addElement(element); 54 this.elementId = ui.addElement(element);
53 55
54 // Place an invisible (fill none) but hittable plane behind the content 56 // Place an invisible (fill none) but hittable plane behind the content
55 // quad, to keep the reticle roughly planar with the content if near 57 // quad, to keep the reticle roughly planar with the content if near
56 // content. 58 // content.
57 let backPlane = new api.UiElement(0, 0, 0, 0); 59 let backPlane = new api.UiElement(0, 0, 0, 0);
58 backPlane.setSize(1000, 1000); 60 backPlane.setSize(1000, 1000);
59 backPlane.setTranslation(0, 0, -0.01); 61 backPlane.setTranslation(0, 0, -0.01);
60 backPlane.setParentId(this.elementId); 62 backPlane.setParentId(this.elementId);
61 backPlane.setFill(new api.NoFill()); 63 backPlane.setFill(new api.NoFill());
62 ui.addElement(backPlane); 64 ui.addElement(backPlane);
63 65
66 // Place invisible plane on top of content quad, to intercept the clicks
67 // while on menu mode.
68 this.interceptor = new DomUiElement(this.DOM_INTERCEPTOR_SELECTOR);
69 let update = new api.UiElementUpdate();
70 update.setTranslation(0, 0, this.DOM_INTERCEPTOR_ELEVATION);
71 update.setVisible(false);
72 update.setParentId(this.elementId);
73 update.setSize(
74 this.MENU_MODE_SCREEN_HEIGHT * this.SCREEN_RATIO,
75 this.MENU_MODE_SCREEN_HEIGHT);
76 ui.updateElement(this.interceptor.id, update);
77 let interceptorButton =
78 document.querySelector(this.DOM_INTERCEPTOR_SELECTOR);
79 interceptorButton.addEventListener('click', function() {
80 uiManager.exitMenuMode();
81 ui.flush();
82 });
83
64 this.updateState(); 84 this.updateState();
65 } 85 }
66 86
67 setEnabled(enabled) { 87 setEnabled(enabled) {
68 let update = new api.UiElementUpdate(); 88 let update = new api.UiElementUpdate();
69 update.setVisible(enabled); 89 update.setVisible(enabled);
70 ui.updateElement(this.elementId, update); 90 ui.updateElement(this.elementId, update);
71 if (enabled) { 91 if (enabled) {
72 api.setContentCssSize( 92 api.setContentCssSize(
73 this.CSS_WIDTH_PIXELS, this.CSS_HEIGHT_PIXELS, this.DPR); 93 this.CSS_WIDTH_PIXELS, this.CSS_HEIGHT_PIXELS, this.DPR);
(...skipping 25 matching lines...) Expand all
99 119
100 // Mode-specific overrides. 120 // Mode-specific overrides.
101 if (this.menuMode) { 121 if (this.menuMode) {
102 y = this.MENU_MODE_SCREEN_ELEVATION; 122 y = this.MENU_MODE_SCREEN_ELEVATION;
103 distance = this.MENU_MODE_SCREEN_DISTANCE; 123 distance = this.MENU_MODE_SCREEN_DISTANCE;
104 height = this.MENU_MODE_SCREEN_HEIGHT; 124 height = this.MENU_MODE_SCREEN_HEIGHT;
105 } else if (this.fullscreen) { 125 } else if (this.fullscreen) {
106 distance = this.FULLSCREEN_DISTANCE; 126 distance = this.FULLSCREEN_DISTANCE;
107 } 127 }
108 128
129 let update = new api.UiElementUpdate();
130 update.setVisible(this.menuMode);
131 ui.updateElement(this.interceptor.id, update);
132
109 let anim; 133 let anim;
110 anim = new api.Animation(this.elementId, ANIM_DURATION); 134 anim = new api.Animation(this.elementId, ANIM_DURATION);
111 anim.setTranslation(0, y, -distance); 135 anim.setTranslation(0, y, -distance);
112 anim.setEasing(new api.InOutEasing()); 136 anim.setEasing(new api.InOutEasing());
113 ui.addAnimation(anim); 137 ui.addAnimation(anim);
114 anim = new api.Animation(this.elementId, ANIM_DURATION); 138 anim = new api.Animation(this.elementId, ANIM_DURATION);
115 anim.setSize(height * this.SCREEN_RATIO, height); 139 anim.setSize(height * this.SCREEN_RATIO, height);
116 anim.setEasing(new api.InOutEasing()); 140 anim.setEasing(new api.InOutEasing());
117 ui.addAnimation(anim); 141 ui.addAnimation(anim);
118 142
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 1016
993 setHistoryButtonsEnabled(canGoBack, canGoForward) { 1017 setHistoryButtonsEnabled(canGoBack, canGoForward) {
994 this.canGoBack = canGoBack; 1018 this.canGoBack = canGoBack;
995 this.canGoForward = canGoForward; 1019 this.canGoForward = canGoForward;
996 1020
997 /** No need to call updateState to adjust button properties. */ 1021 /** No need to call updateState to adjust button properties. */
998 this.controls.setBackButtonEnabled(this.canGoBack || this.fullscreen); 1022 this.controls.setBackButtonEnabled(this.canGoBack || this.fullscreen);
999 this.controls.setForwardButtonEnabled(this.canGoForward); 1023 this.controls.setForwardButtonEnabled(this.canGoForward);
1000 } 1024 }
1001 1025
1026 exitMenuMode() {
1027 if (this.menuMode) {
1028 this.menuMode = false;
1029 this.updateState();
1030 }
1031 }
1032
1002 updateState() { 1033 updateState() {
1003 /** @const */ var URL_INDICATOR_VISIBILITY_TIMEOUT_MS = 5000; 1034 /** @const */ var URL_INDICATOR_VISIBILITY_TIMEOUT_MS = 5000;
1004 1035
1005 let mode = this.mode; 1036 let mode = this.mode;
1006 let menuMode = this.menuMode; 1037 let menuMode = this.menuMode;
1007 let fullscreen = this.fullscreen; 1038 let fullscreen = this.fullscreen;
1008 1039
1009 api.doAction(api.Action.SET_CONTENT_PAUSED, {'paused': menuMode}); 1040 api.doAction(api.Action.SET_CONTENT_PAUSED, {'paused': menuMode});
1010 1041
1011 this.contentQuad.setEnabled(mode == api.Mode.STANDARD); 1042 this.contentQuad.setEnabled(mode == api.Mode.STANDARD);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 nativeCommandHandler.handleCommand(dict); 1170 nativeCommandHandler.handleCommand(dict);
1140 } 1171 }
1141 1172
1142 return { 1173 return {
1143 initialize: initialize, 1174 initialize: initialize,
1144 command: command, 1175 command: command,
1145 }; 1176 };
1146 })(); 1177 })();
1147 1178
1148 window.addEventListener('load', vrShellUi.initialize); 1179 window.addEventListener('load', vrShellUi.initialize);
OLDNEW
« no previous file with comments | « chrome/browser/resources/vr_shell/vr_shell_ui.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698