Merge pull request #2822 from moniika/moniika-fix-statement-input-width

Update statementInput width to reflect what is actually being rendered.
This commit is contained in:
Monica Kozbial
2019-08-14 12:36:33 -07:00
committed by GitHub
4 changed files with 6 additions and 20 deletions

View File

@@ -198,10 +198,9 @@ Blockly.blockRendering.Drawer.prototype.drawStatementInput_ = function(row) {
if (this.highlighter_) {
this.highlighter_.drawStatementInput(row);
}
var input = row.getLastInput();
// Where to start drawing the notch, which is on the right side in LTR.
var x = row.xPos + row.statementEdge +
Blockly.blockRendering.constants.NOTCH_OFFSET_LEFT +
Blockly.blockRendering.constants.NOTCH.width;
var x = input.xPos + input.width;
var innerTopLeftCorner =
Blockly.blockRendering.constants.NOTCH.pathRight + ' h -' +

View File

@@ -487,9 +487,7 @@ Blockly.blockRendering.RenderInfo.prototype.computeBounds_ = function() {
for (var r = 0; r < this.rows.length; r++) {
var row = this.rows[r];
row.measure();
if (!row.hasStatement) {
blockWidth = Math.max(blockWidth, row.width);
}
blockWidth = Math.max(blockWidth, row.width);
if (row.hasStatement) {
var statementInput = row.getLastInput();
var innerWidth = row.width - statementInput.width;
@@ -502,13 +500,7 @@ Blockly.blockRendering.RenderInfo.prototype.computeBounds_ = function() {
this.statementEdge = widestStatementRowFields;
if (widestStatementRowFields) {
this.width =
Math.max(blockWidth,
widestStatementRowFields + Blockly.blockRendering.constants.NOTCH.width * 2);
} else {
this.width = blockWidth;
}
this.width = blockWidth;
for (var r = 0; r < this.rows.length; r++) {
var row = this.rows[r];

View File

@@ -126,11 +126,6 @@ Blockly.blockRendering.constants.EXTERNAL_VALUE_INPUT_PADDING = 2;
Blockly.blockRendering.constants.EMPTY_STATEMENT_INPUT_HEIGHT =
Blockly.blockRendering.constants.MIN_BLOCK_HEIGHT;
Blockly.blockRendering.constants.EMPTY_STATEMENT_INPUT_WIDTH = 32;
Blockly.blockRendering.constants.POPULATED_STATEMENT_INPUT_WIDTH = 25;
Blockly.blockRendering.constants.START_POINT = Blockly.utils.svgPaths.moveBy(0, 0);
/**

View File

@@ -285,15 +285,15 @@ Blockly.blockRendering.StatementInput = function(input) {
if (!this.connectedBlock) {
this.height = Blockly.blockRendering.constants.EMPTY_STATEMENT_INPUT_HEIGHT;
this.width = Blockly.blockRendering.constants.EMPTY_STATEMENT_INPUT_WIDTH;
} else {
this.width = Blockly.blockRendering.constants.POPULATED_STATEMENT_INPUT_WIDTH;
this.height =
this.connectedBlockHeight + Blockly.blockRendering.constants.STATEMENT_BOTTOM_SPACER;
if (this.connectedBlock.nextConnection) {
this.height -= this.notchShape.height;
}
}
this.width = Blockly.blockRendering.constants.NOTCH_OFFSET_LEFT +
this.notchShape.width;
};
goog.inherits(Blockly.blockRendering.StatementInput,
Blockly.blockRendering.Input);