Fix up more zelos spacing (#3445)

* Fix up more of zelos spacing
This commit is contained in:
Sam El-Husseini
2019-11-14 16:04:46 -08:00
committed by GitHub
parent c868a86bdd
commit d8476306f4
5 changed files with 68 additions and 14 deletions

View File

@@ -82,8 +82,29 @@ Blockly.blockRendering.ConstantProvider = function() {
this.STATEMENT_INPUT_PADDING_LEFT = 20;
this.BETWEEN_STATEMENT_PADDING_Y = 4;
// The minimum height of the bottom row following a statement input.
this.AFTER_STATEMENT_BOTTOM_ROW_MIN_HEIGHT = this.LARGE_PADDING;
/**
* The top row's minimum height.
* @type {number}
*/
this.TOP_ROW_MIN_HEIGHT = this.MEDIUM_PADDING;
/**
* The top row's minimum height if it precedes a statement.
* @type {number}
*/
this.TOP_ROW_PRECEDES_STATEMENT_MIN_HEIGHT = this.LARGE_PADDING;
/**
* The bottom row's minimum height.
* @type {number}
*/
this.BOTTOM_ROW_MIN_HEIGHT = this.MEDIUM_PADDING;
/**
* The bottom row's minimum height if it follows a statement input.
* @type {number}
*/
this.BOTTOM_ROW_AFTER_STATEMENT_MIN_HEIGHT = this.LARGE_PADDING;
// This is the max width of a bottom row that follows a statement input and
// has inputs inline.

View File

@@ -286,9 +286,10 @@ Blockly.blockRendering.RenderInfo.prototype.populateTopRow_ = function() {
// This is the minimum height for the row. If one of its elements has a
// greater height it will be overwritten in the compute pass.
if (precedesStatement && !this.block_.isCollapsed()) {
this.topRow.minHeight = this.constants_.LARGE_PADDING;
this.topRow.minHeight =
this.constants_.TOP_ROW_PRECEDES_STATEMENT_MIN_HEIGHT;
} else {
this.topRow.minHeight = this.constants_.MEDIUM_PADDING;
this.topRow.minHeight = this.constants_.TOP_ROW_MIN_HEIGHT;
}
var rightSquareCorner = this.topRow.hasRightSquareCorner(this.block_);
@@ -318,9 +319,9 @@ Blockly.blockRendering.RenderInfo.prototype.populateBottomRow_ = function() {
// greater height it will be overwritten in the compute pass.
if (followsStatement) {
this.bottomRow.minHeight =
this.constants_.AFTER_STATEMENT_BOTTOM_ROW_MIN_HEIGHT;
this.constants_.BOTTOM_ROW_AFTER_STATEMENT_MIN_HEIGHT;
} else {
this.bottomRow.minHeight = this.constants_.MEDIUM_PADDING;
this.bottomRow.minHeight = this.constants_.BOTTOM_ROW_MIN_HEIGHT;
}
var leftSquareCorner = this.bottomRow.hasLeftSquareCorner(this.block_);

View File

@@ -91,6 +91,21 @@ Blockly.zelos.ConstantProvider = function() {
*/
this.TAB_OFFSET_FROM_TOP = 0;
/**
* @override
*/
this.TOP_ROW_MIN_HEIGHT = this.GRID_UNIT;
/**
* @override
*/
this.BOTTOM_ROW_MIN_HEIGHT = this.GRID_UNIT;
/**
* @override
*/
this.BOTTOM_ROW_AFTER_STATEMENT_MIN_HEIGHT = 7 * this.GRID_UNIT;
/**
* @override
*/
@@ -107,11 +122,6 @@ Blockly.zelos.ConstantProvider = function() {
*/
this.STATEMENT_INPUT_PADDING_LEFT = 4 * this.GRID_UNIT;
/**
* @override
*/
this.AFTER_STATEMENT_BOTTOM_ROW_MIN_HEIGHT = 7 * this.GRID_UNIT;
/**
* @override
*/

View File

@@ -109,6 +109,27 @@ Blockly.zelos.RenderInfo.prototype.computeBounds_ = function() {
}
};
/**
* @override
*/
Blockly.zelos.RenderInfo.prototype.getInRowSpacing_ = function(prev, next) {
if (!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) {
return this.constants_.NO_PADDING;
}
}
// Spacing between a rounded corner and a previous or next connection.
if (prev && Blockly.blockRendering.Types.isLeftRoundedCorner(prev) && next) {
if (Blockly.blockRendering.Types.isPreviousConnection(next) ||
Blockly.blockRendering.Types.isNextConnection(next)) {
return next.notchOffset - this.constants_.CORNER_RADIUS;
}
}
return this.constants_.MEDIUM_PADDING;
};
/**
* @override
*/

View File

@@ -32,9 +32,6 @@
<script>
goog.require('Blockly.blockRendering.Debug');
goog.require('Blockly.zelos.Renderer');
Blockly.Field.FONTSIZE = 12;
Blockly.Field.FONTWEIGHT = 'bold';
Blockly.Field.FONTFAMILY = 'Helvetica Neue';
// Blockly.blockRendering.startDebugger();
var blocklyDiv = document.getElementById('blocklyDiv');
var workspace;
@@ -63,6 +60,10 @@
startScale: 2,
}
});
var constants = workspace.getRenderer().getConstants();
constants.FIELD_TEXT_FONTSIZE = 12;
constants.FIELD_TEXT_FONTWEIGHT = 'bold';
constants.FIELD_TEXT_FONTFAMILY = 'Helvetica Neue';
try {
Blockly.Xml.domToWorkspace(Blockly.Xml.textToDom(xml), workspace);