Skip to content

Commit

Permalink
custom connection shape
Browse files Browse the repository at this point in the history
  • Loading branch information
jwklong committed Nov 16, 2024
1 parent d9e33ea commit 96b4b08
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions core/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ Blockly.Connection.prototype.targetConnection = null;
*/
Blockly.Connection.prototype.check_ = null;

/**
* connection shape override
* @type {number?}
* @private
*/
Blockly.Connection.prototype.shape_ = null;

/**
* DOM representation of a shadow block, or null if none.
* @type {Element}
Expand Down Expand Up @@ -689,12 +696,29 @@ Blockly.Connection.prototype.setCheck = function(check) {
return this;
};

/**
* Change a connection's shape
* @param {number} shape Compatible value type or list of value types.
* Null if all types are compatible.
* @return {!Blockly.Connection} The connection being modified
* (to allow chaining).
*/
Blockly.Connection.prototype.setShape = function(shape) {
if (shape) {
this.shape_ = shape
} else {
this.shape_ = null;
}
return this;
};

/**
* Returns a shape enum for this connection.
* Used in scratch-blocks to draw unoccupied inputs.
* @return {number} Enum representing shape.
*/
Blockly.Connection.prototype.getOutputShape = function() {
if (this.shape_) return this.shape_
if (!this.check_) return Blockly.OUTPUT_SHAPE_ROUND;
if (this.check_.indexOf('Boolean') !== -1) {
return Blockly.OUTPUT_SHAPE_HEXAGONAL;
Expand Down

0 comments on commit 96b4b08

Please sign in to comment.