kopia lustrzana https://github.com/backface/turtlestitch
refactored IDE elements resizing
rodzic
bdb13a6c77
commit
f099a64a75
78
src/gui.js
78
src/gui.js
|
@ -4874,7 +4874,7 @@ IDE_Morph.prototype.switchToUserMode = function () {
|
||||||
this.isAutoFill = true;
|
this.isAutoFill = true;
|
||||||
this.isDraggable = false;
|
this.isDraggable = false;
|
||||||
this.reactToWorldResize(world.bounds.copy());
|
this.reactToWorldResize(world.bounds.copy());
|
||||||
this.siblings().forEach(function (morph) {
|
this.siblings().forEach(morph => {
|
||||||
if (morph instanceof DialogBoxMorph) {
|
if (morph instanceof DialogBoxMorph) {
|
||||||
world.add(morph); // bring to front
|
world.add(morph); // bring to front
|
||||||
} else {
|
} else {
|
||||||
|
@ -4885,7 +4885,7 @@ IDE_Morph.prototype.switchToUserMode = function () {
|
||||||
this.refreshPalette();
|
this.refreshPalette();
|
||||||
// prevent non-DialogBoxMorphs from being dropped
|
// prevent non-DialogBoxMorphs from being dropped
|
||||||
// onto the World in user-mode
|
// onto the World in user-mode
|
||||||
world.reactToDropOf = function (morph) {
|
world.reactToDropOf = (morph) => {
|
||||||
if (!(morph instanceof DialogBoxMorph ||
|
if (!(morph instanceof DialogBoxMorph ||
|
||||||
(morph instanceof MenuMorph))) {
|
(morph instanceof MenuMorph))) {
|
||||||
if (world.hand.grabOrigin) {
|
if (world.hand.grabOrigin) {
|
||||||
|
@ -4896,7 +4896,6 @@ IDE_Morph.prototype.switchToUserMode = function () {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.showMessage('entering user mode', 1);
|
this.showMessage('entering user mode', 1);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
IDE_Morph.prototype.switchToDevMode = function () {
|
IDE_Morph.prototype.switchToDevMode = function () {
|
||||||
|
@ -4926,14 +4925,14 @@ IDE_Morph.prototype.flushBlocksCache = function (category) {
|
||||||
// if no category is specified, the whole cache gets flushed
|
// if no category is specified, the whole cache gets flushed
|
||||||
if (category) {
|
if (category) {
|
||||||
this.stage.blocksCache[category] = null;
|
this.stage.blocksCache[category] = null;
|
||||||
this.stage.children.forEach(function (m) {
|
this.stage.children.forEach(m => {
|
||||||
if (m instanceof SpriteMorph) {
|
if (m instanceof SpriteMorph) {
|
||||||
m.blocksCache[category] = null;
|
m.blocksCache[category] = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.stage.blocksCache = {};
|
this.stage.blocksCache = {};
|
||||||
this.stage.children.forEach(function (m) {
|
this.stage.children.forEach(m => {
|
||||||
if (m instanceof SpriteMorph) {
|
if (m instanceof SpriteMorph) {
|
||||||
m.blocksCache = {};
|
m.blocksCache = {};
|
||||||
}
|
}
|
||||||
|
@ -4946,14 +4945,14 @@ IDE_Morph.prototype.flushPaletteCache = function (category) {
|
||||||
// if no category is specified, the whole cache gets flushed
|
// if no category is specified, the whole cache gets flushed
|
||||||
if (category) {
|
if (category) {
|
||||||
this.stage.paletteCache[category] = null;
|
this.stage.paletteCache[category] = null;
|
||||||
this.stage.children.forEach(function (m) {
|
this.stage.children.forEach(m => {
|
||||||
if (m instanceof SpriteMorph) {
|
if (m instanceof SpriteMorph) {
|
||||||
m.paletteCache[category] = null;
|
m.paletteCache[category] = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.stage.paletteCache = {};
|
this.stage.paletteCache = {};
|
||||||
this.stage.children.forEach(function (m) {
|
this.stage.children.forEach(m => {
|
||||||
if (m instanceof SpriteMorph) {
|
if (m instanceof SpriteMorph) {
|
||||||
m.paletteCache = {};
|
m.paletteCache = {};
|
||||||
}
|
}
|
||||||
|
@ -4971,20 +4970,20 @@ IDE_Morph.prototype.toggleZebraColoring = function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
// select all scripts:
|
// select all scripts:
|
||||||
this.stage.children.concat(this.stage).forEach(function (morph) {
|
this.stage.children.concat(this.stage).forEach(morph => {
|
||||||
if (isSnapObject(morph)) {
|
if (isSnapObject(morph)) {
|
||||||
scripts = scripts.concat(
|
scripts = scripts.concat(
|
||||||
morph.scripts.children.filter(function (morph) {
|
morph.scripts.children.filter(morph =>
|
||||||
return morph instanceof BlockMorph;
|
morph instanceof BlockMorph
|
||||||
})
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// force-update all scripts:
|
// force-update all scripts:
|
||||||
scripts.forEach(function (topBlock) {
|
scripts.forEach(topBlock =>
|
||||||
topBlock.fixBlockColor(null, true);
|
topBlock.fixBlockColor(null, true)
|
||||||
});
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
IDE_Morph.prototype.toggleDynamicInputLabels = function () {
|
IDE_Morph.prototype.toggleDynamicInputLabels = function () {
|
||||||
|
@ -5110,10 +5109,10 @@ IDE_Morph.prototype.toggleAppMode = function (appMode) {
|
||||||
this.setColor(this.appModeColor);
|
this.setColor(this.appModeColor);
|
||||||
this.controlBar.setColor(this.color);
|
this.controlBar.setColor(this.color);
|
||||||
this.controlBar.appModeButton.refresh();
|
this.controlBar.appModeButton.refresh();
|
||||||
elements.forEach(function (e) {
|
elements.forEach(e =>
|
||||||
e.hide();
|
e.hide()
|
||||||
});
|
);
|
||||||
world.children.forEach(function (morph) {
|
world.children.forEach(morph => {
|
||||||
if (morph instanceof DialogBoxMorph) {
|
if (morph instanceof DialogBoxMorph) {
|
||||||
morph.hide();
|
morph.hide();
|
||||||
}
|
}
|
||||||
|
@ -5127,26 +5126,26 @@ IDE_Morph.prototype.toggleAppMode = function (appMode) {
|
||||||
}
|
}
|
||||||
this.setColor(this.backgroundColor);
|
this.setColor(this.backgroundColor);
|
||||||
this.controlBar.setColor(this.frameColor);
|
this.controlBar.setColor(this.frameColor);
|
||||||
elements.forEach(function (e) {
|
elements.forEach(e =>
|
||||||
e.show();
|
e.show()
|
||||||
});
|
);
|
||||||
this.stage.setScale(1);
|
this.stage.setScale(1);
|
||||||
// show all hidden dialogs
|
// show all hidden dialogs
|
||||||
world.children.forEach(function (morph) {
|
world.children.forEach(morph => {
|
||||||
if (morph instanceof DialogBoxMorph) {
|
if (morph instanceof DialogBoxMorph) {
|
||||||
morph.show();
|
morph.show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// prevent scrollbars from showing when morph appears
|
// prevent scrollbars from showing when morph appears
|
||||||
world.allChildren().filter(function (c) {
|
world.allChildren().filter(c =>
|
||||||
return c instanceof ScrollFrameMorph;
|
c instanceof ScrollFrameMorph
|
||||||
}).forEach(function (s) {
|
).forEach(s =>
|
||||||
s.adjustScrollBars();
|
s.adjustScrollBars()
|
||||||
});
|
);
|
||||||
// prevent rotation and draggability controls from
|
// prevent rotation and draggability controls from
|
||||||
// showing for the stage
|
// showing for the stage
|
||||||
if (this.currentSprite === this.stage) {
|
if (this.currentSprite === this.stage) {
|
||||||
this.spriteBar.children.forEach(function (child) {
|
this.spriteBar.children.forEach(child => {
|
||||||
if (child instanceof PushButtonMorph) {
|
if (child instanceof PushButtonMorph) {
|
||||||
child.hide();
|
child.hide();
|
||||||
}
|
}
|
||||||
|
@ -5173,17 +5172,15 @@ IDE_Morph.prototype.toggleStageSize = function (isSmall, forcedRatio) {
|
||||||
function zoomTo(targetRatio) {
|
function zoomTo(targetRatio) {
|
||||||
myself.isSmallStage = true;
|
myself.isSmallStage = true;
|
||||||
world.animations.push(new Animation(
|
world.animations.push(new Animation(
|
||||||
function (ratio) {
|
ratio => {
|
||||||
myself.stageRatio = ratio;
|
myself.stageRatio = ratio;
|
||||||
myself.setExtent(world.extent());
|
myself.setExtent(world.extent());
|
||||||
},
|
},
|
||||||
function () {
|
() => myself.stageRatio,
|
||||||
return myself.stageRatio;
|
|
||||||
},
|
|
||||||
targetRatio - myself.stageRatio,
|
targetRatio - myself.stageRatio,
|
||||||
msecs,
|
msecs,
|
||||||
null, // easing
|
null, // easing
|
||||||
function () {
|
() => {
|
||||||
myself.isSmallStage = (targetRatio !== 1);
|
myself.isSmallStage = (targetRatio !== 1);
|
||||||
myself.controlBar.stageSizeButton.refresh();
|
myself.controlBar.stageSizeButton.refresh();
|
||||||
}
|
}
|
||||||
|
@ -5214,18 +5211,15 @@ IDE_Morph.prototype.toggleStageSize = function (isSmall, forcedRatio) {
|
||||||
|
|
||||||
IDE_Morph.prototype.setPaletteWidth = function (newWidth) {
|
IDE_Morph.prototype.setPaletteWidth = function (newWidth) {
|
||||||
var msecs = this.isAnimating ? 100 : 0,
|
var msecs = this.isAnimating ? 100 : 0,
|
||||||
world = this.world(),
|
world = this.world();
|
||||||
myself = this;
|
|
||||||
|
|
||||||
world.animations.push(new Animation(
|
world.animations.push(new Animation(
|
||||||
function (newWidth) {
|
newWidth => {
|
||||||
myself.paletteWidth = newWidth;
|
this.paletteWidth = newWidth;
|
||||||
myself.setExtent(world.extent());
|
this.setExtent(world.extent());
|
||||||
},
|
},
|
||||||
function () {
|
() => this.paletteWidth,
|
||||||
return myself.paletteWidth;
|
newWidth - this.paletteWidth,
|
||||||
},
|
|
||||||
newWidth - myself.paletteWidth,
|
|
||||||
msecs
|
msecs
|
||||||
));
|
));
|
||||||
};
|
};
|
||||||
|
|
Ładowanie…
Reference in New Issue