summaryrefslogtreecommitdiff
path: root/blocks.js
diff options
context:
space:
mode:
authorGubolin <gubolin@fantasymail.de>2015-03-08 09:54:57 +0100
committerGubolin <gubolin@fantasymail.de>2015-03-08 09:54:57 +0100
commit526a595c5e00f171eb814f063e58a6c18c5784d4 (patch)
tree7043e1fe7a6d2434fc6e2072961948bb2c3e44dd /blocks.js
parent1ed98c27ff3c1a825e75783481a4e739fb610bdb (diff)
parentb6d846444e44d41842e253b7276cd590d7163349 (diff)
downloadsnap-526a595c5e00f171eb814f063e58a6c18c5784d4.tar.gz
snap-526a595c5e00f171eb814f063e58a6c18c5784d4.zip
Merge branch 'development' into gh-pages
Diffstat (limited to 'blocks.js')
-rw-r--r--blocks.js67
1 files changed, 62 insertions, 5 deletions
diff --git a/blocks.js b/blocks.js
index 6210e22..470ccd5 100644
--- a/blocks.js
+++ b/blocks.js
@@ -9,7 +9,7 @@
written by Jens Mönig
jens@moenig.org
- Copyright (C) 2014 by Jens Mönig
+ Copyright (C) 2015 by Jens Mönig
This file is part of Snap!.
@@ -155,7 +155,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph, Costume*/
// Global stuff ////////////////////////////////////////////////////////
-modules.blocks = '2014-November-21';
+modules.blocks = '2015-March-06';
var SyntaxElementMorph;
@@ -340,6 +340,7 @@ SyntaxElementMorph.prototype.setScale = function (num) {
};
SyntaxElementMorph.prototype.setScale(1);
+SyntaxElementMorph.prototype.isCachingInputs = true;
// SyntaxElementMorph instance creation:
@@ -356,6 +357,7 @@ SyntaxElementMorph.prototype.init = function () {
SyntaxElementMorph.uber.init.call(this);
this.defaults = [];
+ this.cachedInputs = null;
};
// SyntaxElementMorph accessing:
@@ -375,10 +377,35 @@ SyntaxElementMorph.prototype.parts = function () {
SyntaxElementMorph.prototype.inputs = function () {
// answer my arguments and nested reporters
- return this.parts().filter(function (part) {
- return part instanceof SyntaxElementMorph;
- });
+ if (isNil(this.cachedInputs) || !this.isCachingInputs) {
+ this.cachedInputs = this.parts().filter(function (part) {
+ return part instanceof SyntaxElementMorph;
+ });
+ }
+ // this.debugCachedInputs();
+ return this.cachedInputs;
+};
+SyntaxElementMorph.prototype.debugCachedInputs = function () {
+ // private - only used for manually debugging inputs caching
+ var realInputs, i;
+ if (!isNil(this.cachedInputs)) {
+ realInputs = this.parts().filter(function (part) {
+ return part instanceof SyntaxElementMorph;
+ });
+ }
+ if (this.cachedInputs.length !== realInputs.length) {
+ throw new Error('cached inputs size do not match: ' +
+ this.constructor.name);
+ }
+ for (i = 0; i < realInputs.length; i += 1) {
+ if (this.cachedInputs[i] !== realInputs[i]) {
+ throw new Error('cached input does not match ' +
+ this.constructor.name +
+ ' ' +
+ i);
+ }
+ }
};
SyntaxElementMorph.prototype.allInputs = function () {
@@ -494,6 +521,7 @@ SyntaxElementMorph.prototype.replaceInput = function (oldArg, newArg) {
replacement.drawNew();
this.fixLayout();
}
+ this.cachedInputs = null;
this.endLayout();
};
@@ -529,6 +557,7 @@ SyntaxElementMorph.prototype.silentReplaceInput = function (oldArg, newArg) {
replacement.drawNew();
this.fixLayout();
}
+ this.cachedInputs = null;
};
SyntaxElementMorph.prototype.revertToDefaultInput = function (arg, noValues) {
@@ -571,6 +600,7 @@ SyntaxElementMorph.prototype.revertToDefaultInput = function (arg, noValues) {
} else if (deflt instanceof RingMorph) {
deflt.fixBlockColor();
}
+ this.cachedInputs = null;
};
SyntaxElementMorph.prototype.isLocked = function () {
@@ -848,6 +878,20 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
true // read-only
);
break;
+ case '%interaction':
+ part = new InputSlotMorph(
+ null, // text
+ false, // numeric?
+ {
+ 'clicked' : ['clicked'],
+ 'pressed' : ['pressed'],
+ 'dropped' : ['dropped'],
+ 'mouse-entered' : ['mouse-entered'],
+ 'mouse-departed' : ['mouse-departed']
+ },
+ true // read-only
+ );
+ break;
case '%dates':
part = new InputSlotMorph(
null, // text
@@ -1949,6 +1993,7 @@ BlockMorph.prototype.init = function () {
BlockMorph.uber.init.call(this);
this.color = new Color(0, 17, 173);
+ this.cashedInputs = null;
};
BlockMorph.prototype.receiver = function () {
@@ -2054,6 +2099,7 @@ BlockMorph.prototype.setSpec = function (spec) {
});
this.blockSpec = spec;
this.fixLayout();
+ this.cachedInputs = null;
};
BlockMorph.prototype.buildSpec = function () {
@@ -2446,6 +2492,7 @@ BlockMorph.prototype.restoreInputs = function (oldInputs) {
}
i += 1;
});
+ this.cachedInputs = null;
};
BlockMorph.prototype.showHelp = function () {
@@ -3041,6 +3088,7 @@ BlockMorph.prototype.fullCopy = function () {
//block.comment = null;
});
+ ans.cachedInputs = null;
return ans;
};
@@ -4610,6 +4658,7 @@ RingMorph.uber = ReporterBlockMorph.prototype;
// RingMorph preferences settings:
+RingMorph.prototype.isCachingInputs = false;
// RingMorph.prototype.edge = 2;
// RingMorph.prototype.rounding = 9;
// RingMorph.prototype.alpha = 0.8;
@@ -9227,6 +9276,10 @@ MultiArgMorph.prototype = new ArgMorph();
MultiArgMorph.prototype.constructor = MultiArgMorph;
MultiArgMorph.uber = ArgMorph.prototype;
+// MultiArgMorph preferences settings
+
+MultiArgMorph.prototype.isCachingInputs = false;
+
// MultiArgMorph instance creation:
function MultiArgMorph(
@@ -9657,6 +9710,10 @@ ArgLabelMorph.prototype = new ArgMorph();
ArgLabelMorph.prototype.constructor = ArgLabelMorph;
ArgLabelMorph.uber = ArgMorph.prototype;
+// ArgLabelMorph preferences settings
+
+ArgLabelMorph.prototype.isCachingInputs = false;
+
// MultiArgMorph instance creation:
function ArgLabelMorph(argMorph, labelTxt) {