Adds hat style

This commit is contained in:
alschmiedt
2019-01-08 15:13:00 -08:00
parent 4fad29bf15
commit bac9a16da0
2 changed files with 8 additions and 1 deletions

View File

@@ -152,6 +152,12 @@ Blockly.Block = function(workspace, prototypeName, opt_id) {
*/
this.isInsertionMarker_ = false;
/**
* True if the block has a hat.
* @type {boolean}
*/
this.hat = false;
// Copy the type-specific functions and data from the prototype.
if (prototypeName) {
/** @type {string} */
@@ -941,6 +947,7 @@ Blockly.Block.prototype.setStyle = function(blockStyleName) {
this.style_ = blockStyle;
this.secondaryColour_ = blockStyle.secondaryColour;
this.tertiaryColour_ = blockStyle.tertiaryColour;
this.hat = blockStyle.hat;
// Set colour will trigger an updateColour() on a block_svg
this.setColour(blockStyle.primaryColour);
}

View File

@@ -566,7 +566,7 @@ Blockly.BlockSvg.prototype.renderDraw_ = function(iconWidth, inputRows) {
if (prevBlock && prevBlock.getNextBlock() == this) {
this.squareTopLeftCorner_ = true;
}
} else if (Blockly.BlockSvg.START_HAT) {
} else if (Blockly.BlockSvg.START_HAT || this.hat) {
// No output or previous connection.
this.squareTopLeftCorner_ = true;
this.startHat_ = true;