Class: RenderInfo

Constructor

RenderInfo

new RenderInfo(renderer, block)

An object containing all sizing information needed to draw this block.

This measure pass does not propagate changes to the block (although fields may choose to rerender when getSize() is called). However, calling it repeatedly may be expensive.

Parameter

renderer

Blockly.blockRendering.Renderer

The renderer in use.

Value must not be null.

block

Blockly.BlockSvg

The block to measure.

Value must not be null.

Properties

bottomRow

non-null Blockly.blockRendering.BottomRow

An object with rendering information about the bottom row of the block.

constants_

protected

non-null Blockly.blockRendering.ConstantProvider

The renderer's constant provider.

height

number

The height of the rendered block, including child blocks.

hiddenIcons

non-null Array of non-null Blockly.blockRendering.Icon

An array of measurable objects containing hidden icons.

isCollapsed

boolean

Whether the block is collapsed.

isInline

boolean

Whether the block should be rendered as a single line, either because it's inline or because it has been collapsed.

isInsertionMarker

boolean

Whether the block is an insertion marker. Insertion markers are the same shape as normal blocks, but don't show fields.

outputConnection

Blockly.blockRendering.OutputConnection

A measurable representing the output connection if the block has one. Otherwise null.

renderer_

protected

non-null Blockly.blockRendering.Renderer

The block renderer in use.

rows

non-null Array of non-null Blockly.blockRendering.Row

An array of Row objects containing sizing information.

RTL

boolean

True if the block should be rendered right-to-left.

statementEdge

number

topRow

non-null Blockly.blockRendering.TopRow

An object with rendering information about the top row of the block.

width

number

The width of the rendered block, excluding child blocks. This is the right edge of the block when rendered LTR.

widthWithChildren

number

The width of the rendered block, including child blocks.

Methods

addAlignmentPadding_

protected

addAlignmentPadding_(row, missingSpace)

Modify the given row to add the given amount of padding around its fields. The exact location of the padding is based on the alignment property of the last input in the field.

Parameter

row

Blockly.blockRendering.Row

The row to add padding to.

missingSpace

number

How much padding to add.

addElemSpacing_

protected

addElemSpacing_()

Add horizontal spacing between and around elements within each row.

addInput_

protected

addInput_(input, activeRow)

Add an input element to the active row, if needed, and record the type of the input on the row.

Parameter

input

Blockly.Input

The input to record information about.

Value must not be null.

activeRow

Blockly.blockRendering.Row

The row that is currently being populated.

Value must not be null.

addRowSpacing_

protected

addRowSpacing_()

Add spacers between rows and set their sizes.

alignRowElements_

protected

alignRowElements_()

Extra spacing may be necessary to make sure that the right sides of all rows line up. This can only be calculated after a first pass to calculate the sizes of all rows.

alignStatementRow_

protected

alignStatementRow_(row)

Align the elements of a statement row based on computed bounds. Unlike other types of rows, statement rows add space in multiple places.

Parameter

row

Blockly.blockRendering.InputRow

The statement row to resize.

Value must not be null.

computeBounds_

protected

computeBounds_()

Figure out where the right edge of the block and right edge of statement inputs should be placed.

createRows_

protected

createRows_()

Create rows of Measurable objects representing all renderable parts of the block.

finalize_

protected

finalize_()

Make any final changes to the rendering information object. In particular, store the y position of each row, and record the height of the full block.

getElemCenterline_

protected

getElemCenterline_(row, elem) returns number

Calculate the centerline of an element in a rendered row. This base implementation puts the centerline at the middle of the row vertically, with no special cases. You will likely need extra logic to handle (at minimum) top and bottom rows.

Parameter

row

Blockly.blockRendering.Row

The row containing the element.

Value must not be null.

elem

Blockly.blockRendering.Measurable

The element to place.

Value must not be null.

Returns

number The desired centerline of the given element, as an offset from the top left of the block.

getInRowSpacing_

protected

getInRowSpacing_(prev, next) returns number

Calculate the width of a spacer element in a row based on the previous and next elements in that row. For instance, extra padding is added between two editable fields.

Parameter

prev

Blockly.blockRendering.Measurable

The element before the spacer.

next

Blockly.blockRendering.Measurable

The element after the spacer.

Returns

number The size of the spacing between the two elements.

getRenderer

package

getRenderer() returns Blockly.blockRendering.Renderer

Get the block renderer in use.

Returns

non-null Blockly.blockRendering.Renderer The block renderer in use.

getSpacerRowHeight_

protected

getSpacerRowHeight_(_prev, _next) returns number

Calculate the height of a spacer row.

Parameter

_prev

Blockly.blockRendering.Row

The row before the spacer.

Value must not be null.

_next

Blockly.blockRendering.Row

The row after the spacer.

Value must not be null.

Returns

number The desired height of the spacer row between these two rows.

getSpacerRowWidth_

protected

getSpacerRowWidth_(_prev, _next) returns number

Calculate the width of a spacer row.

Parameter

_prev

Blockly.blockRendering.Row

The row before the spacer.

Value must not be null.

_next

Blockly.blockRendering.Row

The row after the spacer.

Value must not be null.

Returns

number The desired width of the spacer row between these two rows.

makeSpacerRow_

protected

makeSpacerRow_(prev, next) returns Blockly.blockRendering.SpacerRow

Create a spacer row to go between prev and next, and set its size.

Parameter

prev

Blockly.blockRendering.Row

The previous row.

Value must not be null.

next

Blockly.blockRendering.Row

The next row.

Value must not be null.

Returns

non-null Blockly.blockRendering.SpacerRow The newly created spacer row.

measure

package

measure()

Populate and return an object containing all sizing information needed to draw this block.

This measure pass does not propagate changes to the block (although fields may choose to rerender when getSize() is called). However, calling it repeatedly may be expensive.

populateBottomRow_

package

populateBottomRow_()

Create all non-spacer elements that belong on the bottom row.

populateTopRow_

package

populateTopRow_()

Create all non-spacer elements that belong on the top row.

shouldStartNewRow_

protected

shouldStartNewRow_(input, lastInput) returns boolean

Decide whether to start a new row between the two Blockly.Inputs.

Parameter

input

Blockly.Input

The first input to consider

Value must not be null.

lastInput

Blockly.Input

The input that follows.

Returns

boolean True if the next input should be rendered on a new row.