From d50247664acceb9e32fbf26d5c94fbb90e703d7f Mon Sep 17 00:00:00 2001 From: kozbial Date: Mon, 16 Aug 2021 17:06:14 -0700 Subject: [PATCH] Split classes from core/renderers/measurables/connections.js into multiple files --- core/renderers/measurables/connection.js | 43 +++++++ core/renderers/measurables/connections.js | 116 ------------------ core/renderers/measurables/next_connection.js | 42 +++++++ .../measurables/output_connection.js | 48 ++++++++ .../measurables/previous_connection.js | 44 +++++++ tests/deps.js | 5 +- 6 files changed, 181 insertions(+), 117 deletions(-) create mode 100644 core/renderers/measurables/connection.js delete mode 100644 core/renderers/measurables/connections.js create mode 100644 core/renderers/measurables/next_connection.js create mode 100644 core/renderers/measurables/output_connection.js create mode 100644 core/renderers/measurables/previous_connection.js diff --git a/core/renderers/measurables/connection.js b/core/renderers/measurables/connection.js new file mode 100644 index 000000000..c2ad7db99 --- /dev/null +++ b/core/renderers/measurables/connection.js @@ -0,0 +1,43 @@ +/** + * @license + * Copyright 2019 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @fileoverview Base class representing the space a connection takes up during + * rendering. + * @author fenichel@google.com (Rachel Fenichel) + */ + +goog.provide('Blockly.blockRendering.Connection'); + +goog.require('Blockly.blockRendering.Measurable'); +goog.require('Blockly.blockRendering.Types'); +goog.require('Blockly.utils.object'); + +goog.requireType('Blockly.blockRendering.ConstantProvider'); +goog.requireType('Blockly.RenderedConnection'); + + +/** + * The base class to represent a connection and the space that it takes up on + * the block. + * @param {!Blockly.blockRendering.ConstantProvider} constants The rendering + * constants provider. + * @param {!Blockly.RenderedConnection} connectionModel The connection object on + * the block that this represents. + * @package + * @constructor + * @extends {Blockly.blockRendering.Measurable} + */ +Blockly.blockRendering.Connection = function(constants, connectionModel) { + Blockly.blockRendering.Connection.superClass_.constructor.call(this, + constants); + this.connectionModel = connectionModel; + this.shape = this.constants_.shapeFor(connectionModel); + this.isDynamicShape = !!this.shape['isDynamic']; + this.type |= Blockly.blockRendering.Types.CONNECTION; +}; +Blockly.utils.object.inherits(Blockly.blockRendering.Connection, + Blockly.blockRendering.Measurable); diff --git a/core/renderers/measurables/connections.js b/core/renderers/measurables/connections.js deleted file mode 100644 index 0762878c2..000000000 --- a/core/renderers/measurables/connections.js +++ /dev/null @@ -1,116 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC - * SPDX-License-Identifier: Apache-2.0 - */ - -/** - * @fileoverview Objects representing connections on rendered blocks. - * @author fenichel@google.com (Rachel Fenichel) - */ - -goog.provide('Blockly.blockRendering.Connection'); -goog.provide('Blockly.blockRendering.NextConnection'); -goog.provide('Blockly.blockRendering.OutputConnection'); -goog.provide('Blockly.blockRendering.PreviousConnection'); - -goog.require('Blockly.blockRendering.Measurable'); -goog.require('Blockly.blockRendering.Types'); -goog.require('Blockly.utils.object'); - -goog.requireType('Blockly.blockRendering.ConstantProvider'); -goog.requireType('Blockly.RenderedConnection'); - - -/** - * The base class to represent a connection and the space that it takes up on - * the block. - * @param {!Blockly.blockRendering.ConstantProvider} constants The rendering - * constants provider. - * @param {!Blockly.RenderedConnection} connectionModel The connection object on - * the block that this represents. - * @package - * @constructor - * @extends {Blockly.blockRendering.Measurable} - */ -Blockly.blockRendering.Connection = function(constants, connectionModel) { - Blockly.blockRendering.Connection.superClass_.constructor.call(this, - constants); - this.connectionModel = connectionModel; - this.shape = this.constants_.shapeFor(connectionModel); - this.isDynamicShape = !!this.shape['isDynamic']; - this.type |= Blockly.blockRendering.Types.CONNECTION; -}; -Blockly.utils.object.inherits(Blockly.blockRendering.Connection, - Blockly.blockRendering.Measurable); - -/** - * An object containing information about the space an output connection takes - * up during rendering. - * @param {!Blockly.blockRendering.ConstantProvider} constants The rendering - * constants provider. - * @param {Blockly.RenderedConnection} connectionModel The connection object on - * the block that this represents. - * @package - * @constructor - * @extends {Blockly.blockRendering.Connection} - */ -Blockly.blockRendering.OutputConnection = function(constants, connectionModel) { - Blockly.blockRendering.OutputConnection.superClass_.constructor.call(this, - constants, connectionModel); - this.type |= Blockly.blockRendering.Types.OUTPUT_CONNECTION; - - this.height = !this.isDynamicShape ? this.shape.height : 0; - this.width = !this.isDynamicShape ? this.shape.width : 0; - this.startX = this.width; - - this.connectionOffsetY = this.constants_.TAB_OFFSET_FROM_TOP; - this.connectionOffsetX = 0; -}; -Blockly.utils.object.inherits(Blockly.blockRendering.OutputConnection, - Blockly.blockRendering.Connection); - - -/** - * An object containing information about the space a previous connection takes - * up during rendering. - * @param {!Blockly.blockRendering.ConstantProvider} constants The rendering - * constants provider. - * @param {Blockly.RenderedConnection} connectionModel The connection object on - * the block that this represents. - * @package - * @constructor - * @extends {Blockly.blockRendering.Connection} - */ -Blockly.blockRendering.PreviousConnection = function( - constants, connectionModel) { - Blockly.blockRendering.PreviousConnection.superClass_.constructor.call(this, - constants, connectionModel); - this.type |= Blockly.blockRendering.Types.PREVIOUS_CONNECTION; - this.height = this.shape.height; - this.width = this.shape.width; - -}; -Blockly.utils.object.inherits(Blockly.blockRendering.PreviousConnection, - Blockly.blockRendering.Connection); - -/** - * An object containing information about the space a next connection takes - * up during rendering. - * @param {!Blockly.blockRendering.ConstantProvider} constants The rendering - * constants provider. - * @param {Blockly.RenderedConnection} connectionModel The connection object on - * the block that this represents. - * @package - * @constructor - * @extends {Blockly.blockRendering.Connection} - */ -Blockly.blockRendering.NextConnection = function(constants, connectionModel) { - Blockly.blockRendering.NextConnection.superClass_.constructor.call(this, - constants, connectionModel); - this.type |= Blockly.blockRendering.Types.NEXT_CONNECTION; - this.height = this.shape.height; - this.width = this.shape.width; -}; -Blockly.utils.object.inherits(Blockly.blockRendering.NextConnection, - Blockly.blockRendering.Connection); diff --git a/core/renderers/measurables/next_connection.js b/core/renderers/measurables/next_connection.js new file mode 100644 index 000000000..a5874e027 --- /dev/null +++ b/core/renderers/measurables/next_connection.js @@ -0,0 +1,42 @@ +/** + * @license + * Copyright 2019 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @fileoverview Class representing the space a next connection takes up during + * rendering. + * @author fenichel@google.com (Rachel Fenichel) + */ + +goog.provide('Blockly.blockRendering.NextConnection'); + +goog.require('Blockly.blockRendering.Connection'); +goog.require('Blockly.blockRendering.Types'); +goog.require('Blockly.utils.object'); + +goog.requireType('Blockly.blockRendering.ConstantProvider'); +goog.requireType('Blockly.RenderedConnection'); + + +/** + * An object containing information about the space a next connection takes + * up during rendering. + * @param {!Blockly.blockRendering.ConstantProvider} constants The rendering + * constants provider. + * @param {Blockly.RenderedConnection} connectionModel The connection object on + * the block that this represents. + * @package + * @constructor + * @extends {Blockly.blockRendering.Connection} + */ +Blockly.blockRendering.NextConnection = function(constants, connectionModel) { + Blockly.blockRendering.NextConnection.superClass_.constructor.call(this, + constants, connectionModel); + this.type |= Blockly.blockRendering.Types.NEXT_CONNECTION; + this.height = this.shape.height; + this.width = this.shape.width; +}; +Blockly.utils.object.inherits(Blockly.blockRendering.NextConnection, + Blockly.blockRendering.Connection); diff --git a/core/renderers/measurables/output_connection.js b/core/renderers/measurables/output_connection.js new file mode 100644 index 000000000..86ac5ab46 --- /dev/null +++ b/core/renderers/measurables/output_connection.js @@ -0,0 +1,48 @@ + +/** + * @license + * Copyright 2019 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @fileoverview Class representing the space a output connection takes up + * during rendering. + * @author fenichel@google.com (Rachel Fenichel) + */ + +goog.provide('Blockly.blockRendering.OutputConnection'); + +goog.require('Blockly.blockRendering.Connection'); +goog.require('Blockly.blockRendering.Types'); +goog.require('Blockly.utils.object'); + +goog.requireType('Blockly.blockRendering.ConstantProvider'); +goog.requireType('Blockly.RenderedConnection'); + + +/** + * An object containing information about the space an output connection takes + * up during rendering. + * @param {!Blockly.blockRendering.ConstantProvider} constants The rendering + * constants provider. + * @param {Blockly.RenderedConnection} connectionModel The connection object on + * the block that this represents. + * @package + * @constructor + * @extends {Blockly.blockRendering.Connection} + */ +Blockly.blockRendering.OutputConnection = function(constants, connectionModel) { + Blockly.blockRendering.OutputConnection.superClass_.constructor.call(this, + constants, connectionModel); + this.type |= Blockly.blockRendering.Types.OUTPUT_CONNECTION; + + this.height = !this.isDynamicShape ? this.shape.height : 0; + this.width = !this.isDynamicShape ? this.shape.width : 0; + this.startX = this.width; + + this.connectionOffsetY = this.constants_.TAB_OFFSET_FROM_TOP; + this.connectionOffsetX = 0; +}; +Blockly.utils.object.inherits(Blockly.blockRendering.OutputConnection, + Blockly.blockRendering.Connection); diff --git a/core/renderers/measurables/previous_connection.js b/core/renderers/measurables/previous_connection.js new file mode 100644 index 000000000..deb5e9137 --- /dev/null +++ b/core/renderers/measurables/previous_connection.js @@ -0,0 +1,44 @@ +/** + * @license + * Copyright 2019 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @fileoverview Class representing the space a previous connection takes up + * during rendering. + * @author fenichel@google.com (Rachel Fenichel) + */ + +goog.provide('Blockly.blockRendering.PreviousConnection'); + +goog.require('Blockly.blockRendering.Connection'); +goog.require('Blockly.blockRendering.Types'); +goog.require('Blockly.utils.object'); + +goog.requireType('Blockly.blockRendering.ConstantProvider'); +goog.requireType('Blockly.RenderedConnection'); + + +/** + * An object containing information about the space a previous connection takes + * up during rendering. + * @param {!Blockly.blockRendering.ConstantProvider} constants The rendering + * constants provider. + * @param {Blockly.RenderedConnection} connectionModel The connection object on + * the block that this represents. + * @package + * @constructor + * @extends {Blockly.blockRendering.Connection} + */ +Blockly.blockRendering.PreviousConnection = function( + constants, connectionModel) { + Blockly.blockRendering.PreviousConnection.superClass_.constructor.call(this, + constants, connectionModel); + this.type |= Blockly.blockRendering.Types.PREVIOUS_CONNECTION; + this.height = this.shape.height; + this.width = this.shape.width; + +}; +Blockly.utils.object.inherits(Blockly.blockRendering.PreviousConnection, + Blockly.blockRendering.Connection); diff --git a/tests/deps.js b/tests/deps.js index 18cb65bff..267209ed9 100644 --- a/tests/deps.js +++ b/tests/deps.js @@ -150,7 +150,7 @@ goog.addDependency('../../core/renderers/geras/path_object.js', ['Blockly.geras. goog.addDependency('../../core/renderers/geras/renderer.js', ['Blockly.geras.Renderer'], ['Blockly.blockRendering', 'Blockly.blockRendering.Renderer', 'Blockly.geras.ConstantProvider', 'Blockly.geras.Drawer', 'Blockly.geras.HighlightConstantProvider', 'Blockly.geras.PathObject', 'Blockly.geras.RenderInfo', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/renderers/measurables/base.js', ['Blockly.blockRendering.Measurable'], ['Blockly.blockRendering.Types'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/renderers/measurables/bottom_row.js', ['Blockly.blockRendering.BottomRow'], ['Blockly.blockRendering.Row', 'Blockly.blockRendering.Types', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../core/renderers/measurables/connections.js', ['Blockly.blockRendering.Connection', 'Blockly.blockRendering.NextConnection', 'Blockly.blockRendering.OutputConnection', 'Blockly.blockRendering.PreviousConnection'], ['Blockly.blockRendering.Measurable', 'Blockly.blockRendering.Types', 'Blockly.utils.object']); +goog.addDependency('../../core/renderers/measurables/connection.js', ['Blockly.blockRendering.Connection'], ['Blockly.blockRendering.Measurable', 'Blockly.blockRendering.Types', 'Blockly.utils.object']); goog.addDependency('../../core/renderers/measurables/external_value_input.js', ['Blockly.blockRendering.ExternalValueInput'], ['Blockly.blockRendering.InputConnection', 'Blockly.blockRendering.Types', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/renderers/measurables/field.js', ['Blockly.blockRendering.Field'], ['Blockly.blockRendering.Measurable', 'Blockly.blockRendering.Types', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/renderers/measurables/hat.js', ['Blockly.blockRendering.Hat'], ['Blockly.blockRendering.Measurable', 'Blockly.blockRendering.Types', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'}); @@ -160,6 +160,9 @@ goog.addDependency('../../core/renderers/measurables/inline_input.js', ['Blockly goog.addDependency('../../core/renderers/measurables/input_connection.js', ['Blockly.blockRendering.InputConnection'], ['Blockly.blockRendering.Connection', 'Blockly.blockRendering.Types', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/renderers/measurables/input_row.js', ['Blockly.blockRendering.InputRow'], ['Blockly.blockRendering.Row', 'Blockly.blockRendering.Types', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/renderers/measurables/jagged_edge.js', ['Blockly.blockRendering.JaggedEdge'], ['Blockly.blockRendering.Measurable', 'Blockly.blockRendering.Types', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../core/renderers/measurables/next_connection.js', ['Blockly.blockRendering.NextConnection'], ['Blockly.blockRendering.Connection', 'Blockly.blockRendering.Types', 'Blockly.utils.object']); +goog.addDependency('../../core/renderers/measurables/output_connection.js', ['Blockly.blockRendering.OutputConnection'], ['Blockly.blockRendering.Connection', 'Blockly.blockRendering.Types', 'Blockly.utils.object']); +goog.addDependency('../../core/renderers/measurables/previous_connection.js', ['Blockly.blockRendering.PreviousConnection'], ['Blockly.blockRendering.Connection', 'Blockly.blockRendering.Types', 'Blockly.utils.object']); goog.addDependency('../../core/renderers/measurables/round_corner.js', ['Blockly.blockRendering.RoundCorner'], ['Blockly.blockRendering.Measurable', 'Blockly.blockRendering.Types', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/renderers/measurables/row.js', ['Blockly.blockRendering.Row'], ['Blockly.blockRendering.Types'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/renderers/measurables/spacer_row.js', ['Blockly.blockRendering.SpacerRow'], ['Blockly.blockRendering.InRowSpacer', 'Blockly.blockRendering.Row', 'Blockly.blockRendering.Types', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'});