No more explicit layer groups, and separate extension into video and pen.

This commit is contained in:
Karishma Chadha 2018-05-20 22:30:20 -04:00
parent 38875bc65c
commit 5e40bfb7ee
4 changed files with 15 additions and 47 deletions

View file

@ -3,54 +3,25 @@ class StageLayering {
return 'background';
}
static get EXTENSION_LAYER () {
return 'extensions';
static get VIDEO_LAYER () {
return 'video';
}
static get PEN_LAYER () {
return 'pen';
}
static get SPRITE_LAYER () {
return 'sprite';
}
static get BUBBLE_LAYER () {
return 'bubble';
}
static get BACKGROUND_ORDER () {
return 0;
}
// Video should be in the back of the extension group
static get VIDEO_ORDER () {
return 0;
}
static get PEN_ORDER () {
return 1;
}
// Order of layer groups relative to each other,
// and ordering style of each
// Currently extensions are the only layer group
// that have an explicit ordering (e.g. video must be behind pen).
// All other groups here are ordered based on when they get added
static get LAYER_GROUPS () {
return [
{
group: StageLayering.BACKGROUND_LAYER,
// This is a weird use case for a layer group ordering style,
// because in the main Scratch use case, this group has only one item,
// so ordering of the items doesn't really matter.
explicitOrdering: false
},
{
group: StageLayering.EXTENSION_LAYER,
explicitOrdering: true
},
{
group: StageLayering.SPRITE_LAYER,
explicitOrdering: false
}
StageLayering.BACKGROUND_LAYER,
StageLayering.VIDEO_LAYER,
StageLayering.PEN_LAYER,
StageLayering.SPRITE_LAYER
];
}
}

View file

@ -128,8 +128,7 @@ class Scratch3PenBlocks {
_getPenLayerID () {
if (this._penSkinId < 0 && this.runtime.renderer) {
this._penSkinId = this.runtime.renderer.createPenSkin();
this._penDrawableId = this.runtime.renderer.createDrawable(
StageLayering.EXTENSION_LAYER, StageLayering.PEN_ORDER);
this._penDrawableId = this.runtime.renderer.createDrawable(StageLayering.PEN_LAYER);
this.runtime.renderer.updateDrawableProperties(this._penDrawableId, {skinId: this._penSkinId});
}
return this._penSkinId;

View file

@ -146,7 +146,7 @@ class Video {
if (this._skinId === -1 && this._skin === null && this._drawable === -1) {
this._skinId = renderer.createPenSkin();
this._skin = renderer._allSkins[this._skinId];
this._drawable = renderer.createDrawable(StageLayering.EXTENSION_LAYER, StageLayering.VIDEO_ORDER);
this._drawable = renderer.createDrawable(StageLayering.VIDEO_LAYER);
renderer.updateDrawableProperties(this._drawable, {
skinId: this._skinId
});

View file

@ -847,11 +847,9 @@ class RenderedTarget extends Target {
*/
goBehindOther (other) {
if (this.renderer) {
this.renderer.positionDrawableRelativeToOther(
this.drawableID, other.drawableID, -1, StageLayering.SPRITE_LAYER);
// const otherLayer = this.renderer.setDrawableOrder(
// other.drawableID, 0, StageLayering.SPRITE_LAYER, true);
// this.renderer.setDrawableOrder(this.drawableID, otherLayer, StageLayering.SPRITE_LAYER);
const otherLayer = this.renderer.setDrawableOrder(
other.drawableID, 0, StageLayering.SPRITE_LAYER, true);
this.renderer.setDrawableOrder(this.drawableID, otherLayer, StageLayering.SPRITE_LAYER);
}
}