Merge pull request #3006 from moniika/moniika-dummy-input

Fix logic in shouldStartNewRow_ and between row padding in geras.
This commit is contained in:
Monica Kozbial
2019-09-12 13:47:07 -07:00
committed by GitHub
3 changed files with 13 additions and 55 deletions

View File

@@ -262,8 +262,9 @@ 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) {
// 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.
@@ -371,18 +372,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);
}
}
}

View File

@@ -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;

View File

@@ -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
*/