From d3fea64f990a920d37c392a50156de8b7800f139 Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Fri, 30 Aug 2019 17:50:06 -0700 Subject: [PATCH] Fix width on dummy row. --- core/renderers/geras/info.js | 24 ++++++++++++------------ core/renderers/thrasos/info.js | 24 +++++++++++++----------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/core/renderers/geras/info.js b/core/renderers/geras/info.js index 87ffea67c..e119efabd 100644 --- a/core/renderers/geras/info.js +++ b/core/renderers/geras/info.js @@ -228,15 +228,16 @@ Blockly.geras.RenderInfo.prototype.getInRowSpacing_ = function(prev, next) { */ Blockly.geras.RenderInfo.prototype.addAlignmentPadding_ = function(row, missingSpace) { var elems = row.elements; + var firstSpacer = row.getFirstSpacer(); + var lastSpacer = row.getLastSpacer(); + if (row.hasExternalInput || row.hasStatement) { + // Get the spacer right before the input socket. + lastSpacer = elems[elems.length - 3]; + row.widthWithConnectedBlocks += missingSpace; + } + var input = row.getLastInput(); if (input) { - var firstSpacer = row.getFirstSpacer(); - var lastSpacer = row.getLastSpacer(); - if (row.hasExternalInput || row.hasStatement) { - // Get the spacer right before the input socket. - lastSpacer = elems[elems.length - 3]; - row.widthWithConnectedBlocks += missingSpace; - } // Decide where the extra padding goes. if (input.align == Blockly.ALIGN_LEFT) { // Add padding to the end of the row. @@ -249,12 +250,11 @@ Blockly.geras.RenderInfo.prototype.addAlignmentPadding_ = function(row, missingS // Add padding at the beginning of the row. firstSpacer.width += missingSpace; } - row.width += missingSpace; - // Top and bottom rows are always left aligned. - } else if (row.type == 'top row' || row.type == 'bottom row') { - row.getLastSpacer().width += missingSpace; - row.width += missingSpace; + } else { + // Default to left-aligning if there's no input to say where to align. + lastSpacer.width += missingSpace; } + row.width += missingSpace; }; /** diff --git a/core/renderers/thrasos/info.js b/core/renderers/thrasos/info.js index 77369eba6..2275bd95a 100644 --- a/core/renderers/thrasos/info.js +++ b/core/renderers/thrasos/info.js @@ -227,14 +227,17 @@ Blockly.thrasos.RenderInfo.prototype.getInRowSpacing_ = function(prev, next) { * @override */ Blockly.thrasos.RenderInfo.prototype.addAlignmentPadding_ = function(row, missingSpace) { + var elems = row.elements; + var firstSpacer = row.getFirstSpacer(); + var lastSpacer = row.getLastSpacer(); + if (row.hasExternalInput || row.hasStatement) { + // Get the spacer right before the input socket. + lastSpacer = elems[elems.length - 3]; + row.widthWithConnectedBlocks += missingSpace; + } + var input = row.getLastInput(); if (input) { - var firstSpacer = row.getFirstSpacer(); - var lastSpacer = row.getLastSpacer(); - if (row.hasExternalInput || row.hasStatement) { - // Get the spacer right before the input socket. - row.widthWithConnectedBlocks += missingSpace; - } // Decide where the extra padding goes. if (input.align == Blockly.ALIGN_LEFT) { // Add padding to the end of the row. @@ -247,12 +250,11 @@ Blockly.thrasos.RenderInfo.prototype.addAlignmentPadding_ = function(row, missin // Add padding at the beginning of the row. firstSpacer.width += missingSpace; } - row.width += missingSpace; - // Top and bottom rows are always left aligned. - } else if (row.type == 'top row' || row.type == 'bottom row') { - row.getLastSpacer().width += missingSpace; - row.width += missingSpace; + } else { + // Default to left-aligning if there's no input to say where to align. + lastSpacer.width += missingSpace; } + row.width += missingSpace; }; /**