summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmoenig <jens@moenig.org>2014-06-04 12:40:03 +0200
committerjmoenig <jens@moenig.org>2014-06-04 12:40:03 +0200
commit50203901eaac7f4ed277bb8ab981037dcc28687f (patch)
treeb70798c7050e0e55a1f8bc7460930b69f9f72410
parentef3997cccf833aebd3d5d3fbecfdc2c13dab9631 (diff)
downloadsnap-yow-50203901eaac7f4ed277bb8ab981037dcc28687f.tar.gz
snap-yow-50203901eaac7f4ed277bb8ab981037dcc28687f.zip
BYOB: new scriptsPicture() method for custom block definitions
-rw-r--r--byob.js39
1 files changed, 38 insertions, 1 deletions
diff --git a/byob.js b/byob.js
index 6a10110..0f79acf 100644
--- a/byob.js
+++ b/byob.js
@@ -106,7 +106,7 @@ SymbolMorph, isNil*/
// Global stuff ////////////////////////////////////////////////////////
-modules.byob = '2014-May-02';
+modules.byob = '2014-Jun-04';
// Declarations
@@ -336,6 +336,43 @@ CustomBlockDefinition.prototype.parseSpec = function (spec) {
return parts;
};
+// CustomBlockDefinition picturing
+
+CustomBlockDefinition.prototype.scriptsPicture = function () {
+ var scripts, proto, block, comment;
+
+ scripts = new ScriptsMorph();
+ scripts.cleanUpMargin = 10;
+ proto = new PrototypeHatBlockMorph(this);
+ proto.setPosition(scripts.position().add(10));
+ if (this.comment !== null) {
+ comment = this.comment.fullCopy();
+ proto.comment = comment;
+ comment.block = proto;
+ }
+ if (this.body !== null) {
+ proto.nextBlock(this.body.expression.fullCopy());
+ }
+ scripts.add(proto);
+ proto.fixBlockColor(null, true);
+ this.scripts.forEach(function (element) {
+ block = element.fullCopy();
+ block.setPosition(scripts.position().add(element.position()));
+ scripts.add(block);
+ if (block instanceof BlockMorph) {
+ block.allComments().forEach(function (comment) {
+ comment.align(block);
+ });
+ }
+ });
+ proto.allComments().forEach(function (comment) {
+ comment.align(proto);
+ });
+ proto.children[0].fixLayout();
+ scripts.fixMultiArgs();
+ return scripts.scriptsPicture();
+};
+
// CustomCommandBlockMorph /////////////////////////////////////////////
// CustomCommandBlockMorph inherits from CommandBlockMorph: