From 2c6428dcdca77c8555a85ba2e9820e43929e306d Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Tue, 4 Dec 2018 12:30:08 -0500 Subject: [PATCH] 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. --- src/io/video.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/io/video.js b/src/io/video.js index b2920e9aa..4f848215b 100644 --- a/src/io/video.js +++ b/src/io/video.js @@ -39,6 +39,12 @@ class Video { * @type {number} */ this._ghost = 0; + + /** + * Store a flag that allows the preview to be forced transparent. + * @type {number} + */ + this._forceTransparentPreview = false; } static get FORMAT_IMAGE_DATA () { @@ -127,7 +133,9 @@ class Video { setPreviewGhost (ghost) { this._ghost = ghost; 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; 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); + } }