| 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 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 /** | 98 /** |
| 99 * Sets the CSS size for this page. | 99 * Sets the CSS size for this page. |
| 100 * @param {number} width | 100 * @param {number} width |
| 101 * @param {number} height | 101 * @param {number} height |
| 102 * @param {number} dpr | 102 * @param {number} dpr |
| 103 */ | 103 */ |
| 104 api.setUiCssSize = function(width, height, dpr) { | 104 api.setUiCssSize = function(width, height, dpr) { |
| 105 chrome.send('setUiCssSize', [width, height, dpr]); | 105 chrome.send('setUiCssSize', [width, height, dpr]); |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 api.FillType = { |
| 109 'NONE': 0, |
| 110 'SPRITE': 1, |
| 111 'OPAQUE_GRADIENT': 2, |
| 112 'GRID_GRADIENT': 3 |
| 113 }; |
| 114 |
| 115 api.Fill = class { |
| 116 constructor(type) { |
| 117 this.properties = {}; |
| 118 this.properties['fillType'] = type; |
| 119 } |
| 120 } |
| 121 |
| 122 api.Sprite = class extends api.Fill { |
| 123 constructor(pixelX, pixelY, pixelWidth, pixelHeight) { |
| 124 super(api.FillType.SPRITE); |
| 125 this.properties.copyRect = {x: pixelX, y: pixelY, width: pixelWidth, height:
pixelHeight}; |
| 126 } |
| 127 } |
| 128 |
| 129 api.OpaqueGradient = class extends api.Fill { |
| 130 constructor(edgeColor, centerColor) { |
| 131 super(api.FillType.OPAQUE_GRADIENT); |
| 132 this.properties.edgeColor = edgeColor; |
| 133 this.properties.centerColor = centerColor; |
| 134 } |
| 135 } |
| 136 |
| 137 api.GridGradient = class extends api.Fill { |
| 138 constructor(edgeColor, centerColor, tileNumber) { |
| 139 super(api.FillType.GRID_GRADIENT); |
| 140 this.properties.edgeColor = edgeColor; |
| 141 this.properties.centerColor = centerColor; |
| 142 this.properties.tileNumber = tileNumber; |
| 143 } |
| 144 } |
| 145 |
| 108 /** | 146 /** |
| 109 * Represents updates to UI element properties. Any properties set on this | 147 * Represents updates to UI element properties. Any properties set on this |
| 110 * object are relayed to an underlying native element via scene command. | 148 * object are relayed to an underlying native element via scene command. |
| 111 * Properties that are not set on this object are left unchanged. | 149 * Properties that are not set on this object are left unchanged. |
| 112 * @struct | 150 * @struct |
| 113 */ | 151 */ |
| 114 api.UiElementUpdate = class { | 152 api.UiElementUpdate = class { |
| 115 constructor() { | 153 constructor() { |
| 116 /** @private {!Object} */ | 154 /** @private {!Object} */ |
| 117 this.properties = {'id': -1}; | 155 this.properties = {'id': -1}; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 } | 262 } |
| 225 | 263 |
| 226 /** | 264 /** |
| 227 * Causes an element to be rendered with a specified opacity, between 0.0 and | 265 * Causes an element to be rendered with a specified opacity, between 0.0 and |
| 228 * 1.0. Opacity is inherited by children. | 266 * 1.0. Opacity is inherited by children. |
| 229 * @param {number} opacity | 267 * @param {number} opacity |
| 230 */ | 268 */ |
| 231 setOpacity(opacity) { | 269 setOpacity(opacity) { |
| 232 this.properties['opacity'] = opacity; | 270 this.properties['opacity'] = opacity; |
| 233 } | 271 } |
| 272 |
| 273 setFill(fill) { |
| 274 Object.assign(this.properties, fill.properties); |
| 275 } |
| 234 }; | 276 }; |
| 235 | 277 |
| 236 /** | 278 /** |
| 237 * Represents a new UI element. This object builds on UiElementUpdate, | 279 * Represents a new UI element. This object builds on UiElementUpdate, |
| 238 * forcing the underlying texture coordinates to be specified. | 280 * forcing the underlying texture coordinates to be specified. |
| 239 * @struct | 281 * @struct |
| 240 */ | 282 */ |
| 241 api.UiElement = class extends api.UiElementUpdate { | 283 api.UiElement = class extends api.UiElementUpdate { |
| 242 /** | 284 /** |
| 243 * Constructor of UiElement. | 285 * Constructor of UiElement. |
| 244 * pixelX and pixelY values indicate the left upper corner; pixelWidth and | 286 * pixelX and pixelY values indicate the left upper corner; pixelWidth and |
| 245 * pixelHeight is width and height of the texture to be copied from the web | 287 * pixelHeight is width and height of the texture to be copied from the web |
| 246 * contents. | 288 * contents. |
| 247 * @param {number} pixelX | 289 * @param {number} pixelX |
| 248 * @param {number} pixelY | 290 * @param {number} pixelY |
| 249 * @param {number} pixelWidth | 291 * @param {number} pixelWidth |
| 250 * @param {number} pixelHeight | 292 * @param {number} pixelHeight |
| 251 */ | 293 */ |
| 252 constructor(pixelX, pixelY, pixelWidth, pixelHeight) { | 294 constructor(pixelX, pixelY, pixelWidth, pixelHeight) { |
| 253 super(); | 295 super(); |
| 254 | 296 |
| 255 /** @private {Object} */ | 297 this.setFill(new api.Sprite(pixelX, pixelY, pixelWidth, pixelHeight)); |
| 256 this.properties['copyRect'] = | |
| 257 {x: pixelX, y: pixelY, width: pixelWidth, height: pixelHeight}; | |
| 258 } | 298 } |
| 259 }; | 299 }; |
| 260 | 300 |
| 261 /** | 301 /** |
| 262 * Enumeration of animatable properties. | 302 * Enumeration of animatable properties. |
| 263 * @enum {number} | 303 * @enum {number} |
| 264 * @const | 304 * @const |
| 265 */ | 305 */ |
| 266 api.Property = { | 306 api.Property = { |
| 267 'COPYRECT': 0, | 307 'COPYRECT': 0, |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 | 414 |
| 375 /** | 415 /** |
| 376 * Set the animation's final element opacity. | 416 * Set the animation's final element opacity. |
| 377 * @param {number} opacity | 417 * @param {number} opacity |
| 378 */ | 418 */ |
| 379 setOpacity(opacity) { | 419 setOpacity(opacity) { |
| 380 this.property = api.Property.OPACITY; | 420 this.property = api.Property.OPACITY; |
| 381 this.to.x = opacity; | 421 this.to.x = opacity; |
| 382 } | 422 } |
| 383 }; | 423 }; |
| OLD | NEW |