[Zelos] Value to stack block support (#3741)

* Zelos value to stack block support
This commit is contained in:
Sam El-Husseini
2020-03-12 11:47:47 -07:00
committed by GitHub
parent d7ca6996a4
commit 9b071ff7f7
3 changed files with 30 additions and 10 deletions

View File

@@ -70,7 +70,8 @@ Blockly.zelos.Drawer.prototype.draw = function() {
Blockly.zelos.Drawer.prototype.drawOutline_ = function() {
if (this.info_.outputConnection &&
this.info_.outputConnection.isDynamicShape &&
!this.info_.hasStatementInput) {
!this.info_.hasStatementInput &&
!this.info_.bottomRow.hasNextConnection) {
this.drawFlatTop_();
this.drawRightDynamicConnection_();
this.drawFlatBottom_();

View File

@@ -160,7 +160,7 @@ Blockly.zelos.RenderInfo.prototype.getInRowSpacing_ = function(prev, next) {
// No need for padding at the beginning or end of the row if the
// output shape is dynamic.
if (this.outputConnection && this.outputConnection.isDynamicShape &&
!this.hasStatementInput) {
!this.hasStatementInput && !this.bottomRow.hasNextConnection) {
return this.constants_.NO_PADDING;
}
}
@@ -249,6 +249,13 @@ Blockly.zelos.RenderInfo.prototype.getElemCenterline_ = function(row, elem) {
!Blockly.blockRendering.Types.isStatementInput(elem)) {
return row.yPos + this.constants_.EMPTY_STATEMENT_INPUT_HEIGHT / 2;
}
if (Blockly.blockRendering.Types.isInlineInput(elem)) {
var connectedBlock = elem.connectedBlock;
if (connectedBlock && connectedBlock.outputConnection &&
connectedBlock.nextConnection) {
return row.yPos + connectedBlock.height / 2;
}
}
return Blockly.zelos.RenderInfo.superClass_.getElemCenterline_.call(this,
row, elem);
};
@@ -365,8 +372,10 @@ Blockly.zelos.RenderInfo.prototype.finalizeOutputConnection_ = function() {
this.height = yCursor;
// Adjust the height of the output connection.
var connectionHeight = this.outputConnection.shape.height(yCursor);
var connectionWidth = this.outputConnection.shape.width(yCursor);
var blockHeight = this.bottomRow.hasNextConnection ?
this.height - this.bottomRow.descenderHeight : this.height;
var connectionHeight = this.outputConnection.shape.height(blockHeight);
var connectionWidth = this.outputConnection.shape.width(blockHeight);
this.outputConnection.height = connectionHeight;
this.outputConnection.width = connectionWidth;
@@ -377,8 +386,9 @@ Blockly.zelos.RenderInfo.prototype.finalizeOutputConnection_ = function() {
this.outputConnection.shape.connectionOffsetX(connectionWidth);
// Add the right connection measurable.
// Don't add it if we have a value-to-statament or a value-to-stack block.
var rightConnectionWidth = 0;
if (!this.hasStatementInput) {
if (!this.hasStatementInput && !this.bottomRow.hasNextConnection) {
rightConnectionWidth = connectionWidth;
this.rightSide.height = connectionHeight;
this.rightSide.width = rightConnectionWidth;
@@ -398,7 +408,8 @@ Blockly.zelos.RenderInfo.prototype.finalizeOutputConnection_ = function() {
* @protected
*/
Blockly.zelos.RenderInfo.prototype.finalizeHorizontalAlignment_ = function() {
if (!this.outputConnection || this.hasStatementInput) {
if (!this.outputConnection || this.hasStatementInput ||
this.bottomRow.hasNextConnection) {
return;
}
var totalNegativeSpacing = 0;
@@ -472,9 +483,15 @@ Blockly.zelos.RenderInfo.prototype.getNegativeSpacing_ = function(elem) {
}
}
if (Blockly.blockRendering.Types.isInlineInput(elem)) {
var innerShape = elem.connectedBlock ?
elem.connectedBlock.pathObject.outputShapeType :
var connectedBlock = elem.connectedBlock;
var innerShape = connectedBlock ?
connectedBlock.pathObject.outputShapeType :
elem.shape.type;
// Special case for value to stack / value to statement blocks.
if (connectedBlock && connectedBlock.outputConnection &&
(connectedBlock.statementInputCount || connectedBlock.nextConnection)) {
return 0;
}
// Special case for hexagonal output.
if (outerShape == constants.SHAPES.HEXAGONAL &&
outerShape != innerShape) {

View File

@@ -62,7 +62,8 @@ Blockly.zelos.TopRow.prototype.hasLeftSquareCorner = function(block) {
* @override
*/
Blockly.zelos.TopRow.prototype.hasRightSquareCorner = function(block) {
return !!block.outputConnection && !block.statementInputCount;
return !!block.outputConnection && !block.statementInputCount &&
!block.nextConnection;
};
/**
@@ -102,5 +103,6 @@ Blockly.zelos.BottomRow.prototype.hasLeftSquareCorner = function(block) {
* @override
*/
Blockly.zelos.BottomRow.prototype.hasRightSquareCorner = function(block) {
return !!block.outputConnection && !block.statementInputCount;
return !!block.outputConnection && !block.statementInputCount &&
!block.nextConnection;
};