Blockly.blockRendering. RenderInfo
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.
Constructor
RenderInfo
new RenderInfo(renderer, block)
Parameter |
|
---|---|
renderer |
The renderer in use. Value must not be null. |
block |
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_
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.
inputRows
non-null Array of non-null Blockly.blockRendering.InputRow
An array of input rows on the block.
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_
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_
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 |
The row to add padding to. Value must not be null. |
missingSpace |
number How much padding to add. |
addElemSpacing_
addElemSpacing_()
Add horizontal spacing between and around elements within each row.
addInput_
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 |
The input to record information about. Value must not be null. |
activeRow |
The row that is currently being populated. Value must not be null. |
addRowSpacing_
addRowSpacing_()
Add spacers between rows and set their sizes.
alignRowElements_
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_
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_
computeBounds_()
Figure out where the right edge of the block and right edge of statement inputs should be placed.
createRows_
createRows_()
Create rows of Measurable objects representing all renderable parts of the block.
finalize_
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.
getDesiredRowWidth_
getDesiredRowWidth_(_row) returns number
Calculate the desired width of an input row.
Parameter |
|
---|---|
_row |
The input row. Value must not be null. |
- Returns
-
number
The desired width of the input row.
getElemCenterline_
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 |
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_
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
getRenderer() returns Blockly.blockRendering.Renderer
Get the block renderer in use.
- Returns
-
non-null Blockly.blockRendering.Renderer
The block renderer in use.
getSpacerRowHeight_
getSpacerRowHeight_(_prev, _next) returns number
Calculate the height of a spacer row.
Parameter |
|
---|---|
_prev |
The row before the spacer. Value must not be null. |
_next |
The row after the spacer. Value must not be null. |
- Returns
-
number
The desired height of the spacer row between these two rows.
getSpacerRowWidth_
getSpacerRowWidth_(_prev, _next) returns number
Calculate the width of a spacer row.
Parameter |
|
---|---|
_prev |
The row before the spacer. Value must not be null. |
_next |
The row after the spacer. Value must not be null. |
- Returns
-
number
The desired width of the spacer row between these two rows.
makeSpacerRow_
makeSpacerRow_(prev, next) returns Blockly.blockRendering.SpacerRow
Create a spacer row to go between prev and next, and set its size.
Parameter |
|
---|---|
prev |
The previous row. Value must not be null. |
next |
The next row. Value must not be null. |
- Returns
-
non-null Blockly.blockRendering.SpacerRow
The newly created spacer row.
measure
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_
populateBottomRow_()
Create all non-spacer elements that belong on the bottom row.
populateTopRow_
populateTopRow_()
Create all non-spacer elements that belong on the top row.
recordElemPositions_
recordElemPositions_(row)
Record final position information on elements on the given row, for use in drawing. At minimum this records xPos and centerline on each element.
Parameter |
|
---|---|
row |
The row containing the elements. Value must not be null. |
shouldStartNewRow_
shouldStartNewRow_(input, lastInput) returns boolean
Decide whether to start a new row between the two Blockly.Inputs.
Parameter |
|
---|---|
input |
The first input to consider Value must not be null. |
lastInput |
The input that follows. |
- Returns
-
boolean
True if the next input should be rendered on a new row.