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 /** | 8 /** |
9 * Enumeration of valid Anchroing for X axis. | 9 * Enumeration of valid Anchroing for X axis. |
10 * A mesh can either be anchored to the left, right, or center of the main | 10 * A mesh can either be anchored to the left, right, or center of the main |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 ]; | 175 ]; |
176 | 176 |
177 var buttonWidth = 0.3; | 177 var buttonWidth = 0.3; |
178 var buttonHeight = 0.2; | 178 var buttonHeight = 0.2; |
179 var buttonSpacing = 0.5; | 179 var buttonSpacing = 0.5; |
180 var buttonStartPosition = -buttonSpacing * (buttons.length / 2.0 - 0.5); | 180 var buttonStartPosition = -buttonSpacing * (buttons.length / 2.0 - 0.5); |
181 | 181 |
182 for (var i = 0; i < buttons.length; i++) { | 182 for (var i = 0; i < buttons.length; i++) { |
183 var b = document.createElement('div'); | 183 var b = document.createElement('div'); |
184 b.position = 'absolute'; | 184 b.position = 'absolute'; |
185 b.style.top = '200px'; | 185 b.style.top = '384px'; |
186 b.style.left = 50 * i + 'px'; | 186 b.style.left = 50 * i + 'px'; |
187 b.style.width = '50px'; | 187 b.style.width = '50px'; |
188 b.style.height = '50px'; | 188 b.style.height = '50px'; |
189 b.className = 'ui-button'; | 189 b.className = 'ui-button'; |
190 b.textContent = buttons[i][0]; | 190 b.textContent = buttons[i][0]; |
191 | 191 |
192 // Add click behaviour. | 192 // Add click behaviour. |
193 b.addEventListener('click', function(action, e) { | 193 b.addEventListener('click', function(action, e) { |
194 chrome.send('doAction', [action]); | 194 chrome.send('doAction', [action]); |
195 }.bind(undefined, buttons[i][1])); | 195 }.bind(undefined, buttons[i][1])); |
196 | 196 |
197 document.body.appendChild(b); | 197 document.body.appendChild(b); |
198 | 198 |
199 // Add a UI rectangle for the button. | 199 // Add a UI rectangle for the button. |
200 var el = new UiElement(50 * i, 200, 50, 50, buttonWidth, buttonHeight); | 200 var el = new UiElement(50 * i, 384, 50, 50, buttonWidth, buttonHeight); |
201 el.parentId = 0; | 201 el.parentId = 0; |
202 el.setAnchoring(XAnchoring.XNONE, YAnchoring.YBOTTOM); | 202 el.setAnchoring(XAnchoring.XNONE, YAnchoring.YBOTTOM); |
203 el.setTranslation(buttonStartPosition + buttonSpacing * i, -0.3, 0.0); | 203 el.setTranslation(buttonStartPosition + buttonSpacing * i, -0.3, 0.0); |
204 var id = idIndex++; | 204 var id = idIndex++; |
205 addMesh(id, el); | 205 addMesh(id, el); |
206 | 206 |
207 // Add transitions when the mouse hovers over (and leaves) the button. | 207 // Add transitions when the mouse hovers over (and leaves) the button. |
208 b.addEventListener('mouseenter', function(buttonId, width, height, e) { | 208 b.addEventListener('mouseenter', function(buttonId, width, height, e) { |
209 var resize = new Animation(buttonId, 250); | 209 var resize = new Animation(buttonId, 250); |
210 resize.id = idIndex++; | 210 resize.id = idIndex++; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 } | 249 } |
250 chrome.send('updateScene', commands); | 250 chrome.send('updateScene', commands); |
251 } | 251 } |
252 | 252 |
253 return { | 253 return { |
254 initialize: initialize, | 254 initialize: initialize, |
255 }; | 255 }; |
256 })(); | 256 })(); |
257 | 257 |
258 document.addEventListener('DOMContentLoaded', vrShellUi.initialize); | 258 document.addEventListener('DOMContentLoaded', vrShellUi.initialize); |
OLD | NEW |