mirror of
https://github.com/google/blockly.git
synced 2026-01-09 01:50:11 +01:00
Remove special case for spacer after statement
This commit is contained in:
@@ -372,6 +372,7 @@ 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) {
|
||||
var statementInput = row.getLastInput();
|
||||
@@ -440,20 +441,14 @@ Blockly.blockRendering.RenderInfo.prototype.makeSpacerRow_ = function(prev, next
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculate the width of a spacer row. Almost all spacers will be the full
|
||||
* width of the block, but there are some exceptions (e.g. the small spacer row
|
||||
* after a statement input)
|
||||
* @param {Blockly.blockRendering.Row} prev The row before the spacer.
|
||||
* @param {Blockly.blockRendering.Row} next The row after the spacer.
|
||||
* Calculate the width of a spacer row.
|
||||
* @param {Blockly.blockRendering.Row} _prev The row before the spacer.
|
||||
* @param {Blockly.blockRendering.Row} _next The row after the spacer.
|
||||
* @return {number} The desired width of the spacer row between these two rows.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.blockRendering.RenderInfo.prototype.getSpacerRowWidth_ = function(prev, next) {
|
||||
// The width of the spacer before the bottom row should be the same as the
|
||||
// bottom row.
|
||||
if (next.type == 'bottom row' && next.hasFixedWidth) {
|
||||
return next.width;
|
||||
}
|
||||
Blockly.blockRendering.RenderInfo.prototype.getSpacerRowWidth_ = function(
|
||||
_prev, _next) {
|
||||
return this.width - this.startX;
|
||||
};
|
||||
|
||||
|
||||
@@ -223,31 +223,6 @@ Blockly.geras.RenderInfo.prototype.getInRowSpacing_ = function(prev, next) {
|
||||
return this.constants_.MEDIUM_PADDING;
|
||||
};
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
Blockly.geras.RenderInfo.prototype.alignRowElements_ = function() {
|
||||
for (var i = 0, row; (row = this.rows[i]); i++) {
|
||||
if (!row.hasInlineInput) {
|
||||
if (row.hasStatement) {
|
||||
var statementInput = row.getLastInput();
|
||||
var currentWidth = row.width - statementInput.width;
|
||||
var desiredWidth = this.statementEdge - this.startX;
|
||||
} else {
|
||||
var currentWidth = row.width;
|
||||
var desiredWidth = this.width - this.startX;
|
||||
}
|
||||
if (row.type == 'bottom row' && row.hasFixedWidth) {
|
||||
desiredWidth = this.constants_.MAX_BOTTOM_WIDTH;
|
||||
}
|
||||
var missingSpace = desiredWidth - currentWidth;
|
||||
if (missingSpace) {
|
||||
this.addAlignmentPadding_(row, missingSpace);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
@@ -282,18 +257,6 @@ Blockly.geras.RenderInfo.prototype.addAlignmentPadding_ = function(row, missingS
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
Blockly.geras.RenderInfo.prototype.getSpacerRowWidth_ = function(prev, next) {
|
||||
// The width of the spacer before the bottom row should be the same as the
|
||||
// bottom row.
|
||||
if (next.type == 'bottom row' && next.hasFixedWidth) {
|
||||
return next.width;
|
||||
}
|
||||
return this.width - this.startX;
|
||||
};
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
|
||||
@@ -166,13 +166,8 @@ Blockly.blockRendering.Row.prototype.measure = function() {
|
||||
*/
|
||||
Blockly.blockRendering.Row.prototype.getLastInput = function() {
|
||||
for (var i = this.elements.length - 1, elem; (elem = this.elements[i]); i--) {
|
||||
if (elem.isSpacer()) {
|
||||
continue;
|
||||
}
|
||||
if (elem.isInput) {
|
||||
return /** @type {Blockly.blockRendering.InputConnection} */ (elem);
|
||||
} else if (elem.isField()) {
|
||||
return /** @type {Blockly.blockRendering.InputConnection} */ (elem.parentInput);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -341,12 +336,6 @@ Blockly.blockRendering.BottomRow = function() {
|
||||
* @type {number}
|
||||
*/
|
||||
this.overhangY = 0;
|
||||
|
||||
/**
|
||||
* True if the width of this row does not depend on its contents.
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.hasFixedWidth = false;
|
||||
};
|
||||
goog.inherits(Blockly.blockRendering.BottomRow, Blockly.blockRendering.Row);
|
||||
|
||||
@@ -361,7 +350,6 @@ Blockly.blockRendering.BottomRow.prototype.populate = function(block) {
|
||||
var followsStatement =
|
||||
block.inputList.length &&
|
||||
block.inputList[block.inputList.length - 1].type == Blockly.NEXT_STATEMENT;
|
||||
this.hasFixedWidth = followsStatement && block.getInputsInline();
|
||||
|
||||
// This is the minimum height for the row. If one of its elements has a greater
|
||||
// height it will be overwritten in the compute pass.
|
||||
|
||||
@@ -223,31 +223,6 @@ Blockly.thrasos.RenderInfo.prototype.getInRowSpacing_ = function(prev, next) {
|
||||
return this.constants_.MEDIUM_PADDING;
|
||||
};
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
Blockly.thrasos.RenderInfo.prototype.alignRowElements_ = function() {
|
||||
for (var i = 0, row; (row = this.rows[i]); i++) {
|
||||
if (!row.hasInlineInput) {
|
||||
if (row.hasStatement) {
|
||||
var statementInput = row.getLastInput();
|
||||
var currentWidth = row.width - statementInput.width;
|
||||
var desiredWidth = this.statementEdge - this.startX;
|
||||
} else {
|
||||
var currentWidth = row.width;
|
||||
var desiredWidth = this.width - this.startX;
|
||||
}
|
||||
if (row.type == 'bottom row' && row.hasFixedWidth) {
|
||||
desiredWidth = this.constants_.MAX_BOTTOM_WIDTH;
|
||||
}
|
||||
var missingSpace = desiredWidth - currentWidth;
|
||||
if (missingSpace) {
|
||||
this.addAlignmentPadding_(row, missingSpace);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
@@ -280,18 +255,6 @@ Blockly.thrasos.RenderInfo.prototype.addAlignmentPadding_ = function(row, missin
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
Blockly.thrasos.RenderInfo.prototype.getSpacerRowWidth_ = function(prev, next) {
|
||||
// The width of the spacer before the bottom row should be the same as the
|
||||
// bottom row.
|
||||
if (next.type == 'bottom row' && next.hasFixedWidth) {
|
||||
return next.width;
|
||||
}
|
||||
return this.width - this.startX;
|
||||
};
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user