Separate output edge shapes from output types (#447)

* Separate output shape from type checking.

* Fix enum check in actual output shape rendering.

* Add output shapes for most relevant blocks.

* Bring back and update output shapes for unoccupied connections.

* Fix output shapes for boolean-type operators

* Update type-checking in blocks to match Scratch 2.0
This commit is contained in:
Tim Mickel 2016-06-23 19:04:20 -04:00 committed by GitHub
parent d98844de34
commit 553c825d7a
10 changed files with 155 additions and 123 deletions

View file

@ -30,6 +30,8 @@ goog.require('Blockly.Blocks');
goog.require('Blockly.Colours');
goog.require('Blockly.constants');
/**
* Common HSV hue for all blocks in this category.
@ -55,6 +57,7 @@ Blockly.Blocks['math_number'] = {
return (parent && parent.getInputsInline() && parent.tooltip) ||
Blockly.Msg.MATH_NUMBER_TOOLTIP;
});
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
}
};
@ -69,6 +72,7 @@ Blockly.Blocks['math_whole_number'] = {
this.appendDummyInput()
.appendField(new Blockly.FieldNumber('0', 0, Infinity, 1), 'NUM');
this.setOutput(true, 'Number');
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
}
};
@ -83,5 +87,6 @@ Blockly.Blocks['math_positive_number'] = {
this.appendDummyInput()
.appendField(new Blockly.FieldNumber('0', 0, Infinity), 'NUM');
this.setOutput(true, 'Number');
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
}
};

View file

@ -30,6 +30,8 @@ goog.require('Blockly.Blocks');
goog.require('Blockly.Colours');
goog.require('Blockly.constants');
/**
* Common HSV hue for all blocks in this category.
@ -55,6 +57,7 @@ Blockly.Blocks['text'] = {
return (parent && parent.getInputsInline() && parent.tooltip) ||
Blockly.Msg.TEXT_TEXT_TOOLTIP;
});
this.setOutputShape(Blockly.OUTPUT_SHAPE_SQUARE);
},
/**
* Create an image of an open or closed quote.

View file

@ -61,8 +61,7 @@ Blockly.Blocks['control_repeat'] = {
"args0": [
{
"type": "input_value",
"name": "TIMES",
"check": "Number"
"name": "TIMES"
},
{
"type": "input_statement",
@ -201,8 +200,7 @@ Blockly.Blocks['control_stop'] = {
"args0": [
{
"type": "input_value",
"name": "STOP_OPTION",
"check": "String"
"name": "STOP_OPTION"
}
],
"inputsInline": true,
@ -226,8 +224,7 @@ Blockly.Blocks['control_wait'] = {
"args0": [
{
"type": "input_value",
"name": "DURATION",
"check": "Number"
"name": "DURATION"
}
],
"inputsInline": true,
@ -361,8 +358,7 @@ Blockly.Blocks['control_create_clone_of'] = {
"args0": [
{
"type": "input_value",
"name": "CLONE_OPTION",
"check": "String"
"name": "CLONE_OPTION"
}
],
"inputsInline": true,

View file

@ -79,8 +79,7 @@ Blockly.Blocks['event_whenbroadcastreceived'] = {
"args0": [
{
"type": "input_value",
"name": "BROADCAST_OPTION",
"check": "String"
"name": "BROADCAST_OPTION"
}
],
"inputsInline": true,
@ -104,8 +103,7 @@ Blockly.Blocks['event_broadcast'] = {
"args0": [
{
"type": "input_value",
"name": "BROADCAST_OPTION",
"check": "String"
"name": "BROADCAST_OPTION"
}
],
"inputsInline": true,
@ -129,8 +127,7 @@ Blockly.Blocks['event_broadcastandwait'] = {
"args0": [
{
"type": "input_value",
"name": "BROADCAST_OPTION",
"check": "String"
"name": "BROADCAST_OPTION"
}
],
"inputsInline": true,

View file

@ -31,6 +31,8 @@ goog.require('Blockly.Blocks');
goog.require('Blockly.Colours');
goog.require('Blockly.constants');
Blockly.Blocks['operator_add'] = {
/**
* Block for adding two numbers.
@ -43,20 +45,19 @@ Blockly.Blocks['operator_add'] = {
"args0": [
{
"type": "input_value",
"name": "NUM1",
"check": "Number"
"name": "NUM1"
},
{
"type": "input_value",
"name": "NUM2",
"check": "Number"
"name": "NUM2"
}
],
"inputsInline": true,
"output": "Number",
"colour": Blockly.Colours.operators.primary,
"colourSecondary": Blockly.Colours.operators.secondary,
"colourTertiary": Blockly.Colours.operators.tertiary
"colourTertiary": Blockly.Colours.operators.tertiary,
"outputShape": Blockly.OUTPUT_SHAPE_ROUND
});
}
};
@ -73,20 +74,19 @@ Blockly.Blocks['operator_subtract'] = {
"args0": [
{
"type": "input_value",
"name": "NUM1",
"check": "Number"
"name": "NUM1"
},
{
"type": "input_value",
"name": "NUM2",
"check": "Number"
"name": "NUM2"
}
],
"inputsInline": true,
"output": "Number",
"colour": Blockly.Colours.operators.primary,
"colourSecondary": Blockly.Colours.operators.secondary,
"colourTertiary": Blockly.Colours.operators.tertiary
"colourTertiary": Blockly.Colours.operators.tertiary,
"outputShape": Blockly.OUTPUT_SHAPE_ROUND
});
}
};
@ -103,20 +103,19 @@ Blockly.Blocks['operator_multiply'] = {
"args0": [
{
"type": "input_value",
"name": "NUM1",
"check": "Number"
"name": "NUM1"
},
{
"type": "input_value",
"name": "NUM2",
"check": "Number"
"name": "NUM2"
}
],
"inputsInline": true,
"output": "Number",
"colour": Blockly.Colours.operators.primary,
"colourSecondary": Blockly.Colours.operators.secondary,
"colourTertiary": Blockly.Colours.operators.tertiary
"colourTertiary": Blockly.Colours.operators.tertiary,
"outputShape": Blockly.OUTPUT_SHAPE_ROUND
});
}
};
@ -133,20 +132,19 @@ Blockly.Blocks['operator_divide'] = {
"args0": [
{
"type": "input_value",
"name": "NUM1",
"check": "Number"
"name": "NUM1"
},
{
"type": "input_value",
"name": "NUM2",
"check": "Number"
"name": "NUM2"
}
],
"inputsInline": true,
"output": "Number",
"colour": Blockly.Colours.operators.primary,
"colourSecondary": Blockly.Colours.operators.secondary,
"colourTertiary": Blockly.Colours.operators.tertiary
"colourTertiary": Blockly.Colours.operators.tertiary,
"outputShape": Blockly.OUTPUT_SHAPE_ROUND
});
}
};
@ -163,20 +161,19 @@ Blockly.Blocks['operator_random'] = {
"args0": [
{
"type": "input_value",
"name": "FROM",
"check": "Number"
"name": "FROM"
},
{
"type": "input_value",
"name": "TO",
"check": "Number"
"name": "TO"
}
],
"inputsInline": true,
"output": "Number",
"colour": Blockly.Colours.operators.primary,
"colourSecondary": Blockly.Colours.operators.secondary,
"colourTertiary": Blockly.Colours.operators.tertiary
"colourTertiary": Blockly.Colours.operators.tertiary,
"outputShape": Blockly.OUTPUT_SHAPE_ROUND
});
}
};
@ -203,7 +200,8 @@ Blockly.Blocks['operator_lt'] = {
"output": "Boolean",
"colour": Blockly.Colours.operators.primary,
"colourSecondary": Blockly.Colours.operators.secondary,
"colourTertiary": Blockly.Colours.operators.tertiary
"colourTertiary": Blockly.Colours.operators.tertiary,
"outputShape": Blockly.OUTPUT_SHAPE_HEXAGONAL
});
}
};
@ -230,7 +228,8 @@ Blockly.Blocks['operator_equals'] = {
"output": "Boolean",
"colour": Blockly.Colours.operators.primary,
"colourSecondary": Blockly.Colours.operators.secondary,
"colourTertiary": Blockly.Colours.operators.tertiary
"colourTertiary": Blockly.Colours.operators.tertiary,
"outputShape": Blockly.OUTPUT_SHAPE_HEXAGONAL
});
}
};
@ -257,7 +256,8 @@ Blockly.Blocks['operator_gt'] = {
"output": "Boolean",
"colour": Blockly.Colours.operators.primary,
"colourSecondary": Blockly.Colours.operators.secondary,
"colourTertiary": Blockly.Colours.operators.tertiary
"colourTertiary": Blockly.Colours.operators.tertiary,
"outputShape": Blockly.OUTPUT_SHAPE_HEXAGONAL
});
}
};
@ -286,7 +286,8 @@ Blockly.Blocks['operator_and'] = {
"output": "Boolean",
"colour": Blockly.Colours.operators.primary,
"colourSecondary": Blockly.Colours.operators.secondary,
"colourTertiary": Blockly.Colours.operators.tertiary
"colourTertiary": Blockly.Colours.operators.tertiary,
"outputShape": Blockly.OUTPUT_SHAPE_HEXAGONAL
});
}
};
@ -315,7 +316,8 @@ Blockly.Blocks['operator_or'] = {
"output": "Boolean",
"colour": Blockly.Colours.operators.primary,
"colourSecondary": Blockly.Colours.operators.secondary,
"colourTertiary": Blockly.Colours.operators.tertiary
"colourTertiary": Blockly.Colours.operators.tertiary,
"outputShape": Blockly.OUTPUT_SHAPE_HEXAGONAL
});
}
};
@ -339,7 +341,8 @@ Blockly.Blocks['operator_not'] = {
"output": "Boolean",
"colour": Blockly.Colours.operators.primary,
"colourSecondary": Blockly.Colours.operators.secondary,
"colourTertiary": Blockly.Colours.operators.tertiary
"colourTertiary": Blockly.Colours.operators.tertiary,
"outputShape": Blockly.OUTPUT_SHAPE_HEXAGONAL
});
}
};
@ -366,7 +369,8 @@ Blockly.Blocks['operator_join'] = {
"output": "String",
"colour": Blockly.Colours.operators.primary,
"colourSecondary": Blockly.Colours.operators.secondary,
"colourTertiary": Blockly.Colours.operators.tertiary
"colourTertiary": Blockly.Colours.operators.tertiary,
"outputShape": Blockly.OUTPUT_SHAPE_ROUND
});
}
};
@ -382,8 +386,7 @@ Blockly.Blocks['operator_letter_of'] = {
"args0": [
{
"type": "input_value",
"name": "LETTER",
"check": "Number"
"name": "LETTER"
},
{
"type": "input_value",
@ -394,7 +397,8 @@ Blockly.Blocks['operator_letter_of'] = {
"output": "String",
"colour": Blockly.Colours.operators.primary,
"colourSecondary": Blockly.Colours.operators.secondary,
"colourTertiary": Blockly.Colours.operators.tertiary
"colourTertiary": Blockly.Colours.operators.tertiary,
"outputShape": Blockly.OUTPUT_SHAPE_ROUND
});
}
};
@ -417,7 +421,8 @@ Blockly.Blocks['operator_length'] = {
"output": "Number",
"colour": Blockly.Colours.operators.primary,
"colourSecondary": Blockly.Colours.operators.secondary,
"colourTertiary": Blockly.Colours.operators.tertiary
"colourTertiary": Blockly.Colours.operators.tertiary,
"outputShape": Blockly.OUTPUT_SHAPE_ROUND
});
}
};
@ -434,20 +439,19 @@ Blockly.Blocks['operator_mod'] = {
"args0": [
{
"type": "input_value",
"name": "NUM1",
"check": "Number"
"name": "NUM1"
},
{
"type": "input_value",
"name": "NUM2",
"check": "Number"
"name": "NUM2"
}
],
"inputsInline": true,
"output": "Number",
"colour": Blockly.Colours.operators.primary,
"colourSecondary": Blockly.Colours.operators.secondary,
"colourTertiary": Blockly.Colours.operators.tertiary
"colourTertiary": Blockly.Colours.operators.tertiary,
"outputShape": Blockly.OUTPUT_SHAPE_ROUND
});
}
};
@ -464,15 +468,15 @@ Blockly.Blocks['operator_round'] = {
"args0": [
{
"type": "input_value",
"name": "NUM",
"check": "Number"
"name": "NUM"
}
],
"inputsInline": true,
"output": "Number",
"colour": Blockly.Colours.operators.primary,
"colourSecondary": Blockly.Colours.operators.secondary,
"colourTertiary": Blockly.Colours.operators.tertiary
"colourTertiary": Blockly.Colours.operators.tertiary,
"outputShape": Blockly.OUTPUT_SHAPE_ROUND
});
}
};
@ -512,7 +516,8 @@ Blockly.Blocks['operator_mathop_menu'] = {
"output": "String",
"colour": Blockly.Colours.operators.secondary,
"colourSecondary": Blockly.Colours.operators.secondary,
"colourTertiary": Blockly.Colours.operators.tertiary
"colourTertiary": Blockly.Colours.operators.tertiary,
"outputShape": Blockly.OUTPUT_SHAPE_SQUARE
});
}
};
@ -529,20 +534,19 @@ Blockly.Blocks['operator_mathop'] = {
"args0": [
{
"type": "input_value",
"name": "OPERATOR",
"check": "String"
"name": "OPERATOR"
},
{
"type": "input_value",
"name": "NUM",
"check": "Number"
"name": "NUM"
}
],
"inputsInline": true,
"output": "Number",
"colour": Blockly.Colours.operators.primary,
"colourSecondary": Blockly.Colours.operators.secondary,
"colourTertiary": Blockly.Colours.operators.tertiary
"colourTertiary": Blockly.Colours.operators.tertiary,
"outputShape": Blockly.OUTPUT_SHAPE_ROUND
});
}
};

View file

@ -43,8 +43,7 @@ Blockly.Blocks['wedo_motorclockwise'] = {
"args0": [
{
"type": "input_value",
"name": "DURATION",
"check": "Number"
"name": "DURATION"
}
],
"inputsInline": true,
@ -69,8 +68,7 @@ Blockly.Blocks['wedo_motorcounterclockwise'] = {
"args0": [
{
"type": "input_value",
"name": "DURATION",
"check": "Number"
"name": "DURATION"
}
],
"inputsInline": true,

View file

@ -121,6 +121,12 @@ Blockly.Block = function(workspace, prototypeName, opt_id) {
/** @type {string|Blockly.Comment} */
this.comment = null;
/**
* @type {?number}
* @private
*/
this.outputShape_ = null;
/**
* @type {!goog.math.Coordinate}
* @private
@ -1118,6 +1124,9 @@ Blockly.Block.prototype.jsonInit = function(json) {
if (json['helpUrl'] !== undefined) {
this.setHelpUrl(json['helpUrl']);
}
if (json['outputShape'] !== undefined) {
this.setOutputShape(json['outputShape']);
}
};
/**
@ -1411,6 +1420,23 @@ Blockly.Block.prototype.setCommentText = function(text) {
}
};
/**
* Set this block's output shape.
* e.g., null, OUTPUT_SHAPE_HEXAGONAL, OUTPUT_SHAPE_ROUND, OUTPUT_SHAPE_SQUARE.
* @param {?number} outputShape Value representing output shape (see constants.js).
*/
Blockly.Block.prototype.setOutputShape = function(outputShape) {
this.outputShape_ = outputShape;
};
/**
* Get this block's output shape.
* @return {?number} Value representing output shape (see constants.js).
*/
Blockly.Block.prototype.getOutputShape = function() {
return this.outputShape_;
};
/**
* Set this block's warning text.
* @param {?string} text The text, or null to delete.

View file

@ -235,10 +235,10 @@ Blockly.BlockSvg.INNER_BOTTOM_LEFT_CORNER =
Blockly.BlockSvg.CORNER_RADIUS;
/**
* SVG path for an empty boolean input shape.
* SVG path for an empty hexagonal input shape.
* @const
*/
Blockly.BlockSvg.INPUT_SHAPE_BOOLEAN =
Blockly.BlockSvg.INPUT_SHAPE_HEXAGONAL =
'M ' + 4 * Blockly.BlockSvg.GRID_UNIT + ',0 ' +
' h ' + 4 * Blockly.BlockSvg.GRID_UNIT +
' l ' + 4 * Blockly.BlockSvg.GRID_UNIT + ',' + 4 * Blockly.BlockSvg.GRID_UNIT +
@ -252,13 +252,13 @@ Blockly.BlockSvg.INPUT_SHAPE_BOOLEAN =
* Width of empty boolean input shape.
* @const
*/
Blockly.BlockSvg.INPUT_SHAPE_BOOLEAN_WIDTH = 10 * Blockly.BlockSvg.GRID_UNIT;
Blockly.BlockSvg.INPUT_SHAPE_HEXAGONAL_WIDTH = 10 * Blockly.BlockSvg.GRID_UNIT;
/**
* SVG path for an empty string input shape.
* SVG path for an empty square input shape.
* @const
*/
Blockly.BlockSvg.INPUT_SHAPE_STRING =
Blockly.BlockSvg.INPUT_SHAPE_SQUARE =
Blockly.BlockSvg.TOP_LEFT_CORNER_START +
Blockly.BlockSvg.TOP_LEFT_CORNER +
' h ' + (12 * Blockly.BlockSvg.GRID_UNIT - 2 * Blockly.BlockSvg.CORNER_RADIUS) +
@ -270,17 +270,17 @@ Blockly.BlockSvg.INPUT_SHAPE_STRING =
' z';
/**
* Width of empty string input shape.
* Width of empty square input shape.
* @const
*/
Blockly.BlockSvg.INPUT_SHAPE_STRING_WIDTH = 9 * Blockly.BlockSvg.GRID_UNIT;
Blockly.BlockSvg.INPUT_SHAPE_SQUARE_WIDTH = 9 * Blockly.BlockSvg.GRID_UNIT;
/**
* SVG path for an empty string input shape.
* SVG path for an empty round input shape.
* @const
*/
Blockly.BlockSvg.INPUT_SHAPE_NUMBER =
Blockly.BlockSvg.INPUT_SHAPE_ROUND =
'M ' + (4 * Blockly.BlockSvg.GRID_UNIT) + ',0' +
' h ' + (4 * Blockly.BlockSvg.GRID_UNIT) +
' a ' + (4 * Blockly.BlockSvg.GRID_UNIT) + ' ' +
@ -291,10 +291,10 @@ Blockly.BlockSvg.INPUT_SHAPE_NUMBER =
' z';
/**
* Width of empty string input shape.
* Width of empty round input shape.
* @const
*/
Blockly.BlockSvg.INPUT_SHAPE_NUMBER_WIDTH = 10 * Blockly.BlockSvg.GRID_UNIT;
Blockly.BlockSvg.INPUT_SHAPE_ROUND_WIDTH = 10 * Blockly.BlockSvg.GRID_UNIT;
/**
* Height of empty input shape.
@ -768,8 +768,8 @@ Blockly.BlockSvg.prototype.renderDraw_ = function(iconWidth, inputRows) {
this.edgeShape_ = null;
if (this.outputConnection) {
// Width of the curve/pointy-curve
var shape = this.outputConnection.getOutputShape();
if (shape === Blockly.Connection.BOOLEAN || shape === Blockly.Connection.NUMBER) {
var shape = this.getOutputShape();
if (shape === Blockly.OUTPUT_SHAPE_HEXAGONAL || shape === Blockly.OUTPUT_SHAPE_ROUND) {
this.edgeShapeWidth_ = inputRows.bottomEdge / 2;
this.edgeShape_ = shape;
this.squareTopLeftCorner_ = true;
@ -970,13 +970,13 @@ Blockly.BlockSvg.prototype.renderDrawRight_ = function(steps,
cursorY += row.height;
}
if (this.edgeShape_) {
// Draw the right-side edge shape
if (this.edgeShape_ === Blockly.Connection.NUMBER) {
// Draw a rounded arc
// Draw the right-side edge shape.
if (this.edgeShape_ === Blockly.OUTPUT_SHAPE_ROUND) {
// Draw a rounded arc.
steps.push('a ' + this.edgeShapeWidth_ + ' ' + this.edgeShapeWidth_ +
' 0 0 1 0 ' + this.edgeShapeWidth_ * 2);
} else if (this.edgeShape_ === Blockly.Connection.BOOLEAN) {
// Draw an angle
} else if (this.edgeShape_ === Blockly.OUTPUT_SHAPE_HEXAGONAL) {
// Draw an half-hexagon.
steps.push('l ' + this.edgeShapeWidth_ + ' ' + this.edgeShapeWidth_ +
' l ' + -this.edgeShapeWidth_ + ' ' + this.edgeShapeWidth_);
}
@ -1008,18 +1008,18 @@ Blockly.BlockSvg.prototype.renderInputShape_ = function(input, x, y) {
// If the input connection is not connected, draw a hole shape.
var inputShapePath = null;
switch (input.connection.getOutputShape()) {
case Blockly.Connection.BOOLEAN:
inputShapePath = Blockly.BlockSvg.INPUT_SHAPE_BOOLEAN;
inputShapeWidth = Blockly.BlockSvg.INPUT_SHAPE_BOOLEAN_WIDTH;
case Blockly.OUTPUT_SHAPE_HEXAGONAL:
inputShapePath = Blockly.BlockSvg.INPUT_SHAPE_HEXAGONAL;
inputShapeWidth = Blockly.BlockSvg.INPUT_SHAPE_HEXAGONAL_WIDTH;
break;
case Blockly.Connection.NUMBER:
inputShapePath = Blockly.BlockSvg.INPUT_SHAPE_NUMBER;
inputShapeWidth = Blockly.BlockSvg.INPUT_SHAPE_NUMBER_WIDTH;
case Blockly.OUTPUT_SHAPE_ROUND:
inputShapePath = Blockly.BlockSvg.INPUT_SHAPE_ROUND;
inputShapeWidth = Blockly.BlockSvg.INPUT_SHAPE_ROUND_WIDTH;
break;
case Blockly.Connection.STRING:
case Blockly.OUTPUT_SHAPE_SQUARE:
default:
inputShapePath = Blockly.BlockSvg.INPUT_SHAPE_STRING;
inputShapeWidth = Blockly.BlockSvg.INPUT_SHAPE_STRING_WIDTH;
inputShapePath = Blockly.BlockSvg.INPUT_SHAPE_SQUARE;
inputShapeWidth = Blockly.BlockSvg.INPUT_SHAPE_SQUARE_WIDTH;
break;
}
if (this.RTL) {
@ -1099,12 +1099,12 @@ Blockly.BlockSvg.prototype.renderDrawLeft_ = function(steps, connectionsXY) {
// This connection will be tightened when the parent renders.
}
if (this.edgeShape_) {
// Draw the left-side edge shape
if (this.edgeShape_ === Blockly.Connection.NUMBER) {
// Draw a rounded arc
// Draw the left-side edge shape.
if (this.edgeShape_ === Blockly.OUTPUT_SHAPE_ROUND) {
// Draw a rounded arc.
steps.push('a ' + this.edgeShapeWidth_ + ' ' + this.edgeShapeWidth_ + ' 0 0 1 0 -' + this.edgeShapeWidth_*2);
} else if (this.edgeShape_ === Blockly.Connection.BOOLEAN) {
// Draw an angle
} else if (this.edgeShape_ === Blockly.OUTPUT_SHAPE_HEXAGONAL) {
// Draw a half-hexagon.
steps.push('l ' + -this.edgeShapeWidth_ + ' ' + -this.edgeShapeWidth_ +
' l ' + this.edgeShapeWidth_ + ' ' + -this.edgeShapeWidth_);
}

View file

@ -53,24 +53,6 @@ Blockly.Connection = function(source, type) {
}
};
/**
* Constant for identifying connections that accept a boolean.
* @const
*/
Blockly.Connection.BOOLEAN = 1;
/**
* Constant for identifying connections that accept a string.
* @const
*/
Blockly.Connection.STRING = 2;
/**
* Constant for identifying connections that accept a number OR null.
* @const
*/
Blockly.Connection.NUMBER = 3;
/**
* Constants for checking whether two connections are compatible.
*/
@ -700,18 +682,21 @@ Blockly.Connection.prototype.setCheck = function(check) {
/**
* 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.check_) return Blockly.Connection.NUMBER;
if (!this.check_) return Blockly.OUTPUT_SHAPE_SQUARE;
if (this.check_.indexOf('Boolean') !== -1) {
return Blockly.Connection.BOOLEAN;
return Blockly.OUTPUT_SHAPE_HEXAGONAL;
}
if (this.check_.indexOf('Number') !== -1) {
return Blockly.OUTPUT_SHAPE_ROUND;
}
if (this.check_.indexOf('String') !== -1) {
return Blockly.Connection.STRING;
return Blockly.OUTPUT_SHAPE_SQUARE;
}
return Blockly.Connection.NUMBER;
return Blockly.OUTPUT_SHAPE_SQUARE;
};
/**

View file

@ -205,3 +205,21 @@ Blockly.TOOLBOX_AT_LEFT = 2;
* @const
*/
Blockly.TOOLBOX_AT_RIGHT = 3;
/**
* ENUM for output shape: hexagonal (booleans/predicates).
* @const
*/
Blockly.OUTPUT_SHAPE_HEXAGONAL = 1;
/**
* ENUM for output shape: rounded (numbers).
* @const
*/
Blockly.OUTPUT_SHAPE_ROUND = 2;
/**
* ENUM for output shape: squared (any/all values; strings).
* @const
*/
Blockly.OUTPUT_SHAPE_SQUARE = 3;