summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmoenig <jens@moenig.org>2014-06-04 12:40:44 +0200
committerjmoenig <jens@moenig.org>2014-06-04 12:40:44 +0200
commitbae41fde2870706b200aa9ec2b0e00ca5ceb59d9 (patch)
tree34f9ce12d6dc62d99030289407461d1303a41f4a
parent50203901eaac7f4ed277bb8ab981037dcc28687f (diff)
downloadsnap-yow-bae41fde2870706b200aa9ec2b0e00ca5ceb59d9.tar.gz
snap-yow-bae41fde2870706b200aa9ec2b0e00ca5ceb59d9.zip
GUI: new (hidden) feature: “Export all scripts as pic”
(including custom block refs)
-rw-r--r--gui.js61
-rwxr-xr-xhistory.txt6
2 files changed, 66 insertions, 1 deletions
diff --git a/gui.js b/gui.js
index 981696a..67510cf 100644
--- a/gui.js
+++ b/gui.js
@@ -69,7 +69,7 @@ SpeechBubbleMorph*/
// Global stuff ////////////////////////////////////////////////////////
-modules.gui = '2014-May-26';
+modules.gui = '2014-Jun-04';
// Declarations
@@ -2350,6 +2350,15 @@ IDE_Morph.prototype.projectMenu = function () {
'show global custom block definitions as XML\nin a new browser window'
);
+ if (shiftClicked) {
+ menu.addItem(
+ 'Export all scripts as pic...',
+ function () {myself.exportScriptsPicture(); },
+ 'show a picture of all scripts\nand block definitions',
+ new Color(100, 0, 0)
+ );
+ }
+
menu.addLine();
menu.addItem(
'Import tools',
@@ -2847,6 +2856,56 @@ IDE_Morph.prototype.exportSprite = function (sprite) {
+ '</sprites>');
};
+IDE_Morph.prototype.exportScriptsPicture = function () {
+ var pics = [],
+ pic,
+ padding = 20,
+ w = 0,
+ h = 0,
+ y = 0,
+ ctx;
+
+ // collect all script pics
+ this.sprites.asArray().forEach(function (sprite) {
+ pics.push(sprite.image);
+ pics.push(sprite.scripts.scriptsPicture());
+ sprite.customBlocks.forEach(function (def) {
+ pics.push(def.scriptsPicture());
+ });
+ });
+ pics.push(this.stage.image);
+ pics.push(this.stage.scripts.scriptsPicture());
+ this.stage.customBlocks.forEach(function (def) {
+ pics.push(def.scriptsPicture());
+ });
+
+ // collect global block pics
+ this.stage.globalBlocks.forEach(function (def) {
+ pics.push(def.scriptsPicture());
+ });
+
+ pics = pics.filter(function (each) {return !isNil(each); });
+
+ // determine dimensions of composite
+ pics.forEach(function (each) {
+ w = Math.max(w, each.width);
+ h += (each.height);
+ h += padding;
+ });
+ h -= padding;
+ pic = newCanvas(new Point(w, h));
+ ctx = pic.getContext('2d');
+
+ // draw all parts
+ pics.forEach(function (each) {
+ ctx.drawImage(each, 0, y);
+ y += padding;
+ y += each.height;
+ });
+
+ window.open(pic.toDataURL());
+};
+
IDE_Morph.prototype.openProjectString = function (str) {
var msg,
myself = this;
diff --git a/history.txt b/history.txt
index bd4d9fe..a72aa2c 100755
--- a/history.txt
+++ b/history.txt
@@ -2139,3 +2139,9 @@ ______
* Objects: Fixed #445 (minor search + zoom issues)
* Localization additions and Portuguese translation update, thanks, Manuel!
* GUI, cloud: Show last-changed-timestamp when opening cloud projects
+
+140604
+------
+* Blocks: refactor “script pics” feature
+* BYOB: new scriptsPicture() method for custom block definitions
+* GUI: new (hidden) feature: “Export all scripts as pic” (including custom block refs)