mirror of
https://github.com/google/blockly.git
synced 2026-01-08 17:40:09 +01:00
@@ -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.
|
||||
|
||||
@@ -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_);
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user