From b1d86a57aa636dd000de445118d3ccb2b7863cce Mon Sep 17 00:00:00 2001 From: kozbial Date: Wed, 31 Jul 2019 13:55:19 -0700 Subject: [PATCH 1/6] Updating logic to handle rendering collapsed blocks. --- .../block_render_draw.js | 28 ++++++++++- .../block_render_draw_highlight.js | 14 ++++++ .../block_render_info.js | 47 ++++++++++++++++--- .../block_rendering_constants.js | 22 +++++++++ .../highlight_constants.js | 1 - .../block_rendering_rewrite/measurables.js | 35 ++++++++++++-- 6 files changed, 134 insertions(+), 13 deletions(-) diff --git a/core/renderers/block_rendering_rewrite/block_render_draw.js b/core/renderers/block_rendering_rewrite/block_render_draw.js index c7a423b0d..f678e496d 100644 --- a/core/renderers/block_rendering_rewrite/block_render_draw.js +++ b/core/renderers/block_rendering_rewrite/block_render_draw.js @@ -60,6 +60,7 @@ Blockly.blockRendering.Drawer = function(block, info) { * @private */ Blockly.blockRendering.Drawer.prototype.draw_ = function() { + this.hideHiddenIcons_(); this.drawOutline_(); this.drawInternals_(); this.block_.setPaths_(this.pathObject_); @@ -83,6 +84,17 @@ Blockly.blockRendering.Drawer.prototype.recordSizeOnBlock_ = function() { this.block_.startHat_ = this.info_.topRow.startHat; }; +/** + * Hide icons that were marked as hidden. + * @private + */ +Blockly.blockRendering.Drawer.prototype.hideHiddenIcons_ = function() { + for (var i = 0; i < this.info_.hiddenIcons.length; i++) { + var iconInfo = this.info_.hiddenIcons[i]; + iconInfo.icon.iconGroup_.setAttribute('display', 'none'); + } +}; + /** * Create the outline of the block. This is a single continuous path. * @private @@ -91,7 +103,9 @@ Blockly.blockRendering.Drawer.prototype.drawOutline_ = function() { this.drawTop_(); for (var r = 1; r < this.info_.rows.length - 1; r++) { var row = this.info_.rows[r]; - if (row.hasStatement) { + if (!row.isSpacer() && this.info_.isCollapsed) { + this.drawJaggedEdge_(row) + } else if (row.hasStatement) { this.drawStatementInput_(row); } else if (row.hasExternalInput) { this.drawValueInput_(row); @@ -136,6 +150,18 @@ Blockly.blockRendering.Drawer.prototype.drawTop_ = function() { this.steps_.push('v', topRow.height); }; +/** + * Add steps for the jagged edge of a row on a collapsed block. + * @param {!Blockly.blockRendering.Row} row The row to draw the side of. + * @private + */ +Blockly.blockRendering.Drawer.prototype.drawJaggedEdge_ = function(row) { + this.highlighter_.drawJaggedEdge_(row); + this.steps_.push(Blockly.blockRendering.constants.JAGGED_TEETH); + var remainder = row.height - Blockly.blockRendering.constants.JAGGED_TEETH_HEIGHT; + this.steps_.push('v', remainder); + console.log('remainder: ' + remainder); +}; /** * Add steps for an external value input, rendered as a notch in the side 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 323e13b83..6438058ee 100644 --- a/core/renderers/block_rendering_rewrite/block_render_draw_highlight.js +++ b/core/renderers/block_rendering_rewrite/block_render_draw_highlight.js @@ -91,6 +91,20 @@ Blockly.blockRendering.Highlighter.prototype.drawTopCorner = function(row) { this.steps_.push('H', row.width - this.highlightOffset_); }; +Blockly.blockRendering.Highlighter.prototype.drawJaggedEdge_ = function(row) { + if (this.info_.RTL) { + var remainder = + row.height - Blockly.blockRendering.constants.JAGGED_TEETH_HEIGHT - this.highlightOffset_; + this.steps_.push('H', row.width - this.highlightOffset_); + var steps = + Blockly.utils.svgPaths.lineTo(5.1, 2.6) + + Blockly.utils.svgPaths.moveBy(-10.2, 6.8) + + Blockly.utils.svgPaths.lineTo(5.1, 2.6) + + Blockly.utils.svgPaths.lineOnAxis('v', remainder); + this.steps_.push(steps); + } +}; + Blockly.blockRendering.Highlighter.prototype.drawValueInput = function(row) { var input = row.getLastInput(); var steps = ''; diff --git a/core/renderers/block_rendering_rewrite/block_render_info.js b/core/renderers/block_rendering_rewrite/block_render_info.js index b9de72069..69c70af81 100644 --- a/core/renderers/block_rendering_rewrite/block_render_info.js +++ b/core/renderers/block_rendering_rewrite/block_render_info.js @@ -59,6 +59,12 @@ Blockly.blockRendering.RenderInfo = function(block) { */ this.isInline = block.getInputsInline() && !block.isCollapsed(); + /** + * Whether the block is collapsed. + * @type {boolean} + */ + this.isCollapsed = block.isCollapsed(); + /** * Whether the block is an insertion marker. Insertion markers are the same * shape as normal blocks, but don't show fields. @@ -103,6 +109,12 @@ Blockly.blockRendering.RenderInfo = function(block) { */ this.rows = []; + /** + * An array of measureable objects containing hidden icons. + * @type {Array} + */ + this.hiddenIcons = []; + this.topRow = null; this.bottomRow = null; @@ -145,16 +157,25 @@ Blockly.blockRendering.RenderInfo.prototype.createRows_ = function() { var icons = this.block_.getIcons(); if (icons.length) { for (var i = 0; i < icons.length; i++) { - activeRow.elements.push( - new Blockly.blockRendering.Icon(icons[i])); + var icon = icons[i]; + var iconInfo = new Blockly.blockRendering.Icon(icon); + if (this.isCollapsed && icon.collapseHidden) { + this.hiddenIcons.push(iconInfo); + } else { + activeRow.elements.push(iconInfo); + } } } + var lastInput = undefined; // Loop across all of the inputs on the block, creating objects for anything // that needs to be rendered and breaking the block up into visual rows. for (var i = 0; i < this.block_.inputList.length; i++) { var input = this.block_.inputList[i]; - if (this.shouldStartNewRow_(input, this.block_.inputList[i - 1])) { + if (!input.isVisible()) { + continue; + } + if (this.shouldStartNewRow_(input, lastInput)) { // Finish this row and create a new one. this.rows.push(activeRow); activeRow = new Blockly.blockRendering.Row(); @@ -166,6 +187,11 @@ Blockly.blockRendering.RenderInfo.prototype.createRows_ = function() { activeRow.elements.push(new Blockly.blockRendering.Field(field, input)); } this.addInput_(input, activeRow); + lastInput = input; + } + + if (this.isCollapsed) { + activeRow.elements.push(new Blockly.blockRendering.JaggedEdge()); } if (activeRow.elements.length) { @@ -285,7 +311,6 @@ Blockly.blockRendering.RenderInfo.prototype.addElemSpacing_ = function() { row.elements.push(new Blockly.blockRendering.InRowSpacer( this.getInRowSpacing_(null, oldElems[0]))); } - for (var e = 0; e < oldElems.length; e++) { row.elements.push(oldElems[e]); var spacing = this.getInRowSpacing_(oldElems[e], oldElems[e + 1]); @@ -321,7 +346,7 @@ Blockly.blockRendering.RenderInfo.prototype.getInRowSpacing_ = function(prev, ne return Blockly.blockRendering.constants.LARGE_PADDING; } - // Spacing between a field or icon and the end of the row. + // Spacing between a non-input and the end of the row. if (!prev.isInput && !next) { // Between an editable field and the end of the row. if (prev.isField() && prev.isEditable) { @@ -342,6 +367,10 @@ Blockly.blockRendering.RenderInfo.prototype.getInRowSpacing_ = function(prev, ne if (prev.isRoundedCorner()) { return Blockly.blockRendering.constants.MIN_BLOCK_WIDTH; } + // Between a jagged edge and the end of the row. + if (prev.isJaggedEdge()) { + return Blockly.blockRendering.constants.NO_PADDING; + } // Between noneditable fields and icons and the end of the row. return Blockly.blockRendering.constants.LARGE_PADDING; } @@ -357,7 +386,7 @@ Blockly.blockRendering.RenderInfo.prototype.getInRowSpacing_ = function(prev, ne } } - // Spacing between a field or icon and an input. + // Spacing between a non-input and an input. if (!prev.isInput && next.isInput) { // Between an editable field and an input. if (prev.isEditable) { @@ -411,7 +440,7 @@ Blockly.blockRendering.RenderInfo.prototype.getInRowSpacing_ = function(prev, ne } } - // Spacing between a rounded corner and a previous or next connection + // Spacing between a rounded corner and a previous or next connection. if (prev.isRoundedCorner()){ if (next.isPreviousConnection()) { return Blockly.blockRendering.constants.NOTCH_OFFSET_ROUNDED_CORNER_PREV; @@ -429,6 +458,10 @@ Blockly.blockRendering.RenderInfo.prototype.getInRowSpacing_ = function(prev, ne return Blockly.blockRendering.constants.LARGE_PADDING; } + if (next.isJaggedEdge()) { + return Blockly.blockRendering.constants.LARGE_PADDING; + } + return Blockly.blockRendering.constants.MEDIUM_PADDING; }; diff --git a/core/renderers/block_rendering_rewrite/block_rendering_constants.js b/core/renderers/block_rendering_rewrite/block_rendering_constants.js index 1439d3fbf..9809c49e8 100644 --- a/core/renderers/block_rendering_rewrite/block_rendering_constants.js +++ b/core/renderers/block_rendering_rewrite/block_rendering_constants.js @@ -141,6 +141,28 @@ Blockly.blockRendering.constants.START_POINT = Blockly.utils.svgPaths.moveBy(0, Blockly.blockRendering.constants.TOP_LEFT_CORNER_START = 'm 0,' + Blockly.blockRendering.constants.CORNER_RADIUS; +/** + * SVG path for drawing jagged teeth at the end of collapsed blocks. + * @const + */ +Blockly.blockRendering.constants.JAGGED_TEETH = Blockly.utils.svgPaths.line( + [ + Blockly.utils.svgPaths.point(6, 3), + Blockly.utils.svgPaths.point(-12, 6), + Blockly.utils.svgPaths.point(6, 3) + ]); + +/** + * Height of SVG path for jagged teeth at the end of collapsed blocks. + * @const + */ +Blockly.blockRendering.constants.JAGGED_TEETH_HEIGHT = 12; +/** + * Width of SVG path for jagged teeth at the end of collapsed blocks. + * @const + */ +Blockly.blockRendering.constants.JAGGED_TEETH_WIDTH = 6; + /** * Information about the hat on a start block. */ diff --git a/core/renderers/block_rendering_rewrite/highlight_constants.js b/core/renderers/block_rendering_rewrite/highlight_constants.js index 340aadc2d..77692a93c 100644 --- a/core/renderers/block_rendering_rewrite/highlight_constants.js +++ b/core/renderers/block_rendering_rewrite/highlight_constants.js @@ -140,7 +140,6 @@ Blockly.blockRendering.highlightConstants.OUTSIDE_CORNER = (function() { }; })(); - Blockly.blockRendering.highlightConstants.PUZZLE_TAB = (function() { var width = Blockly.blockRendering.constants.TAB_WIDTH; var height = Blockly.blockRendering.constants.TAB_HEIGHT; diff --git a/core/renderers/block_rendering_rewrite/measurables.js b/core/renderers/block_rendering_rewrite/measurables.js index be247d114..0be8a3058 100644 --- a/core/renderers/block_rendering_rewrite/measurables.js +++ b/core/renderers/block_rendering_rewrite/measurables.js @@ -127,6 +127,16 @@ Blockly.blockRendering.Measurable.prototype.isRoundedCorner = function() { Blockly.blockRendering.Measurable.prototype.isSquareCorner = function() { return this.type == 'square corner'; }; + +/** + * Whether this stores information about a jagged edge. + * @return {boolean} True if this object stores information about a jagged edge. + * @package + */ +Blockly.blockRendering.Measurable.prototype.isJaggedEdge = function() { + return this.type == 'jagged edge'; +}; + /** * The base class to represent an input that takes up space on a block * during rendering @@ -178,6 +188,21 @@ Blockly.blockRendering.Icon = function(icon) { }; goog.inherits(Blockly.blockRendering.Icon, Blockly.blockRendering.Measurable); +/** + * An object containing information about the jagged edge of a collapsed block + * takes up during rendering + * @package + * @constructor + */ +Blockly.blockRendering.JaggedEdge = function() { + Blockly.blockRendering.JaggedEdge.superClass_.constructor.call(this); + this.type = 'jagged edge'; + this.height = Blockly.blockRendering.constants.JAGGED_TEETH_HEIGHT; + this.width = Blockly.blockRendering.constants.JAGGED_TEETH_WIDTH; +}; +goog.inherits(Blockly.blockRendering.JaggedEdge, Blockly.blockRendering.Measurable); + + /** * An object containing information about the space a field takes up during * rendering @@ -409,9 +434,11 @@ Blockly.blockRendering.Row.prototype.measure = function() { }; Blockly.blockRendering.Row.prototype.getLastInput = function() { - // There's always a spacer after the last input, unless there are no inputs. - if (this.elements.length > 1) { - var elem = this.elements[this.elements.length - 2]; + for (var i = this.elements.length - 1; i >= 0; i--) { + var elem = this.elements[i]; + if (elem.isSpacer()) { + continue; + } if (elem.isInput) { return elem; } else if (elem.isField()) { @@ -468,7 +495,7 @@ Blockly.blockRendering.TopRow = function(block) { // 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) { + if (precedesStatement && !block.isCollapsed()) { this.height = Blockly.blockRendering.constants.LARGE_PADDING; } else { this.height = Blockly.blockRendering.constants.MEDIUM_PADDING; From c6b0d961a19308b7178c06816aad6907a60d2766 Mon Sep 17 00:00:00 2001 From: kozbial Date: Thu, 1 Aug 2019 11:33:27 -0700 Subject: [PATCH 2/6] Running eslint on modified files. --- core/blockly.js | 2 +- core/bubble.js | 2 +- core/insertion_marker_manager.js | 16 ++++---- core/keyboard_nav/ast_node.js | 10 ++--- core/keyboard_nav/cursor_svg.js | 18 ++++----- core/keyboard_nav/navigation.js | 40 +++++++++---------- .../block_render_draw.js | 4 +- .../block_rendering_constants.js | 2 +- core/toolbox.js | 2 +- core/touch_gesture.js | 6 +-- core/workspace_comment_render_svg.js | 4 +- core/workspace_svg.js | 2 +- 12 files changed, 54 insertions(+), 54 deletions(-) diff --git a/core/blockly.js b/core/blockly.js index 6e3a3ddd8..0ea4f0fee 100644 --- a/core/blockly.js +++ b/core/blockly.js @@ -38,7 +38,7 @@ goog.require('Blockly.FieldCheckbox'); goog.require('Blockly.FieldColour'); // Date picker commented out since it increases footprint by 60%. // Add it only if you need it. -//goog.require('Blockly.FieldDate'); +// goog.require('Blockly.FieldDate'); goog.require('Blockly.FieldDropdown'); goog.require('Blockly.FieldLabelSerializable'); goog.require('Blockly.FieldImage'); diff --git a/core/bubble.js b/core/bubble.js index 516c4b208..8e9968c52 100644 --- a/core/bubble.js +++ b/core/bubble.js @@ -151,7 +151,7 @@ Blockly.Bubble.unbindDragEvents_ = function() { * @param {!Event} e Mouse up event. * @private */ -Blockly.Bubble.bubbleMouseUp_ = function(/*e*/) { +Blockly.Bubble.bubbleMouseUp_ = function(/* e */) { Blockly.Touch.clearTouchIdentifier(); Blockly.Bubble.unbindDragEvents_(); }; diff --git a/core/insertion_marker_manager.js b/core/insertion_marker_manager.js index a40b3b7ba..2a2bea945 100644 --- a/core/insertion_marker_manager.js +++ b/core/insertion_marker_manager.js @@ -245,7 +245,7 @@ Blockly.InsertionMarkerManager.prototype.update = function(dxy, deleteArea) { } }; -/**** Begin initialization functions ****/ +/** ** Begin initialization functions *** */ /** * Create an insertion marker that represents the given block. @@ -310,7 +310,7 @@ Blockly.InsertionMarkerManager.prototype.initAvailableConnections_ = function() return available; }; -/**** End initialization functions ****/ +/** ** End initialization functions *** */ /** @@ -472,7 +472,7 @@ Blockly.InsertionMarkerManager.prototype.shouldDelete_ = function(candidate, return wouldDelete && !wouldConnect; }; -/**** Begin preview visibility functions ****/ +/** ** Begin preview visibility functions *** */ /** * Show an insertion marker or replacement highlighting during a drag, if @@ -574,9 +574,9 @@ Blockly.InsertionMarkerManager.prototype.hidePreview_ = function() { } }; -/**** End preview visibility functions ****/ +/** ** End preview visibility functions *** */ -/**** Begin block highlighting functions ****/ +/** ** Begin block highlighting functions *** */ /** * Add highlighting showing which block will be replaced. @@ -611,9 +611,9 @@ Blockly.InsertionMarkerManager.prototype.unhighlightBlock_ = function() { this.highlightingBlock_ = false; }; -/**** End block highlighting functions ****/ +/** ** End block highlighting functions *** */ -/**** Begin insertion marker display functions ****/ +/** ** Begin insertion marker display functions *** */ /** * Disconnect the insertion marker block in a manner that returns the stack to @@ -698,7 +698,7 @@ Blockly.InsertionMarkerManager.prototype.connectMarker_ = function() { this.markerConnection_ = imConn; }; -/**** End insertion marker display functions ****/ +/** ** End insertion marker display functions *** */ /** * Get a list of the insertion markers that currently exist. Drags have 0, 1, diff --git a/core/keyboard_nav/ast_node.js b/core/keyboard_nav/ast_node.js index 842a5d7d4..5c8653b82 100644 --- a/core/keyboard_nav/ast_node.js +++ b/core/keyboard_nav/ast_node.js @@ -401,7 +401,7 @@ Blockly.ASTNode.prototype.findPrevForField_ = function() { } fieldIdx--; } - //Reset the fieldIdx to the length of the field row of the previous input + // Reset the fieldIdx to the length of the field row of the previous input if (i - 1 >= 0) { fieldIdx = block.inputList[i - 1].fieldRow.length - 1; } @@ -483,7 +483,7 @@ Blockly.ASTNode.prototype.getOutAstNodeForBlock_ = function(block) { return Blockly.ASTNode.createInputNode( topConnection.targetConnection.getParentInput()); } else { - //Go to stack level if you are not underneath an input + // Go to stack level if you are not underneath an input return Blockly.ASTNode.createStackNode(topBlock); } }; @@ -539,8 +539,8 @@ Blockly.ASTNode.prototype.findTopOfSubStack_ = function(sourceBlock) { Blockly.ASTNode.prototype.next = function() { switch (this.type_) { case Blockly.ASTNode.types.WORKSPACE: - //TODO: Need to limit this. The view is bounded to half a screen beyond - //the furthest block. + // TODO: Need to limit this. The view is bounded to half a screen beyond + // the furthest block. var newX = this.wsCoordinate_.x + Blockly.ASTNode.wsMove_; var newWsCoordinate = new Blockly.utils.Coordinate(newX, this.wsCoordinate_.y); var workspace = /** @type {Blockly.Workspace} */ (this.location_); @@ -672,7 +672,7 @@ Blockly.ASTNode.prototype.out = function() { switch (this.type_) { case Blockly.ASTNode.types.STACK: var blockPos = this.location_.getRelativeToSurfaceXY(); - //TODO: Make sure this is in the bounds of the workspace + // TODO: Make sure this is in the bounds of the workspace var wsCoordinate = new Blockly.utils.Coordinate( blockPos.x, blockPos.y + Blockly.ASTNode.DEFAULT_OFFSET_Y); return Blockly.ASTNode.createWorkspaceNode( diff --git a/core/keyboard_nav/cursor_svg.js b/core/keyboard_nav/cursor_svg.js index 7214cd90d..32580dad2 100644 --- a/core/keyboard_nav/cursor_svg.js +++ b/core/keyboard_nav/cursor_svg.js @@ -152,9 +152,9 @@ Blockly.CursorSvg.prototype.setParent_ = function(newParent) { this.parent_ = newParent; }; -/**************************/ -/**** Display ****/ -/**************************/ +/** *********************** */ +/** ** Display *** */ +/** *********************** */ /** * Show the cursor using coordinates. @@ -174,7 +174,7 @@ Blockly.CursorSvg.prototype.showWithCoordinates_ = function() { * @private */ Blockly.CursorSvg.prototype.showWithBlock_ = function() { - //TODO: Change this from getLocation to something else + // TODO: Change this from getLocation to something else var block = this.getCurNode().getLocation(); this.currentCursorSvg = this.cursorSvgRect_; @@ -274,9 +274,9 @@ Blockly.CursorSvg.prototype.showWithStack_ = function() { }; -/**************************/ -/**** Position ****/ -/**************************/ +/** *********************** */ +/** ** Position *** */ +/** *********************** */ /** * Move and show the cursor at the specified coordinate in workspace units. @@ -348,8 +348,8 @@ Blockly.CursorSvg.prototype.update_ = function() { var curNode = this.getCurNode(); if (curNode.getType() === Blockly.ASTNode.types.BLOCK) { this.showWithBlock_(); - //This needs to be the location type because next connections can be input - //type but they need to draw like they are a next statement + // This needs to be the location type because next connections can be input + // type but they need to draw like they are a next statement } else if (curNode.getLocation().type === Blockly.INPUT_VALUE || curNode.getType() === Blockly.ASTNode.types.OUTPUT) { this.showWithInputOutput_(); diff --git a/core/keyboard_nav/navigation.js b/core/keyboard_nav/navigation.js index 6f9d0a5f9..5ef820c99 100644 --- a/core/keyboard_nav/navigation.js +++ b/core/keyboard_nav/navigation.js @@ -129,9 +129,9 @@ Blockly.Navigation.removeMark = function() { Blockly.Navigation.marker_.hide(); }; -/************************/ -/** Toolbox Navigation **/ -/************************/ +/** ********************* */ +/** Toolbox Navigation * */ +/** ********************* */ /** * Set the state to the toolbox state and the current category as the first @@ -232,9 +232,9 @@ Blockly.Navigation.outCategory = function() { } }; -/***********************/ -/** Flyout Navigation **/ -/***********************/ +/** ******************** */ +/** Flyout Navigation * */ +/** ******************** */ /** * Change focus to the flyout. @@ -357,8 +357,8 @@ Blockly.Navigation.insertFromFlyout = function() { var prevConnection = newBlock.previousConnection; var outConnection = newBlock.outputConnection; var topConnection = prevConnection ? prevConnection : outConnection; - //TODO: This will have to be fixed when we add in a block that does not have - //a previous or output connection + // TODO: This will have to be fixed when we add in a block that does not have + // a previous or output connection var astNode = Blockly.ASTNode.createConnectionNode(topConnection); Blockly.Navigation.cursor_.setLocation(astNode); Blockly.Navigation.removeMark(); @@ -377,9 +377,9 @@ Blockly.Navigation.resetFlyout = function(shouldHide) { } }; -/************/ -/** Modify **/ -/************/ +/** ********* */ +/** Modify * */ +/** ********* */ /** * Handle the modifier key (currently I for Insert). @@ -587,9 +587,9 @@ Blockly.Navigation.disconnectBlocks = function() { Blockly.Navigation.cursor_.setLocation(connectionNode); }; -/*************************/ -/** Keyboard Navigation **/ -/*************************/ +/** ********************** */ +/** Keyboard Navigation * */ +/** ********************** */ /** * Sets the cursor to the previous or output connection of the selected block @@ -606,8 +606,8 @@ Blockly.Navigation.focusWorkspace = function() { if (Blockly.selected) { var previousConnection = Blockly.selected.previousConnection; var outputConnection = Blockly.selected.outputConnection; - //TODO: This still needs to work with blocks that have neither previous - //or output connection. + // TODO: This still needs to work with blocks that have neither previous + // or output connection. var connection = previousConnection ? previousConnection : outputConnection; var newAstNode = Blockly.ASTNode.createConnectionNode(connection); cursor.setLocation(newAstNode); @@ -641,9 +641,9 @@ Blockly.Navigation.handleEnterForWS = function() { } }; -/**********************/ -/** Helper Functions **/ -/**********************/ +/** ******************* */ +/** Helper Functions * */ +/** ******************* */ /** @@ -730,7 +730,7 @@ Blockly.Navigation.toolboxKeyHandler = function(e) { Blockly.Navigation.log('D: Toolbox : Go to flyout'); return true; } else if (e.keyCode === goog.events.KeyCodes.ENTER) { - //TODO: focus on flyout OR open if the category is nested + // TODO: focus on flyout OR open if the category is nested return true; } else if (e.keyCode === goog.events.KeyCodes.E || e.keyCode === goog.events.KeyCodes.ESC) { diff --git a/core/renderers/block_rendering_rewrite/block_render_draw.js b/core/renderers/block_rendering_rewrite/block_render_draw.js index f678e496d..8f3ea1337 100644 --- a/core/renderers/block_rendering_rewrite/block_render_draw.js +++ b/core/renderers/block_rendering_rewrite/block_render_draw.js @@ -103,8 +103,8 @@ Blockly.blockRendering.Drawer.prototype.drawOutline_ = function() { this.drawTop_(); for (var r = 1; r < this.info_.rows.length - 1; r++) { var row = this.info_.rows[r]; - if (!row.isSpacer() && this.info_.isCollapsed) { - this.drawJaggedEdge_(row) + if (!row.isSpacer() && this.info_.isCollapsed) { + this.drawJaggedEdge_(row); } else if (row.hasStatement) { this.drawStatementInput_(row); } else if (row.hasExternalInput) { diff --git a/core/renderers/block_rendering_rewrite/block_rendering_constants.js b/core/renderers/block_rendering_rewrite/block_rendering_constants.js index 9809c49e8..de53cda26 100644 --- a/core/renderers/block_rendering_rewrite/block_rendering_constants.js +++ b/core/renderers/block_rendering_rewrite/block_rendering_constants.js @@ -202,7 +202,7 @@ Blockly.blockRendering.constants.PUZZLE_TAB = (function() { var halfHeight = height / 2; var control1Y = halfHeight + overlap; var control2Y = halfHeight + 0.5; - var control3Y = overlap; //2.5 + var control3Y = overlap; // 2.5 var endPoint1 = Blockly.utils.svgPaths.point(-width, forward * halfHeight); var endPoint2 = Blockly.utils.svgPaths.point(width, forward * halfHeight); diff --git a/core/toolbox.js b/core/toolbox.js index d0619276d..b3006dc0e 100644 --- a/core/toolbox.js +++ b/core/toolbox.js @@ -173,7 +173,7 @@ Blockly.Toolbox.prototype.init = function() { Blockly.hideChaff(true); } Blockly.Touch.clearTouchIdentifier(); // Don't block future drags. - }, /*opt_noCaptureIdentifier*/ false, /*opt_noPreventDefault*/ true); + }, /* opt_noCaptureIdentifier */ false, /* opt_noPreventDefault */ true); var workspaceOptions = { disabledPatternId: workspace.options.disabledPatternId, parentWorkspace: workspace, diff --git a/core/touch_gesture.js b/core/touch_gesture.js index 780579cf1..019fb8fb0 100644 --- a/core/touch_gesture.js +++ b/core/touch_gesture.js @@ -127,13 +127,13 @@ Blockly.TouchGesture.prototype.doStart = function(e) { Blockly.TouchGesture.prototype.bindMouseEvents = function(e) { this.onStartWrapper_ = Blockly.bindEventWithChecks_( document, 'mousedown', null, this.handleStart.bind(this), - /*opt_noCaptureIdentifier*/ true); + /* opt_noCaptureIdentifier */ true); this.onMoveWrapper_ = Blockly.bindEventWithChecks_( document, 'mousemove', null, this.handleMove.bind(this), - /*opt_noCaptureIdentifier*/ true); + /* opt_noCaptureIdentifier */ true); this.onUpWrapper_ = Blockly.bindEventWithChecks_( document, 'mouseup', null, this.handleUp.bind(this), - /*opt_noCaptureIdentifier*/ true); + /* opt_noCaptureIdentifier */ true); e.preventDefault(); e.stopPropagation(); diff --git a/core/workspace_comment_render_svg.js b/core/workspace_comment_render_svg.js index de5bdec3a..ccff7e0d9 100644 --- a/core/workspace_comment_render_svg.js +++ b/core/workspace_comment_render_svg.js @@ -257,7 +257,7 @@ Blockly.WorkspaceCommentSvg.prototype.addDeleteDom_ = function() { * @private */ Blockly.WorkspaceCommentSvg.prototype.resizeMouseDown_ = function(e) { - //this.promote_(); + // this.promote_(); this.unbindDragEvents_(); if (Blockly.utils.isRightButton(e)) { // No right-click. @@ -335,7 +335,7 @@ Blockly.WorkspaceCommentSvg.prototype.unbindDragEvents_ = function() { * @param {!Event} e Mouse up event. * @private */ -Blockly.WorkspaceCommentSvg.prototype.resizeMouseUp_ = function(/*e*/) { +Blockly.WorkspaceCommentSvg.prototype.resizeMouseUp_ = function(/* e */) { Blockly.Touch.clearTouchIdentifier(); this.unbindDragEvents_(); }; diff --git a/core/workspace_svg.js b/core/workspace_svg.js index 215dad9fa..42820ef96 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -27,7 +27,7 @@ goog.provide('Blockly.WorkspaceSvg'); // TODO(scr): Fix circular dependencies -//goog.require('Blockly.BlockSvg'); +// goog.require('Blockly.BlockSvg'); goog.require('Blockly.ConnectionDB'); goog.require('Blockly.constants'); goog.require('Blockly.CursorSvg'); From 3a983c53e10b61142a3a145c2c86826a0ab63ce7 Mon Sep 17 00:00:00 2001 From: kozbial Date: Thu, 1 Aug 2019 11:42:00 -0700 Subject: [PATCH 3/6] Reverting extra files touched by eslint. --- core/bubble.js | 2 +- core/insertion_marker_manager.js | 16 ++++---- core/keyboard_nav/ast_node.js | 10 ++--- core/keyboard_nav/cursor_svg.js | 18 ++++----- core/keyboard_nav/navigation.js | 40 +++++++++---------- .../highlight_constants.js | 1 + core/toolbox.js | 2 +- core/touch_gesture.js | 6 +-- core/workspace_comment_render_svg.js | 4 +- core/workspace_svg.js | 2 +- 10 files changed, 51 insertions(+), 50 deletions(-) diff --git a/core/bubble.js b/core/bubble.js index 8e9968c52..516c4b208 100644 --- a/core/bubble.js +++ b/core/bubble.js @@ -151,7 +151,7 @@ Blockly.Bubble.unbindDragEvents_ = function() { * @param {!Event} e Mouse up event. * @private */ -Blockly.Bubble.bubbleMouseUp_ = function(/* e */) { +Blockly.Bubble.bubbleMouseUp_ = function(/*e*/) { Blockly.Touch.clearTouchIdentifier(); Blockly.Bubble.unbindDragEvents_(); }; diff --git a/core/insertion_marker_manager.js b/core/insertion_marker_manager.js index 2a2bea945..a40b3b7ba 100644 --- a/core/insertion_marker_manager.js +++ b/core/insertion_marker_manager.js @@ -245,7 +245,7 @@ Blockly.InsertionMarkerManager.prototype.update = function(dxy, deleteArea) { } }; -/** ** Begin initialization functions *** */ +/**** Begin initialization functions ****/ /** * Create an insertion marker that represents the given block. @@ -310,7 +310,7 @@ Blockly.InsertionMarkerManager.prototype.initAvailableConnections_ = function() return available; }; -/** ** End initialization functions *** */ +/**** End initialization functions ****/ /** @@ -472,7 +472,7 @@ Blockly.InsertionMarkerManager.prototype.shouldDelete_ = function(candidate, return wouldDelete && !wouldConnect; }; -/** ** Begin preview visibility functions *** */ +/**** Begin preview visibility functions ****/ /** * Show an insertion marker or replacement highlighting during a drag, if @@ -574,9 +574,9 @@ Blockly.InsertionMarkerManager.prototype.hidePreview_ = function() { } }; -/** ** End preview visibility functions *** */ +/**** End preview visibility functions ****/ -/** ** Begin block highlighting functions *** */ +/**** Begin block highlighting functions ****/ /** * Add highlighting showing which block will be replaced. @@ -611,9 +611,9 @@ Blockly.InsertionMarkerManager.prototype.unhighlightBlock_ = function() { this.highlightingBlock_ = false; }; -/** ** End block highlighting functions *** */ +/**** End block highlighting functions ****/ -/** ** Begin insertion marker display functions *** */ +/**** Begin insertion marker display functions ****/ /** * Disconnect the insertion marker block in a manner that returns the stack to @@ -698,7 +698,7 @@ Blockly.InsertionMarkerManager.prototype.connectMarker_ = function() { this.markerConnection_ = imConn; }; -/** ** End insertion marker display functions *** */ +/**** End insertion marker display functions ****/ /** * Get a list of the insertion markers that currently exist. Drags have 0, 1, diff --git a/core/keyboard_nav/ast_node.js b/core/keyboard_nav/ast_node.js index 5c8653b82..842a5d7d4 100644 --- a/core/keyboard_nav/ast_node.js +++ b/core/keyboard_nav/ast_node.js @@ -401,7 +401,7 @@ Blockly.ASTNode.prototype.findPrevForField_ = function() { } fieldIdx--; } - // Reset the fieldIdx to the length of the field row of the previous input + //Reset the fieldIdx to the length of the field row of the previous input if (i - 1 >= 0) { fieldIdx = block.inputList[i - 1].fieldRow.length - 1; } @@ -483,7 +483,7 @@ Blockly.ASTNode.prototype.getOutAstNodeForBlock_ = function(block) { return Blockly.ASTNode.createInputNode( topConnection.targetConnection.getParentInput()); } else { - // Go to stack level if you are not underneath an input + //Go to stack level if you are not underneath an input return Blockly.ASTNode.createStackNode(topBlock); } }; @@ -539,8 +539,8 @@ Blockly.ASTNode.prototype.findTopOfSubStack_ = function(sourceBlock) { Blockly.ASTNode.prototype.next = function() { switch (this.type_) { case Blockly.ASTNode.types.WORKSPACE: - // TODO: Need to limit this. The view is bounded to half a screen beyond - // the furthest block. + //TODO: Need to limit this. The view is bounded to half a screen beyond + //the furthest block. var newX = this.wsCoordinate_.x + Blockly.ASTNode.wsMove_; var newWsCoordinate = new Blockly.utils.Coordinate(newX, this.wsCoordinate_.y); var workspace = /** @type {Blockly.Workspace} */ (this.location_); @@ -672,7 +672,7 @@ Blockly.ASTNode.prototype.out = function() { switch (this.type_) { case Blockly.ASTNode.types.STACK: var blockPos = this.location_.getRelativeToSurfaceXY(); - // TODO: Make sure this is in the bounds of the workspace + //TODO: Make sure this is in the bounds of the workspace var wsCoordinate = new Blockly.utils.Coordinate( blockPos.x, blockPos.y + Blockly.ASTNode.DEFAULT_OFFSET_Y); return Blockly.ASTNode.createWorkspaceNode( diff --git a/core/keyboard_nav/cursor_svg.js b/core/keyboard_nav/cursor_svg.js index 32580dad2..7214cd90d 100644 --- a/core/keyboard_nav/cursor_svg.js +++ b/core/keyboard_nav/cursor_svg.js @@ -152,9 +152,9 @@ Blockly.CursorSvg.prototype.setParent_ = function(newParent) { this.parent_ = newParent; }; -/** *********************** */ -/** ** Display *** */ -/** *********************** */ +/**************************/ +/**** Display ****/ +/**************************/ /** * Show the cursor using coordinates. @@ -174,7 +174,7 @@ Blockly.CursorSvg.prototype.showWithCoordinates_ = function() { * @private */ Blockly.CursorSvg.prototype.showWithBlock_ = function() { - // TODO: Change this from getLocation to something else + //TODO: Change this from getLocation to something else var block = this.getCurNode().getLocation(); this.currentCursorSvg = this.cursorSvgRect_; @@ -274,9 +274,9 @@ Blockly.CursorSvg.prototype.showWithStack_ = function() { }; -/** *********************** */ -/** ** Position *** */ -/** *********************** */ +/**************************/ +/**** Position ****/ +/**************************/ /** * Move and show the cursor at the specified coordinate in workspace units. @@ -348,8 +348,8 @@ Blockly.CursorSvg.prototype.update_ = function() { var curNode = this.getCurNode(); if (curNode.getType() === Blockly.ASTNode.types.BLOCK) { this.showWithBlock_(); - // This needs to be the location type because next connections can be input - // type but they need to draw like they are a next statement + //This needs to be the location type because next connections can be input + //type but they need to draw like they are a next statement } else if (curNode.getLocation().type === Blockly.INPUT_VALUE || curNode.getType() === Blockly.ASTNode.types.OUTPUT) { this.showWithInputOutput_(); diff --git a/core/keyboard_nav/navigation.js b/core/keyboard_nav/navigation.js index 5ef820c99..6f9d0a5f9 100644 --- a/core/keyboard_nav/navigation.js +++ b/core/keyboard_nav/navigation.js @@ -129,9 +129,9 @@ Blockly.Navigation.removeMark = function() { Blockly.Navigation.marker_.hide(); }; -/** ********************* */ -/** Toolbox Navigation * */ -/** ********************* */ +/************************/ +/** Toolbox Navigation **/ +/************************/ /** * Set the state to the toolbox state and the current category as the first @@ -232,9 +232,9 @@ Blockly.Navigation.outCategory = function() { } }; -/** ******************** */ -/** Flyout Navigation * */ -/** ******************** */ +/***********************/ +/** Flyout Navigation **/ +/***********************/ /** * Change focus to the flyout. @@ -357,8 +357,8 @@ Blockly.Navigation.insertFromFlyout = function() { var prevConnection = newBlock.previousConnection; var outConnection = newBlock.outputConnection; var topConnection = prevConnection ? prevConnection : outConnection; - // TODO: This will have to be fixed when we add in a block that does not have - // a previous or output connection + //TODO: This will have to be fixed when we add in a block that does not have + //a previous or output connection var astNode = Blockly.ASTNode.createConnectionNode(topConnection); Blockly.Navigation.cursor_.setLocation(astNode); Blockly.Navigation.removeMark(); @@ -377,9 +377,9 @@ Blockly.Navigation.resetFlyout = function(shouldHide) { } }; -/** ********* */ -/** Modify * */ -/** ********* */ +/************/ +/** Modify **/ +/************/ /** * Handle the modifier key (currently I for Insert). @@ -587,9 +587,9 @@ Blockly.Navigation.disconnectBlocks = function() { Blockly.Navigation.cursor_.setLocation(connectionNode); }; -/** ********************** */ -/** Keyboard Navigation * */ -/** ********************** */ +/*************************/ +/** Keyboard Navigation **/ +/*************************/ /** * Sets the cursor to the previous or output connection of the selected block @@ -606,8 +606,8 @@ Blockly.Navigation.focusWorkspace = function() { if (Blockly.selected) { var previousConnection = Blockly.selected.previousConnection; var outputConnection = Blockly.selected.outputConnection; - // TODO: This still needs to work with blocks that have neither previous - // or output connection. + //TODO: This still needs to work with blocks that have neither previous + //or output connection. var connection = previousConnection ? previousConnection : outputConnection; var newAstNode = Blockly.ASTNode.createConnectionNode(connection); cursor.setLocation(newAstNode); @@ -641,9 +641,9 @@ Blockly.Navigation.handleEnterForWS = function() { } }; -/** ******************* */ -/** Helper Functions * */ -/** ******************* */ +/**********************/ +/** Helper Functions **/ +/**********************/ /** @@ -730,7 +730,7 @@ Blockly.Navigation.toolboxKeyHandler = function(e) { Blockly.Navigation.log('D: Toolbox : Go to flyout'); return true; } else if (e.keyCode === goog.events.KeyCodes.ENTER) { - // TODO: focus on flyout OR open if the category is nested + //TODO: focus on flyout OR open if the category is nested return true; } else if (e.keyCode === goog.events.KeyCodes.E || e.keyCode === goog.events.KeyCodes.ESC) { diff --git a/core/renderers/block_rendering_rewrite/highlight_constants.js b/core/renderers/block_rendering_rewrite/highlight_constants.js index 77692a93c..340aadc2d 100644 --- a/core/renderers/block_rendering_rewrite/highlight_constants.js +++ b/core/renderers/block_rendering_rewrite/highlight_constants.js @@ -140,6 +140,7 @@ Blockly.blockRendering.highlightConstants.OUTSIDE_CORNER = (function() { }; })(); + Blockly.blockRendering.highlightConstants.PUZZLE_TAB = (function() { var width = Blockly.blockRendering.constants.TAB_WIDTH; var height = Blockly.blockRendering.constants.TAB_HEIGHT; diff --git a/core/toolbox.js b/core/toolbox.js index b3006dc0e..d0619276d 100644 --- a/core/toolbox.js +++ b/core/toolbox.js @@ -173,7 +173,7 @@ Blockly.Toolbox.prototype.init = function() { Blockly.hideChaff(true); } Blockly.Touch.clearTouchIdentifier(); // Don't block future drags. - }, /* opt_noCaptureIdentifier */ false, /* opt_noPreventDefault */ true); + }, /*opt_noCaptureIdentifier*/ false, /*opt_noPreventDefault*/ true); var workspaceOptions = { disabledPatternId: workspace.options.disabledPatternId, parentWorkspace: workspace, diff --git a/core/touch_gesture.js b/core/touch_gesture.js index 019fb8fb0..780579cf1 100644 --- a/core/touch_gesture.js +++ b/core/touch_gesture.js @@ -127,13 +127,13 @@ Blockly.TouchGesture.prototype.doStart = function(e) { Blockly.TouchGesture.prototype.bindMouseEvents = function(e) { this.onStartWrapper_ = Blockly.bindEventWithChecks_( document, 'mousedown', null, this.handleStart.bind(this), - /* opt_noCaptureIdentifier */ true); + /*opt_noCaptureIdentifier*/ true); this.onMoveWrapper_ = Blockly.bindEventWithChecks_( document, 'mousemove', null, this.handleMove.bind(this), - /* opt_noCaptureIdentifier */ true); + /*opt_noCaptureIdentifier*/ true); this.onUpWrapper_ = Blockly.bindEventWithChecks_( document, 'mouseup', null, this.handleUp.bind(this), - /* opt_noCaptureIdentifier */ true); + /*opt_noCaptureIdentifier*/ true); e.preventDefault(); e.stopPropagation(); diff --git a/core/workspace_comment_render_svg.js b/core/workspace_comment_render_svg.js index ccff7e0d9..de5bdec3a 100644 --- a/core/workspace_comment_render_svg.js +++ b/core/workspace_comment_render_svg.js @@ -257,7 +257,7 @@ Blockly.WorkspaceCommentSvg.prototype.addDeleteDom_ = function() { * @private */ Blockly.WorkspaceCommentSvg.prototype.resizeMouseDown_ = function(e) { - // this.promote_(); + //this.promote_(); this.unbindDragEvents_(); if (Blockly.utils.isRightButton(e)) { // No right-click. @@ -335,7 +335,7 @@ Blockly.WorkspaceCommentSvg.prototype.unbindDragEvents_ = function() { * @param {!Event} e Mouse up event. * @private */ -Blockly.WorkspaceCommentSvg.prototype.resizeMouseUp_ = function(/* e */) { +Blockly.WorkspaceCommentSvg.prototype.resizeMouseUp_ = function(/*e*/) { Blockly.Touch.clearTouchIdentifier(); this.unbindDragEvents_(); }; diff --git a/core/workspace_svg.js b/core/workspace_svg.js index 42820ef96..215dad9fa 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -27,7 +27,7 @@ goog.provide('Blockly.WorkspaceSvg'); // TODO(scr): Fix circular dependencies -// goog.require('Blockly.BlockSvg'); +//goog.require('Blockly.BlockSvg'); goog.require('Blockly.ConnectionDB'); goog.require('Blockly.constants'); goog.require('Blockly.CursorSvg'); From b98b433dff04f74f3149a9f1b141ea562bff8f62 Mon Sep 17 00:00:00 2001 From: kozbial Date: Thu, 1 Aug 2019 11:43:23 -0700 Subject: [PATCH 4/6] Reverting blockly.js edit. --- core/blockly.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/blockly.js b/core/blockly.js index 0ea4f0fee..6e3a3ddd8 100644 --- a/core/blockly.js +++ b/core/blockly.js @@ -38,7 +38,7 @@ goog.require('Blockly.FieldCheckbox'); goog.require('Blockly.FieldColour'); // Date picker commented out since it increases footprint by 60%. // Add it only if you need it. -// goog.require('Blockly.FieldDate'); +//goog.require('Blockly.FieldDate'); goog.require('Blockly.FieldDropdown'); goog.require('Blockly.FieldLabelSerializable'); goog.require('Blockly.FieldImage'); From 9ba91980e5dbe5c8eff6e91a892a1a66def91e31 Mon Sep 17 00:00:00 2001 From: kozbial Date: Thu, 1 Aug 2019 13:01:57 -0700 Subject: [PATCH 5/6] Addressing PR comments and refactoring path constants. --- .../block_render_draw.js | 12 ++++--- .../block_render_draw_highlight.js | 15 ++++----- .../block_render_info.js | 4 ++- .../block_rendering_constants.js | 33 ++++++++++++------- .../highlight_constants.js | 10 ++++++ .../block_rendering_rewrite/measurables.js | 5 +-- 6 files changed, 52 insertions(+), 27 deletions(-) diff --git a/core/renderers/block_rendering_rewrite/block_render_draw.js b/core/renderers/block_rendering_rewrite/block_render_draw.js index 8f3ea1337..c9b683632 100644 --- a/core/renderers/block_rendering_rewrite/block_render_draw.js +++ b/core/renderers/block_rendering_rewrite/block_render_draw.js @@ -103,7 +103,7 @@ Blockly.blockRendering.Drawer.prototype.drawOutline_ = function() { this.drawTop_(); for (var r = 1; r < this.info_.rows.length - 1; r++) { var row = this.info_.rows[r]; - if (!row.isSpacer() && this.info_.isCollapsed) { + if (row.hasJaggedEdge) { this.drawJaggedEdge_(row); } else if (row.hasStatement) { this.drawStatementInput_(row); @@ -156,11 +156,13 @@ Blockly.blockRendering.Drawer.prototype.drawTop_ = function() { * @private */ Blockly.blockRendering.Drawer.prototype.drawJaggedEdge_ = function(row) { - this.highlighter_.drawJaggedEdge_(row); - this.steps_.push(Blockly.blockRendering.constants.JAGGED_TEETH); - var remainder = row.height - Blockly.blockRendering.constants.JAGGED_TEETH_HEIGHT; + if (this.highlighter_) { + this.highlighter_.drawJaggedEdge_(row); + } + this.steps_.push(Blockly.blockRendering.constants.JAGGED_TEETH.path); + var remainder = + row.height - Blockly.blockRendering.constants.JAGGED_TEETH.height; this.steps_.push('v', remainder); - console.log('remainder: ' + remainder); }; /** 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 6438058ee..b1ccc91ad 100644 --- a/core/renderers/block_rendering_rewrite/block_render_draw_highlight.js +++ b/core/renderers/block_rendering_rewrite/block_render_draw_highlight.js @@ -67,6 +67,8 @@ Blockly.blockRendering.Highlighter = function(info, pathObject) { this.puzzleTabPaths_ = Blockly.blockRendering.highlightConstants.PUZZLE_TAB; this.notchPaths_ = Blockly.blockRendering.highlightConstants.NOTCH; this.startPaths_ = Blockly.blockRendering.highlightConstants.START_HAT; + this.jaggedTeethPaths_ = + Blockly.blockRendering.highlightConstants.JAGGED_TEETH; }; Blockly.blockRendering.Highlighter.prototype.drawTopCorner = function(row) { @@ -93,15 +95,12 @@ Blockly.blockRendering.Highlighter.prototype.drawTopCorner = function(row) { Blockly.blockRendering.Highlighter.prototype.drawJaggedEdge_ = function(row) { if (this.info_.RTL) { - var remainder = - row.height - Blockly.blockRendering.constants.JAGGED_TEETH_HEIGHT - this.highlightOffset_; this.steps_.push('H', row.width - this.highlightOffset_); - var steps = - Blockly.utils.svgPaths.lineTo(5.1, 2.6) + - Blockly.utils.svgPaths.moveBy(-10.2, 6.8) + - Blockly.utils.svgPaths.lineTo(5.1, 2.6) + - Blockly.utils.svgPaths.lineOnAxis('v', remainder); - this.steps_.push(steps); + this.steps_.push(this.jaggedTeethPaths_.pathLeft); + var remainder = + row.height - Blockly.blockRendering.constants.JAGGED_TEETH.height - + this.highlightOffset_; + this.steps_.push(Blockly.utils.svgPaths.lineOnAxis('v', remainder)); } }; diff --git a/core/renderers/block_rendering_rewrite/block_render_info.js b/core/renderers/block_rendering_rewrite/block_render_info.js index 69c70af81..11920b7a9 100644 --- a/core/renderers/block_rendering_rewrite/block_render_info.js +++ b/core/renderers/block_rendering_rewrite/block_render_info.js @@ -111,7 +111,7 @@ Blockly.blockRendering.RenderInfo = function(block) { /** * An array of measureable objects containing hidden icons. - * @type {Array} + * @type {!Array.} */ this.hiddenIcons = []; @@ -191,6 +191,7 @@ Blockly.blockRendering.RenderInfo.prototype.createRows_ = function() { } if (this.isCollapsed) { + activeRow.hasJaggedEdge = true; activeRow.elements.push(new Blockly.blockRendering.JaggedEdge()); } @@ -458,6 +459,7 @@ Blockly.blockRendering.RenderInfo.prototype.getInRowSpacing_ = function(prev, ne return Blockly.blockRendering.constants.LARGE_PADDING; } + // Spacing between anything and a jagged edge. if (next.isJaggedEdge()) { return Blockly.blockRendering.constants.LARGE_PADDING; } diff --git a/core/renderers/block_rendering_rewrite/block_rendering_constants.js b/core/renderers/block_rendering_rewrite/block_rendering_constants.js index de53cda26..e82ab67c7 100644 --- a/core/renderers/block_rendering_rewrite/block_rendering_constants.js +++ b/core/renderers/block_rendering_rewrite/block_rendering_constants.js @@ -141,17 +141,6 @@ Blockly.blockRendering.constants.START_POINT = Blockly.utils.svgPaths.moveBy(0, Blockly.blockRendering.constants.TOP_LEFT_CORNER_START = 'm 0,' + Blockly.blockRendering.constants.CORNER_RADIUS; -/** - * SVG path for drawing jagged teeth at the end of collapsed blocks. - * @const - */ -Blockly.blockRendering.constants.JAGGED_TEETH = Blockly.utils.svgPaths.line( - [ - Blockly.utils.svgPaths.point(6, 3), - Blockly.utils.svgPaths.point(-12, 6), - Blockly.utils.svgPaths.point(6, 3) - ]); - /** * Height of SVG path for jagged teeth at the end of collapsed blocks. * @const @@ -163,6 +152,28 @@ Blockly.blockRendering.constants.JAGGED_TEETH_HEIGHT = 12; */ Blockly.blockRendering.constants.JAGGED_TEETH_WIDTH = 6; +/** + * SVG path for drawing jagged teeth at the end of collapsed blocks. + * @const + */ +Blockly.blockRendering.constants.JAGGED_TEETH = (function() { + var height = Blockly.blockRendering.constants.JAGGED_TEETH_HEIGHT; + var width = Blockly.blockRendering.constants.JAGGED_TEETH_WIDTH; + + var mainPath = + Blockly.utils.svgPaths.line( + [ + Blockly.utils.svgPaths.point(6, 3), + Blockly.utils.svgPaths.point(-12, 6), + Blockly.utils.svgPaths.point(6, 3) + ]); + return { + height: height, + width: width, + path: mainPath + }; +})(); + /** * Information about the hat on a start block. */ diff --git a/core/renderers/block_rendering_rewrite/highlight_constants.js b/core/renderers/block_rendering_rewrite/highlight_constants.js index 340aadc2d..bd8ac7f32 100644 --- a/core/renderers/block_rendering_rewrite/highlight_constants.js +++ b/core/renderers/block_rendering_rewrite/highlight_constants.js @@ -205,6 +205,16 @@ Blockly.blockRendering.highlightConstants.NOTCH = (function() { }; })(); +Blockly.blockRendering.highlightConstants.JAGGED_TEETH = (function() { + var pathLeft = + Blockly.utils.svgPaths.lineTo(5.1, 2.6) + + Blockly.utils.svgPaths.moveBy(-10.2, 6.8) + + Blockly.utils.svgPaths.lineTo(5.1, 2.6); + return { + pathLeft: pathLeft + }; +})(); + Blockly.blockRendering.highlightConstants.START_HAT = (function() { var pathRtl = Blockly.utils.svgPaths.moveBy(25, -8.7) + diff --git a/core/renderers/block_rendering_rewrite/measurables.js b/core/renderers/block_rendering_rewrite/measurables.js index 0be8a3058..f2c81fefe 100644 --- a/core/renderers/block_rendering_rewrite/measurables.js +++ b/core/renderers/block_rendering_rewrite/measurables.js @@ -197,8 +197,8 @@ goog.inherits(Blockly.blockRendering.Icon, Blockly.blockRendering.Measurable); Blockly.blockRendering.JaggedEdge = function() { Blockly.blockRendering.JaggedEdge.superClass_.constructor.call(this); this.type = 'jagged edge'; - this.height = Blockly.blockRendering.constants.JAGGED_TEETH_HEIGHT; - this.width = Blockly.blockRendering.constants.JAGGED_TEETH_WIDTH; + this.height = Blockly.blockRendering.constants.JAGGED_TEETH.height; + this.width = Blockly.blockRendering.constants.JAGGED_TEETH.width; }; goog.inherits(Blockly.blockRendering.JaggedEdge, Blockly.blockRendering.Measurable); @@ -411,6 +411,7 @@ Blockly.blockRendering.Row = function() { this.hasStatement = false; this.hasInlineInput = false; this.hasDummyInput = false; + this.hasJaggedEdge = false; }; Blockly.blockRendering.Row.prototype.isSpacer = function() { From eb3cb76300d50fa4e4c0270fd1bb537e9f99baa7 Mon Sep 17 00:00:00 2001 From: kozbial Date: Fri, 2 Aug 2019 14:16:52 -0700 Subject: [PATCH 6/6] Addressing PR comment. --- .../block_rendering_rewrite/block_render_draw_highlight.js | 3 +-- 1 file changed, 1 insertion(+), 2 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 b1ccc91ad..234244450 100644 --- a/core/renderers/block_rendering_rewrite/block_render_draw_highlight.js +++ b/core/renderers/block_rendering_rewrite/block_render_draw_highlight.js @@ -98,8 +98,7 @@ Blockly.blockRendering.Highlighter.prototype.drawJaggedEdge_ = function(row) { this.steps_.push('H', row.width - this.highlightOffset_); this.steps_.push(this.jaggedTeethPaths_.pathLeft); var remainder = - row.height - Blockly.blockRendering.constants.JAGGED_TEETH.height - - this.highlightOffset_; + row.height - this.jaggedTeethPaths_.height - this.highlightOffset_; this.steps_.push(Blockly.utils.svgPaths.lineOnAxis('v', remainder)); } };