Fix width on dummy row.

This commit is contained in:
Rachel Fenichel
2019-08-30 17:50:06 -07:00
parent 6050456bcf
commit d3fea64f99
2 changed files with 25 additions and 23 deletions

View File

@@ -228,15 +228,16 @@ Blockly.geras.RenderInfo.prototype.getInRowSpacing_ = function(prev, next) {
*/
Blockly.geras.RenderInfo.prototype.addAlignmentPadding_ = function(row, missingSpace) {
var elems = row.elements;
var firstSpacer = row.getFirstSpacer();
var lastSpacer = row.getLastSpacer();
if (row.hasExternalInput || row.hasStatement) {
// Get the spacer right before the input socket.
lastSpacer = elems[elems.length - 3];
row.widthWithConnectedBlocks += missingSpace;
}
var input = row.getLastInput();
if (input) {
var firstSpacer = row.getFirstSpacer();
var lastSpacer = row.getLastSpacer();
if (row.hasExternalInput || row.hasStatement) {
// Get the spacer right before the input socket.
lastSpacer = elems[elems.length - 3];
row.widthWithConnectedBlocks += missingSpace;
}
// Decide where the extra padding goes.
if (input.align == Blockly.ALIGN_LEFT) {
// Add padding to the end of the row.
@@ -249,12 +250,11 @@ Blockly.geras.RenderInfo.prototype.addAlignmentPadding_ = function(row, missingS
// Add padding at the beginning of the row.
firstSpacer.width += missingSpace;
}
row.width += missingSpace;
// Top and bottom rows are always left aligned.
} else if (row.type == 'top row' || row.type == 'bottom row') {
row.getLastSpacer().width += missingSpace;
row.width += missingSpace;
} else {
// Default to left-aligning if there's no input to say where to align.
lastSpacer.width += missingSpace;
}
row.width += missingSpace;
};
/**

View File

@@ -227,14 +227,17 @@ Blockly.thrasos.RenderInfo.prototype.getInRowSpacing_ = function(prev, next) {
* @override
*/
Blockly.thrasos.RenderInfo.prototype.addAlignmentPadding_ = function(row, missingSpace) {
var elems = row.elements;
var firstSpacer = row.getFirstSpacer();
var lastSpacer = row.getLastSpacer();
if (row.hasExternalInput || row.hasStatement) {
// Get the spacer right before the input socket.
lastSpacer = elems[elems.length - 3];
row.widthWithConnectedBlocks += missingSpace;
}
var input = row.getLastInput();
if (input) {
var firstSpacer = row.getFirstSpacer();
var lastSpacer = row.getLastSpacer();
if (row.hasExternalInput || row.hasStatement) {
// Get the spacer right before the input socket.
row.widthWithConnectedBlocks += missingSpace;
}
// Decide where the extra padding goes.
if (input.align == Blockly.ALIGN_LEFT) {
// Add padding to the end of the row.
@@ -247,12 +250,11 @@ Blockly.thrasos.RenderInfo.prototype.addAlignmentPadding_ = function(row, missin
// Add padding at the beginning of the row.
firstSpacer.width += missingSpace;
}
row.width += missingSpace;
// Top and bottom rows are always left aligned.
} else if (row.type == 'top row' || row.type == 'bottom row') {
row.getLastSpacer().width += missingSpace;
row.width += missingSpace;
} else {
// Default to left-aligning if there's no input to say where to align.
lastSpacer.width += missingSpace;
}
row.width += missingSpace;
};
/**