From a6dea08bba02fd325f10831b869804948c275f14 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Mon, 30 Mar 2020 00:12:11 +0200 Subject: [PATCH] new outline path rendering for variadic c-slots in command blocks --- src/blocks.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/blocks.js b/src/blocks.js index 1639246b..899a8e61 100644 --- a/src/blocks.js +++ b/src/blocks.js @@ -148,7 +148,7 @@ CustomCommandBlockMorph, SymbolMorph, ToggleButtonMorph, DialMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2020-March-29'; +modules.blocks = '2020-March-30'; var SyntaxElementMorph; var BlockMorph; @@ -5044,7 +5044,7 @@ CommandBlockMorph.prototype.outlinePath = function(ctx, inset) { bottomCorner = this.height() - this.corner * 2, radius = Math.max(this.corner - inset, 0), pos = this.position(), - cslots = this.parts().filter(part => part instanceof CSlotMorph); + cslots = this.cSlots(); // top left: ctx.arc( @@ -5107,6 +5107,22 @@ CommandBlockMorph.prototype.outlinePath = function(ctx, inset) { ); }; +CommandBlockMorph.prototype.cSlots = function () { + var result = []; + this.parts().forEach(part => { + if (part instanceof CSlotMorph) { + result.push(part); + } else if (part instanceof MultiArgMorph) { + part.parts().forEach(slot => { + if (slot instanceof CSlotMorph) { + result.push(slot); + } + }); + } + }); + return result; +}; + CommandBlockMorph.prototype.drawEdges = function (ctx) { this.drawTopDentEdge(ctx, 0, 0); this.drawBottomDentEdge(ctx, 0, this.height() - this.corner); @@ -5291,7 +5307,7 @@ CommandBlockMorph.prototype.drawLeftEdge = function (ctx) { CommandBlockMorph.prototype.drawRightEdge = function (ctx) { var shift = this.edge * 0.5, - cslots = this.parts().filter(part => part instanceof CSlotMorph), + cslots = this.cSlots(), top = this.top(), x = this.width(), y,