more speech bubble widget migrations

pull/95/head
jmoenig 2020-03-18 15:08:42 +01:00
rodzic 7c09289a3b
commit 2bcdfba8db
3 zmienionych plików z 27 dodań i 68 usunięć

Wyświetl plik

@ -62,7 +62,7 @@ CellMorph, ArrowMorph, MenuMorph, snapEquals, Morph, isNil, localize, isString,
MorphicPreferences, TableDialogMorph, SpriteBubbleMorph, SpeechBubbleMorph, MorphicPreferences, TableDialogMorph, SpriteBubbleMorph, SpeechBubbleMorph,
TableFrameMorph, TableMorph, Variable, isSnapObject, Costume, contains*/ TableFrameMorph, TableMorph, Variable, isSnapObject, Costume, contains*/
modules.lists = '2020-March-16'; modules.lists = '2020-March-18';
var List; var List;
var ListWatcherMorph; var ListWatcherMorph;
@ -881,8 +881,10 @@ ListWatcherMorph.prototype.fixLayout = function () {
this.plusButton.setBottom(this.bottom() - 3); this.plusButton.setBottom(this.bottom() - 3);
} }
if (this.parent && this.parent.fixLayout) { if (this.parent) {
this.parent.changed();
this.parent.fixLayout(); this.parent.fixLayout();
this.parent.rerender();
} }
}; };

Wyświetl plik

@ -9437,20 +9437,22 @@ SpriteBubbleMorph.prototype.init = function (
SpriteBubbleMorph.uber.init.call( SpriteBubbleMorph.uber.init.call(
this, this,
this.dataAsMorph(data), this.data,
sprite.bubbleColor, sprite.bubbleColor,
null, null,
null, null,
isQuestion ? sprite.blockColor.sensing : sprite.bubbleBorderColor, isQuestion ? sprite.blockColor.sensing : sprite.bubbleBorderColor,
null, null,
isThought isThought,
true // no shadow
); );
}; };
// SpriteBubbleMorph contents formatting // SpriteBubbleMorph contents formatting
SpriteBubbleMorph.prototype.dataAsMorph = function (data, toggle) { SpriteBubbleMorph.prototype.dataAsMorph = function (data) {
var contents, var toggle = false, // +++ former argument governing whether a list is shown as table view or list view
contents,
isTable, isTable,
sprite = SpriteMorph.prototype, sprite = SpriteMorph.prototype,
isText, isText,
@ -9565,7 +9567,7 @@ SpriteBubbleMorph.prototype.dataAsMorph = function (data, toggle) {
// scale contents image // scale contents image
scaledImg = newCanvas(contents.extent().multiplyBy(this.scale)); scaledImg = newCanvas(contents.extent().multiplyBy(this.scale));
scaledImg.getContext('2d').drawImage( scaledImg.getContext('2d').drawImage(
contents.image, contents.cachedImage,
0, 0,
0, 0,
scaledImg.width, scaledImg.width,
@ -9590,27 +9592,21 @@ SpriteBubbleMorph.prototype.setScale = function (scale) {
SpriteBubbleMorph.prototype.fixLayout = function () { SpriteBubbleMorph.prototype.fixLayout = function () {
var sprite = SpriteMorph.prototype, var sprite = SpriteMorph.prototype,
toggle; // +++ old parameter used to switch from table to list view, to be replaced toggle; // ++++ old parameter used to switch from table to list view, to be replaced
if (this.data instanceof List) { // rebuild my contents
this.fixLayoutForList(); if (!(this.contentsMorph instanceof ListWatcherMorph ||
return; this.contentsMorph instanceof TableFrameMorph)) {
this.contentsMorph.destroy();
this.contentsMorph = this.dataAsMorph(this.data);
} }
this.add(this.contentsMorph);
// scale my settings // scale my settings
this.edge = sprite.bubbleCorner * this.scale; this.edge = sprite.bubbleCorner * this.scale;
this.border = sprite.bubbleBorder * this.scale; this.border = sprite.bubbleBorder * this.scale;
this.padding = sprite.bubbleCorner / 2 * this.scale; this.padding = sprite.bubbleCorner / 2 * this.scale;
// re-build my contents
// ++++ to do: move this into a separate method, then collapse both
// fixLayout() methods into a single one
if (this.contentsMorph) {
this.contentsMorph.destroy();
}
this.contentsMorph = this.dataAsMorph(this.data, toggle);
this.add(this.contentsMorph);
// adjust my dimensions // adjust my dimensions
this.bounds.setWidth(this.contentsMorph.width() this.bounds.setWidth(this.contentsMorph.width()
+ (this.padding ? this.padding * 2 : this.edge * 2)); + (this.padding ? this.padding * 2 : this.edge * 2));
@ -9620,9 +9616,6 @@ SpriteBubbleMorph.prototype.fixLayout = function () {
+ this.padding * 2 + this.padding * 2
+ 2); + 2);
// draw my outline // +++ to be removed, should we call uber >> fixLayout()??
// ++++ SpeechBubbleMorph.uber.drawNew.call(this);
// position my contents // position my contents
this.contentsMorph.setPosition(this.position().add( this.contentsMorph.setPosition(this.position().add(
new Point( new Point(
@ -9632,42 +9625,6 @@ SpriteBubbleMorph.prototype.fixLayout = function () {
)); ));
}; };
// SpriteBubbleMorph resizing:
SpriteBubbleMorph.prototype.fixLayoutForList = function () {
// ++++ to do: collapse this into a a single method
// to be used when resizing list watchers
var sprite = SpriteMorph.prototype;
this.changed();
// scale my settings
this.edge = sprite.bubbleCorner * this.scale;
this.border = sprite.bubbleBorder * this.scale;
this.padding = sprite.bubbleCorner / 2 * this.scale;
// adjust my layout
this.bounds.setWidth(this.contentsMorph.width()
+ (this.padding ? this.padding * 2 : this.edge * 2));
this.bounds.setHeight(this.contentsMorph.height()
+ this.edge
+ this.border * 2
+ this.padding * 2
+ 2);
// draw my outline
// ++++ SpeechBubbleMorph.uber.drawNew.call(this);
// position my contents
this.contentsMorph.setPosition(this.position().add(
new Point(
this.padding || this.edge,
this.border + this.padding + 1
)
));
// +++ this.changed();
};
// Costume ///////////////////////////////////////////////////////////// // Costume /////////////////////////////////////////////////////////////
/* /*
@ -10855,13 +10812,11 @@ CellMorph.prototype.fixLayout = function (justMe) {
this.contentsMorph.setCenter(this.center()); this.contentsMorph.setCenter(this.center());
} }
if (this.parent && this.parent.fixLayout) { // variable watcher if (this.parent) {
// ++++ to do: reflow list watcher parent
this.parent.changed();
this.parent.fixLayout(); this.parent.fixLayout();
} else { this.parent.rerender();
listwatcher = this.parentThatIsA(ListWatcherMorph);
if (listwatcher) {
listwatcher.fixLayout();
}
} }
}; };

Wyświetl plik

@ -70,7 +70,7 @@ SpriteMorph, Context, Costume, BlockEditorMorph, SymbolMorph, List,
SyntaxElementMorph, MenuMorph, SpriteBubbleMorph, SpeechBubbleMorph, Sound, SyntaxElementMorph, MenuMorph, SpriteBubbleMorph, SpeechBubbleMorph, Sound,
CellMorph, ListWatcherMorph, isNil, BoxMorph, Variable, isSnapObject*/ CellMorph, ListWatcherMorph, isNil, BoxMorph, Variable, isSnapObject*/
modules.tables = '2020-March-17'; modules.tables = '2020-March-18';
var Table; var Table;
var TableCellMorph; var TableCellMorph;
@ -1133,9 +1133,11 @@ TableFrameMorph.prototype.fixLayout = function () {
var ext = this.extent(); var ext = this.extent();
if (this.tableMorph.extent().eq(ext)) {return; } if (this.tableMorph.extent().eq(ext)) {return; }
this.tableMorph.setExtent(this.extent()); this.tableMorph.setExtent(this.extent());
if (this.parent && this.parent.fixLayout) { if (this.parent) {
this.parent.changed();
this.parent.fixLayout(); this.parent.fixLayout();
} this.parent.rerender();
}
}; };
// TableFrameMorph result / speech balloon support: // TableFrameMorph result / speech balloon support: