mirror of
https://github.com/google/blockly.git
synced 2026-01-07 09:00:11 +01:00
Geras inline alignment of rows + max bottom row width (#3575)
* Add a desired width getter method for input rows. Override in geras to fix the width of the bottom row and statement input to a max width.
This commit is contained in:
@@ -554,15 +554,26 @@ Blockly.blockRendering.RenderInfo.prototype.alignRowElements_ = function() {
|
||||
/** @type {!Blockly.blockRendering.InputRow} */ (row));
|
||||
} else {
|
||||
var currentWidth = row.width;
|
||||
var desiredWidth = this.width - this.startX;
|
||||
var desiredWidth = this.getDesiredRowWidth_(row);
|
||||
var missingSpace = desiredWidth - currentWidth;
|
||||
if (missingSpace) {
|
||||
if (missingSpace > 0) {
|
||||
this.addAlignmentPadding_(row, missingSpace);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculate the desired width of an input row.
|
||||
* @param {!Blockly.blockRendering.Row} _row The input row.
|
||||
* @return {number} The desired width of the input row.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.blockRendering.RenderInfo.prototype.getDesiredRowWidth_ = function(
|
||||
_row) {
|
||||
return this.width - this.startX;
|
||||
};
|
||||
|
||||
/**
|
||||
* Modify the given row to add the given amount of padding around its fields.
|
||||
* The exact location of the padding is based on the alignment property of the
|
||||
@@ -609,14 +620,13 @@ Blockly.blockRendering.RenderInfo.prototype.alignStatementRow_ = function(row) {
|
||||
var desiredWidth = this.statementEdge;
|
||||
// Add padding before the statement input.
|
||||
var missingSpace = desiredWidth - currentWidth;
|
||||
if (missingSpace) {
|
||||
if (missingSpace > 0) {
|
||||
this.addAlignmentPadding_(row, missingSpace);
|
||||
}
|
||||
// Also widen the statement input to reach to the right side of the
|
||||
// block. Note that this does not add padding.
|
||||
currentWidth = row.width;
|
||||
var rightCornerWidth = this.constants_.INSIDE_CORNERS.rightWidth || 0;
|
||||
desiredWidth = this.width - this.startX - rightCornerWidth;
|
||||
desiredWidth = this.getDesiredRowWidth_(row);
|
||||
statementInput.width += (desiredWidth - currentWidth);
|
||||
statementInput.height = Math.max(statementInput.height, row.height);
|
||||
row.width += (desiredWidth - currentWidth);
|
||||
|
||||
Reference in New Issue
Block a user