Add a flag to force the video layer to be transparent.

This is needed to allow the GUI to toggle the video preview using postIOData('video', {forceTransparentPreview: true}) before taking a snapshot.
This commit is contained in:
Paul Kaplan 2018-12-04 12:30:08 -05:00
parent 122443a75f
commit 2c6428dcdc

View file

@ -39,6 +39,12 @@ class Video {
* @type {number} * @type {number}
*/ */
this._ghost = 0; this._ghost = 0;
/**
* Store a flag that allows the preview to be forced transparent.
* @type {number}
*/
this._forceTransparentPreview = false;
} }
static get FORMAT_IMAGE_DATA () { static get FORMAT_IMAGE_DATA () {
@ -127,7 +133,9 @@ class Video {
setPreviewGhost (ghost) { setPreviewGhost (ghost) {
this._ghost = ghost; this._ghost = ghost;
if (this._drawable) { if (this._drawable) {
this.runtime.renderer.updateDrawableProperties(this._drawable, {ghost}); this.runtime.renderer.updateDrawableProperties(this._drawable, {
ghost: this._forceTransparentPreview ? 100 : ghost
});
} }
} }
@ -188,6 +196,21 @@ class Video {
if (this.provider) return this.provider.videoReady; if (this.provider) return this.provider.videoReady;
return false; return false;
} }
/**
* Method implemented by all IO devices to allow external changes.
* The only change available externally is hiding the preview, used e.g. to
* prevent drawing the preview into project thumbnails.
* @param {object} - data passed to this IO device.
* @property {boolean} forceTransparentPreview - whether the preview should be forced transparent.
*/
postData ({forceTransparentPreview}) {
this._forceTransparentPreview = forceTransparentPreview;
// Setting the ghost to the current value will pick up the forceTransparentPreview
// flag and override the current ghost. The complexity is to prevent blocks
// from overriding forceTransparentPreview
this.setPreviewGhost(this._ghost);
}
} }