Blockly. uiPosition
Utility functions for positioning UI elements.
Enumerations
bumpDirection
number
Enum for bump rules to use for dealing with collisions.
Value |
|
---|---|
UP |
|
DOWN |
horizontalPosition
number
Enum for horizontal positioning.
Value |
|
---|---|
LEFT |
|
RIGHT |
verticalPosition
number
Enum for vertical positioning.
Value |
|
---|---|
TOP |
|
BOTTOM |
Properties
bumpDirection
number
Enum for bump rules to use for dealing with collisions.
Value |
|
---|---|
UP |
|
DOWN |
horizontalPosition
number
Enum for horizontal positioning.
Value |
|
---|---|
LEFT |
|
RIGHT |
verticalPosition
number
Enum for vertical positioning.
Value |
|
---|---|
TOP |
|
BOTTOM |
Methods
bumpPositionRect
bumpPositionRect(startRect, margin, bumpDir, savedPositions) returns Blockly.utils.Rect
Returns a position Rect based on a starting position that is bumped so that it doesn't intersect with any of the provided savedPositions. This method does not check that the bumped position is still within bounds.
Parameter |
|
---|---|
startRect |
The starting position to use. Value must not be null. |
margin |
number The margin to use between elements when bumping. |
bumpDir |
bumpDirection The direction to bump if there is a collision with an existing UI element. Value must not be null. |
savedPositions |
Array of non-null Blockly.utils.Rect List of rectangles that represent the positions of UI elements already placed. Value must not be null. |
- Returns
-
non-null Blockly.utils.Rect
The suggested position rectangle.
getCornerOppositeToolbox
getCornerOppositeToolbox(workspace, metrics) returns Position
Returns a corner position that is on the opposite side of the workspace from the toolbox. If in horizontal orientation, defaults to the bottom corner. If in vertical orientation, defaults to the right corner.
Parameter |
|
---|---|
workspace |
The workspace. Value must not be null. |
metrics |
Blockly.MetricsManager.UiMetrics The workspace metrics. Value must not be null. |
- Returns
-
non-null Position
The suggested corner position.
getStartPositionRect
getStartPositionRect(position, size, horizontalPadding, verticalPadding, metrics, workspace) returns Blockly.utils.Rect
Returns a rectangle representing reasonable position for where to place a UI element of the specified size given the restraints and locations of the scrollbars. This method does not take into account any already placed UI elements.
Parameter |
|
---|---|
position |
Position The starting horizontal and vertical position. Value must not be null. |
size |
the size of the UI element to get a start position for. Value must not be null. |
horizontalPadding |
number The horizontal padding to use. |
verticalPadding |
number The vertical padding to use. |
metrics |
Blockly.MetricsManager.UiMetrics The workspace UI metrics. Value must not be null. |
workspace |
The workspace. Value must not be null. |
- Returns
-
non-null Blockly.utils.Rect
The suggested start position.
Abstract type
Position
{horizontal: non-null horizontalPosition, vertical: non-null verticalPosition}
An object defining a horizontal and vertical positioning.