kopia lustrzana https://github.com/backface/turtlestitch
export script pic with result bubble
hidden option in the shift-context-menu of reporter scriptspull/3/merge
rodzic
9f7028dbf9
commit
61dd479a2b
54
blocks.js
54
blocks.js
|
@ -155,7 +155,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph, Costume*/
|
||||||
|
|
||||||
// Global stuff ////////////////////////////////////////////////////////
|
// Global stuff ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
modules.blocks = '2014-July-29';
|
modules.blocks = '2014-July-30';
|
||||||
|
|
||||||
|
|
||||||
var SyntaxElementMorph;
|
var SyntaxElementMorph;
|
||||||
|
@ -1621,7 +1621,7 @@ SyntaxElementMorph.prototype.isEmptySlot = function () {
|
||||||
|
|
||||||
// SyntaxElementMorph speech bubble feedback:
|
// SyntaxElementMorph speech bubble feedback:
|
||||||
|
|
||||||
SyntaxElementMorph.prototype.showBubble = function (value) {
|
SyntaxElementMorph.prototype.showBubble = function (value, exportPic) {
|
||||||
var bubble,
|
var bubble,
|
||||||
txt,
|
txt,
|
||||||
img,
|
img,
|
||||||
|
@ -1695,11 +1695,28 @@ SyntaxElementMorph.prototype.showBubble = function (value) {
|
||||||
this.rightCenter().add(new Point(2, 0)),
|
this.rightCenter().add(new Point(2, 0)),
|
||||||
isClickable
|
isClickable
|
||||||
);
|
);
|
||||||
|
if (exportPic) {
|
||||||
|
this.exportPictureWithResult(bubble);
|
||||||
|
}
|
||||||
if (sf) {
|
if (sf) {
|
||||||
bubble.keepWithin(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
|
// SyntaxElementMorph code mapping
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2026,13 +2043,29 @@ BlockMorph.prototype.userMenu = function () {
|
||||||
var menu = new MenuMorph(this),
|
var menu = new MenuMorph(this),
|
||||||
world = this.world(),
|
world = this.world(),
|
||||||
myself = this,
|
myself = this,
|
||||||
|
shiftClicked = world.currentKey === 16,
|
||||||
alternatives,
|
alternatives,
|
||||||
|
top,
|
||||||
blck;
|
blck;
|
||||||
|
|
||||||
menu.addItem(
|
menu.addItem(
|
||||||
"help...",
|
"help...",
|
||||||
'showHelp'
|
'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.isTemplate) {
|
||||||
if (!(this.parent instanceof SyntaxElementMorph)) {
|
if (!(this.parent instanceof SyntaxElementMorph)) {
|
||||||
if (this.selector !== 'evaluateCustomBlock') {
|
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 deleting
|
||||||
|
|
||||||
ReporterBlockMorph.prototype.userDestroy = function () {
|
ReporterBlockMorph.prototype.userDestroy = function () {
|
||||||
|
|
|
@ -2255,3 +2255,4 @@ ______
|
||||||
------
|
------
|
||||||
* Objects: propagate HIDE and SHOW to nested sprite parts
|
* Objects: propagate HIDE and SHOW to nested sprite parts
|
||||||
* GUI: propagate DELETE to nested sprite parts
|
* GUI: propagate DELETE to nested sprite parts
|
||||||
|
* Blocks, Threads: export script pic with result bubble (shift-context-menu of reporter scripts)
|
||||||
|
|
24
threads.js
24
threads.js
|
@ -83,7 +83,7 @@ ArgLabelMorph, localize, XML_Element, hex_sha512*/
|
||||||
|
|
||||||
// Global stuff ////////////////////////////////////////////////////////
|
// Global stuff ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
modules.threads = '2014-July-28';
|
modules.threads = '2014-July-30';
|
||||||
|
|
||||||
var ThreadManager;
|
var ThreadManager;
|
||||||
var Process;
|
var Process;
|
||||||
|
@ -134,7 +134,11 @@ ThreadManager.prototype.toggleProcess = function (block) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ThreadManager.prototype.startProcess = function (block, isThreadSafe) {
|
ThreadManager.prototype.startProcess = function (
|
||||||
|
block,
|
||||||
|
isThreadSafe,
|
||||||
|
exportResult
|
||||||
|
) {
|
||||||
var active = this.findProcess(block),
|
var active = this.findProcess(block),
|
||||||
top = block.topBlock(),
|
top = block.topBlock(),
|
||||||
newProc;
|
newProc;
|
||||||
|
@ -147,6 +151,7 @@ ThreadManager.prototype.startProcess = function (block, isThreadSafe) {
|
||||||
}
|
}
|
||||||
top.addHighlight();
|
top.addHighlight();
|
||||||
newProc = new Process(block.topBlock());
|
newProc = new Process(block.topBlock());
|
||||||
|
newProc.exportResult = exportResult;
|
||||||
this.processes.push(newProc);
|
this.processes.push(newProc);
|
||||||
return newProc;
|
return newProc;
|
||||||
};
|
};
|
||||||
|
@ -232,11 +237,17 @@ ThreadManager.prototype.removeTerminatedProcesses = function () {
|
||||||
|
|
||||||
if (proc.topBlock instanceof ReporterBlockMorph) {
|
if (proc.topBlock instanceof ReporterBlockMorph) {
|
||||||
if (proc.homeContext.inputs[0] instanceof List) {
|
if (proc.homeContext.inputs[0] instanceof List) {
|
||||||
proc.topBlock.showBubble(new ListWatcherMorph(
|
proc.topBlock.showBubble(
|
||||||
|
new ListWatcherMorph(
|
||||||
proc.homeContext.inputs[0]
|
proc.homeContext.inputs[0]
|
||||||
));
|
),
|
||||||
|
proc.exportResult
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
proc.topBlock.showBubble(proc.homeContext.inputs[0]);
|
proc.topBlock.showBubble(
|
||||||
|
proc.homeContext.inputs[0],
|
||||||
|
proc.exportResult
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -302,6 +313,8 @@ ThreadManager.prototype.findProcess = function (block) {
|
||||||
httpRequest active instance of an HttpRequest or null
|
httpRequest active instance of an HttpRequest or null
|
||||||
pauseOffset msecs between the start of an interpolated operation
|
pauseOffset msecs between the start of an interpolated operation
|
||||||
and when the process was paused
|
and when the process was paused
|
||||||
|
exportResult boolean flag indicating whether a picture of the top
|
||||||
|
block along with the result bubble shoud be exported
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Process.prototype = {};
|
Process.prototype = {};
|
||||||
|
@ -325,6 +338,7 @@ function Process(topBlock) {
|
||||||
this.isPaused = false;
|
this.isPaused = false;
|
||||||
this.pauseOffset = null;
|
this.pauseOffset = null;
|
||||||
this.frameCount = 0;
|
this.frameCount = 0;
|
||||||
|
this.exportResult = false;
|
||||||
|
|
||||||
if (topBlock) {
|
if (topBlock) {
|
||||||
this.homeContext.receiver = topBlock.receiver();
|
this.homeContext.receiver = topBlock.receiver();
|
||||||
|
|
Ładowanie…
Reference in New Issue