Class: MarkerSvg

Constructor

MarkerSvg

new MarkerSvg(workspace, constants, marker)

Class for a marker.

Parameter

workspace

Blockly.WorkspaceSvg

The workspace the marker belongs to.

Value must not be null.

constants

Blockly.blockRendering.ConstantProvider

The constants for the renderer.

Value must not be null.

marker

Blockly.Marker

The marker to draw.

Value must not be null.

Properties

CURSOR_CLASS

constant   static

string

The name of the CSS class for a cursor.

HEIGHT_MULTIPLIER

constant   static

number

What we multiply the height by to get the height of the marker. Only used for the block and block connections.

MARKER_CLASS

constant   static

string

The name of the CSS class for a marker.

colour_

string

The colour of the marker.

constants_

protected

Blockly.blockRendering.ConstantProvider

The constants necessary to draw the marker.

currentMarkerSvg

Element

The current SVG element for the marker.

Methods

applyColour_

protected

applyColour_(_curNode)

Apply the marker's colour.

Parameter

_curNode

Blockly.ASTNode

The node that we want to draw the marker for.

Value must not be null.

createDom

package

createDom() returns SVGElement

Create the DOM element for the marker.

Returns

non-null SVGElement The marker controls SVG group.

createDomInternal_

protected

createDomInternal_() returns Element

Create the marker SVG.

Returns

Element The SVG node created.

dispose

dispose()

Dispose of this marker.

draw

draw(oldNode, curNode)

Update the marker.

Parameter

oldNode

Blockly.ASTNode

The previous node the marker was on or null.

curNode

Blockly.ASTNode

The node that we want to draw the marker for.

getBlinkProperties_

protected

getBlinkProperties_() returns Object

Get the properties to make a marker blink.

Returns

non-null Object The object holding attributes to make the marker blink.

getMarker

getMarker() returns Blockly.Marker

Get the marker.

Returns

non-null Blockly.Marker The marker to draw for.

getSvgRoot

getSvgRoot() returns SVGElement

Return the root node of the SVG or null if none exists.

Returns

SVGElement The root SVG node.

hide

hide()

Hide the marker.

isCursor

isCursor() returns boolean

True if the marker should be drawn as a cursor, false otherwise. A cursor is drawn as a flashing line. A marker is drawn as a solid line.

Returns

boolean True if the marker is a cursor, false otherwise.

positionBlock_

protected

positionBlock_(width, markerOffset, markerHeight)

Position the marker for a block. Displays an outline of the top half of a rectangle around a block.

Parameter

width

number

The width of the block.

markerOffset

number

The extra padding for around the block.

markerHeight

number

The height of the marker.

positionInput_

protected

positionInput_(connection)

Position the marker for an input connection. Displays a filled in puzzle piece.

Parameter

connection

Blockly.RenderedConnection

The connection to position marker around.

Value must not be null.

positionLine_

protected

positionLine_(x, y, width)

Move and show the marker at the specified coordinate in workspace units. Displays a horizontal line.

Parameter

x

number

The new x, in workspace units.

y

number

The new y, in workspace units.

width

number

The new width, in workspace units.

positionOutput_

protected

positionOutput_(width, height, connectionShape)

Position the marker for an output connection. Displays a puzzle outline and the top and bottom path.

Parameter

width

number

The width of the block.

height

number

The height of the block.

connectionShape

Object

The shape object for the connection.

Value must not be null.

positionPrevious_

protected

positionPrevious_(width, markerOffset, markerHeight, connectionShape)

Position the marker for a previous connection. Displays a half rectangle with a notch in the top to represent the previous connection.

Parameter

width

number

The width of the block.

markerOffset

number

The offset of the marker from around the block.

markerHeight

number

The height of the marker.

connectionShape

Object

The shape object for the connection.

Value must not be null.

positionRect_

protected

positionRect_(x, y, width, height)

Move and show the marker at the specified coordinate in workspace units. Displays a filled in rectangle.

Parameter

x

number

The new x, in workspace units.

y

number

The new y, in workspace units.

width

number

The new width, in workspace units.

height

number

The new height, in workspace units.

setParent_

protected

setParent_(newParent)

Attaches the SVG root of the marker to the SVG group of the parent.

Parameter

newParent

Blockly.IASTNodeLocationSvg

The workspace, field, or block that the marker SVG element should be attached to.

Value must not be null.

showAtLocation_

protected

showAtLocation_(curNode)

Update the marker's visible state based on the type of curNode..

Parameter

curNode

Blockly.ASTNode

The node that we want to draw the marker for.

Value must not be null.

showCurrent_

protected

showCurrent_()

Show the current marker.

showWithBlock_

protected

showWithBlock_(curNode)

Position and display the marker for a block.

Parameter

curNode

Blockly.ASTNode

The node to draw the marker for.

Value must not be null.

showWithCoordinates_

protected

showWithCoordinates_(curNode)

Position and display the marker for a workspace coordinate. This is a horizontal line.

Parameter

curNode

Blockly.ASTNode

The node to draw the marker for.

Value must not be null.

showWithField_

protected

showWithField_(curNode)

Position and display the marker for a field. This is a box around the field.

Parameter

curNode

Blockly.ASTNode

The node to draw the marker for.

Value must not be null.

showWithInput_

protected

showWithInput_(curNode)

Position and display the marker for an input. This is a puzzle piece.

Parameter

curNode

Blockly.ASTNode

The node to draw the marker for.

Value must not be null.

showWithNext_

protected

showWithNext_(curNode)

Position and display the marker for a next connection. This is a horizontal line.

Parameter

curNode

Blockly.ASTNode

The node to draw the marker for.

Value must not be null.

showWithOutput_

protected

showWithOutput_(curNode)

Position and display the marker for an output connection.

Parameter

curNode

Blockly.ASTNode

The node to draw the marker for.

Value must not be null.

showWithPrevious_

protected

showWithPrevious_(curNode)

Position and display the marker for a previous connection.

Parameter

curNode

Blockly.ASTNode

The node to draw the marker for.

Value must not be null.

showWithStack_

protected

showWithStack_(curNode)

Position and display the marker for a stack. This is a box with extra padding around the entire stack of blocks.

Parameter

curNode

Blockly.ASTNode

The node to draw the marker for.

Value must not be null.