| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 /** | 112 /** |
| 113 * Sets the CSS size for this page. | 113 * Sets the CSS size for this page. |
| 114 * @param {number} width | 114 * @param {number} width |
| 115 * @param {number} height | 115 * @param {number} height |
| 116 * @param {number} dpr | 116 * @param {number} dpr |
| 117 */ | 117 */ |
| 118 api.setUiCssSize = function(width, height, dpr) { | 118 api.setUiCssSize = function(width, height, dpr) { |
| 119 chrome.send('setUiCssSize', [width, height, dpr]); | 119 chrome.send('setUiCssSize', [width, height, dpr]); |
| 120 }; | 120 }; |
| 121 | 121 |
| 122 api.FillType = { |
| 123 'NONE': 0, |
| 124 'SPRITE': 1, |
| 125 'OPAQUE_GRADIENT': 2, |
| 126 'GRID_GRADIENT': 3, |
| 127 'CONTENT': 4 |
| 128 }; |
| 129 |
| 130 api.Fill = class { |
| 131 constructor(type) { |
| 132 this.properties = {}; |
| 133 this.properties['fillType'] = type; |
| 134 } |
| 135 } |
| 136 |
| 137 api.Sprite = class extends api.Fill { |
| 138 constructor(pixelX, pixelY, pixelWidth, pixelHeight) { |
| 139 super(api.FillType.SPRITE); |
| 140 this.properties.copyRect = |
| 141 {x: pixelX, y: pixelY, width: pixelWidth, height: pixelHeight}; |
| 142 } |
| 143 } |
| 144 |
| 145 api.OpaqueGradient = class extends api.Fill { |
| 146 constructor(edgeColor, centerColor) { |
| 147 super(api.FillType.OPAQUE_GRADIENT); |
| 148 this.properties.edgeColor = edgeColor; |
| 149 this.properties.centerColor = centerColor; |
| 150 } |
| 151 } |
| 152 |
| 153 api.GridGradient = class extends api.Fill { |
| 154 constructor(edgeColor, centerColor, gridlineCount) { |
| 155 super(api.FillType.GRID_GRADIENT); |
| 156 this.properties.edgeColor = edgeColor; |
| 157 this.properties.centerColor = centerColor; |
| 158 this.properties.gridlineCount = gridlineCount; |
| 159 } |
| 160 } |
| 161 |
| 162 api.Content = class extends api.Fill { |
| 163 constructor() { |
| 164 super(api.FillType.CONTENT); |
| 165 } |
| 166 } |
| 167 |
| 122 /** | 168 /** |
| 123 * Represents updates to UI element properties. Any properties set on this | 169 * Represents updates to UI element properties. Any properties set on this |
| 124 * object are relayed to an underlying native element via scene command. | 170 * object are relayed to an underlying native element via scene command. |
| 125 * Properties that are not set on this object are left unchanged. | 171 * Properties that are not set on this object are left unchanged. |
| 126 * @struct | 172 * @struct |
| 127 */ | 173 */ |
| 128 api.UiElementUpdate = class { | 174 api.UiElementUpdate = class { |
| 129 constructor() { | 175 constructor() { |
| 130 /** @private {!Object} */ | 176 /** @private {!Object} */ |
| 131 this.properties = {'id': -1}; | 177 this.properties = {'id': -1}; |
| 132 } | 178 } |
| 133 | 179 |
| 134 /** | 180 /** |
| 135 * Set the id of the element to update. | 181 * Set the id of the element to update. |
| 136 * @param {number} id | 182 * @param {number} id |
| 137 */ | 183 */ |
| 138 setId(id) { | 184 setId(id) { |
| 139 this.properties['id'] = id; | 185 this.properties['id'] = id; |
| 140 } | 186 } |
| 141 | 187 |
| 142 /** | 188 /** |
| 143 * Operates on an instance of MyClass and returns something. | |
| 144 */ | |
| 145 setIsContentQuad() { | |
| 146 this.properties['contentQuad'] = true; | |
| 147 } | |
| 148 | |
| 149 /** | |
| 150 * Specify a parent for this element. If set, this element is positioned | 189 * Specify a parent for this element. If set, this element is positioned |
| 151 * relative to its parent element, rather than absolutely. This allows | 190 * relative to its parent element, rather than absolutely. This allows |
| 152 * elements to automatically move with a parent. | 191 * elements to automatically move with a parent. |
| 153 * @param {number} id | 192 * @param {number} id |
| 154 */ | 193 */ |
| 155 setParentId(id) { | 194 setParentId(id) { |
| 156 this.properties['parentId'] = id; | 195 this.properties['parentId'] = id; |
| 157 } | 196 } |
| 158 | 197 |
| 159 /** | 198 /** |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 } | 277 } |
| 239 | 278 |
| 240 /** | 279 /** |
| 241 * Causes an element to be rendered with a specified opacity, between 0.0 and | 280 * Causes an element to be rendered with a specified opacity, between 0.0 and |
| 242 * 1.0. Opacity is inherited by children. | 281 * 1.0. Opacity is inherited by children. |
| 243 * @param {number} opacity | 282 * @param {number} opacity |
| 244 */ | 283 */ |
| 245 setOpacity(opacity) { | 284 setOpacity(opacity) { |
| 246 this.properties['opacity'] = opacity; | 285 this.properties['opacity'] = opacity; |
| 247 } | 286 } |
| 287 |
| 288 setFill(fill) { |
| 289 Object.assign(this.properties, fill.properties); |
| 290 } |
| 248 }; | 291 }; |
| 249 | 292 |
| 250 /** | 293 /** |
| 251 * Represents a new UI element. This object builds on UiElementUpdate, | 294 * Represents a new UI element. This object builds on UiElementUpdate, |
| 252 * forcing the underlying texture coordinates to be specified. | 295 * forcing the underlying texture coordinates to be specified. |
| 253 * @struct | 296 * @struct |
| 254 */ | 297 */ |
| 255 api.UiElement = class extends api.UiElementUpdate { | 298 api.UiElement = class extends api.UiElementUpdate { |
| 256 /** | 299 /** |
| 257 * Constructor of UiElement. | 300 * Constructor of UiElement. |
| 258 * pixelX and pixelY values indicate the left upper corner; pixelWidth and | 301 * pixelX and pixelY values indicate the left upper corner; pixelWidth and |
| 259 * pixelHeight is width and height of the texture to be copied from the web | 302 * pixelHeight is width and height of the texture to be copied from the web |
| 260 * contents. | 303 * contents. |
| 261 * @param {number} pixelX | 304 * @param {number} pixelX |
| 262 * @param {number} pixelY | 305 * @param {number} pixelY |
| 263 * @param {number} pixelWidth | 306 * @param {number} pixelWidth |
| 264 * @param {number} pixelHeight | 307 * @param {number} pixelHeight |
| 265 */ | 308 */ |
| 266 constructor(pixelX, pixelY, pixelWidth, pixelHeight) { | 309 constructor(pixelX, pixelY, pixelWidth, pixelHeight) { |
| 267 super(); | 310 super(); |
| 268 | 311 |
| 269 /** @private {Object} */ | 312 this.setFill(new api.Sprite(pixelX, pixelY, pixelWidth, pixelHeight)); |
| 270 this.properties['copyRect'] = | |
| 271 {x: pixelX, y: pixelY, width: pixelWidth, height: pixelHeight}; | |
| 272 } | 313 } |
| 273 }; | 314 }; |
| 274 | 315 |
| 275 /** | 316 /** |
| 276 * Enumeration of animatable properties. | 317 * Enumeration of animatable properties. |
| 277 * @enum {number} | 318 * @enum {number} |
| 278 * @const | 319 * @const |
| 279 */ | 320 */ |
| 280 api.Property = { | 321 api.Property = { |
| 281 'COPYRECT': 0, | 322 'COPYRECT': 0, |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 | 429 |
| 389 /** | 430 /** |
| 390 * Set the animation's final element opacity. | 431 * Set the animation's final element opacity. |
| 391 * @param {number} opacity | 432 * @param {number} opacity |
| 392 */ | 433 */ |
| 393 setOpacity(opacity) { | 434 setOpacity(opacity) { |
| 394 this.property = api.Property.OPACITY; | 435 this.property = api.Property.OPACITY; |
| 395 this.to.x = opacity; | 436 this.to.x = opacity; |
| 396 } | 437 } |
| 397 }; | 438 }; |
| OLD | NEW |