mirror of
https://github.com/google/blockly.git
synced 2026-01-10 10:27:08 +01:00
[zelos] Fix centered textinputs (#3703)
* Fix bug in centering text inputs. Shouldn't add right corner element for output only blocks.
This commit is contained in:
@@ -170,6 +170,13 @@ Blockly.Block = function(workspace, prototypeName, opt_id) {
|
||||
*/
|
||||
this.hat = undefined;
|
||||
|
||||
/**
|
||||
* A count of statement inputs on the block.
|
||||
* @type {number}
|
||||
* @package
|
||||
*/
|
||||
this.statementInputCount = 0;
|
||||
|
||||
// Copy the type-specific functions and data from the prototype.
|
||||
if (prototypeName) {
|
||||
/** @type {string} */
|
||||
@@ -1635,6 +1642,9 @@ Blockly.Block.prototype.appendInput_ = function(type, name) {
|
||||
if (type == Blockly.INPUT_VALUE || type == Blockly.NEXT_STATEMENT) {
|
||||
connection = this.makeConnection_(type);
|
||||
}
|
||||
if (type == Blockly.NEXT_STATEMENT) {
|
||||
this.statementInputCount++;
|
||||
}
|
||||
var input = new Blockly.Input(type, name, this, connection);
|
||||
// Append input to list.
|
||||
this.inputList.push(input);
|
||||
@@ -1712,6 +1722,9 @@ Blockly.Block.prototype.moveNumberedInputBefore = function(
|
||||
Blockly.Block.prototype.removeInput = function(name, opt_quiet) {
|
||||
for (var i = 0, input; (input = this.inputList[i]); i++) {
|
||||
if (input.name == name) {
|
||||
if (input.type == Blockly.NEXT_STATEMENT) {
|
||||
this.statementInputCount--;
|
||||
}
|
||||
input.dispose();
|
||||
this.inputList.splice(i, 1);
|
||||
return;
|
||||
|
||||
@@ -82,7 +82,7 @@ Blockly.zelos.RenderInfo = function(renderer, block) {
|
||||
* Whether or not the block has a statement input in one of its rows.
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.hasStatementInput = false;
|
||||
this.hasStatementInput = block.statementInputCount > 0;
|
||||
|
||||
/**
|
||||
* An object with rendering information about the right connection shape.
|
||||
@@ -264,32 +264,7 @@ Blockly.zelos.RenderInfo.prototype.addInput_ = function(input, activeRow) {
|
||||
input.align == Blockly.ALIGN_RIGHT) {
|
||||
activeRow.rightAlignedDummyInput = input;
|
||||
}
|
||||
// Non-dummy inputs have visual representations onscreen.
|
||||
if (this.isInline && input.type == Blockly.INPUT_VALUE) {
|
||||
activeRow.elements.push(
|
||||
new Blockly.blockRendering.InlineInput(this.constants_, input));
|
||||
activeRow.hasInlineInput = true;
|
||||
} else if (input.type == Blockly.NEXT_STATEMENT) {
|
||||
activeRow.elements.push(
|
||||
new Blockly.zelos.StatementInput(this.constants_, input));
|
||||
activeRow.hasStatement = true;
|
||||
this.hasStatementInput = true;
|
||||
} else if (input.type == Blockly.INPUT_VALUE) {
|
||||
activeRow.elements.push(
|
||||
new Blockly.blockRendering.ExternalValueInput(this.constants_, input));
|
||||
activeRow.hasExternalInput = true;
|
||||
} else if (input.type == Blockly.DUMMY_INPUT) {
|
||||
// Dummy inputs have no visual representation, but the information is still
|
||||
// important.
|
||||
activeRow.minHeight = Math.max(activeRow.minHeight,
|
||||
input.getSourceBlock() && input.getSourceBlock().isShadow() ?
|
||||
this.constants_.DUMMY_INPUT_SHADOW_MIN_HEIGHT :
|
||||
this.constants_.DUMMY_INPUT_MIN_HEIGHT);
|
||||
activeRow.hasDummyInput = true;
|
||||
}
|
||||
if (activeRow.align == null) {
|
||||
activeRow.align = input.align;
|
||||
}
|
||||
Blockly.zelos.RenderInfo.superClass_.addInput_.call(this, input, activeRow);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -61,8 +61,8 @@ Blockly.zelos.TopRow.prototype.hasLeftSquareCorner = function(block) {
|
||||
* Render a round corner unless the block has an output connection.
|
||||
* @override
|
||||
*/
|
||||
Blockly.zelos.TopRow.prototype.hasRightSquareCorner = function(_block) {
|
||||
return false;
|
||||
Blockly.zelos.TopRow.prototype.hasRightSquareCorner = function(block) {
|
||||
return !!block.outputConnection && !block.statementInputCount;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -101,6 +101,6 @@ Blockly.zelos.BottomRow.prototype.hasLeftSquareCorner = function(block) {
|
||||
* Render a round corner unless the block has an output connection.
|
||||
* @override
|
||||
*/
|
||||
Blockly.zelos.BottomRow.prototype.hasRightSquareCorner = function(_block) {
|
||||
return false;
|
||||
Blockly.zelos.BottomRow.prototype.hasRightSquareCorner = function(block) {
|
||||
return !!block.outputConnection && !block.statementInputCount;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user