From 17c1537a4f5bec4544549a6748874312c7f98d0f Mon Sep 17 00:00:00 2001 From: kozbial Date: Wed, 14 Aug 2019 16:15:14 -0700 Subject: [PATCH 1/3] Updating draw for statement input and value input to use element xPos and more approriate constants. --- .../block_render_draw.js | 15 ++++--- .../block_render_draw_highlight.js | 39 ++++++++----------- .../block_rendering_constants.js | 1 + 3 files changed, 27 insertions(+), 28 deletions(-) diff --git a/core/renderers/block_rendering_rewrite/block_render_draw.js b/core/renderers/block_rendering_rewrite/block_render_draw.js index f229717d5..7e784124b 100644 --- a/core/renderers/block_rendering_rewrite/block_render_draw.js +++ b/core/renderers/block_rendering_rewrite/block_render_draw.js @@ -191,7 +191,7 @@ Blockly.blockRendering.Drawer.prototype.drawValueInput_ = function(row) { this.positionExternalValueConnection_(row); this.outlinePath_ += - Blockly.utils.svgPaths.lineOnAxis('H', row.xPos + row.width) + + Blockly.utils.svgPaths.lineOnAxis('H', input.xPos + input.width) + input.connectionShape.pathDown + Blockly.utils.svgPaths.lineOnAxis('v', row.height - input.connectionHeight); }; @@ -212,15 +212,18 @@ Blockly.blockRendering.Drawer.prototype.drawStatementInput_ = function(row) { var x = input.xPos + input.width; var innerTopLeftCorner = - Blockly.blockRendering.constants.NOTCH.pathRight + ' h -' + - (Blockly.blockRendering.constants.NOTCH_WIDTH - - Blockly.blockRendering.constants.CORNER_RADIUS) + + input.notchShape.pathRight + + Blockly.utils.svgPaths.lineOnAxis('h', + -(Blockly.blockRendering.constants.NOTCH_OFFSET_LEFT - + Blockly.blockRendering.constants.INSIDE_CORNERS.width)) + Blockly.blockRendering.constants.INSIDE_CORNERS.pathTop; + var innerHeight = + row.height -(2 * Blockly.blockRendering.constants.INSIDE_CORNERS.height); + this.outlinePath_ += Blockly.utils.svgPaths.lineOnAxis('H', x) + innerTopLeftCorner + - Blockly.utils.svgPaths.lineOnAxis('v', - row.height - (2 * Blockly.blockRendering.constants.INSIDE_CORNERS.height)) + + Blockly.utils.svgPaths.lineOnAxis('v', innerHeight) + Blockly.blockRendering.constants.INSIDE_CORNERS.pathBottom; this.positionStatementInputConnection_(row); diff --git a/core/renderers/block_rendering_rewrite/block_render_draw_highlight.js b/core/renderers/block_rendering_rewrite/block_render_draw_highlight.js index 413eae58f..46fffc8a2 100644 --- a/core/renderers/block_rendering_rewrite/block_render_draw_highlight.js +++ b/core/renderers/block_rendering_rewrite/block_render_draw_highlight.js @@ -115,40 +115,35 @@ Blockly.blockRendering.Highlighter.prototype.drawJaggedEdge_ = function(row) { Blockly.blockRendering.Highlighter.prototype.drawValueInput = function(row) { var input = row.getLastInput(); - var steps = ''; if (this.RTL_) { var belowTabHeight = row.height - input.connectionHeight; - steps = - Blockly.utils.svgPaths.moveTo( - row.xPos + row.width - this.highlightOffset_, row.yPos) + - this.puzzleTabPaths_.pathDown(this.RTL_) + - Blockly.utils.svgPaths.lineOnAxis('v', belowTabHeight); + this.steps_.push(Blockly.utils.svgPaths.moveTo( + input.xPos + input.width - this.highlightOffset_, row.yPos)); + this.steps_.push(this.puzzleTabPaths_.pathDown(this.RTL_)); + this.steps_.push( + Blockly.utils.svgPaths.lineOnAxis('v', belowTabHeight)); } else { - steps = - Blockly.utils.svgPaths.moveTo(row.xPos + row.width, row.yPos) + - this.puzzleTabPaths_.pathDown(this.RTL_); + this.steps_.push( + Blockly.utils.svgPaths.moveTo(input.xPos + input.width, row.yPos)); + this.steps_.push(this.puzzleTabPaths_.pathDown(this.RTL_)); } - - this.steps_.push(steps); }; Blockly.blockRendering.Highlighter.prototype.drawStatementInput = function(row) { - var steps = ''; - var statementEdge = row.xPos + row.statementEdge; + var input = row.getLastInput(); if (this.RTL_) { var innerHeight = row.height - (2 * this.insideCornerPaths_.height); - steps = - Blockly.utils.svgPaths.moveTo(statementEdge, row.yPos) + - this.insideCornerPaths_.pathTop(this.RTL_) + - Blockly.utils.svgPaths.lineOnAxis('v', innerHeight) + - this.insideCornerPaths_.pathBottom(this.RTL_); + this.steps_.push(Blockly.utils.svgPaths.moveTo(input.xPos, row.yPos)); + this.steps_.push(this.insideCornerPaths_.pathTop(this.RTL_)); + this.steps_.push( + Blockly.utils.svgPaths.lineOnAxis('v', innerHeight)); + this.steps_.push(this.insideCornerPaths_.pathBottom(this.RTL_)); } else { - steps = - Blockly.utils.svgPaths.moveTo(statementEdge, row.yPos + row.height) + - this.insideCornerPaths_.pathBottom(this.RTL_); + this.steps_.push( + Blockly.utils.svgPaths.moveTo(input.xPos, row.yPos + row.height) + + this.insideCornerPaths_.pathBottom(this.RTL_)); } - this.steps_.push(steps); }; Blockly.blockRendering.Highlighter.prototype.drawRightSideRow = function(row) { diff --git a/core/renderers/block_rendering_rewrite/block_rendering_constants.js b/core/renderers/block_rendering_rewrite/block_rendering_constants.js index 76a5e3072..f39b06718 100644 --- a/core/renderers/block_rendering_rewrite/block_rendering_constants.js +++ b/core/renderers/block_rendering_rewrite/block_rendering_constants.js @@ -289,6 +289,7 @@ Blockly.blockRendering.constants.INSIDE_CORNERS = (function() { Blockly.utils.svgPaths.point(radius, radius)); return { + width: radius, height: radius, pathTop: innerTopLeftCorner, pathBottom: innerBottomLeftCorner From 2d314cbd4a6a1db5eb014883f5ace352c0f60b9e Mon Sep 17 00:00:00 2001 From: kozbial Date: Mon, 19 Aug 2019 11:11:45 -0700 Subject: [PATCH 2/3] Reverting highlight methods restructure. --- .../block_render_draw_highlight.js | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/core/renderers/block_rendering_rewrite/block_render_draw_highlight.js b/core/renderers/block_rendering_rewrite/block_render_draw_highlight.js index 46fffc8a2..bf397a8f9 100644 --- a/core/renderers/block_rendering_rewrite/block_render_draw_highlight.js +++ b/core/renderers/block_rendering_rewrite/block_render_draw_highlight.js @@ -115,35 +115,39 @@ Blockly.blockRendering.Highlighter.prototype.drawJaggedEdge_ = function(row) { Blockly.blockRendering.Highlighter.prototype.drawValueInput = function(row) { var input = row.getLastInput(); + var steps = ''; if (this.RTL_) { var belowTabHeight = row.height - input.connectionHeight; - this.steps_.push(Blockly.utils.svgPaths.moveTo( - input.xPos + input.width - this.highlightOffset_, row.yPos)); - this.steps_.push(this.puzzleTabPaths_.pathDown(this.RTL_)); - this.steps_.push( - Blockly.utils.svgPaths.lineOnAxis('v', belowTabHeight)); + steps = + Blockly.utils.svgPaths.moveTo( + input.xPos + input.width - this.highlightOffset_, row.yPos) + + this.puzzleTabPaths_.pathDown(this.RTL_) + + Blockly.utils.svgPaths.lineOnAxis('v', belowTabHeight); } else { - this.steps_.push( - Blockly.utils.svgPaths.moveTo(input.xPos + input.width, row.yPos)); - this.steps_.push(this.puzzleTabPaths_.pathDown(this.RTL_)); + steps = + Blockly.utils.svgPaths.moveTo(input.xPos + input.width, row.yPos) + + this.puzzleTabPaths_.pathDown(this.RTL_); } + + this.steps_.push(steps); }; Blockly.blockRendering.Highlighter.prototype.drawStatementInput = function(row) { - var input = row.getLastInput(); + var steps = ''; if (this.RTL_) { var innerHeight = row.height - (2 * this.insideCornerPaths_.height); - this.steps_.push(Blockly.utils.svgPaths.moveTo(input.xPos, row.yPos)); - this.steps_.push(this.insideCornerPaths_.pathTop(this.RTL_)); - this.steps_.push( - Blockly.utils.svgPaths.lineOnAxis('v', innerHeight)); - this.steps_.push(this.insideCornerPaths_.pathBottom(this.RTL_)); + steps = + Blockly.utils.svgPaths.moveTo(input.xPos, row.yPos) + + this.insideCornerPaths_.pathTop(this.RTL_) + + Blockly.utils.svgPaths.lineOnAxis('v', innerHeight) + + this.insideCornerPaths_.pathBottom(this.RTL_); } else { - this.steps_.push( + steps = Blockly.utils.svgPaths.moveTo(input.xPos, row.yPos + row.height) + - this.insideCornerPaths_.pathBottom(this.RTL_)); + this.insideCornerPaths_.pathBottom(this.RTL_); } + this.steps_.push(steps); }; Blockly.blockRendering.Highlighter.prototype.drawRightSideRow = function(row) { From 4debe8f96787f731deef4b77a4006e7d2f43e3c3 Mon Sep 17 00:00:00 2001 From: kozbial Date: Mon, 19 Aug 2019 14:14:11 -0700 Subject: [PATCH 3/3] Fixing eslint issue and missing getLastInput call. --- core/renderers/block_rendering_rewrite/block_render_draw.js | 2 +- .../block_rendering_rewrite/block_render_draw_highlight.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/core/renderers/block_rendering_rewrite/block_render_draw.js b/core/renderers/block_rendering_rewrite/block_render_draw.js index 7e784124b..02135ad36 100644 --- a/core/renderers/block_rendering_rewrite/block_render_draw.js +++ b/core/renderers/block_rendering_rewrite/block_render_draw.js @@ -219,7 +219,7 @@ Blockly.blockRendering.Drawer.prototype.drawStatementInput_ = function(row) { Blockly.blockRendering.constants.INSIDE_CORNERS.pathTop; var innerHeight = - row.height -(2 * Blockly.blockRendering.constants.INSIDE_CORNERS.height); + row.height - (2 * Blockly.blockRendering.constants.INSIDE_CORNERS.height); this.outlinePath_ += Blockly.utils.svgPaths.lineOnAxis('H', x) + innerTopLeftCorner + diff --git a/core/renderers/block_rendering_rewrite/block_render_draw_highlight.js b/core/renderers/block_rendering_rewrite/block_render_draw_highlight.js index bf397a8f9..8a6b5ba4c 100644 --- a/core/renderers/block_rendering_rewrite/block_render_draw_highlight.js +++ b/core/renderers/block_rendering_rewrite/block_render_draw_highlight.js @@ -134,6 +134,7 @@ Blockly.blockRendering.Highlighter.prototype.drawValueInput = function(row) { }; Blockly.blockRendering.Highlighter.prototype.drawStatementInput = function(row) { + var input = row.getLastInput(); var steps = ''; if (this.RTL_) { var innerHeight = row.height - (2 * this.insideCornerPaths_.height);