mirror of
https://github.com/google/blockly.git
synced 2026-01-09 01:50:11 +01:00
Works for positive x and y offsets; fails for negative
This commit is contained in:
@@ -180,7 +180,7 @@ Blockly.blockRendering.Drawer.prototype.drawValueInput_ = function(row) {
|
||||
if (this.highlighter_) {
|
||||
this.highlighter_.drawValueInput(row);
|
||||
}
|
||||
this.steps_.push('H', row.width);
|
||||
this.steps_.push('H', this.info_.startX + row.width);
|
||||
this.steps_.push(Blockly.blockRendering.constants.PUZZLE_TAB.pathDown);
|
||||
this.steps_.push('v', row.height - input.connectionHeight);
|
||||
this.positionExternalValueConnection_(row);
|
||||
@@ -201,7 +201,7 @@ Blockly.blockRendering.Drawer.prototype.drawStatementInput_ = function(row) {
|
||||
var x = row.statementEdge + Blockly.blockRendering.constants.NOTCH_OFFSET_LEFT +
|
||||
Blockly.blockRendering.constants.NOTCH.width;
|
||||
|
||||
this.steps_.push('H', x);
|
||||
this.steps_.push('H', this.info_.startX + x);
|
||||
|
||||
var innerTopLeftCorner =
|
||||
Blockly.blockRendering.constants.NOTCH.pathRight + ' h -' +
|
||||
@@ -227,7 +227,7 @@ Blockly.blockRendering.Drawer.prototype.drawRightSideRow_ = function(row) {
|
||||
if (this.highlighter_) {
|
||||
this.highlighter_.drawRightSideRow(row);
|
||||
}
|
||||
this.steps_.push('H', row.width);
|
||||
this.steps_.push('H', this.info_.startX + row.width);
|
||||
this.steps_.push('v', row.height);
|
||||
};
|
||||
|
||||
@@ -250,7 +250,7 @@ Blockly.blockRendering.Drawer.prototype.drawBottom_ = function() {
|
||||
if (elem.type === 'next connection') {
|
||||
this.steps_.push(Blockly.blockRendering.constants.NOTCH.pathRight);
|
||||
} else if (elem.type === 'square corner') {
|
||||
this.steps_.push('H 0');
|
||||
this.steps_.push(Blockly.utils.svgPaths.lineOnAxis('H', this.info_.startX));
|
||||
} else if (elem.type === 'round corner') {
|
||||
this.steps_.push(Blockly.blockRendering.constants.OUTSIDE_CORNERS.bottomLeft);
|
||||
} else if (elem.isSpacer()) {
|
||||
@@ -386,6 +386,7 @@ Blockly.blockRendering.Drawer.prototype.positionInlineInputConnection_ = functio
|
||||
var yPos = input.centerline - input.height / 2;
|
||||
// Move the connection.
|
||||
if (input.connection) {
|
||||
// xPos already contains info about startX
|
||||
var connX = input.xPos + input.connectionWidth +
|
||||
Blockly.blockRendering.constants.DARK_PATH_OFFSET;
|
||||
if (this.info_.RTL) {
|
||||
@@ -407,7 +408,7 @@ Blockly.blockRendering.Drawer.prototype.positionInlineInputConnection_ = functio
|
||||
Blockly.blockRendering.Drawer.prototype.positionStatementInputConnection_ = function(row) {
|
||||
var input = row.getLastInput();
|
||||
if (input.connection) {
|
||||
var connX = row.statementEdge +
|
||||
var connX = this.info_.startX + row.statementEdge +
|
||||
Blockly.blockRendering.constants.NOTCH_OFFSET_LEFT;
|
||||
if (this.info_.RTL) {
|
||||
connX *= -1;
|
||||
@@ -428,7 +429,7 @@ Blockly.blockRendering.Drawer.prototype.positionStatementInputConnection_ = func
|
||||
Blockly.blockRendering.Drawer.prototype.positionExternalValueConnection_ = function(row) {
|
||||
var input = row.getLastInput();
|
||||
if (input.connection) {
|
||||
var connX = row.width + Blockly.blockRendering.constants.DARK_PATH_OFFSET;
|
||||
var connX = this.info_.startX + row.width + Blockly.blockRendering.constants.DARK_PATH_OFFSET;
|
||||
if (this.info_.RTL) {
|
||||
connX *= -1;
|
||||
}
|
||||
@@ -442,7 +443,7 @@ Blockly.blockRendering.Drawer.prototype.positionExternalValueConnection_ = funct
|
||||
*/
|
||||
Blockly.blockRendering.Drawer.prototype.positionPreviousConnection_ = function() {
|
||||
if (this.info_.topRow.hasPreviousConnection) {
|
||||
var x = Blockly.blockRendering.constants.NOTCH_OFFSET_LEFT;
|
||||
var x = this.info_.startX + Blockly.blockRendering.constants.NOTCH_OFFSET_LEFT;
|
||||
var connX = (this.info_.RTL ? -x : x);
|
||||
this.info_.topRow.connection.setOffsetInBlock(connX, this.info_.startY);
|
||||
}
|
||||
@@ -457,7 +458,7 @@ Blockly.blockRendering.Drawer.prototype.positionNextConnection_ = function() {
|
||||
|
||||
if (bottomRow.hasNextConnection) {
|
||||
var connInfo = bottomRow.getNextConnection();
|
||||
var x = connInfo.xPos;
|
||||
var x = connInfo.xPos; // Alreaady contains info about startX
|
||||
var connX = (this.info_.RTL ? -x : x) + 0.5;
|
||||
bottomRow.connection.setOffsetInBlock(
|
||||
connX, this.info_.startY + this.info_.height +
|
||||
@@ -472,7 +473,9 @@ Blockly.blockRendering.Drawer.prototype.positionNextConnection_ = function() {
|
||||
*/
|
||||
Blockly.blockRendering.Drawer.prototype.positionOutputConnection_ = function() {
|
||||
if (this.info_.outputConnection) {
|
||||
this.block_.outputConnection.setOffsetInBlock(this.info_.startX,
|
||||
var x = this.info_.startX;
|
||||
var connX = this.info_.RTL ? -x : x;
|
||||
this.block_.outputConnection.setOffsetInBlock(connX,
|
||||
this.info_.startY + this.info_.outputConnection.connectionOffsetY);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -109,17 +109,19 @@ Blockly.blockRendering.Highlighter.prototype.drawValueInput = function(row) {
|
||||
var input = row.getLastInput();
|
||||
var steps = '';
|
||||
if (this.RTL_) {
|
||||
var aboveTabHeight = -this.highlightOffset_;
|
||||
var aboveTabHeight = 0;//-this.highlightOffset_;
|
||||
var belowTabHeight =
|
||||
row.height - input.connectionHeight + this.highlightOffset_;
|
||||
row.height - input.connectionHeight;
|
||||
|
||||
steps =
|
||||
Blockly.utils.svgPaths.moveTo(
|
||||
this.info_.startX + row.width - this.highlightOffset_, row.yPos) +
|
||||
Blockly.utils.svgPaths.lineOnAxis('v', aboveTabHeight) +
|
||||
this.puzzleTabPaths_.pathDown(this.RTL_) +
|
||||
Blockly.utils.svgPaths.lineOnAxis('v', belowTabHeight);
|
||||
} else {
|
||||
steps =
|
||||
Blockly.utils.svgPaths.moveTo(row.width, row.yPos) +
|
||||
Blockly.utils.svgPaths.moveTo(this.info_.startX + row.width, row.yPos) +
|
||||
this.puzzleTabPaths_.pathDown(this.RTL_);
|
||||
}
|
||||
|
||||
@@ -131,13 +133,15 @@ Blockly.blockRendering.Highlighter.prototype.drawStatementInput = function(row)
|
||||
if (this.RTL_) {
|
||||
var innerHeight = row.height - (2 * this.insideCornerPaths_.height);
|
||||
steps =
|
||||
Blockly.utils.svgPaths.moveTo(row.statementEdge, row.yPos) +
|
||||
Blockly.utils.svgPaths.moveTo(
|
||||
this.info_.startX + row.statementEdge, row.yPos) +
|
||||
this.insideCornerPaths_.pathTop(this.RTL_) +
|
||||
Blockly.utils.svgPaths.lineOnAxis('v', innerHeight) +
|
||||
this.insideCornerPaths_.pathBottom(this.RTL_);
|
||||
} else {
|
||||
steps =
|
||||
Blockly.utils.svgPaths.moveTo(row.statementEdge, row.yPos + row.height) +
|
||||
Blockly.utils.svgPaths.moveTo(
|
||||
this.info_.startX + row.statementEdge, row.yPos + row.height) +
|
||||
this.insideCornerPaths_.pathBottom(this.RTL_);
|
||||
}
|
||||
this.steps_.push(steps);
|
||||
@@ -145,30 +149,29 @@ Blockly.blockRendering.Highlighter.prototype.drawStatementInput = function(row)
|
||||
|
||||
Blockly.blockRendering.Highlighter.prototype.drawRightSideRow = function(row) {
|
||||
if (row.followsStatement) {
|
||||
this.steps_.push('H', row.width);
|
||||
this.steps_.push('H', this.info_.startX + row.width - this.highlightOffset_);
|
||||
}
|
||||
if (this.RTL_) {
|
||||
this.steps_.push('H', row.width - this.highlightOffset_);
|
||||
this.steps_.push('v', row.height);
|
||||
this.steps_.push('H', this.info_.startX + row.width - this.highlightOffset_);
|
||||
this.steps_.push('v', row.height - this.highlightOffset_);
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.blockRendering.Highlighter.prototype.drawBottomRow = function(row) {
|
||||
var height = row.yPos + row.height;
|
||||
//var height = this.info_.height;
|
||||
|
||||
// Highlight the vertical edge of the bottom row on the input side.
|
||||
// Highlighting is always from the top left, both in LTR and RTL.
|
||||
if (this.RTL_) {
|
||||
this.steps_.push('V', height);
|
||||
this.steps_.push('V', height - this.highlightOffset_);
|
||||
} else {
|
||||
var cornerElem = this.info_.bottomRow.elements[0];
|
||||
if (cornerElem.type === 'square corner') {
|
||||
this.steps_.push(
|
||||
Blockly.utils.svgPaths.moveTo(
|
||||
this.highlightOffset_, height - this.highlightOffset_));
|
||||
this.info_.startX + this.highlightOffset_, height - this.highlightOffset_));
|
||||
} else if (cornerElem.type === 'round corner') {
|
||||
this.steps_.push(Blockly.utils.svgPaths.moveTo(0, height));
|
||||
this.steps_.push(Blockly.utils.svgPaths.moveTo(this.info_.startX, height));
|
||||
this.steps_.push(this.outsideCornerPaths_.bottomLeft());
|
||||
}
|
||||
}
|
||||
@@ -181,6 +184,10 @@ Blockly.blockRendering.Highlighter.prototype.drawLeft = function() {
|
||||
outputConnection.connectionOffsetY + outputConnection.height;
|
||||
// Draw a line up to the bottom of the tab.
|
||||
if (!this.RTL_) {
|
||||
this.steps_.push(
|
||||
Blockly.utils.svgPaths.moveTo(
|
||||
this.info_.startX + this.highlightOffset_,
|
||||
this.info_.startY + this.info_.height - this.highlightOffset_));
|
||||
this.steps_.push('V', tabBottom);
|
||||
} else {
|
||||
this.steps_.push(Blockly.utils.svgPaths.moveTo(this.info_.startX, tabBottom));
|
||||
|
||||
@@ -119,7 +119,7 @@ Blockly.blockRendering.highlightConstants.OUTSIDE_CORNER = (function() {
|
||||
Blockly.utils.svgPaths.point(radius, -radius + offset));
|
||||
|
||||
var bottomLeftStartX = distance45inside;
|
||||
var bottomLeftStartY = - distance45inside;
|
||||
var bottomLeftStartY = -distance45inside;
|
||||
var bottomLeftPath = Blockly.utils.svgPaths.moveBy(
|
||||
bottomLeftStartX, bottomLeftStartY) +
|
||||
Blockly.utils.svgPaths.arc('a', '0 0,1', radius - offset,
|
||||
|
||||
Reference in New Issue
Block a user