mirror of
https://github.com/google/blockly.git
synced 2026-01-07 09:00:11 +01:00
Make alignment common renderer behaviour (#3498)
* Make alignment common
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user