summaryrefslogtreecommitdiff
path: root/blocks.js
diff options
context:
space:
mode:
Diffstat (limited to 'blocks.js')
-rw-r--r--blocks.js42
1 files changed, 39 insertions, 3 deletions
diff --git a/blocks.js b/blocks.js
index 061e176..3e9e16c 100644
--- a/blocks.js
+++ b/blocks.js
@@ -153,7 +153,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph*/
// Global stuff ////////////////////////////////////////////////////////
-modules.blocks = '2013-April-05';
+modules.blocks = '2013-April-17';
var SyntaxElementMorph;
var BlockMorph;
@@ -4285,6 +4285,11 @@ ScriptsMorph.prototype.userMenu = function () {
}
menu.addItem('clean up', 'cleanUp', 'arrange scripts\nvertically');
menu.addItem('add comment', 'addComment');
+ menu.addItem(
+ 'scripts pic...',
+ 'exportScriptsPicture',
+ 'open a new window\nwith a picture of all scripts'
+ );
if (ide) {
menu.addLine();
menu.addItem(
@@ -4343,6 +4348,29 @@ ScriptsMorph.prototype.cleanUp = function () {
this.adjustBounds();
};
+ScriptsMorph.prototype.exportScriptsPicture = function () {
+ var boundingBox, pic, ctx;
+ if (this.children.length === 0) {return; }
+ boundingBox = this.children[0].fullBounds();
+ this.children.forEach(function (child) {
+ if (child.isVisible) {
+ boundingBox = boundingBox.merge(child.fullBounds());
+ }
+ });
+ pic = newCanvas(boundingBox.extent());
+ ctx = pic.getContext('2d');
+ this.children.forEach(function (child) {
+ var pos = child.position();
+ if (child.isVisible) {
+ ctx.drawImage(
+ child.fullImageClassic(),
+ pos.x - boundingBox.origin.x,
+ pos.y - boundingBox.origin.y
+ );
+ }
+ });
+ window.open(pic.toDataURL());
+};
ScriptsMorph.prototype.addComment = function () {
new CommentMorph().pickUp(this.world());
@@ -7707,13 +7735,20 @@ MultiArgMorph.prototype.drawNew = function () {
// MultiArgMorph arity control:
MultiArgMorph.prototype.addInput = function (contents) {
- var newPart = this.labelPart(this.slotSpec),
+ var i, name,
+ newPart = this.labelPart(this.slotSpec),
idx = this.children.length - 1;
// newPart.alpha = this.alpha ? 1 : (1 - this.alpha) / 2;
if (contents) {
newPart.setContents(contents);
} else if (this.elementSpec === '%scriptVars') {
- newPart.setContents('abcdefghijklmnopqrstuvwxyz'[idx - 1] || 'foo');
+ name = '';
+ i = idx;
+ while (i > 0) {
+ name = String.fromCharCode(97 + (i - 1) % 26) + name;
+ i = Math.floor((i - 1) / 26);
+ }
+ newPart.setContents(name);
} else if (contains(['%parms', '%ringparms'], this.elementSpec)) {
newPart.setContents('#' + idx);
}
@@ -9057,6 +9092,7 @@ CommentMorph.prototype.align = function (topBlock, ignoreLayer) {
CommentMorph.prototype.startFollowing = function (topBlock) {
var myself = this;
this.align(topBlock);
+ this.world().add(this);
this.addShadow();
this.stickyOffset = this.position().subtract(this.block.position());
this.step = function () {