| 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 api = {}; | 5 var api = {}; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Enumeration of scene update commands. | 8 * Enumeration of scene update commands. |
| 9 * @enum {number} | 9 * @enum {number} |
| 10 * @const | 10 * @const |
| 11 */ | 11 */ |
| 12 api.Command = { | 12 api.Command = { |
| 13 'ADD_ELEMENT': 0, | 13 'ADD_ELEMENT': 0, |
| 14 'UPDATE_ELEMENT': 1, | 14 'UPDATE_ELEMENT': 1, |
| 15 'REMOVE_ELEMENT': 2, | 15 'REMOVE_ELEMENT': 2, |
| 16 'ADD_ANIMATION': 3, | 16 'ADD_ANIMATION': 3, |
| 17 'REMOVE_ANIMATION': 4 | 17 'REMOVE_ANIMATION': 4 |
| 18 }; | 18 }; |
| 19 | 19 |
| 20 /** | 20 /** |
| 21 * Sends one or more commands to native scene management. Commands are used | 21 * Sends one or more commands to native scene management. Commands are used |
| 22 * to add, modify or remove elements and animations. For examples of how to | 22 * to add, modify or remove elements and animations. For examples of how to |
| 23 * format command parameters, refer to examples in scene.js. | 23 * format command parameters, refer to examples in scene.js. |
| 24 * @param {Array<Object>} commands | 24 * @param {Array<Object>} commands |
| 25 */ | 25 */ |
| 26 api.sendCommands = function(commands) { | 26 api.sendCommands = function(commands) { |
| 27 chrome.send('updateScene', commands); | 27 if (commands.length > 0) { |
| 28 chrome.send('updateScene', commands); |
| 29 } |
| 28 }; | 30 }; |
| 29 | 31 |
| 30 /** | 32 /** |
| 31 * Enumeration of valid Anchroing for X axis. | 33 * Enumeration of valid Anchroing for X axis. |
| 32 * An element can either be anchored to the left, right, or center of the main | 34 * An element can either be anchored to the left, right, or center of the main |
| 33 * content rect (or it can be absolutely positioned using NONE). Any | 35 * content rect (or it can be absolutely positioned using NONE). Any |
| 34 * translations applied will be relative to this anchoring. | 36 * translations applied will be relative to this anchoring. |
| 35 * @enum {number} | 37 * @enum {number} |
| 36 * @const | 38 * @const |
| 37 */ | 39 */ |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 /** | 209 /** |
| 208 * Hit-testable implies that the reticle will hit the element, if visible. | 210 * Hit-testable implies that the reticle will hit the element, if visible. |
| 209 * @param {boolean} testable | 211 * @param {boolean} testable |
| 210 */ | 212 */ |
| 211 setHitTestable(testable) { | 213 setHitTestable(testable) { |
| 212 this.properties['hitTestable'] = !!testable; | 214 this.properties['hitTestable'] = !!testable; |
| 213 } | 215 } |
| 214 | 216 |
| 215 /** | 217 /** |
| 216 * Causes an element to be rendered relative to the field of view, rather | 218 * Causes an element to be rendered relative to the field of view, rather |
| 217 * than the scene. Elements locked in this way should not have a parent. | 219 * than the scene. Elements locked in this way should not have a parent. |
| 218 * @param {boolean} locked | 220 * @param {boolean} locked |
| 219 */ | 221 */ |
| 220 setLockToFieldOfView(locked) { | 222 setLockToFieldOfView(locked) { |
| 221 this.properties['lockToFov'] = !!locked; | 223 this.properties['lockToFov'] = !!locked; |
| 222 } | 224 } |
| 225 |
| 226 /** |
| 227 * Causes an element to be rendered with a specified opacity, between 0.0 and |
| 228 * 1.0. Opacity is inherited by children. |
| 229 * @param {number} opacity |
| 230 */ |
| 231 setOpacity(opacity) { |
| 232 this.properties['opacity'] = opacity; |
| 233 } |
| 223 }; | 234 }; |
| 224 | 235 |
| 225 /** | 236 /** |
| 226 * Represents a new UI element. This object builds on UiElementUpdate, | 237 * Represents a new UI element. This object builds on UiElementUpdate, |
| 227 * forcing the underlying texture coordinates to be specified. | 238 * forcing the underlying texture coordinates to be specified. |
| 228 * @struct | 239 * @struct |
| 229 */ | 240 */ |
| 230 api.UiElement = class extends api.UiElementUpdate { | 241 api.UiElement = class extends api.UiElementUpdate { |
| 231 /** | 242 /** |
| 232 * Constructor of UiElement. | 243 * Constructor of UiElement. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 250 /** | 261 /** |
| 251 * Enumeration of animatable properties. | 262 * Enumeration of animatable properties. |
| 252 * @enum {number} | 263 * @enum {number} |
| 253 * @const | 264 * @const |
| 254 */ | 265 */ |
| 255 api.Property = { | 266 api.Property = { |
| 256 'COPYRECT': 0, | 267 'COPYRECT': 0, |
| 257 'SIZE': 1, | 268 'SIZE': 1, |
| 258 'TRANSLATION': 2, | 269 'TRANSLATION': 2, |
| 259 'SCALE': 3, | 270 'SCALE': 3, |
| 260 'ROTATION': 4 | 271 'ROTATION': 4, |
| 272 'OPACITY': 5 |
| 261 }; | 273 }; |
| 262 | 274 |
| 263 /** | 275 /** |
| 264 * Enumeration of easing type. | 276 * Enumeration of easing type. |
| 265 * @enum {number} | 277 * @enum {number} |
| 266 * @const | 278 * @const |
| 267 */ | 279 */ |
| 268 api.Easing = { | 280 api.Easing = { |
| 269 'LINEAR': 0, | 281 'LINEAR': 0, |
| 270 'CUBICBEZIER': 1, | 282 'CUBICBEZIER': 1, |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 * @param {number} x | 364 * @param {number} x |
| 353 * @param {number} y | 365 * @param {number} y |
| 354 * @param {number} z | 366 * @param {number} z |
| 355 */ | 367 */ |
| 356 setTranslation(x, y, z) { | 368 setTranslation(x, y, z) { |
| 357 this.property = api.Property.TRANSLATION; | 369 this.property = api.Property.TRANSLATION; |
| 358 this.to.x = x; | 370 this.to.x = x; |
| 359 this.to.y = y; | 371 this.to.y = y; |
| 360 this.to.z = z; | 372 this.to.z = z; |
| 361 } | 373 } |
| 374 |
| 375 /** |
| 376 * Set the animation's final element opacity. |
| 377 * @param {number} opacity |
| 378 */ |
| 379 setOpacity(opacity) { |
| 380 this.property = api.Property.OPACITY; |
| 381 this.to.x = opacity; |
| 382 } |
| 362 }; | 383 }; |
| OLD | NEW |