kopia lustrzana https://github.com/backface/turtlestitch
cleaned up data monitoring
rodzic
9fa9ec2146
commit
f23f76b204
179
src/objects.js
179
src/objects.js
|
@ -84,7 +84,7 @@ BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, BooleanSlotMorph,
|
||||||
localize, TableMorph, TableFrameMorph, normalizeCanvas, VectorPaintEditorMorph,
|
localize, TableMorph, TableFrameMorph, normalizeCanvas, VectorPaintEditorMorph,
|
||||||
HandleMorph, AlignmentMorph, Process, XML_Element, WorldMap, copyCanvas*/
|
HandleMorph, AlignmentMorph, Process, XML_Element, WorldMap, copyCanvas*/
|
||||||
|
|
||||||
modules.objects = '2020-April-06';
|
modules.objects = '2020-April-12';
|
||||||
|
|
||||||
var SpriteMorph;
|
var SpriteMorph;
|
||||||
var StageMorph;
|
var StageMorph;
|
||||||
|
@ -4384,18 +4384,12 @@ SpriteMorph.prototype.overlappingPixels = function (otherSprite) {
|
||||||
SpriteMorph.prototype.doStamp = function () {
|
SpriteMorph.prototype.doStamp = function () {
|
||||||
var stage = this.parent,
|
var stage = this.parent,
|
||||||
ctx = stage.penTrails().getContext('2d'),
|
ctx = stage.penTrails().getContext('2d'),
|
||||||
isWarped = this.isWarped, // +++ should be obsolete
|
|
||||||
img = this.getImage();
|
img = this.getImage();
|
||||||
|
|
||||||
if (img.width < 1 || (img.height < 1)) {
|
if (img.width < 1 || (img.height < 1)) {
|
||||||
// too small to draw
|
// too small to draw
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* +++
|
|
||||||
if (isWarped) { // t+++ his should be obsolete and removable
|
|
||||||
this.endWarp();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
ctx.save();
|
ctx.save();
|
||||||
ctx.scale(1 / stage.scale, 1 / stage.scale);
|
ctx.scale(1 / stage.scale, 1 / stage.scale);
|
||||||
ctx.globalAlpha = this.alpha;
|
ctx.globalAlpha = this.alpha;
|
||||||
|
@ -4406,13 +4400,6 @@ SpriteMorph.prototype.doStamp = function () {
|
||||||
);
|
);
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
this.changed();
|
this.changed();
|
||||||
|
|
||||||
/* +++
|
|
||||||
if (isWarped) { // +++ this should be obsolete
|
|
||||||
this.startWarp();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
stage.cachedPenTrailsMorph = null;
|
stage.cachedPenTrailsMorph = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -9466,9 +9453,8 @@ SpriteBubbleMorph.prototype.init = function (
|
||||||
|
|
||||||
// SpriteBubbleMorph contents formatting
|
// SpriteBubbleMorph contents formatting
|
||||||
|
|
||||||
SpriteBubbleMorph.prototype.dataAsMorph = function (data, toggle) {
|
SpriteBubbleMorph.prototype.dataAsMorph = function (data) {
|
||||||
var contents,
|
var contents,
|
||||||
isTable,
|
|
||||||
sprite = SpriteMorph.prototype,
|
sprite = SpriteMorph.prototype,
|
||||||
isText,
|
isText,
|
||||||
img,
|
img,
|
||||||
|
@ -9528,13 +9514,7 @@ SpriteBubbleMorph.prototype.dataAsMorph = function (data, toggle) {
|
||||||
contents.bounds.setHeight(img.height);
|
contents.bounds.setHeight(img.height);
|
||||||
contents.cachedImage = img;
|
contents.cachedImage = img;
|
||||||
} else if (data instanceof List) {
|
} else if (data instanceof List) {
|
||||||
if (toggle && this.contentsMorph) {
|
if (data.isTable()) {
|
||||||
isTable = (this.contentsMorph instanceof ListWatcherMorph);
|
|
||||||
} else {
|
|
||||||
isTable = data.isTable();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isTable) { // (!toggle && data.isTable()) {
|
|
||||||
contents = new TableFrameMorph(new TableMorph(data, 10));
|
contents = new TableFrameMorph(new TableMorph(data, 10));
|
||||||
if (this.stage) {
|
if (this.stage) {
|
||||||
contents.expand(this.stage.extent().translateBy(
|
contents.expand(this.stage.extent().translateBy(
|
||||||
|
@ -9606,14 +9586,14 @@ SpriteBubbleMorph.prototype.setScale = function (scale) {
|
||||||
|
|
||||||
// SpriteBubbleMorph layout:
|
// SpriteBubbleMorph layout:
|
||||||
|
|
||||||
SpriteBubbleMorph.prototype.fixLayout = function (toggle) { // +++ get rid of "toggle"
|
SpriteBubbleMorph.prototype.fixLayout = function () {
|
||||||
var sprite = SpriteMorph.prototype;
|
var sprite = SpriteMorph.prototype;
|
||||||
|
|
||||||
// rebuild my contents - why? +++
|
// rebuild my contents
|
||||||
if (!(this.contentsMorph instanceof ListWatcherMorph ||
|
if (!(this.contentsMorph instanceof ListWatcherMorph ||
|
||||||
this.contentsMorph instanceof TableFrameMorph)) {
|
this.contentsMorph instanceof TableFrameMorph)) {
|
||||||
this.contentsMorph.destroy();
|
this.contentsMorph.destroy();
|
||||||
this.contentsMorph = this.dataAsMorph(this.data, toggle); // +++ get rid of "toggle"
|
this.contentsMorph = this.dataAsMorph(this.data);
|
||||||
}
|
}
|
||||||
this.add(this.contentsMorph);
|
this.add(this.contentsMorph);
|
||||||
|
|
||||||
|
@ -10842,8 +10822,7 @@ CellMorph.prototype.fixLayout = function (justMe) {
|
||||||
|
|
||||||
CellMorph.prototype.createContents = function () {
|
CellMorph.prototype.createContents = function () {
|
||||||
// re-build my contents
|
// re-build my contents
|
||||||
var type, toggle, // +++ old parameters, not sure if they're ever used and how
|
var txt,
|
||||||
txt,
|
|
||||||
img,
|
img,
|
||||||
fontSize = SyntaxElementMorph.prototype.fontSize,
|
fontSize = SyntaxElementMorph.prototype.fontSize,
|
||||||
isSameList = this.contentsMorph instanceof ListWatcherMorph
|
isSameList = this.contentsMorph instanceof ListWatcherMorph
|
||||||
|
@ -10921,7 +10900,7 @@ CellMorph.prototype.createContents = function () {
|
||||||
} else if (this.contents instanceof Sound) {
|
} else if (this.contents instanceof Sound) {
|
||||||
this.contentsMorph = new SymbolMorph('notes', 30);
|
this.contentsMorph = new SymbolMorph('notes', 30);
|
||||||
} else if (this.contents instanceof List) {
|
} else if (this.contents instanceof List) {
|
||||||
if ('table' === type || (!toggle && this.contents.isTable())) {
|
if (this.contents.isTable()) {
|
||||||
this.contentsMorph = new TableFrameMorph(new TableMorph(
|
this.contentsMorph = new TableFrameMorph(new TableMorph(
|
||||||
this.contents,
|
this.contents,
|
||||||
10
|
10
|
||||||
|
@ -10973,147 +10952,18 @@ CellMorph.prototype.update = function () {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.version !== this.contents.version) {
|
if (this.version !== this.contents.version) {
|
||||||
this.rerender(); // +++ ??
|
this.rerender();
|
||||||
this.version = this.contents.version;
|
this.version = this.contents.version;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
CellMorph.prototype.render = function (ctx) { // +++ (toggle, type) {
|
CellMorph.prototype.render = function (ctx) {
|
||||||
var toggle, type, // +++ old parameters, not sure if they're ever used
|
var fontSize = SyntaxElementMorph.prototype.fontSize;
|
||||||
txt,
|
|
||||||
img,
|
|
||||||
fontSize = SyntaxElementMorph.prototype.fontSize,
|
|
||||||
isSameList = this.contentsMorph instanceof ListWatcherMorph
|
|
||||||
&& (this.contentsMorph.list === this.contents),
|
|
||||||
isSameTable = this.contentsMorph instanceof TableFrameMorph
|
|
||||||
&& (this.contentsMorph.tableMorph.table === this.contents);
|
|
||||||
|
|
||||||
if (this.isBig) {
|
if (this.isBig) {
|
||||||
fontSize = fontSize * 1.5;
|
fontSize = fontSize * 1.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* // +++
|
|
||||||
// re-build my contents
|
|
||||||
// +++ all of this should definitely be moved to fixLayout() or to update()
|
|
||||||
if (toggle || (this.contentsMorph && !isSameList && !isSameTable)) {
|
|
||||||
this.contentsMorph.destroy();
|
|
||||||
this.version = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (toggle || (!isSameList && !isSameTable)) {
|
|
||||||
if (this.contents instanceof Morph) {
|
|
||||||
if (isSnapObject(this.contents)) {
|
|
||||||
img = this.contents.thumbnail(new Point(40, 40));
|
|
||||||
this.contentsMorph = new Morph();
|
|
||||||
this.contentsMorph.silentSetWidth(img.width);
|
|
||||||
this.contentsMorph.silentSetHeight(img.height);
|
|
||||||
this.contentsMorph.image = img;
|
|
||||||
this.version = this.contents.version;
|
|
||||||
} else {
|
|
||||||
this.contentsMorph = this.contents;
|
|
||||||
}
|
|
||||||
} else if (isString(this.contents)) {
|
|
||||||
txt = this.contents.length > 500 ?
|
|
||||||
this.contents.slice(0, 500) + '...' : this.contents;
|
|
||||||
this.contentsMorph = new TextMorph(
|
|
||||||
txt,
|
|
||||||
fontSize,
|
|
||||||
null,
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
'left' // was formerly 'center', reverted b/c of code-mapping
|
|
||||||
);
|
|
||||||
if (this.isEditable) {
|
|
||||||
this.contentsMorph.isEditable = true;
|
|
||||||
this.contentsMorph.enableSelecting();
|
|
||||||
}
|
|
||||||
this.contentsMorph.setColor(new Color(255, 255, 255));
|
|
||||||
} else if (typeof this.contents === 'boolean') {
|
|
||||||
img = SpriteMorph.prototype.booleanMorph.call(
|
|
||||||
null,
|
|
||||||
this.contents
|
|
||||||
).fullImage();
|
|
||||||
this.contentsMorph = new Morph();
|
|
||||||
this.contentsMorph.silentSetWidth(img.width);
|
|
||||||
this.contentsMorph.silentSetHeight(img.height);
|
|
||||||
this.contentsMorph.image = img;
|
|
||||||
} else if (this.contents instanceof HTMLCanvasElement) {
|
|
||||||
this.contentsMorph = new Morph();
|
|
||||||
this.contentsMorph.silentSetWidth(this.contents.width);
|
|
||||||
this.contentsMorph.silentSetHeight(this.contents.height);
|
|
||||||
this.contentsMorph.image = this.contents;
|
|
||||||
} else if (this.contents instanceof Context) {
|
|
||||||
img = this.contents.image();
|
|
||||||
this.contentsMorph = new Morph();
|
|
||||||
this.contentsMorph.silentSetWidth(img.width);
|
|
||||||
this.contentsMorph.silentSetHeight(img.height);
|
|
||||||
this.contentsMorph.image = img;
|
|
||||||
} else if (this.contents instanceof Costume) {
|
|
||||||
img = this.contents.thumbnail(new Point(40, 40));
|
|
||||||
this.contentsMorph = new Morph();
|
|
||||||
this.contentsMorph.silentSetWidth(img.width);
|
|
||||||
this.contentsMorph.silentSetHeight(img.height);
|
|
||||||
this.contentsMorph.image = img;
|
|
||||||
} else if (this.contents instanceof Sound) {
|
|
||||||
this.contentsMorph = new SymbolMorph('notes', 30);
|
|
||||||
} else if (this.contents instanceof List) {
|
|
||||||
if ('table' === type || (!toggle && this.contents.isTable())) {
|
|
||||||
this.contentsMorph = new TableFrameMorph(new TableMorph(
|
|
||||||
this.contents,
|
|
||||||
10
|
|
||||||
));
|
|
||||||
this.contentsMorph.expand(new Point(200, 150));
|
|
||||||
} else {
|
|
||||||
if (this.isCircular()) {
|
|
||||||
this.contentsMorph = new TextMorph(
|
|
||||||
'(...)',
|
|
||||||
fontSize,
|
|
||||||
null,
|
|
||||||
false, // bold
|
|
||||||
true, // italic
|
|
||||||
'center'
|
|
||||||
);
|
|
||||||
this.contentsMorph.setColor(new Color(255, 255, 255));
|
|
||||||
} else {
|
|
||||||
this.contentsMorph = new ListWatcherMorph(
|
|
||||||
this.contents,
|
|
||||||
this
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.contentsMorph.isDraggable = false;
|
|
||||||
} else {
|
|
||||||
this.contentsMorph = new TextMorph(
|
|
||||||
!isNil(this.contents) ? this.contents.toString() : '',
|
|
||||||
fontSize,
|
|
||||||
null,
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
'center'
|
|
||||||
);
|
|
||||||
if (this.isEditable) {
|
|
||||||
this.contentsMorph.isEditable = true;
|
|
||||||
this.contentsMorph.enableSelecting();
|
|
||||||
}
|
|
||||||
this.contentsMorph.setColor(new Color(255, 255, 255));
|
|
||||||
}
|
|
||||||
this.add(this.contentsMorph);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// adjust my dimensions
|
|
||||||
/* // +++
|
|
||||||
this.bounds.setHeight(this.contentsMorph.height()
|
|
||||||
+ this.edge
|
|
||||||
+ this.border * 2);
|
|
||||||
this.bounds.setWidth(Math.max(
|
|
||||||
this.contentsMorph.width() + this.edge * 2,
|
|
||||||
(this.contents instanceof Context ||
|
|
||||||
this.contents instanceof List ? 0 :
|
|
||||||
SyntaxElementMorph.prototype.fontSize * 3.5)
|
|
||||||
));
|
|
||||||
*/
|
|
||||||
|
|
||||||
// draw my outline
|
// draw my outline
|
||||||
if ((this.edge === 0) && (this.border === 0)) {
|
if ((this.edge === 0) && (this.border === 0)) {
|
||||||
BoxMorph.uber.render.call(this, ctx);
|
BoxMorph.uber.render.call(this, ctx);
|
||||||
|
@ -11142,13 +10992,6 @@ CellMorph.prototype.render = function (ctx) { // +++ (toggle, type) {
|
||||||
ctx.shadowColor = this.color.darker(80).toString();
|
ctx.shadowColor = this.color.darker(80).toString();
|
||||||
this.drawShadow(ctx, this.edge, this.border / 2);
|
this.drawShadow(ctx, this.edge, this.border / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// position my contents
|
|
||||||
/* // +++
|
|
||||||
if (toggle || (!isSameList && !isSameTable)) {
|
|
||||||
this.contentsMorph.setCenter(this.center());
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
CellMorph.prototype.drawShadow = function (context, radius, inset) {
|
CellMorph.prototype.drawShadow = function (context, radius, inset) {
|
||||||
|
|
Ładowanie…
Reference in New Issue