| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 api.FillType = { | 123 api.FillType = { |
| 124 'NONE': 0, | 124 'NONE': 0, |
| 125 'SPRITE': 1, | 125 'SPRITE': 1, |
| 126 'OPAQUE_GRADIENT': 2, | 126 'OPAQUE_GRADIENT': 2, |
| 127 'GRID_GRADIENT': 3, | 127 'GRID_GRADIENT': 3, |
| 128 'CONTENT': 4 | 128 'CONTENT': 4 |
| 129 }; | 129 }; |
| 130 | 130 |
| 131 /** |
| 132 * Abstract fill base class. |
| 133 * @abstract |
| 134 */ |
| 131 api.Fill = class { | 135 api.Fill = class { |
| 132 constructor(type) { | 136 constructor(type) { |
| 133 this.properties = {}; | 137 this.properties = {}; |
| 134 this.properties['fillType'] = type; | 138 this.properties['fillType'] = type; |
| 135 } | 139 } |
| 136 } | 140 } |
| 137 | 141 |
| 138 api.Sprite = class extends api.Fill { | 142 api.Sprite = class extends api.Fill { |
| 139 constructor(pixelX, pixelY, pixelWidth, pixelHeight) { | 143 constructor(pixelX, pixelY, pixelWidth, pixelHeight) { |
| 140 super(api.FillType.SPRITE); | 144 super(api.FillType.SPRITE); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 'SCALE': 3, | 330 'SCALE': 3, |
| 327 'ROTATION': 4, | 331 'ROTATION': 4, |
| 328 'OPACITY': 5 | 332 'OPACITY': 5 |
| 329 }; | 333 }; |
| 330 | 334 |
| 331 /** | 335 /** |
| 332 * Enumeration of easing type. | 336 * Enumeration of easing type. |
| 333 * @enum {number} | 337 * @enum {number} |
| 334 * @const | 338 * @const |
| 335 */ | 339 */ |
| 336 api.Easing = { | 340 api.EasingType = { |
| 337 'LINEAR': 0, | 341 'LINEAR': 0, |
| 338 'CUBICBEZIER': 1, | 342 'CUBICBEZIER': 1, |
| 339 'EASEIN': 2, | 343 'EASEIN': 2, |
| 340 'EASEOUT': 3 | 344 'EASEOUT': 3 |
| 341 }; | 345 }; |
| 342 | 346 |
| 347 /** @const */ var DEFAULT_EASING_POW = 2; |
| 348 /** @const */ var DEFAULT_CUBIC_BEZIER_P1X = 0.25; |
| 349 /** @const */ var DEFAULT_CUBIC_BEZIER_P1Y = 0; |
| 350 /** @const */ var DEFAULT_CUBIC_BEZIER_P2X = 0.75; |
| 351 /** @const */ var DEFAULT_CUBIC_BEZIER_P2Y = 1; |
| 352 |
| 353 /** |
| 354 * Abstract easing base class. |
| 355 * @abstract |
| 356 */ |
| 357 api.Easing = class { |
| 358 constructor(type) { |
| 359 this.type = type; |
| 360 } |
| 361 } |
| 362 |
| 363 api.LinearEasing = class extends api.Easing { |
| 364 constructor() { |
| 365 super(api.EasingType.LINEAR); |
| 366 } |
| 367 } |
| 368 |
| 369 api.CubicBezierEasing = class extends api.Easing { |
| 370 constructor( |
| 371 p1x = DEFAULT_CUBIC_BEZIER_P1X, |
| 372 p1y = DEFAULT_CUBIC_BEZIER_P1Y, |
| 373 p2x = DEFAULT_CUBIC_BEZIER_P2X, |
| 374 p2y = DEFAULT_CUBIC_BEZIER_P2Y) { |
| 375 super(api.EasingType.CUBICBEZIER); |
| 376 this.p1x = p1x; |
| 377 this.p1y = p1y; |
| 378 this.p2x = p2x; |
| 379 this.p2y = p2y; |
| 380 } |
| 381 } |
| 382 |
| 383 api.InEasing = class extends api.Easing { |
| 384 constructor(pow = DEFAULT_EASING_POW) { |
| 385 super(api.EasingType.EASEIN); |
| 386 this.pow = pow; |
| 387 } |
| 388 } |
| 389 |
| 390 api.OutEasing = class extends api.Easing { |
| 391 constructor(pow = DEFAULT_EASING_POW) { |
| 392 super(api.EasingType.EASEOUT); |
| 393 this.pow = pow; |
| 394 } |
| 395 } |
| 396 |
| 343 /** | 397 /** |
| 344 * Base animation class. An animation can vary only one object property. | 398 * Base animation class. An animation can vary only one object property. |
| 345 * @struct | 399 * @struct |
| 346 */ | 400 */ |
| 347 api.Animation = class { | 401 api.Animation = class { |
| 348 constructor(elementId, durationMs) { | 402 constructor(elementId, durationMs) { |
| 349 /** @private {number} */ | 403 /** @private {number} */ |
| 350 this.id = -1; | 404 this.id = -1; |
| 351 /** @private {number} */ | 405 /** @private {number} */ |
| 352 this.meshId = elementId; | 406 this.meshId = elementId; |
| 353 /** @private {number} */ | 407 /** @private {number} */ |
| 354 this.property = -1; | 408 this.property = -1; |
| 355 /** @private {Object} */ | 409 /** @private {Object} */ |
| 356 this.to = {}; | 410 this.to = {}; |
| 357 /** @private {Object} */ | 411 /** @private {Object} */ |
| 358 this.easing = {}; | 412 this.easing = new api.LinearEasing(); |
| 359 | 413 |
| 360 // How many milliseconds in the future to start the animation. | 414 // How many milliseconds in the future to start the animation. |
| 361 /** @private {number} */ | 415 /** @private {number} */ |
| 362 this.startInMillis = 0.0; | 416 this.startInMillis = 0.0; |
| 363 | 417 |
| 364 // Duration of the animation (milliseconds). | 418 // Duration of the animation (milliseconds). |
| 365 /** @private {number} */ | 419 /** @private {number} */ |
| 366 this.durationMillis = durationMs; | 420 this.durationMillis = durationMs; |
| 367 | |
| 368 this.easing.type = api.Easing.LINEAR; | |
| 369 } | 421 } |
| 370 | 422 |
| 371 /** | 423 /** |
| 372 * Set the id of the animation. | 424 * Set the id of the animation. |
| 373 * @param {number} id | 425 * @param {number} id |
| 374 */ | 426 */ |
| 375 setId(id) { | 427 setId(id) { |
| 376 this.id = id; | 428 this.id = id; |
| 377 } | 429 } |
| 378 | 430 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 } | 481 } |
| 430 | 482 |
| 431 /** | 483 /** |
| 432 * Set the animation's final element opacity. | 484 * Set the animation's final element opacity. |
| 433 * @param {number} opacity | 485 * @param {number} opacity |
| 434 */ | 486 */ |
| 435 setOpacity(opacity) { | 487 setOpacity(opacity) { |
| 436 this.property = api.Property.OPACITY; | 488 this.property = api.Property.OPACITY; |
| 437 this.to.x = opacity; | 489 this.to.x = opacity; |
| 438 } | 490 } |
| 491 |
| 492 /** |
| 493 * Set the animation's easing. |
| 494 * @param {api.Easing} easing |
| 495 */ |
| 496 setEasing(easing) { |
| 497 this.easing = easing; |
| 498 } |
| 439 }; | 499 }; |
| 440 | 500 |
| 441 /** | 501 /** |
| 442 * Abstract class handling webui command calls from native. The UI must | 502 * Abstract class handling webui command calls from native. The UI must |
| 443 * subclass this and override the handlers. | 503 * subclass this and override the handlers. |
| 504 * @abstract |
| 444 */ | 505 */ |
| 445 api.NativeCommandHandler = class { | 506 api.NativeCommandHandler = class { |
| 446 /** | 507 /** |
| 447 * @param {api.Mode} mode | 508 * @param {api.Mode} mode |
| 448 */ | 509 */ |
| 449 onSetMode(mode) {} | 510 onSetMode(mode) {} |
| 450 | 511 |
| 451 /** | 512 /** |
| 452 * Handles entering or exiting full-screen mode. | 513 * Handles entering or exiting full-screen mode. |
| 453 * @param {boolean} fullscreen | 514 * @param {boolean} fullscreen |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 if ('updateTab' in dict) { | 629 if ('updateTab' in dict) { |
| 569 this.onUpdateTab(dict['updateTabs']); | 630 this.onUpdateTab(dict['updateTabs']); |
| 570 } | 631 } |
| 571 if ('removeTab' in dict) { | 632 if ('removeTab' in dict) { |
| 572 this.onRemoveTab(dict['removeTab']); | 633 this.onRemoveTab(dict['removeTab']); |
| 573 } | 634 } |
| 574 | 635 |
| 575 this.onCommandHandlerFinished() | 636 this.onCommandHandlerFinished() |
| 576 } | 637 } |
| 577 }; | 638 }; |
| OLD | NEW |