mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 15:02:52 -05:00
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:
parent
122443a75f
commit
2c6428dcdc
1 changed files with 24 additions and 1 deletions
|
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue