Make alignment common renderer behaviour (#3498)

* Make alignment common
This commit is contained in:
Sam El-Husseini
2019-12-11 13:42:10 -08:00
committed by GitHub
parent 38fe5189bb
commit 2b335dcb6b
5 changed files with 23 additions and 82 deletions

View File

@@ -560,14 +560,28 @@ Blockly.blockRendering.RenderInfo.prototype.alignRowElements_ = function() {
*/
Blockly.blockRendering.RenderInfo.prototype.addAlignmentPadding_ = function(row,
missingSpace) {
var firstSpacer = row.getFirstSpacer();
var lastSpacer = row.getLastSpacer();
if (lastSpacer) {
lastSpacer.width += missingSpace;
row.width += missingSpace;
if (row.hasExternalInput || row.hasStatement) {
row.widthWithConnectedBlocks += missingSpace;
}
if (row.hasExternalInput || row.hasStatement) {
row.widthWithConnectedBlocks += missingSpace;
}
// Decide where the extra padding goes.
if (row.align == Blockly.ALIGN_LEFT) {
// Add padding to the end of the row.
lastSpacer.width += missingSpace;
} else if (row.align == Blockly.ALIGN_CENTRE) {
// Split the padding between the beginning and end of the row.
firstSpacer.width += missingSpace / 2;
lastSpacer.width += missingSpace / 2;
} else if (row.align == Blockly.ALIGN_RIGHT) {
// Add padding at the beginning of the row.
firstSpacer.width += missingSpace;
} else {
// Default to left-aligning.
lastSpacer.width += missingSpace;
}
row.width += missingSpace;
};
/**