summaryrefslogtreecommitdiff
path: root/blocks.js
diff options
context:
space:
mode:
authorjmoenig <jens@moenig.org>2014-07-30 16:28:01 +0200
committerjmoenig <jens@moenig.org>2014-07-30 16:28:01 +0200
commit61dd479a2b5b79714cf9125d222fb7996674f1a7 (patch)
tree008cc0e5e941741646e5e3934564f457d96003f7 /blocks.js
parent9f7028dbf95262cde83a524abc59987736eb5d32 (diff)
downloadsnap-yow-61dd479a2b5b79714cf9125d222fb7996674f1a7.tar.gz
snap-yow-61dd479a2b5b79714cf9125d222fb7996674f1a7.zip
export script pic with result bubble
hidden option in the shift-context-menu of reporter scripts
Diffstat (limited to 'blocks.js')
-rw-r--r--blocks.js54
1 files changed, 52 insertions, 2 deletions
diff --git a/blocks.js b/blocks.js
index 5a15fa4..2e297ab 100644
--- a/blocks.js
+++ b/blocks.js
@@ -155,7 +155,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph, Costume*/
// Global stuff ////////////////////////////////////////////////////////
-modules.blocks = '2014-July-29';
+modules.blocks = '2014-July-30';
var SyntaxElementMorph;
@@ -1621,7 +1621,7 @@ SyntaxElementMorph.prototype.isEmptySlot = function () {
// SyntaxElementMorph speech bubble feedback:
-SyntaxElementMorph.prototype.showBubble = function (value) {
+SyntaxElementMorph.prototype.showBubble = function (value, exportPic) {
var bubble,
txt,
img,
@@ -1695,11 +1695,28 @@ SyntaxElementMorph.prototype.showBubble = function (value) {
this.rightCenter().add(new Point(2, 0)),
isClickable
);
+ if (exportPic) {
+ this.exportPictureWithResult(bubble);
+ }
if (sf) {
bubble.keepWithin(sf);
}
};
+SyntaxElementMorph.prototype.exportPictureWithResult = function (aBubble) {
+ var scr = this.fullImage(),
+ bub = aBubble.fullImageClassic(),
+ taller = Math.max(0, bub.height - scr.height),
+ pic = newCanvas(new Point(
+ scr.width + bub.width + 2,
+ scr.height + taller
+ )),
+ ctx = pic.getContext('2d');
+ ctx.drawImage(scr, 0, pic.height - scr.height);
+ ctx.drawImage(bub, scr.width + 2, 0);
+ window.open(pic.toDataURL());
+};
+
// SyntaxElementMorph code mapping
/*
@@ -2026,13 +2043,29 @@ BlockMorph.prototype.userMenu = function () {
var menu = new MenuMorph(this),
world = this.world(),
myself = this,
+ shiftClicked = world.currentKey === 16,
alternatives,
+ top,
blck;
menu.addItem(
"help...",
'showHelp'
);
+ if (shiftClicked) {
+ top = this.topBlock();
+ if (top instanceof ReporterBlockMorph) {
+ menu.addItem(
+ "script pic with result...",
+ function () {
+ top.ExportResultPic();
+ },
+ 'open a new window\n' +
+ 'with a picture of both\nthis script and its result',
+ new Color(100, 0, 0)
+ );
+ }
+ }
if (this.isTemplate) {
if (!(this.parent instanceof SyntaxElementMorph)) {
if (this.selector !== 'evaluateCustomBlock') {
@@ -4115,6 +4148,23 @@ ReporterBlockMorph.prototype.mouseClickLeft = function (pos) {
}
};
+// ReporterBlock exporting picture with result bubble
+
+ReporterBlockMorph.prototype.ExportResultPic = function () {
+ var top = this.topBlock(),
+ receiver = top.receiver(),
+ stage;
+ if (top !== this) {return; }
+ if (receiver) {
+ stage = receiver.parentThatIsA(StageMorph);
+ if (stage) {
+ stage.threads.stopProcess(top);
+ stage.threads.startProcess(top, false, true);
+ }
+ }
+};
+
+
// ReporterBlockMorph deleting
ReporterBlockMorph.prototype.userDestroy = function () {