From c3867443f52bb0232fd9ac8ff9ac6821d5350c5d Mon Sep 17 00:00:00 2001 From: Sam El-Husseini Date: Tue, 7 Jan 2020 16:05:34 -0800 Subject: [PATCH] Fix value to stack width measurement (#3559) * Include width of connected block in value to stack width measurement. --- core/renderers/common/info.js | 7 +++++++ core/renderers/geras/info.js | 9 +++++++++ core/renderers/thrasos/info.js | 7 +++++++ 3 files changed, 23 insertions(+) diff --git a/core/renderers/common/info.js b/core/renderers/common/info.js index 9a35bcb70..460cee391 100644 --- a/core/renderers/common/info.js +++ b/core/renderers/common/info.js @@ -754,6 +754,13 @@ Blockly.blockRendering.RenderInfo.prototype.finalize_ = function() { Math.max(widestRowWithConnectedBlocks, row.widthWithConnectedBlocks); this.recordElemPositions_(row); } + if (this.outputConnection && this.block_.nextConnection && + this.block_.nextConnection.isConnected()) { + // Include width of connected block in value to stack width measurement. + widestRowWithConnectedBlocks = + Math.max(widestRowWithConnectedBlocks, + this.block_.nextConnection.targetBlock().getHeightWidth().width); + } this.widthWithChildren = Math.max(this.widthWithChildren, widestRowWithConnectedBlocks + this.startX); diff --git a/core/renderers/geras/info.js b/core/renderers/geras/info.js index f0b2dcb25..00b85b35f 100644 --- a/core/renderers/geras/info.js +++ b/core/renderers/geras/info.js @@ -403,6 +403,15 @@ Blockly.geras.RenderInfo.prototype.finalize_ = function() { } this.recordElemPositions_(row); } + if (this.outputConnection && this.block_.nextConnection && + this.block_.nextConnection.isConnected()) { + // Include width of connected block in value to stack width measurement. + widestRowWithConnectedBlocks = + Math.max(widestRowWithConnectedBlocks, + this.block_.nextConnection.targetBlock().getHeightWidth().width - + this.constants_.DARK_PATH_OFFSET); + } + this.bottomRow.baseline = yCursor - this.bottomRow.descenderHeight; // The dark (lowlight) adds to the size of the block in both x and y. diff --git a/core/renderers/thrasos/info.js b/core/renderers/thrasos/info.js index 6484d86ee..9589ef27f 100644 --- a/core/renderers/thrasos/info.js +++ b/core/renderers/thrasos/info.js @@ -329,6 +329,13 @@ Blockly.thrasos.RenderInfo.prototype.finalize_ = function() { } this.recordElemPositions_(row); } + if (this.outputConnection && this.block_.nextConnection && + this.block_.nextConnection.isConnected()) { + // Include width of connected block in value to stack width measurement. + widestRowWithConnectedBlocks = + Math.max(widestRowWithConnectedBlocks, + this.block_.nextConnection.targetBlock().getHeightWidth().width); + } this.bottomRow.baseline = yCursor - this.bottomRow.descenderHeight; this.widthWithChildren = widestRowWithConnectedBlocks + this.startX;