Chromium Code Reviews| 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 let ui = new scene.Scene(); | 8 let ui = new scene.Scene(); |
| 9 let uiManager; | 9 let uiManager; |
| 10 | 10 |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 446 if (visible == this.nativeState.visible) { | 446 if (visible == this.nativeState.visible) { |
| 447 return; | 447 return; |
| 448 } | 448 } |
| 449 this.nativeState.visible = visible; | 449 this.nativeState.visible = visible; |
| 450 let update = new api.UiElementUpdate(); | 450 let update = new api.UiElementUpdate(); |
| 451 update.setVisible(visible); | 451 update.setVisible(visible); |
| 452 ui.updateElement(this.domUiElement.uiElementId, update); | 452 ui.updateElement(this.domUiElement.uiElementId, update); |
| 453 ui.flush(); | 453 ui.flush(); |
| 454 } | 454 } |
| 455 }; | 455 }; |
| 456 | |
| 457 class Background { | |
| 458 constructor() { | |
| 459 // Make ground plane. | |
| 460 let groundPlane = new api.UiElementUpdate(); | |
| 461 groundPlane.setVisible(true); | |
| 462 groundPlane.setSize(25.0, 25.0); | |
| 463 groundPlane.setFill(new api.OpaqueGradient({r: 0.48, g: 0.48, b: 0.48, a:1 }, | |
| 464 {r: 0.57, g: 0.57, b: 0.57, a:1})); | |
| 465 groundPlane.setTranslation(0, -2, 0); | |
| 466 groundPlane.setRotation(1.0, 0.0, 0.0, -Math.PI/2); | |
| 467 this.groundPlaneId = ui.addElement(groundPlane); | |
| 468 | |
| 469 // Make ceiling plane. | |
| 470 let ceilingPlane = new api.UiElementUpdate(); | |
| 471 ceilingPlane.setVisible(true); | |
| 472 ceilingPlane.setSize(25.0, 25.0); | |
| 473 ceilingPlane.setFill(new api.OpaqueGradient({r: 0.48, g: 0.48, b: 0.48, a: 1}, | |
| 474 {r: 0.57, g: 0.57, b: 0.57, a:1})); | |
| 475 ceilingPlane.setTranslation(0, 2, 0); | |
| 476 ceilingPlane.setRotation(1.0, 0.0, 0.0, Math.PI/2); | |
| 477 this.ceilingPlaneId = ui.addElement(ceilingPlane); | |
| 478 | |
| 479 // Ground grid. | |
| 480 let groundGrid = new api.UiElementUpdate(); | |
| 481 groundGrid.setVisible(true); | |
| 482 groundGrid.setSize(25.0, 25.0); | |
| 483 groundGrid.setFill(new api.GridGradient({r: 0.57, g: 0.57, b: 0.57, a:1}, | |
| 484 {r: 0.57, g: 0.57, b: 0.57, a:1}, 10)); | |
| 485 groundGrid.setTranslation(0, -1.99, 0); | |
| 486 groundGrid.setRotation(1.0, 0.0, 0.0, -Math.PI/2); | |
| 487 this.groundGridId = ui.addElement(groundGrid); | |
| 488 } | |
| 489 | |
| 490 setEnabled(enabled) { | |
| 491 let groundPlaneUpdate = new api.UiElementUpdate(); | |
| 492 groundPlaneUpdate.setVisible(enabled); | |
| 493 ui.updateElement(this.groundPlaneId, groundPlaneUpdate); | |
| 494 let ceilingPlaneUpdate = new api.UiElementUpdate(); | |
| 495 ceilingPlaneUpdate.setVisible(enabled); | |
| 496 ui.updateElement(this.ceilingPlaneId, ceilingPlaneUpdate); | |
| 497 let groundGridUpdate = new api.UiElementUpdate(); | |
| 498 groundGridUpdate.setVisible(enabled); | |
| 499 ui.updateElement(this.groundGridId, groundGridUpdate); | |
| 500 } | |
| 501 }; | |
| 456 | 502 |
| 457 class UiManager { | 503 class UiManager { |
| 458 constructor() { | 504 constructor() { |
| 459 this.mode = api.Mode.UNKNOWN; | 505 this.mode = api.Mode.UNKNOWN; |
| 460 this.menuMode = false; | 506 this.menuMode = false; |
| 461 this.fullscreen = false; | 507 this.fullscreen = false; |
| 462 | 508 |
|
mthiesse
2017/01/31 20:54:54
nit: whitespace here and below
tiborg1
2017/02/01 00:22:18
Done.
| |
| 509 this.background = new Background(); | |
| 463 this.contentQuad = new ContentQuad(); | 510 this.contentQuad = new ContentQuad(); |
| 464 let contentId = this.contentQuad.getElementId(); | 511 let contentId = this.contentQuad.getElementId(); |
| 465 | 512 |
| 466 this.controls = new Controls(contentId); | 513 this.controls = new Controls(contentId); |
| 467 this.secureOriginWarnings = new SecureOriginWarnings(); | 514 this.secureOriginWarnings = new SecureOriginWarnings(); |
| 468 this.urlIndicator = new UrlIndicator(); | 515 this.urlIndicator = new UrlIndicator(); |
| 516 | |
| 517 | |
| 469 } | 518 } |
| 470 | 519 |
| 471 setMode(mode, menuMode, fullscreen) { | 520 setMode(mode, menuMode, fullscreen) { |
| 472 /** @const */ var URL_INDICATOR_VISIBILITY_TIMEOUT_MS = 5000; | 521 /** @const */ var URL_INDICATOR_VISIBILITY_TIMEOUT_MS = 5000; |
| 473 | 522 |
| 474 this.mode = mode; | 523 this.mode = mode; |
| 475 this.menuMode = menuMode; | 524 this.menuMode = menuMode; |
| 476 this.fullscreen = fullscreen; | 525 this.fullscreen = fullscreen; |
| 477 | 526 |
| 478 this.contentQuad.setEnabled(mode == api.Mode.STANDARD && !menuMode); | 527 this.contentQuad.setEnabled(mode == api.Mode.STANDARD && !menuMode); |
| 479 this.contentQuad.setFullscreen(fullscreen); | 528 this.contentQuad.setFullscreen(fullscreen); |
| 480 // TODO(crbug/643815): Set aspect ratio on content quad when available. | 529 // TODO(crbug/643815): Set aspect ratio on content quad when available. |
| 481 // TODO(amp): Don't show controls in fullscreen once MENU mode lands. | 530 // TODO(amp): Don't show controls in fullscreen once MENU mode lands. |
| 482 this.controls.setEnabled(mode == api.Mode.STANDARD && !menuMode); | 531 this.controls.setEnabled(mode == api.Mode.STANDARD && !menuMode); |
| 483 this.urlIndicator.setEnabled(mode == api.Mode.STANDARD && !menuMode); | 532 this.urlIndicator.setEnabled(mode == api.Mode.STANDARD && !menuMode); |
| 484 // TODO(amp): Don't show controls in CINEMA mode once MENU mode lands. | 533 // TODO(amp): Don't show controls in CINEMA mode once MENU mode lands. |
| 485 this.urlIndicator.setVisibilityTimeout( | 534 this.urlIndicator.setVisibilityTimeout( |
| 486 mode == api.Mode.STANDARD && !menuMode ? | 535 mode == api.Mode.STANDARD && !menuMode ? |
| 487 0 : | 536 0 : |
| 488 URL_INDICATOR_VISIBILITY_TIMEOUT_MS); | 537 URL_INDICATOR_VISIBILITY_TIMEOUT_MS); |
| 489 this.secureOriginWarnings.setEnabled(mode == api.Mode.WEB_VR); | 538 this.secureOriginWarnings.setEnabled(mode == api.Mode.WEB_VR); |
| 539 this.background.setEnabled(mode == api.Mode.STANDARD && !menuMode); | |
| 490 | 540 |
| 491 api.setUiCssSize( | 541 api.setUiCssSize( |
| 492 uiRootElement.clientWidth, uiRootElement.clientHeight, UI_DPR); | 542 uiRootElement.clientWidth, uiRootElement.clientHeight, UI_DPR); |
| 493 } | 543 } |
| 494 | 544 |
| 495 setSecurityLevel(level) { | 545 setSecurityLevel(level) { |
| 496 this.urlIndicator.setSecurityLevel(level); | 546 this.urlIndicator.setSecurityLevel(level); |
| 497 } | 547 } |
| 498 | 548 |
| 499 setWebVRSecureOrigin(secure) { | 549 setWebVRSecureOrigin(secure) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 538 ui.flush(); | 588 ui.flush(); |
| 539 } | 589 } |
| 540 | 590 |
| 541 return { | 591 return { |
| 542 initialize: initialize, | 592 initialize: initialize, |
| 543 command: command, | 593 command: command, |
| 544 }; | 594 }; |
| 545 })(); | 595 })(); |
| 546 | 596 |
| 547 window.addEventListener('load', vrShellUi.initialize); | 597 window.addEventListener('load', vrShellUi.initialize); |
| OLD | NEW |