mirror of
https://github.com/google/blockly.git
synced 2026-01-21 15:57:10 +01:00
Migrate core/renderers/measurables/rows.js named requires
This commit is contained in:
@@ -13,12 +13,15 @@
|
||||
goog.module('Blockly.blockRendering.BottomRow');
|
||||
goog.module.declareLegacyNamespace();
|
||||
|
||||
goog.requireType('Blockly.BlockSvg');
|
||||
goog.requireType('Blockly.blockRendering.ConstantProvider');
|
||||
goog.requireType('Blockly.blockRendering.NextConnection');
|
||||
goog.require('Blockly.blockRendering.Row');
|
||||
goog.require('Blockly.blockRendering.Types');
|
||||
goog.require('Blockly.utils.object');
|
||||
/* eslint-disable-next-line no-unused-vars */
|
||||
const BlockSvg = goog.requireType('Blockly.BlockSvg');
|
||||
/* eslint-disable-next-line no-unused-vars */
|
||||
const ConstantProvider = goog.requireType('Blockly.blockRendering.ConstantProvider');
|
||||
/* eslint-disable-next-line no-unused-vars */
|
||||
const NextConnection = goog.requireType('Blockly.blockRendering.NextConnection');
|
||||
const Row = goog.require('Blockly.blockRendering.Row');
|
||||
const Types = goog.require('Blockly.blockRendering.Types');
|
||||
const object = goog.require('Blockly.utils.object');
|
||||
|
||||
|
||||
/**
|
||||
@@ -26,16 +29,16 @@ goog.require('Blockly.utils.object');
|
||||
* a block as well as spacing information for the top row.
|
||||
* Elements in a bottom row can consist of corners, spacers and next
|
||||
* connections.
|
||||
* @param {!Blockly.blockRendering.ConstantProvider} constants The rendering
|
||||
* @param {!ConstantProvider} constants The rendering
|
||||
* constants provider.
|
||||
* @package
|
||||
* @constructor
|
||||
* @extends {Blockly.blockRendering.Row}
|
||||
* @extends {Row}
|
||||
*/
|
||||
const BottomRow = function(constants) {
|
||||
BottomRow.superClass_.constructor.call(this,
|
||||
constants);
|
||||
this.type |= Blockly.blockRendering.Types.BOTTOM_ROW;
|
||||
this.type |= Types.BOTTOM_ROW;
|
||||
|
||||
/**
|
||||
* Whether this row has a next connection.
|
||||
@@ -47,7 +50,7 @@ const BottomRow = function(constants) {
|
||||
/**
|
||||
* The next connection on the row, if any.
|
||||
* @package
|
||||
* @type {Blockly.blockRendering.NextConnection}
|
||||
* @type {NextConnection}
|
||||
*/
|
||||
this.connection = null;
|
||||
|
||||
@@ -66,12 +69,12 @@ const BottomRow = function(constants) {
|
||||
*/
|
||||
this.baseline = 0;
|
||||
};
|
||||
Blockly.utils.object.inherits(BottomRow,
|
||||
Blockly.blockRendering.Row);
|
||||
object.inherits(BottomRow,
|
||||
Row);
|
||||
|
||||
/**
|
||||
* Returns whether or not the bottom row has a left square corner.
|
||||
* @param {!Blockly.BlockSvg} block The block whose bottom row this represents.
|
||||
* @param {!BlockSvg} block The block whose bottom row this represents.
|
||||
* @return {boolean} Whether or not the bottom row has a left square corner.
|
||||
*/
|
||||
BottomRow.prototype.hasLeftSquareCorner = function(
|
||||
@@ -81,7 +84,7 @@ BottomRow.prototype.hasLeftSquareCorner = function(
|
||||
|
||||
/**
|
||||
* Returns whether or not the bottom row has a right square corner.
|
||||
* @param {!Blockly.BlockSvg} _block The block whose bottom row this represents.
|
||||
* @param {!BlockSvg} _block The block whose bottom row this represents.
|
||||
* @return {boolean} Whether or not the bottom row has a right square corner.
|
||||
*/
|
||||
BottomRow.prototype.hasRightSquareCorner = function(
|
||||
@@ -99,10 +102,10 @@ BottomRow.prototype.measure = function() {
|
||||
for (let i = 0; i < this.elements.length; i++) {
|
||||
const elem = this.elements[i];
|
||||
width += elem.width;
|
||||
if (!(Blockly.blockRendering.Types.isSpacer(elem))) {
|
||||
if (!(Types.isSpacer(elem))) {
|
||||
// Note: this assumes that next connections have *only* descenderHeight,
|
||||
// with no height above the baseline.
|
||||
if (Blockly.blockRendering.Types.isNextConnection(elem)) {
|
||||
if (Types.isNextConnection(elem)) {
|
||||
descenderHeight = Math.max(descenderHeight, elem.height);
|
||||
} else {
|
||||
height = Math.max(height, elem.height);
|
||||
|
||||
@@ -13,23 +13,24 @@
|
||||
goog.module('Blockly.blockRendering.InputRow');
|
||||
goog.module.declareLegacyNamespace();
|
||||
|
||||
goog.requireType('Blockly.blockRendering.ConstantProvider');
|
||||
goog.require('Blockly.blockRendering.Row');
|
||||
goog.require('Blockly.blockRendering.Types');
|
||||
goog.require('Blockly.utils.object');
|
||||
/* eslint-disable-next-line no-unused-vars */
|
||||
const ConstantProvider = goog.requireType('Blockly.blockRendering.ConstantProvider');
|
||||
const Row = goog.require('Blockly.blockRendering.Row');
|
||||
const Types = goog.require('Blockly.blockRendering.Types');
|
||||
const object = goog.require('Blockly.utils.object');
|
||||
|
||||
|
||||
/**
|
||||
* An object containing information about a row that holds one or more inputs.
|
||||
* @param {!Blockly.blockRendering.ConstantProvider} constants The rendering
|
||||
* @param {!ConstantProvider} constants The rendering
|
||||
* constants provider.
|
||||
* @package
|
||||
* @constructor
|
||||
* @extends {Blockly.blockRendering.Row}
|
||||
* @extends {Row}
|
||||
*/
|
||||
const InputRow = function(constants) {
|
||||
InputRow.superClass_.constructor.call(this, constants);
|
||||
this.type |= Blockly.blockRendering.Types.INPUT_ROW;
|
||||
this.type |= Types.INPUT_ROW;
|
||||
|
||||
/**
|
||||
* The total width of all blocks connected to this row.
|
||||
@@ -38,8 +39,8 @@ const InputRow = function(constants) {
|
||||
*/
|
||||
this.connectedBlockWidths = 0;
|
||||
};
|
||||
Blockly.utils.object.inherits(InputRow,
|
||||
Blockly.blockRendering.Row);
|
||||
object.inherits(InputRow,
|
||||
Row);
|
||||
|
||||
/**
|
||||
* Inspect all subcomponents and populate all size properties on the row.
|
||||
@@ -52,16 +53,16 @@ InputRow.prototype.measure = function() {
|
||||
for (let i = 0; i < this.elements.length; i++) {
|
||||
const elem = this.elements[i];
|
||||
this.width += elem.width;
|
||||
if (Blockly.blockRendering.Types.isInput(elem)) {
|
||||
if (Blockly.blockRendering.Types.isStatementInput(elem)) {
|
||||
if (Types.isInput(elem)) {
|
||||
if (Types.isStatementInput(elem)) {
|
||||
connectedBlockWidths += elem.connectedBlockWidth;
|
||||
} else if (Blockly.blockRendering.Types.isExternalInput(elem) &&
|
||||
} else if (Types.isExternalInput(elem) &&
|
||||
elem.connectedBlockWidth != 0) {
|
||||
connectedBlockWidths += (elem.connectedBlockWidth -
|
||||
elem.connectionWidth);
|
||||
}
|
||||
}
|
||||
if (!(Blockly.blockRendering.Types.isSpacer(elem))) {
|
||||
if (!(Types.isSpacer(elem))) {
|
||||
this.height = Math.max(this.height, elem.height);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,17 +12,21 @@
|
||||
goog.module('Blockly.blockRendering.Row');
|
||||
goog.module.declareLegacyNamespace();
|
||||
|
||||
goog.requireType('Blockly.blockRendering.ConstantProvider');
|
||||
goog.requireType('Blockly.blockRendering.InputConnection');
|
||||
goog.requireType('Blockly.blockRendering.InRowSpacer');
|
||||
goog.requireType('Blockly.blockRendering.Measurable');
|
||||
goog.require('Blockly.blockRendering.Types');
|
||||
/* eslint-disable-next-line no-unused-vars */
|
||||
const ConstantProvider = goog.requireType('Blockly.blockRendering.ConstantProvider');
|
||||
/* eslint-disable-next-line no-unused-vars */
|
||||
const InputConnection = goog.requireType('Blockly.blockRendering.InputConnection');
|
||||
/* eslint-disable-next-line no-unused-vars */
|
||||
const InRowSpacer = goog.requireType('Blockly.blockRendering.InRowSpacer');
|
||||
/* eslint-disable-next-line no-unused-vars */
|
||||
const Measurable = goog.requireType('Blockly.blockRendering.Measurable');
|
||||
const Types = goog.require('Blockly.blockRendering.Types');
|
||||
|
||||
|
||||
/**
|
||||
* An object representing a single row on a rendered block and all of its
|
||||
* subcomponents.
|
||||
* @param {!Blockly.blockRendering.ConstantProvider} constants The rendering
|
||||
* @param {!ConstantProvider} constants The rendering
|
||||
* constants provider.
|
||||
* @package
|
||||
* @constructor
|
||||
@@ -33,12 +37,12 @@ const Row = function(constants) {
|
||||
* @package
|
||||
* @type {number}
|
||||
*/
|
||||
this.type = Blockly.blockRendering.Types.ROW;
|
||||
this.type = Types.ROW;
|
||||
|
||||
/**
|
||||
* An array of elements contained in this row.
|
||||
* @package
|
||||
* @type {!Array<!Blockly.blockRendering.Measurable>}
|
||||
* @type {!Array<!Measurable>}
|
||||
*/
|
||||
this.elements = [];
|
||||
|
||||
@@ -131,7 +135,7 @@ const Row = function(constants) {
|
||||
|
||||
/**
|
||||
* The renderer's constant provider.
|
||||
* @type {!Blockly.blockRendering.ConstantProvider}
|
||||
* @type {!ConstantProvider}
|
||||
* @protected
|
||||
*/
|
||||
this.constants_ = constants;
|
||||
@@ -148,7 +152,7 @@ const Row = function(constants) {
|
||||
|
||||
/**
|
||||
* Get the last input on this row, if it has one.
|
||||
* @return {Blockly.blockRendering.InputConnection} The last input on the row,
|
||||
* @return {InputConnection} The last input on the row,
|
||||
* or null.
|
||||
* @package
|
||||
*/
|
||||
@@ -156,8 +160,8 @@ const Row = function(constants) {
|
||||
Row.prototype.getLastInput = function() {
|
||||
for (let i = this.elements.length - 1; i >= 0; i--) {
|
||||
const elem = this.elements[i];
|
||||
if (Blockly.blockRendering.Types.isInput(elem)) {
|
||||
return /** @type {Blockly.blockRendering.InputConnection} */ (elem);
|
||||
if (Types.isInput(elem)) {
|
||||
return /** @type {InputConnection} */ (elem);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -191,15 +195,15 @@ Row.prototype.endsWithElemSpacer = function() {
|
||||
|
||||
/**
|
||||
* Convenience method to get the first spacer element on this row.
|
||||
* @return {Blockly.blockRendering.InRowSpacer} The first spacer element on
|
||||
* @return {InRowSpacer} The first spacer element on
|
||||
* this row.
|
||||
* @package
|
||||
*/
|
||||
Row.prototype.getFirstSpacer = function() {
|
||||
for (let i = 0; i < this.elements.length; i++) {
|
||||
const elem = this.elements[i];
|
||||
if (Blockly.blockRendering.Types.isSpacer(elem)) {
|
||||
return /** @type {Blockly.blockRendering.InRowSpacer} */ (elem);
|
||||
if (Types.isSpacer(elem)) {
|
||||
return /** @type {InRowSpacer} */ (elem);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -207,15 +211,15 @@ Row.prototype.getFirstSpacer = function() {
|
||||
|
||||
/**
|
||||
* Convenience method to get the last spacer element on this row.
|
||||
* @return {Blockly.blockRendering.InRowSpacer} The last spacer element on
|
||||
* @return {InRowSpacer} The last spacer element on
|
||||
* this row.
|
||||
* @package
|
||||
*/
|
||||
Row.prototype.getLastSpacer = function() {
|
||||
for (let i = this.elements.length - 1; i >= 0; i--) {
|
||||
const elem = this.elements[i];
|
||||
if (Blockly.blockRendering.Types.isSpacer(elem)) {
|
||||
return /** @type {Blockly.blockRendering.InRowSpacer} */ (elem);
|
||||
if (Types.isSpacer(elem)) {
|
||||
return /** @type {InRowSpacer} */ (elem);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -12,37 +12,38 @@
|
||||
goog.module('Blockly.blockRendering.SpacerRow');
|
||||
goog.module.declareLegacyNamespace();
|
||||
|
||||
goog.requireType('Blockly.blockRendering.ConstantProvider');
|
||||
goog.require('Blockly.blockRendering.InRowSpacer');
|
||||
goog.require('Blockly.blockRendering.Row');
|
||||
goog.require('Blockly.blockRendering.Types');
|
||||
goog.require('Blockly.utils.object');
|
||||
/* eslint-disable-next-line no-unused-vars */
|
||||
const ConstantProvider = goog.requireType('Blockly.blockRendering.ConstantProvider');
|
||||
const InRowSpacer = goog.require('Blockly.blockRendering.InRowSpacer');
|
||||
const Row = goog.require('Blockly.blockRendering.Row');
|
||||
const Types = goog.require('Blockly.blockRendering.Types');
|
||||
const object = goog.require('Blockly.utils.object');
|
||||
|
||||
|
||||
/**
|
||||
* An object containing information about a spacer between two rows.
|
||||
* @param {!Blockly.blockRendering.ConstantProvider} constants The rendering
|
||||
* @param {!ConstantProvider} constants The rendering
|
||||
* constants provider.
|
||||
* @param {number} height The height of the spacer.
|
||||
* @param {number} width The width of the spacer.
|
||||
* @package
|
||||
* @constructor
|
||||
* @extends {Blockly.blockRendering.Row}
|
||||
* @extends {Row}
|
||||
*/
|
||||
const SpacerRow = function(constants, height, width) {
|
||||
SpacerRow.superClass_.constructor.call(this,
|
||||
constants);
|
||||
this.type |= Blockly.blockRendering.Types.SPACER |
|
||||
Blockly.blockRendering.Types.BETWEEN_ROW_SPACER;
|
||||
this.type |= Types.SPACER |
|
||||
Types.BETWEEN_ROW_SPACER;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.followsStatement = false;
|
||||
this.widthWithConnectedBlocks = 0;
|
||||
this.elements = [
|
||||
new Blockly.blockRendering.InRowSpacer(this.constants_, width)];
|
||||
new InRowSpacer(this.constants_, width)];
|
||||
};
|
||||
Blockly.utils.object.inherits(SpacerRow,
|
||||
Blockly.blockRendering.Row);
|
||||
object.inherits(SpacerRow,
|
||||
Row);
|
||||
|
||||
/**
|
||||
* @override
|
||||
|
||||
@@ -12,12 +12,15 @@
|
||||
goog.module('Blockly.blockRendering.TopRow');
|
||||
goog.module.declareLegacyNamespace();
|
||||
|
||||
goog.requireType('Blockly.BlockSvg');
|
||||
goog.requireType('Blockly.blockRendering.ConstantProvider');
|
||||
goog.requireType('Blockly.blockRendering.PreviousConnection');
|
||||
goog.require('Blockly.blockRendering.Row');
|
||||
goog.require('Blockly.blockRendering.Types');
|
||||
goog.require('Blockly.utils.object');
|
||||
/* eslint-disable-next-line no-unused-vars */
|
||||
const BlockSvg = goog.requireType('Blockly.BlockSvg');
|
||||
/* eslint-disable-next-line no-unused-vars */
|
||||
const ConstantProvider = goog.requireType('Blockly.blockRendering.ConstantProvider');
|
||||
/* eslint-disable-next-line no-unused-vars */
|
||||
const PreviousConnection = goog.requireType('Blockly.blockRendering.PreviousConnection');
|
||||
const Row = goog.require('Blockly.blockRendering.Row');
|
||||
const Types = goog.require('Blockly.blockRendering.Types');
|
||||
const object = goog.require('Blockly.utils.object');
|
||||
|
||||
|
||||
/**
|
||||
@@ -27,16 +30,16 @@ goog.require('Blockly.utils.object');
|
||||
* connections.
|
||||
* After this constructor is called, the row will contain all non-spacer
|
||||
* elements it needs.
|
||||
* @param {!Blockly.blockRendering.ConstantProvider} constants The rendering
|
||||
* @param {!ConstantProvider} constants The rendering
|
||||
* constants provider.
|
||||
* @package
|
||||
* @constructor
|
||||
* @extends {Blockly.blockRendering.Row}
|
||||
* @extends {Row}
|
||||
*/
|
||||
const TopRow = function(constants) {
|
||||
TopRow.superClass_.constructor.call(this, constants);
|
||||
|
||||
this.type |= Blockly.blockRendering.Types.TOP_ROW;
|
||||
this.type |= Types.TOP_ROW;
|
||||
|
||||
/**
|
||||
* The starting point for drawing the row, in the y direction.
|
||||
@@ -62,16 +65,16 @@ const TopRow = function(constants) {
|
||||
|
||||
/**
|
||||
* The previous connection on the block, if any.
|
||||
* @type {Blockly.blockRendering.PreviousConnection}
|
||||
* @type {PreviousConnection}
|
||||
*/
|
||||
this.connection = null;
|
||||
};
|
||||
Blockly.utils.object.inherits(TopRow,
|
||||
Blockly.blockRendering.Row);
|
||||
object.inherits(TopRow,
|
||||
Row);
|
||||
|
||||
/**
|
||||
* Returns whether or not the top row has a left square corner.
|
||||
* @param {!Blockly.BlockSvg} block The block whose top row this represents.
|
||||
* @param {!BlockSvg} block The block whose top row this represents.
|
||||
* @return {boolean} Whether or not the top row has a left square corner.
|
||||
*/
|
||||
TopRow.prototype.hasLeftSquareCorner = function(block) {
|
||||
@@ -86,7 +89,7 @@ TopRow.prototype.hasLeftSquareCorner = function(block) {
|
||||
|
||||
/**
|
||||
* Returns whether or not the top row has a right square corner.
|
||||
* @param {!Blockly.BlockSvg} _block The block whose top row this represents.
|
||||
* @param {!BlockSvg} _block The block whose top row this represents.
|
||||
* @return {boolean} Whether or not the top row has a right square corner.
|
||||
*/
|
||||
TopRow.prototype.hasRightSquareCorner = function(
|
||||
@@ -105,8 +108,8 @@ TopRow.prototype.measure = function() {
|
||||
for (let i = 0; i < this.elements.length; i++) {
|
||||
const elem = this.elements[i];
|
||||
width += elem.width;
|
||||
if (!(Blockly.blockRendering.Types.isSpacer(elem))) {
|
||||
if (Blockly.blockRendering.Types.isHat(elem)) {
|
||||
if (!(Types.isSpacer(elem))) {
|
||||
if (Types.isHat(elem)) {
|
||||
ascenderHeight = Math.max(ascenderHeight, elem.ascenderHeight);
|
||||
} else {
|
||||
height = Math.max(height, elem.height);
|
||||
|
||||
Reference in New Issue
Block a user