diff --git a/core/block_render_svg.js b/core/block_render_svg.js index e560afcaf..e21083b7f 100644 --- a/core/block_render_svg.js +++ b/core/block_render_svg.js @@ -102,6 +102,21 @@ Blockly.BlockSvg.TAB_WIDTH = 8; * @const */ Blockly.BlockSvg.NOTCH_WIDTH = 30; + +/** + * Offset of the notch from the left side of the block. + * @type {number} + * @const + */ +Blockly.BlockSvg.NOTCH_OFFSET_X = 15; + +/** + * Offset of the puzzle tab from the top of the block. + * @type {number} + * @const + */ +Blockly.BlockSvg.TAB_OFFSET_Y = 5; + /** * Rounded corner radius. * @const @@ -651,8 +666,8 @@ Blockly.BlockSvg.prototype.renderDrawTop_ = function(pathObject, rightEdge) { steps.push(Blockly.BlockSvg.NOTCH_PATH_LEFT); highlightSteps.push(Blockly.BlockSvg.NOTCH_PATH_LEFT_HIGHLIGHT); - var notchOffsetStart = 15; - var connectionX = (this.RTL ? -notchOffsetStart : notchOffsetStart); + var connectionX = (this.RTL ? + -Blockly.BlockSvg.NOTCH_OFFSET_X : Blockly.BlockSvg.NOTCH_OFFSET_X); this.previousConnection.setOffsetInBlock(connectionX, 0); } steps.push('H', rightEdge); @@ -734,8 +749,8 @@ Blockly.BlockSvg.prototype.renderDrawBottom_ = function(pathObject, cursorY) { steps.push('H', (Blockly.BlockSvg.NOTCH_WIDTH + (this.RTL ? 0.5 : - 0.5)) + ' ' + Blockly.BlockSvg.NOTCH_PATH_RIGHT); - var notchOffsetStart = 15; - var connectionX = (this.RTL ? -notchOffsetStart : notchOffsetStart); + var connectionX = (this.RTL ? + -Blockly.BlockSvg.NOTCH_OFFSET_X : Blockly.BlockSvg.NOTCH_OFFSET_X); this.nextConnection.setOffsetInBlock(connectionX, cursorY + 1); this.height += 4; // Height of tab. } @@ -773,7 +788,7 @@ Blockly.BlockSvg.prototype.renderDrawLeft_ = function(pathObject) { var highlightSteps = pathObject.highlightSteps; if (this.outputConnection) { // Create output connection. - this.outputConnection.setOffsetInBlock(0, 5); + this.outputConnection.setOffsetInBlock(0, Blockly.BlockSvg.TAB_OFFSET_Y); steps.push('V', Blockly.BlockSvg.TAB_HEIGHT); steps.push('c 0,-10 -' + Blockly.BlockSvg.TAB_WIDTH + ',8 -' + Blockly.BlockSvg.TAB_WIDTH + ',-7.5 s ' + Blockly.BlockSvg.TAB_WIDTH + @@ -910,8 +925,9 @@ Blockly.BlockSvg.prototype.renderInlineRow_ = function(pathObject, row, cursor, Blockly.BlockSvg.TAB_WIDTH - Blockly.BlockSvg.SEP_SPACE_X - input.renderWidth - 1; } - connectionPos.y = cursor.y + Blockly.BlockSvg.INLINE_PADDING_Y + 1; - input.connection.setOffsetInBlock(connectionPos.x, connectionPos.y + 5); + connectionPos.y = cursor.y + Blockly.BlockSvg.INLINE_PADDING_Y + + Blockly.BlockSvg.TAB_OFFSET_Y + 1; + input.connection.setOffsetInBlock(connectionPos.x, connectionPos.y); } } @@ -973,7 +989,8 @@ Blockly.BlockSvg.prototype.renderExternalValueInput_ = function(pathObject, row, } // Create external input connection. connectionPos.x = this.RTL ? -rightEdge - 1 : rightEdge + 1; - input.connection.setOffsetInBlock(connectionPos.x, cursor.y + 5); + input.connection.setOffsetInBlock( + connectionPos.x, cursor.y + Blockly.BlockSvg.TAB_OFFSET_Y); if (input.connection.isConnected()) { this.width = Math.max(this.width, rightEdge + input.connection.targetBlock().getHeightWidth().width - @@ -1089,7 +1106,7 @@ Blockly.BlockSvg.prototype.renderStatementInput_ = function(pathObject, row, highlightSteps.push('H', inputRows.rightEdge - 0.5); } // Create statement connection. - var x = inputRows.statementEdge + 15; // Notch offset from left. + var x = inputRows.statementEdge + Blockly.BlockSvg.NOTCH_OFFSET_X; connectionPos.x = this.RTL ? -x : x + 1; input.connection.setOffsetInBlock(connectionPos.x, cursor.y + 1); diff --git a/core/block_svg.js b/core/block_svg.js index f2674f507..99dcc9cf1 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -1547,7 +1547,7 @@ Blockly.BlockSvg.prototype.render = function(opt_bubble) { } else { this.renderInternal(); } - // No matter how we rendered, connections locations should now be correct. + // No matter how we rendered, connection locations should now be correct. this.updateConnectionLocations_(); if (opt_bubble !== false) { // Render all blocks above this one (propagate a reflow).