Start hat support in zelos. (#3580)

* Start hat support in zelos.
This commit is contained in:
Sam El-Husseini
2020-01-13 13:22:49 -08:00
committed by GitHub
parent 1fedbfa591
commit 8013f80251
4 changed files with 42 additions and 3 deletions

View File

@@ -194,13 +194,13 @@ Blockly.blockRendering.ConstantProvider = function() {
/**
* Height of the top hat.
* @private
* @type {number}
*/
this.START_HAT_HEIGHT = 15;
/**
* Width of the top hat.
* @private
* @type {number}
*/
this.START_HAT_WIDTH = 100;

View File

@@ -189,6 +189,16 @@ Blockly.zelos.ConstantProvider = function() {
*/
this.JAGGED_TEETH_WIDTH = 0;
/**
* @override
*/
this.START_HAT_HEIGHT = 22;
/**
* @override
*/
this.START_HAT_WIDTH = 96;
/**
* @enum {number}
* @override
@@ -423,6 +433,27 @@ Blockly.zelos.ConstantProvider.prototype.dispose = function() {
}
};
/**
* @override
*/
Blockly.zelos.ConstantProvider.prototype.makeStartHat = function() {
var height = this.START_HAT_HEIGHT;
var width = this.START_HAT_WIDTH;
var mainPath =
Blockly.utils.svgPaths.curve('c',
[
Blockly.utils.svgPaths.point(25, -height),
Blockly.utils.svgPaths.point(71, -height),
Blockly.utils.svgPaths.point(width, 0)
]);
return {
height: height,
width: width,
path: mainPath
};
};
/**
* Create sizing and path information about a hexagonal shape.
* @return {!Object} An object containing sizing and path information about

View File

@@ -181,6 +181,11 @@ Blockly.zelos.RenderInfo.prototype.getInRowSpacing_ = function(prev, next) {
return next.notchOffset - this.constants_.CORNER_RADIUS;
}
}
// Spacing between a square corner and a hat.
if (prev && Blockly.blockRendering.Types.isLeftSquareCorner(prev) && next &&
Blockly.blockRendering.Types.isHat(next)) {
return this.constants_.NO_PADDING;
}
return this.constants_.MEDIUM_PADDING;
};

View File

@@ -62,7 +62,10 @@ Blockly.zelos.TopRow.prototype.endsWithElemSpacer = function() {
* @override
*/
Blockly.zelos.TopRow.prototype.hasLeftSquareCorner = function(block) {
return !!block.outputConnection;
var hasHat = (typeof block.hat !== 'undefined' ?
block.hat === 'cap' : this.constants_.ADD_START_HATS) &&
!block.outputConnection && !block.previousConnection;
return !!block.outputConnection || hasHat;
};
/**