From 90a10e5f441d0d6243e4ce4dd7693c6a61c80d59 Mon Sep 17 00:00:00 2001 From: kozbial Date: Wed, 11 Sep 2019 17:17:14 -0700 Subject: [PATCH 1/2] Fix logic in shouldStartNewRow_ and between row padding in geras. --- core/renderers/common/debugger.js | 4 ++-- core/renderers/common/info.js | 26 ++++++++++++++------------ core/renderers/geras/info.js | 22 +--------------------- core/renderers/thrasos/info.js | 20 -------------------- 4 files changed, 17 insertions(+), 55 deletions(-) diff --git a/core/renderers/common/debugger.js b/core/renderers/common/debugger.js index b0b4ff709..b335ffd97 100644 --- a/core/renderers/common/debugger.js +++ b/core/renderers/common/debugger.js @@ -64,9 +64,9 @@ Blockly.blockRendering.Debug = function() { Blockly.blockRendering.Debug.getDebugConfig = function() { return { - // rowSpacers: true, + rowSpacers: true, // elemSpacers: true, - // rows: true, + rows: true, elems: true, // connections: true, blockBounds: true, diff --git a/core/renderers/common/info.js b/core/renderers/common/info.js index ca1f50923..3b8394ac9 100644 --- a/core/renderers/common/info.js +++ b/core/renderers/common/info.js @@ -266,6 +266,11 @@ Blockly.blockRendering.RenderInfo.prototype.shouldStartNewRow_ = function(input, if (input.type == Blockly.NEXT_STATEMENT) { return true; } + // A statement input or an input following one always gets a new row. + if (input.type == Blockly.NEXT_STATEMENT || + lastInput.type == Blockly.NEXT_STATEMENT) { + return true; + } // Value and dummy inputs get new row if inputs are not inlined. if (input.type == Blockly.INPUT_VALUE || input.type == Blockly.DUMMY_INPUT) { return !this.isInline; @@ -371,18 +376,15 @@ Blockly.blockRendering.RenderInfo.prototype.computeBounds_ = function() { */ Blockly.blockRendering.RenderInfo.prototype.alignRowElements_ = function() { for (var i = 0, row; (row = this.rows[i]); i++) { - // TODO (#2921): this still doesn't handle the row having an inline input. - if (!row.hasInlineInput) { - if (row.hasStatement) { - this.alignStatementRow_( - /** @type {Blockly.RenderedConnection} */ (row)); - } else { - var currentWidth = row.width; - var desiredWidth = this.width - this.startX; - var missingSpace = desiredWidth - currentWidth; - if (missingSpace) { - this.addAlignmentPadding_(row, missingSpace); - } + if (row.hasStatement) { + this.alignStatementRow_( + /** @type {Blockly.RenderedConnection} */ (row)); + } else { + var currentWidth = row.width; + var desiredWidth = this.width - this.startX; + var missingSpace = desiredWidth - currentWidth; + if (missingSpace) { + this.addAlignmentPadding_(row, missingSpace); } } } diff --git a/core/renderers/geras/info.js b/core/renderers/geras/info.js index 7f9c89991..e2591a62f 100644 --- a/core/renderers/geras/info.js +++ b/core/renderers/geras/info.js @@ -64,26 +64,6 @@ Blockly.geras.RenderInfo = function(block) { Blockly.utils.object.inherits(Blockly.geras.RenderInfo, Blockly.blockRendering.RenderInfo); -/** - * @override - */ -Blockly.geras.RenderInfo.prototype.shouldStartNewRow_ = function(input, lastInput) { - // If this is the first input, just add to the existing row. - // That row is either empty or has some icons in it. - if (!lastInput) { - return false; - } - // A statement input always gets a new row. - if (input.type == Blockly.NEXT_STATEMENT) { - return true; - } - // Value and dummy inputs get new row if inputs are not inlined. - if (input.type == Blockly.INPUT_VALUE || input.type == Blockly.DUMMY_INPUT) { - return !this.isInline; - } - return false; -}; - /** * @override */ @@ -286,7 +266,7 @@ Blockly.geras.RenderInfo.prototype.getSpacerRowHeight_ = function(prev, next) { if (prev.hasStatement && next.hasStatement) { return this.constants_.LARGE_PADDING; } - if (next.hasDummyInput) { + if (!prev.hasStatement && next.hasDummyInput) { return this.constants_.LARGE_PADDING; } return this.constants_.MEDIUM_PADDING; diff --git a/core/renderers/thrasos/info.js b/core/renderers/thrasos/info.js index 44e3a3d59..71d6c97a5 100644 --- a/core/renderers/thrasos/info.js +++ b/core/renderers/thrasos/info.js @@ -64,26 +64,6 @@ Blockly.thrasos.RenderInfo = function(block) { Blockly.utils.object.inherits(Blockly.thrasos.RenderInfo, Blockly.blockRendering.RenderInfo); -/** - * @override - */ -Blockly.thrasos.RenderInfo.prototype.shouldStartNewRow_ = function(input, lastInput) { - // If this is the first input, just add to the existing row. - // That row is either empty or has some icons in it. - if (!lastInput) { - return false; - } - // A statement input always gets a new row. - if (input.type == Blockly.NEXT_STATEMENT) { - return true; - } - // Value and dummy inputs get new row if inputs are not inlined. - if (input.type == Blockly.INPUT_VALUE || input.type == Blockly.DUMMY_INPUT) { - return !this.isInline; - } - return false; -}; - /** * @override */ From 8a00ed9eb2535a3a9800fc840cdf3460ae23b63d Mon Sep 17 00:00:00 2001 From: kozbial Date: Thu, 12 Sep 2019 13:36:45 -0700 Subject: [PATCH 2/2] Remove duplicate check and undo changes in debugger render. --- core/renderers/common/debugger.js | 4 ++-- core/renderers/common/info.js | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/core/renderers/common/debugger.js b/core/renderers/common/debugger.js index b335ffd97..b0b4ff709 100644 --- a/core/renderers/common/debugger.js +++ b/core/renderers/common/debugger.js @@ -64,9 +64,9 @@ Blockly.blockRendering.Debug = function() { Blockly.blockRendering.Debug.getDebugConfig = function() { return { - rowSpacers: true, + // rowSpacers: true, // elemSpacers: true, - rows: true, + // rows: true, elems: true, // connections: true, blockBounds: true, diff --git a/core/renderers/common/info.js b/core/renderers/common/info.js index 3b8394ac9..8357b6c0a 100644 --- a/core/renderers/common/info.js +++ b/core/renderers/common/info.js @@ -262,10 +262,6 @@ Blockly.blockRendering.RenderInfo.prototype.shouldStartNewRow_ = function(input, if (!lastInput) { return false; } - // A statement input always gets a new row. - if (input.type == Blockly.NEXT_STATEMENT) { - return true; - } // A statement input or an input following one always gets a new row. if (input.type == Blockly.NEXT_STATEMENT || lastInput.type == Blockly.NEXT_STATEMENT) {