mirror of
https://github.com/google/blockly.git
synced 2026-01-18 22:37:09 +01:00
Move of render contant START_HAT into ConstantProvider. (#3563)
* Move of render contant START_HAT into ConstantProvider.
This commit is contained in:
@@ -156,16 +156,6 @@ Blockly.BlockSvg.INLINE = -1;
|
||||
*/
|
||||
Blockly.BlockSvg.COLLAPSED_WARNING_ID = 'TEMP_COLLAPSED_WARNING_';
|
||||
|
||||
// Leftover UI constants from block_render_svg.js.
|
||||
|
||||
/**
|
||||
* Do blocks with no previous or output connections have a 'hat' on top?
|
||||
* @const
|
||||
* @package
|
||||
*/
|
||||
// TODO (#3142): Remove.
|
||||
Blockly.BlockSvg.START_HAT = false;
|
||||
|
||||
/**
|
||||
* An optional method called when a mutator dialog is first opened.
|
||||
* This function must create and initialize a top-level block for the mutator
|
||||
|
||||
@@ -192,6 +192,13 @@ Blockly.blockRendering.ConstantProvider = function() {
|
||||
*/
|
||||
this.MAX_BOTTOM_WIDTH = 66.5;
|
||||
|
||||
/**
|
||||
* Whether to add a 'hat' on top of all blocks with no previous or output
|
||||
* connections. Can be overridden by 'hat' property on Theme.BlockStyle.
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.ADD_START_HATS = false;
|
||||
|
||||
/**
|
||||
* Height of the top hat.
|
||||
* @private
|
||||
|
||||
@@ -262,8 +262,8 @@ Blockly.blockRendering.RenderInfo.prototype.createRows_ = function() {
|
||||
*/
|
||||
Blockly.blockRendering.RenderInfo.prototype.populateTopRow_ = function() {
|
||||
var hasPrevious = !!this.block_.previousConnection;
|
||||
var hasHat = (this.block_.hat ?
|
||||
this.block_.hat === 'cap' : Blockly.BlockSvg.START_HAT) &&
|
||||
var hasHat = (typeof this.block_.hat !== 'undefined' ?
|
||||
this.block_.hat === 'cap' : this.constants_.ADD_START_HATS) &&
|
||||
!this.outputConnection && !hasPrevious;
|
||||
var leftSquareCorner = this.topRow.hasLeftSquareCorner(this.block_);
|
||||
|
||||
|
||||
@@ -290,8 +290,9 @@ Blockly.utils.object.inherits(Blockly.blockRendering.TopRow,
|
||||
* @return {boolean} Whether or not the top row has a left square corner.
|
||||
*/
|
||||
Blockly.blockRendering.TopRow.prototype.hasLeftSquareCorner = function(block) {
|
||||
var hasHat = (block.hat ? block.hat === 'cap' : Blockly.BlockSvg.START_HAT) &&
|
||||
!block.outputConnection && !block.previousConnection;
|
||||
var hasHat = (typeof block.hat !== 'undefined' ?
|
||||
block.hat === 'cap' : this.constants_.ADD_START_HATS) &&
|
||||
!block.outputConnection && !block.previousConnection;
|
||||
var prevBlock = block.getPreviousBlock();
|
||||
|
||||
return !!block.outputConnection ||
|
||||
|
||||
Reference in New Issue
Block a user