refactor: Rename ALIGN to Align and move from constants.js to input.js (#5742)

This constant is used to specify the alignment of
an Input, so it should live in the same file as the Input class.

I've done this as a separate named export, but it could alternatively
be made a static member of Input (i.e., Input.Align with only Input
being exported by name).

Where mocha tests were referring to Blockly.constants.ALIGN.*
without actually requiring Blockly.constants, I have reverted
them to refer to Blockly.ALIGN_* instead (pending conversion
to named requries).

Part of #5073.
This commit is contained in:
Christopher Allen
2021-11-29 21:59:48 +00:00
committed by GitHub
parent 985af10f6e
commit c0d22f2002
9 changed files with 56 additions and 42 deletions

View File

@@ -15,7 +15,7 @@
*/
goog.module('Blockly.blockRendering.RenderInfo');
const constants = goog.require('Blockly.constants');
const {Align} = goog.require('Blockly.Input');
/* eslint-disable-next-line no-unused-vars */
const {BlockSvg} = goog.requireType('Blockly.BlockSvg');
const {BottomRow} = goog.require('Blockly.blockRendering.BottomRow');
@@ -578,14 +578,14 @@ RenderInfo.prototype.addAlignmentPadding_ = function(row, missingSpace) {
}
// Decide where the extra padding goes.
if (row.align === constants.ALIGN.LEFT) {
if (row.align === Align.LEFT) {
// Add padding to the end of the row.
lastSpacer.width += missingSpace;
} else if (row.align === constants.ALIGN.CENTRE) {
} else if (row.align === 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 === constants.ALIGN.RIGHT) {
} else if (row.align === Align.RIGHT) {
// Add padding at the beginning of the row.
firstSpacer.width += missingSpace;
} else {

View File

@@ -16,7 +16,7 @@
*/
goog.module('Blockly.zelos.RenderInfo');
const constants = goog.require('Blockly.constants');
const {Align} = goog.require('Blockly.Input');
const object = goog.require('Blockly.utils.object');
/* eslint-disable-next-line no-unused-vars */
const {BlockSvg} = goog.requireType('Blockly.BlockSvg');
@@ -266,8 +266,7 @@ RenderInfo.prototype.addInput_ = function(input, activeRow) {
// right, keep track of the right aligned dummy input so we can add padding
// later.
if (input.type === inputTypes.DUMMY && activeRow.hasDummyInput &&
activeRow.align === constants.ALIGN.LEFT &&
input.align === constants.ALIGN.RIGHT) {
activeRow.align === Align.LEFT && input.align === Align.RIGHT) {
activeRow.rightAlignedDummyInput = input;
} else if (input.type === inputTypes.STATEMENT) {
// Handle statements without next connections correctly.