Include tab width in block width

This commit is contained in:
Rachel Fenichel
2019-08-09 16:42:45 -07:00
parent ace1971795
commit 797b8dae46
6 changed files with 10 additions and 8 deletions

View File

@@ -723,12 +723,9 @@ Blockly.Flyout.prototype.moveRectToBlock_ = function(rect, block) {
rect.setAttribute('width', blockHW.width);
rect.setAttribute('height', blockHW.height);
// Blocks with output tabs are shifted a bit.
var tab = block.outputConnection ? Blockly.BlockSvg.TAB_WIDTH : 0;
var blockXY = block.getRelativeToSurfaceXY();
rect.setAttribute('y', blockXY.y);
rect.setAttribute('x',
this.RTL ? blockXY.x - blockHW.width + tab : blockXY.x - tab);
rect.setAttribute('x', this.RTL ? blockXY.x - blockHW.width : blockXY.x);
};
/**

View File

@@ -133,7 +133,7 @@ Blockly.blockRendering.Drawer.prototype.drawTop_ = function() {
}
this.positionPreviousConnection_();
this.steps_.push(
Blockly.utils.svgPaths.moveBy(this.info_.startX, 0));
Blockly.utils.svgPaths.moveBy(this.info_.startX, this.info_.startY));
for (var i = 0, elem; elem = elements[i]; i++) {
if (elem.type === 'round corner') {
this.steps_.push(Blockly.blockRendering.constants.OUTSIDE_CORNERS.topLeft);

View File

@@ -73,7 +73,7 @@ Blockly.blockRendering.Highlighter = function(info, pathObject) {
Blockly.blockRendering.Highlighter.prototype.drawTopCorner = function(row) {
this.steps_.push(
Blockly.utils.svgPaths.moveBy(this.info_.startX, 0));
Blockly.utils.svgPaths.moveBy(this.info_.startX, this.info_.startY));
for (var i = 0, elem; elem = row.elements[i]; i++) {
if (elem.type === 'square corner') {
this.steps_.push(Blockly.blockRendering.highlightConstants.START_POINT);

View File

@@ -697,6 +697,12 @@ Blockly.blockRendering.RenderInfo.prototype.finalize_ = function() {
// Performance note: this could be combined with the draw pass, if the time
// that this takes is excessive. But it shouldn't be, because it only
// accesses and sets properties that already exist on the objects.
// TODO: Decide if there's a better place for this.
if (this.outputConnection) {
this.startX = this.outputConnection.startX;
this.width += this.outputConnection.width;
}
var yCursor = 0;
for (var r = 0; r < this.rows.length; r++) {
var row = this.rows[r];

View File

@@ -211,7 +211,6 @@ Blockly.blockRendering.highlightConstants.JAGGED_TEETH = (function() {
Blockly.blockRendering.highlightConstants.START_HAT = (function() {
var hatHeight = Blockly.blockRendering.constants.START_HAT.height;
var pathRtl =
Blockly.utils.svgPaths.moveBy(0, hatHeight) +
Blockly.utils.svgPaths.moveBy(25, -8.7) +
Blockly.utils.svgPaths.curve('c',
[
@@ -221,7 +220,6 @@ Blockly.blockRendering.highlightConstants.START_HAT = (function() {
]);
var pathLtr =
Blockly.utils.svgPaths.moveBy(0, hatHeight) +
Blockly.utils.svgPaths.curve('c',
[
Blockly.utils.svgPaths.point(17.8, -9.2),

View File

@@ -337,6 +337,7 @@ Blockly.blockRendering.OutputConnection = function() {
this.height = this.connectionShape.height;
this.width = this.connectionShape.width;
this.connectionOffsetY = Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP;
this.startX = this.width;
};
goog.inherits(Blockly.blockRendering.OutputConnection, Blockly.blockRendering.Measurable);