diff --git a/HISTORY.md b/HISTORY.md
index 04860ea8..5e84b98c 100755
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -6,6 +6,9 @@
* repeat stops when encountering a non-numerical counter input, thanks, Stefan!
* updated list-utilities library, thanks, Brian!
+### 2021-03-18
+* gui, scenes, objects: more scene-refactorings
+
### 2021-03-17
* objects, gui, paint, sketch, store: de-globalized stage dimensions
* new dev version
diff --git a/snap.html b/snap.html
index f034ddb6..acfe9f0b 100755
--- a/snap.html
+++ b/snap.html
@@ -10,9 +10,9 @@
-
-
-
+
+
+
diff --git a/src/gui.js b/src/gui.js
index dec19d82..f9b8cc9b 100644
--- a/src/gui.js
+++ b/src/gui.js
@@ -62,7 +62,7 @@
*/
/*global modules, Morph, SpriteMorph, SyntaxElementMorph, Color, Cloud, Audio,
-ListWatcherMorph, TextMorph, newCanvas, useBlurredShadows, VariableFrame, Sound,
+ListWatcherMorph, TextMorph, newCanvas, useBlurredShadows, Sound, Scene,
StringMorph, Point, MenuMorph, morphicVersion, DialogBoxMorph, normalizeCanvas,
ToggleButtonMorph, contains, ScrollFrameMorph, StageMorph, PushButtonMorph, sb,
InputFieldMorph, FrameMorph, Process, nop, SnapSerializer, ListMorph, detect,
@@ -74,12 +74,11 @@ CommandBlockMorph, BooleanSlotMorph, RingReporterSlotMorph, ScriptFocusMorph,
BlockLabelPlaceHolderMorph, SpeechBubbleMorph, XML_Element, WatcherMorph, WHITE,
BlockRemovalDialogMorph,TableMorph, isSnapObject, isRetinaEnabled, SliderMorph,
disableRetinaSupport, enableRetinaSupport, isRetinaSupported, MediaRecorder,
-Animation, BoxMorph, BlockEditorMorph, BlockDialogMorph, Note, ZERO, BLACK,
-Scene*/
+Animation, BoxMorph, BlockEditorMorph, BlockDialogMorph, Note, ZERO, BLACK*/
// Global stuff ////////////////////////////////////////////////////////
-modules.gui = '2021-March-17';
+modules.gui = '2021-March-18';
// Declarations
@@ -213,7 +212,7 @@ function IDE_Morph(isAutoFill) {
this.init(isAutoFill);
}
-IDE_Morph.prototype.init = function (isAutoFill) {
+IDE_Morph.prototype.init = function (isAutoFill) { // +++
// global font setting
MorphicPreferences.globalFontFamily = 'Helvetica, Arial';
@@ -230,12 +229,12 @@ IDE_Morph.prototype.init = function (isAutoFill) {
this.scene = new Scene();
this.globalVariables = this.scene.globalVariables;
- this.currentSprite = new SpriteMorph(this.globalVariables);
+ this.currentSprite = this.scene.addDefaultSprite();
this.sprites = new List([this.currentSprite]);
+ this.projectName = this.scene.name;
+ this.projectNotes = this.scene.notes;
this.currentCategory = 'motion';
this.currentTab = 'scripts';
- this.projectName = '';
- this.projectNotes = '';
this.trash = []; // deleted sprites
@@ -1377,20 +1376,11 @@ IDE_Morph.prototype.createPaletteHandle = function () {
};
IDE_Morph.prototype.createStage = function () {
- // assumes that the logo pane has already been created
- if (this.stage) {this.stage.destroy(); }
- StageMorph.prototype.frameRate = 0;
- this.stage = new StageMorph(this.globalVariables);
- this.stage.setExtent(this.stage.dimensions); // dimensions are fixed
- if (this.currentSprite instanceof SpriteMorph) {
- this.currentSprite.setPosition(
- this.stage.center().subtract(
- this.currentSprite.extent().divideBy(2)
- )
- );
- this.stage.add(this.currentSprite);
+ if (this.stage) {
+ this.stage.destroy();
}
- this.add(this.stage);
+ this.add(this.scene.stage);
+ this.stage = this.scene.stage;
};
IDE_Morph.prototype.createStageHandle = function () {
@@ -2820,7 +2810,7 @@ IDE_Morph.prototype.restore = function () {
// IDE_Morph sprite list access
-IDE_Morph.prototype.addNewSprite = function () {
+IDE_Morph.prototype.addNewSprite = function () { // +++ sceneify
var sprite = new SpriteMorph(this.globalVariables),
rnd = Process.prototype.reportBasicRandom;
@@ -2847,7 +2837,7 @@ IDE_Morph.prototype.addNewSprite = function () {
this.selectSprite(sprite);
};
-IDE_Morph.prototype.paintNewSprite = function () {
+IDE_Morph.prototype.paintNewSprite = function () { // +++ sceneify
var sprite = new SpriteMorph(this.globalVariables),
cos = new Costume();
@@ -2870,7 +2860,7 @@ IDE_Morph.prototype.paintNewSprite = function () {
);
};
-IDE_Morph.prototype.newCamSprite = function () {
+IDE_Morph.prototype.newCamSprite = function () { // +++ sceneify
var sprite = new SpriteMorph(this.globalVariables),
camDialog;
@@ -4588,6 +4578,9 @@ IDE_Morph.prototype.editProjectNotes = function () {
};
IDE_Morph.prototype.newProject = function () { // +++
+ var scene = new Scene();
+
+ scene.addDefaultSprite();
this.source = this.cloud.username ? 'cloud' : null;
if (this.stage) {
this.stage.destroy();
@@ -4595,32 +4588,7 @@ IDE_Morph.prototype.newProject = function () { // +++
if (location.hash.substr(0, 6) !== '#lang:') {
location.hash = '';
}
- // +++ this.switchToScene(new Scene());
-
-
- this.globalVariables = new VariableFrame();
- this.currentSprite = new SpriteMorph(this.globalVariables);
- this.sprites = new List([this.currentSprite]);
- // +++ StageMorph.prototype.dimensions = new Point(480, 360);
- StageMorph.prototype.hiddenPrimitives = {};
- StageMorph.prototype.codeMappings = {};
- StageMorph.prototype.codeHeaders = {};
- StageMorph.prototype.enableCodeMapping = false;
- StageMorph.prototype.enableInheritance = true;
- StageMorph.prototype.enableSublistIDs = false;
- StageMorph.prototype.enablePenLogging = false;
- SpriteMorph.prototype.useFlatLineEnds = false;
- Process.prototype.enableLiveCoding = false;
- Process.prototype.enableHyperOps = true;
- this.hasUnsavedEdits = false;
- this.setProjectName('');
- this.projectNotes = '';
- this.trash = [];
- this.createStage();
- this.add(this.stage);
- this.createCorral();
- this.selectSprite(this.stage.children[0]);
- this.fixLayout();
+ this.switchToScene(scene);
};
IDE_Morph.prototype.save = function () {
@@ -5091,19 +5059,9 @@ IDE_Morph.prototype.openProjectString = function (str, callback) {
]);
};
-IDE_Morph.prototype.rawOpenProjectString = function (str) { // +++
+IDE_Morph.prototype.rawOpenProjectString = function (str) {
this.toggleAppMode(false);
this.spriteBar.tabBar.tabTo('scripts');
- StageMorph.prototype.hiddenPrimitives = {};
- StageMorph.prototype.codeMappings = {};
- StageMorph.prototype.codeHeaders = {};
- StageMorph.prototype.enableCodeMapping = false;
- StageMorph.prototype.enableInheritance = true;
- StageMorph.prototype.enableSublistIDs = false;
- StageMorph.prototype.enablePenLogging = false;
- Process.prototype.enableLiveCoding = false;
- this.trash = [];
- this.hasUnsavedEdits = false;
if (Process.prototype.isCatchingErrors) {
try {
this.switchToScene(
@@ -5132,18 +5090,9 @@ IDE_Morph.prototype.openCloudDataString = function (str) {
]);
};
-IDE_Morph.prototype.rawOpenCloudDataString = function (str) { // +++
+IDE_Morph.prototype.rawOpenCloudDataString = function (str) {
var model;
- StageMorph.prototype.hiddenPrimitives = {};
- StageMorph.prototype.codeMappings = {};
- StageMorph.prototype.codeHeaders = {};
- StageMorph.prototype.enableCodeMapping = false;
- StageMorph.prototype.enableInheritance = true;
- StageMorph.prototype.enableSublistIDs = false;
- StageMorph.prototype.enablePenLogging = false;
- Process.prototype.enableLiveCoding = false;
- this.trash = [];
- this.hasUnsavedEdits = false;
+
if (Process.prototype.isCatchingErrors) {
try {
model = this.serializer.parse(str);
@@ -5359,7 +5308,7 @@ IDE_Morph.prototype.openProject = function (name) {
}
};
-IDE_Morph.prototype.switchToScene = function (scene) { // +++
+IDE_Morph.prototype.switchToScene = function (scene) {
var sprites = [];
if (!scene || !scene.stage) {
return;
@@ -5383,6 +5332,21 @@ IDE_Morph.prototype.switchToScene = function (scene) { // +++
this.createCorral();
this.selectSprite(sprites[0] || this.stage);
this.fixLayout();
+
+ // +++ to do: de-globablize settings:
+ StageMorph.prototype.hiddenPrimitives = {};
+ StageMorph.prototype.codeMappings = {};
+ StageMorph.prototype.codeHeaders = {};
+ StageMorph.prototype.enableCodeMapping = false;
+ StageMorph.prototype.enableInheritance = true;
+ StageMorph.prototype.enableSublistIDs = false;
+ StageMorph.prototype.enablePenLogging = false;
+ SpriteMorph.prototype.useFlatLineEnds = false;
+ Process.prototype.enableLiveCoding = false;
+ Process.prototype.enableHyperOps = true;
+ this.hasUnsavedEdits = false;
+ this.trash = [];
+
this.world().keyboardFocus = this.stage;
};
diff --git a/src/objects.js b/src/objects.js
index c1ef99b9..a8f30ad7 100644
--- a/src/objects.js
+++ b/src/objects.js
@@ -84,7 +84,7 @@ BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, BooleanSlotMorph,
localize, TableMorph, TableFrameMorph, normalizeCanvas, VectorPaintEditorMorph,
AlignmentMorph, Process, WorldMap, copyCanvas, useBlurredShadows*/
-modules.objects = '2021-March-17';
+modules.objects = '2021-March-18';
var SpriteMorph;
var StageMorph;
@@ -7776,6 +7776,7 @@ StageMorph.prototype.init = function (globals) {
StageMorph.uber.init.call(this);
+ this.setExtent(this.dimensions);
this.isCachingImage = true;
this.cachedHSV = this.color.hsv();
this.acceptsDrops = false;
diff --git a/src/scenes.js b/src/scenes.js
index 1174385f..78ac0bcf 100644
--- a/src/scenes.js
+++ b/src/scenes.js
@@ -47,9 +47,9 @@
// Global stuff ////////////////////////////////////////////////////////
-/*global modules, VariableFrame, aStageMorph*/
+/*global modules, VariableFrame, StageMorph, SpriteMorph*/
-modules.scenes = '2021-March-12';
+modules.scenes = '2021-March-18';
// Scene /////////////////////////////////////////////////////////
@@ -61,8 +61,8 @@ modules.scenes = '2021-March-12';
// Scene instance creation:
function Scene(aStageMorph) {
- this.name = null;
- this.notes = null;
+ this.name = '';
+ this.notes = '';
this.globalVariables = aStageMorph ?
aStageMorph.globalVariables() : new VariableFrame();
this.stage = aStageMorph || new StageMorph(this.globalVariables);
@@ -71,3 +71,14 @@ function Scene(aStageMorph) {
this.sprites = {};
this.targetStage = null;
}
+
+Scene.prototype.addDefaultSprite = function () {
+ var sprite = new SpriteMorph(this.globalVariables);
+ sprite.setPosition(
+ this.stage.center().subtract(
+ sprite.extent().divideBy(2)
+ )
+ );
+ this.stage.add(sprite);
+ return sprite;
+};