kopia lustrzana https://github.com/backface/turtlestitch
rodzic
020f95992d
commit
d098dbb4ba
|
@ -1653,3 +1653,7 @@ ______
|
|||
130422
|
||||
------
|
||||
* GUI: Double clicking support for cloud side of project dialog
|
||||
|
||||
130423
|
||||
------
|
||||
* Lists, Objects: Circularity no longer breaks watchers
|
||||
|
|
13
lists.js
13
lists.js
|
@ -61,7 +61,7 @@ PushButtonMorph, SyntaxElementMorph, Color, Point, WatcherMorph,
|
|||
StringMorph, SpriteMorph, ScrollFrameMorph, CellMorph, ArrowMorph,
|
||||
MenuMorph, snapEquals, Morph, isNil, localize*/
|
||||
|
||||
modules.lists = '2013-April-12';
|
||||
modules.lists = '2013-April-23';
|
||||
|
||||
var List;
|
||||
var ListWatcherMorph;
|
||||
|
@ -345,11 +345,11 @@ ListWatcherMorph.prototype.cellColor =
|
|||
|
||||
// ListWatcherMorph instance creation:
|
||||
|
||||
function ListWatcherMorph(list) {
|
||||
this.init(list);
|
||||
function ListWatcherMorph(list, parentCell) {
|
||||
this.init(list, parentCell);
|
||||
}
|
||||
|
||||
ListWatcherMorph.prototype.init = function (list) {
|
||||
ListWatcherMorph.prototype.init = function (list, parentCell) {
|
||||
var myself = this;
|
||||
|
||||
this.list = list || new List();
|
||||
|
@ -357,6 +357,7 @@ ListWatcherMorph.prototype.init = function (list) {
|
|||
this.range = 100;
|
||||
this.lastUpdated = Date.now();
|
||||
this.lastCell = null;
|
||||
this.parentCell = parentCell || null; // for circularity detection
|
||||
|
||||
// elements declarations
|
||||
this.label = new StringMorph(
|
||||
|
@ -434,6 +435,7 @@ ListWatcherMorph.prototype.update = function (anyway) {
|
|||
starttime, maxtime = 1000;
|
||||
|
||||
this.frame.contents.children.forEach(function (m) {
|
||||
|
||||
if (m instanceof CellMorph
|
||||
&& m.contentsMorph instanceof ListWatcherMorph) {
|
||||
m.contentsMorph.update();
|
||||
|
@ -529,7 +531,8 @@ ListWatcherMorph.prototype.update = function (anyway) {
|
|||
cell = new CellMorph(
|
||||
this.list.at(idx),
|
||||
this.cellColor,
|
||||
idx
|
||||
idx,
|
||||
this.parentCell
|
||||
);
|
||||
button = new PushButtonMorph(
|
||||
this.list.remove,
|
||||
|
|
39
objects.js
39
objects.js
|
@ -120,7 +120,7 @@ PrototypeHatBlockMorph*/
|
|||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.objects = '2013-April-19';
|
||||
modules.objects = '2013-April-23';
|
||||
|
||||
var SpriteMorph;
|
||||
var StageMorph;
|
||||
|
@ -4805,16 +4805,17 @@ CellMorph.uber = BoxMorph.prototype;
|
|||
|
||||
// CellMorph instance creation:
|
||||
|
||||
function CellMorph(contents, color, idx) {
|
||||
this.init(contents, color, idx);
|
||||
function CellMorph(contents, color, idx, parentCell) {
|
||||
this.init(contents, color, idx, parentCell);
|
||||
}
|
||||
|
||||
CellMorph.prototype.init = function (contents, color, idx) {
|
||||
CellMorph.prototype.init = function (contents, color, idx, parentCell) {
|
||||
this.contents = (contents === 0 ? 0
|
||||
: contents === false ? false
|
||||
: contents || '');
|
||||
this.isEditable = isNil(idx) ? false : true;
|
||||
this.idx = idx || null; // for list watchers
|
||||
this.parentCell = parentCell || null; // for list circularity detection
|
||||
CellMorph.uber.init.call(
|
||||
this,
|
||||
SyntaxElementMorph.prototype.corner,
|
||||
|
@ -4842,6 +4843,17 @@ CellMorph.prototype.normal = function () {
|
|||
this.changed();
|
||||
};
|
||||
|
||||
// CellMorph circularity testing:
|
||||
|
||||
|
||||
CellMorph.prototype.isCircular = function (list) {
|
||||
if (!this.parentCell) {return false; }
|
||||
if (list instanceof List) {
|
||||
return this.contents === list || this.parentCell.isCircular(list);
|
||||
}
|
||||
return this.parentCell.isCircular(this.contents);
|
||||
};
|
||||
|
||||
// CellMorph layout:
|
||||
|
||||
CellMorph.prototype.fixLayout = function () {
|
||||
|
@ -4914,8 +4926,23 @@ CellMorph.prototype.drawNew = function () {
|
|||
this.contentsMorph.silentSetHeight(img.height);
|
||||
this.contentsMorph.image = img;
|
||||
} else if (this.contents instanceof List) {
|
||||
this.contentsMorph = new ListWatcherMorph(this.contents);
|
||||
this.contentsMorph.isDraggable = false;
|
||||
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() : '',
|
||||
|
|
Ładowanie…
Reference in New Issue