de-globalized stage dimensions

snap7
jmoenig 2021-03-17 18:28:17 +01:00
rodzic 6025a62d6d
commit f4ea4bf25e
7 zmienionych plików z 83 dodań i 62 usunięć

Wyświetl plik

@ -2,6 +2,9 @@
## in development:
### 2021-03-17
* objects, gui, paint, sketch, store: de-globalized stage dimensions
## 6.7.2
* **Notable Changes:**
* disabled empty-slot implicit parameter in FOREACH

Wyświetl plik

@ -10,18 +10,18 @@
<script src="src/widgets.js?version=2021-01-05"></script>
<script src="src/blocks.js?version=2021-02-27"></script>
<script src="src/threads.js?version=2021-03-15"></script>
<script src="src/objects.js?version=2021-03-09"></script>
<script src="src/objects.js?version=2021-03-17"></script>
<script src="src/scenes.js?version=2021-03-12"></script>
<script src="src/gui.js?version=2021-03-15"></script>
<script src="src/paint.js?version=2020-05-17"></script>
<script src="src/gui.js?version=2021-03-17"></script>
<script src="src/paint.js?version=2021-03-17"></script>
<script src="src/lists.js?version=2021-03-15"></script>
<script src="src/byob.js?version=2021-03-05"></script>
<script src="src/tables.js?version=2021-03-05"></script>
<script src="src/sketch.js?version=2020-07-13"></script>
<script src="src/sketch.js?version=2021-03-17"></script>
<script src="src/video.js?version=2019-06-27"></script>
<script src="src/maps.js?version=2020-03-25"></script>
<script src="src/xml.js?version=2020-04-27"></script>
<script src="src/store.js?version=2021-03-12"></script>
<script src="src/store.js?version=2021-03-17"></script>
<script src="src/locale.js?version=2021-03-15"></script>
<script src="src/cloud.js?version=2021-02-04"></script>
<script src="src/api.js?version=2021-01-25"></script>

Wyświetl plik

@ -79,7 +79,7 @@ Scene*/
// Global stuff ////////////////////////////////////////////////////////
modules.gui = '2021-March-15';
modules.gui = '2021-March-17';
// Declarations
@ -1092,7 +1092,7 @@ IDE_Morph.prototype.createControlBar = function () {
x = Math.min(
startButton.left() - (3 * padding + 2 * stageSizeButton.width()),
myself.right() - StageMorph.prototype.dimensions.x *
myself.right() - myself.stage.dimensions.x *
(myself.isSmallStage ? myself.stageRatio : 1)
);
[stageSizeButton, appModeButton].forEach(button => {
@ -2108,16 +2108,16 @@ IDE_Morph.prototype.setExtent = function (point) {
if (this.isEmbedMode) {
minExt = new Point(100, 100);
} else {
minExt = StageMorph.prototype.dimensions.add(
minExt = this.stage.dimensions.add(
this.controlBar.height() + 10
);
}
} else {
if (this.stageRatio > 1) {
minExt = padding.add(StageMorph.prototype.dimensions);
minExt = padding.add(this.stage.dimensions);
} else {
minExt = padding.add(
StageMorph.prototype.dimensions.multiplyBy(this.stageRatio)
this.stage.dimensions.multiplyBy(this.stageRatio)
);
}
}
@ -2245,11 +2245,10 @@ IDE_Morph.prototype.droppedSVG = function (anImage, name) {
}
// checking if the costume is bigger than the stage and, if so, fit it
if (StageMorph.prototype.dimensions.x < w ||
StageMorph.prototype.dimensions.y < h) {
if (this.stage.dimensions.x < w || this.stage.dimensions.y < h) {
scale = Math.min(
(StageMorph.prototype.dimensions.x / w),
(StageMorph.prototype.dimensions.y / h)
(this.stage.dimensions.x / w),
(this.stage.dimensions.y / h)
);
normalizing = true;
w = w * scale;
@ -4602,7 +4601,7 @@ IDE_Morph.prototype.newProject = function () { // +++
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.dimensions = new Point(480, 360);
StageMorph.prototype.hiddenPrimitives = {};
StageMorph.prototype.codeMappings = {};
StageMorph.prototype.codeHeaders = {};
@ -6168,7 +6167,7 @@ IDE_Morph.prototype.userSetStageSize = function () {
this
).promptVector(
"Stage size",
StageMorph.prototype.dimensions,
this.stage.dimensions,
new Point(480, 360),
'Stage width',
'Stage height',
@ -6186,16 +6185,16 @@ IDE_Morph.prototype.setStageExtent = function (aPoint) {
function zoom() {
myself.step = function () {
var delta = ext.subtract(
StageMorph.prototype.dimensions
myself.stage.dimensions
).divideBy(2);
if (delta.abs().lt(new Point(5, 5))) {
StageMorph.prototype.dimensions = ext;
myself.stage.dimensions = ext;
delete myself.step;
} else {
StageMorph.prototype.dimensions =
StageMorph.prototype.dimensions.add(delta);
myself.stage.dimensions =
myself.stage.dimensions.add(delta);
}
myself.stage.setExtent(StageMorph.prototype.dimensions);
myself.stage.setExtent(myself.stage.dimensions);
myself.stage.clearPenTrails();
myself.fixLayout();
this.setExtent(world.extent());
@ -6210,8 +6209,8 @@ IDE_Morph.prototype.setStageExtent = function (aPoint) {
if (this.isAnimating) {
zoom();
} else {
StageMorph.prototype.dimensions = ext;
this.stage.setExtent(StageMorph.prototype.dimensions);
this.stage.dimensions = ext;
this.stage.setExtent(this.stage.dimensions);
this.stage.clearPenTrails();
this.fixLayout();
this.setExtent(world.extent());
@ -9597,11 +9596,14 @@ WardrobeMorph.prototype.removeCostumeAt = function (idx) {
};
WardrobeMorph.prototype.paintNew = function () {
var cos = new Costume(
var ide = this.parentThatIsA(IDE_Morph),
cos = new Costume(
newCanvas(null, true),
this.sprite.newCostumeName(localize('Untitled'))
),
ide = this.parentThatIsA(IDE_Morph);
this.sprite.newCostumeName(localize('Untitled')),
null, // rotation center
null, // don't shrink-to-fit
ide.stage.dimensions // max extent
);
cos.edit(
this.world(),

Wyświetl plik

@ -84,7 +84,7 @@ BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, BooleanSlotMorph,
localize, TableMorph, TableFrameMorph, normalizeCanvas, VectorPaintEditorMorph,
AlignmentMorph, Process, WorldMap, copyCanvas, useBlurredShadows*/
modules.objects = '2021-March-09';
modules.objects = '2021-March-17';
var SpriteMorph;
var StageMorph;
@ -3732,7 +3732,9 @@ SpriteMorph.prototype.doWearPreviousCostume = function () {
};
SpriteMorph.prototype.doSwitchToCostume = function (id, noShadow) {
var w = 0, h = 0;
var w = 0,
h = 0,
stage;
if (id instanceof List) { // try to turn a list of pixels into a costume
if (this.costume) {
// recycle dimensions of current costume
@ -3741,8 +3743,9 @@ SpriteMorph.prototype.doSwitchToCostume = function (id, noShadow) {
}
if (w * h !== id.length()) {
// assume stage's dimensions
w = StageMorph.prototype.dimensions.x;
h = StageMorph.prototype.dimensions.y;
stage = this.parentThatIsA(StageMorph);
w = stage.dimensions.x;
h = stage.dimensions.y;
}
id = Process.prototype.reportNewCostume(
id,
@ -7660,7 +7663,7 @@ StageMorph.uber = FrameMorph.prototype;
// StageMorph preferences settings
StageMorph.prototype.dimensions = new Point(480, 360); // unscaled extent
StageMorph.prototype.dimensions = new Point(480, 360); // fallback unscaled ext
StageMorph.prototype.frameRate = 0; // unscheduled per default
StageMorph.prototype.isCachingPrimitives
@ -7688,6 +7691,7 @@ function StageMorph(globals) {
StageMorph.prototype.init = function (globals) {
this.name = localize('Stage');
this.dimensions = new Point(480, 360); // unscaled extent
this.instrument = null;
this.threads = new ThreadManager();
this.variables = new VariableFrame(globals || null, this);
@ -9886,10 +9890,10 @@ SpriteBubbleMorph.prototype.fixLayout = function () {
// Costume instance creation
function Costume(canvas, name, rotationCenter, noFit) {
function Costume(canvas, name, rotationCenter, noFit, maxExtent) {
this.contents = canvas ? normalizeCanvas(canvas, true)
: newCanvas(null, true);
if (!noFit) {this.shrinkToFit(this.maxExtent()); }
if (!noFit) {this.shrinkToFit(maxExtent || this.maxExtent()); }
this.name = name || null;
this.rotationCenter = rotationCenter || this.center();
this.version = Date.now(); // for observer optimization
@ -10094,7 +10098,7 @@ Costume.prototype.edit = function (aWorld, anIDE, isnew, oncancel, onsubmit) {
editor.openIn(
aWorld,
isnew ?
newCanvas(StageMorph.prototype.dimensions, true) :
newCanvas(anIDE.stage.dimensions, true) :
this.contents,
isnew ?
null :
@ -10341,7 +10345,7 @@ SVG_Costume.prototype.edit = function (
editor.oncancel = oncancel || nop;
editor.openIn(
aWorld,
isnew ? newCanvas(StageMorph.prototype.dimensions) : this.contents,
isnew ? newCanvas(anIDE.stage.dimensions) : this.contents,
isnew ? new Point(240, 180) : this.rotationCenter,
(img, rc, shapes) => {
myself.contents = img;
@ -12165,7 +12169,6 @@ StagePrompterMorph.prototype.init = function (question) {
if (this.label) {this.add(this.label); }
this.add(this.inputField);
this.add(this.button);
this.setWidth(StageMorph.prototype.dimensions.x - 20);
this.fixLayout();
};

Wyświetl plik

@ -71,18 +71,19 @@
2020 Apr 14 - Morphic2 migration (Jens)
2020 May 17 - Pipette alpha fix (Joan)
2020 July 13 - modified scale buttons (Jadga)
2020 Jul 13 - modified scale buttons (Jadga)
2021 Mar 17 - moved stage dimension handling to scenes (Jens)
*/
/*global Point, Rectangle, DialogBoxMorph, AlignmentMorph, PushButtonMorph,
Color, SymbolMorph, newCanvas, Morph, StringMorph, Costume, SpriteMorph, nop,
localize, InputFieldMorph, SliderMorph, ToggleMorph, ToggleButtonMorph,
BoxMorph, modules, radians, MorphicPreferences, getDocumentPositionOf,
StageMorph, isNil, SVG_Costume*/
/*global Point, Rectangle, DialogBoxMorph, AlignmentMorph, PushButtonMorph, nop,
Color, SymbolMorph, newCanvas, Morph, StringMorph, Costume, SpriteMorph, isNil,
localize, InputFieldMorph, SliderMorph, ToggleMorph, ToggleButtonMorph, modules,
BoxMorph, radians, MorphicPreferences, getDocumentPositionOf, SVG_Costume*/
// Global stuff ////////////////////////////////////////////////////////
modules.paint = '2020-July-13';
modules.paint = '2021-March-17';
// Declarations
@ -106,6 +107,7 @@ function PaintEditorMorph() {
PaintEditorMorph.prototype.init = function () {
// additional properties:
this.ide = null;
this.paper = null; // paint canvas
this.oncancel = null;
@ -116,15 +118,16 @@ PaintEditorMorph.prototype.init = function () {
this.labelString = "Paint Editor";
this.createLabel();
// build contents:
this.buildContents();
// building the contents happens when I am opened with an IDE
// so my extent can be adjusted accordingly (jens)
// this.buildContents();
};
PaintEditorMorph.prototype.buildContents = function () {
var myself = this;
this.paper = new PaintCanvasMorph(function () {return myself.shift; });
this.paper.setExtent(StageMorph.prototype.dimensions);
this.paper.setExtent(this.ide.stage.dimensions);
this.addBody(new AlignmentMorph('row', this.padding));
this.controls = new AlignmentMorph('column', this.padding / 2);
@ -293,6 +296,8 @@ PaintEditorMorph.prototype.openIn = function (
this.callback = callback || nop;
this.ide = anIDE;
this.buildContents();
this.processKeyUp = function () {
myself.shift = false;
myself.propertiesControls.constrain.refresh();

Wyświetl plik

@ -54,14 +54,16 @@
- select primary color with right-click (in addition to shift-click)
2020, April 15 (Jens):
- migrated to new Morphic2 architecture
2021, March 17 (Jens):
- moved stage dimension handling to scenes
*/
/*global Point, Object, Rectangle, AlignmentMorph, Morph, XML_Element, nop,
PaintColorPickerMorph, Color, SliderMorph, InputFieldMorph, ToggleMorph,
TextMorph, Image, newCanvas, PaintEditorMorph, StageMorph, Costume, isNil,
localize, PaintCanvasMorph, StringMorph, detect, modules*/
/*global Point, Object, Rectangle, AlignmentMorph, Morph, XML_Element, localize,
PaintColorPickerMorph, Color, SliderMorph, InputFieldMorph, ToggleMorph, isNil,
TextMorph, Image, newCanvas, PaintEditorMorph, Costume, nop, PaintCanvasMorph,
StringMorph, detect, modules*/
modules.sketch = '2020-July-13';
modules.sketch = '2021-March-17';
// Declarations
@ -999,7 +1001,7 @@ VectorPaintEditorMorph.prototype.buildEdits = function () {
};
VectorPaintEditorMorph.prototype.convertToBitmap = function () {
var canvas = newCanvas(StageMorph.prototype.dimensions),
var canvas = newCanvas(this.ide.stage.dimensions),
myself = this;
this.object = new Costume();
@ -1053,7 +1055,14 @@ VectorPaintEditorMorph.prototype.openIn = function (
var myself = this,
isEmpty = isNil(shapes) || shapes.length === 0;
VectorPaintEditorMorph.uber.openIn.call(this, world, null, oldrc, callback, anIDE);
VectorPaintEditorMorph.uber.openIn.call(
this,
world,
null,
oldrc,
callback,
anIDE
);
this.ide = anIDE;
this.paper.drawNew();
this.paper.changed();
@ -1203,7 +1212,7 @@ VectorPaintEditorMorph.prototype.buildContents = function() {
this.paper.destroy();
this.paper = new VectorPaintCanvasMorph(myself.shift);
this.paper.setExtent(StageMorph.prototype.dimensions);
this.paper.setExtent(this.ide.stage.dimensions);
this.body.add(this.paper);
this.refreshToolButtons();

Wyświetl plik

@ -60,7 +60,7 @@ SyntaxElementMorph, BooleanSlotMorph, normalizeCanvas, contains, Scene*/
// Global stuff ////////////////////////////////////////////////////////
modules.store = '2021-March-12';
modules.store = '2021-March-17';
// XML_Serializer ///////////////////////////////////////////////////////
@ -411,16 +411,15 @@ SnapSerializer.prototype.rawLoadProjectModel = function (xmlNode, remixID) {
project.pentrails.src = model.pentrails.contents;
}
project.stage.setTempo(model.stage.attributes.tempo);
StageMorph.prototype.dimensions = new Point(480, 360);
if (model.stage.attributes.width) {
StageMorph.prototype.dimensions.x =
project.stage.dimensions.x =
Math.max(+model.stage.attributes.width, 240);
}
if (model.stage.attributes.height) {
StageMorph.prototype.dimensions.y =
project.stage.dimensions.y =
Math.max(+model.stage.attributes.height, 180);
}
project.stage.setExtent(StageMorph.prototype.dimensions);
project.stage.setExtent(project.stage.dimensions);
SpriteMorph.prototype.useFlatLineEnds =
model.stage.attributes.lines === 'flat';
BooleanSlotMorph.prototype.isTernary =
@ -1692,8 +1691,8 @@ StageMorph.prototype.toXML = function (serializer) {
(ide && ide.projectNotes) ? ide.projectNotes : '',
thumbdata,
this.name,
StageMorph.prototype.dimensions.x,
StageMorph.prototype.dimensions.y,
this.dimensions.x,
this.dimensions.y,
costumeIdx,
this.color.r,
this.color.g,