Class: Renderer

Constructor

Renderer

new Renderer(name)

The base class for a block renderer.

Parameter

name

string

The renderer name.

Implements
Blockly.IRegistrable

Properties

constants_

non-null Blockly.blockRendering.ConstantProvider

constants_

non-null Blockly.blockRendering.ConstantProvider

name

package

string

The renderer name.

overrides

package

nullable Object

Rendering constant overrides, passed in through options.

Methods

createDom

package

createDom(svg, theme)

Create any DOM elements that this renderer needs.

Parameter

svg

SVGElement

The root of the workspace's SVG.

Value must not be null.

theme

Blockly.Theme

The workspace theme object.

Value must not be null.

dispose

package

dispose()

Dispose of this renderer. Delete all DOM elements that this renderer and its constants created.

getClassName

package

getClassName() returns string

Gets the class name that identifies this renderer.

Returns

string The CSS class name.

getConnectionPreviewMethod

package

getConnectionPreviewMethod(closest, local, topBlock) returns Blockly.InsertionMarkerManager.PREVIEW_TYPE

Chooses a connection preview method based on the available connection, the current dragged connection, and the block being dragged.

Parameter

closest

Blockly.RenderedConnection

The available connection.

Value must not be null.

local

Blockly.RenderedConnection

The connection currently being dragged.

Value must not be null.

topBlock

Blockly.BlockSvg

The block currently being dragged.

Value must not be null.

Returns

non-null Blockly.InsertionMarkerManager.PREVIEW_TYPE The preview type to display.

getConstants

package

getConstants() returns Blockly.blockRendering.ConstantProvider

Get the current renderer's constant provider. We assume that when this is called, the renderer has already been initialized.

Returns

non-null Blockly.blockRendering.ConstantProvider The constant provider.

init

package

init(theme, opt_rendererOverrides)

Initialize the renderer.

Parameter

theme

Blockly.Theme

The workspace theme object.

Value must not be null.

opt_rendererOverrides

Optional

Object

Rendering constant overrides.

makeConstants_

protected

makeConstants_() returns Blockly.blockRendering.ConstantProvider

Create a new instance of the renderer's constant provider.

Returns

non-null Blockly.blockRendering.ConstantProvider The constant provider.

makeDebugger_

protected

makeDebugger_() returns Blockly.blockRendering.Debug

Create a new instance of the renderer's debugger.

Returns

non-null Blockly.blockRendering.Debug The renderer debugger.

makeDrawer_

protected

makeDrawer_(block, info) returns Blockly.blockRendering.Drawer

Create a new instance of the renderer's drawer.

Parameter

block

Blockly.BlockSvg

The block to render.

Value must not be null.

info

Blockly.blockRendering.RenderInfo

An object containing all information needed to render this block.

Value must not be null.

Returns

non-null Blockly.blockRendering.Drawer The drawer.

makeMarkerDrawer

package

makeMarkerDrawer(workspace, marker) returns Blockly.blockRendering.MarkerSvg

Create a new instance of the renderer's marker drawer.

Parameter

workspace

Blockly.WorkspaceSvg

The workspace the marker belongs to.

Value must not be null.

marker

Blockly.Marker

The marker.

Value must not be null.

Returns

non-null Blockly.blockRendering.MarkerSvg The object in charge of drawing the marker.

makePathObject

package

makePathObject(root, style) returns Blockly.blockRendering.IPathObject

Create a new instance of a renderer path object.

Parameter

root

SVGElement

The root SVG element.

Value must not be null.

style

Blockly.Theme.BlockStyle

The style object to use for colouring.

Value must not be null.

Returns

non-null Blockly.blockRendering.IPathObject The renderer path object.

makeRenderInfo_

protected

makeRenderInfo_(block) returns Blockly.blockRendering.RenderInfo

Create a new instance of the renderer's render info object.

Parameter

block

Blockly.BlockSvg

The block to measure.

Value must not be null.

Returns

non-null Blockly.blockRendering.RenderInfo The render info object.

orphanCanConnectAtEnd

package

orphanCanConnectAtEnd(topBlock, orphanBlock, localType) returns boolean

Checks if an orphaned block can connect to the "end" of the topBlock's block-clump. If the clump is a row the end is the last input. If the clump is a stack, the end is the last next connection. If the clump is neither, then this returns false.

Parameter

topBlock

Blockly.BlockSvg

The top block of the block clump we want to try and connect to.

Value must not be null.

orphanBlock

Blockly.BlockSvg

The orphan block that wants to find a home.

Value must not be null.

localType

number

The type of the connection being dragged.

Returns

boolean Whether there is a home for the orphan or not.

refreshDom

package

refreshDom(svg, theme)

Refresh the renderer after a theme change.

Parameter

svg

SVGElement

The root of the workspace's SVG.

Value must not be null.

theme

Blockly.Theme

The workspace theme object.

Value must not be null.

render

package

render(block)

Render the block.

Parameter

block

Blockly.BlockSvg

The block to render.

Value must not be null.

shouldHighlightConnection

package

shouldHighlightConnection(_conn) returns boolean

Determine whether or not to highlight a connection.

Parameter

_conn

Blockly.Connection

The connection to determine whether or not to highlight.

Returns

boolean True if we should highlight the connection.