Class: FlyoutMetricsManager
Defined in: packages/blockly/core/flyout_metrics_manager.ts:22
Calculates metrics for a flyout's workspace. The metrics are mainly used to size scrollbars for the flyout.
Extends
Properties index
| Property | Description |
|---|---|
| flyout_ | The flyout that owns the workspace to calculate metrics for. |
| workspace_ | The workspace to calculate metrics for. |
Methods index
| Method | Description |
|---|---|
| getContentMetrics | Gets content metrics in either pixel or workspace coordinates. The content area is a rectangle around all the top bounded elements on the workspace (workspace comments and blocks). |
| getScrollMetrics | Returns the metrics for the scroll area of the workspace. |
| getDimensionsPx_ | Gets the dimensions of the given workspace component, in pixel coordinates. |
| getFlyoutMetrics | Gets the width and the height of the flyout in pixel coordinates. By default, will get metrics for either a simple flyout (owned directly by the workspace) or for the flyout owned by the toolbox. If you pass opt_own as true then only metrics for the simple flyout will be returned, and it will return 0 for the width and height if the workspace has a category toolbox instead of a simple toolbox. |
| getToolboxMetrics | Gets the width, height and position of the toolbox on the workspace in pixel coordinates. Returns 0 for the width and height if the workspace has a simple toolbox instead of a category toolbox. To get the width and height of a simple toolbox, see (MetricsManager:class).getFlyoutMetrics. |
| getSvgMetrics | Gets the width and height of the workspace's parent SVG element in pixel coordinates. This area includes the toolbox and the visible workspace area. |
| getAbsoluteMetrics | Gets the absolute left and absolute top in pixel coordinates. This is where the visible workspace starts in relation to the SVG container. |
| getViewMetrics | Gets the metrics for the visible workspace in either pixel or workspace coordinates. The visible workspace does not include the toolbox or flyout. |
| getComputedFixedEdges_ | Computes the fixed edges of the scroll area. |
| getPaddedContent_ | Returns the content area with added padding. |
| getUiMetrics | Returns common metrics used by UI elements. |
| getMetrics | Returns an object with all the metrics required to size scrollbars for a top level workspace. The following properties are computed: Coordinate system: pixel coordinates, -left, -up, +right, +down .viewHeight: Height of the visible portion of the workspace. .viewWidth: Width of the visible portion of the workspace. .contentHeight: Height of the content. .contentWidth: Width of the content. .scrollHeight: Height of the scroll area. .scrollWidth: Width of the scroll area. .svgHeight: Height of the Blockly div (the view + the toolbox, simple or otherwise), .svgWidth: Width of the Blockly div (the view + the toolbox, simple or otherwise), .viewTop: Top-edge of the visible portion of the workspace, relative to the workspace origin. .viewLeft: Left-edge of the visible portion of the workspace, relative to the workspace origin. .contentTop: Top-edge of the content, relative to the workspace origin. .contentLeft: Left-edge of the content relative to the workspace origin. .scrollTop: Top-edge of the scroll area, relative to the workspace origin. .scrollLeft: Left-edge of the scroll area relative to the workspace origin. .absoluteTop: Top-edge of the visible portion of the workspace, relative to the blocklyDiv. .absoluteLeft: Left-edge of the visible portion of the workspace, relative to the blocklyDiv. .toolboxWidth: Width of the toolbox, if it exists. Otherwise zero. .toolboxHeight: Height of the toolbox, if it exists. Otherwise zero. .flyoutWidth: Width of the flyout if it is always open. Otherwise zero. .flyoutHeight: Height of the flyout if it is always open. Otherwise zero. .toolboxPosition: Top, bottom, left or right. Use TOOLBOX_AT constants to compare. |
Constructors
Constructor
new FlyoutMetricsManager(workspace, flyout): FlyoutMetricsManager;
Defined in: packages/blockly/core/flyout_metrics_manager.ts:30
Parameters
| Parameter | Type | Description |
|---|---|---|
workspace | WorkspaceSvg | The flyout's workspace. |
flyout | IFlyout | The flyout. |
Returns
FlyoutMetricsManager
Overrides
Properties
flyout_
protected flyout_: IFlyout;
Defined in: packages/blockly/core/flyout_metrics_manager.ts:24
The flyout that owns the workspace to calculate metrics for.
workspace_
protected readonly workspace_: WorkspaceSvg;
Defined in: packages/blockly/core/metrics_manager.ts:28
The workspace to calculate metrics for.
Inherited from
Methods
getContentMetrics()
getContentMetrics(opt_getWorkspaceCoordinates?): object;
Defined in: packages/blockly/core/flyout_metrics_manager.ts:55
Gets content metrics in either pixel or workspace coordinates. The content area is a rectangle around all the top bounded elements on the workspace (workspace comments and blocks).
Parameters
| Parameter | Type | Description |
|---|---|---|
opt_getWorkspaceCoordinates? | boolean | True to get the content metrics in workspace coordinates, false to get them in pixel coordinates. |
Returns
object
The metrics for the content container.
height
height: number;
width
width: number;
top
top: number;
left
left: number;
Overrides
MetricsManager.getContentMetrics
getScrollMetrics()
getScrollMetrics(
opt_getWorkspaceCoordinates?,
opt_viewMetrics?,
opt_contentMetrics?
): object;
Defined in: packages/blockly/core/flyout_metrics_manager.ts:68
Returns the metrics for the scroll area of the workspace.
Parameters
| Parameter | Type | Description |
|---|---|---|
opt_getWorkspaceCoordinates? | boolean | True to get the scroll metrics in workspace coordinates, false to get them in pixel coordinates. |
opt_viewMetrics? | ContainerRegion | The view metrics if they have been previously computed. Passing in null may cause the view metrics to be computed again, if it is needed. |
opt_contentMetrics? | ContainerRegion | The content metrics if they have been previously computed. Passing in null may cause the content metrics to be computed again, if it is needed. |
Returns
object
The metrics for the scroll container.
height
height: number;
width
width: number;
top
top: number = 0;
left
left: number = 0;
Overrides
MetricsManager.getScrollMetrics
getDimensionsPx_()
protected getDimensionsPx_(elem): Size;
Defined in: packages/blockly/core/metrics_manager.ts:43
Gets the dimensions of the given workspace component, in pixel coordinates.
Parameters
| Parameter | Type | Description |
|---|---|---|
elem | | IFlyout | IToolbox | null | The element to get the dimensions of, or null. It should be a toolbox or flyout, and should implement getWidth() and getHeight(). |
Returns
An object containing width and height attributes, which will both be zero if elem did not exist.
Inherited from
MetricsManager.getDimensionsPx_
getFlyoutMetrics()
getFlyoutMetrics(opt_own?): ToolboxMetrics;
Defined in: packages/blockly/core/metrics_manager.ts:64
Gets the width and the height of the flyout in pixel
coordinates. By default, will get metrics for either a simple flyout (owned
directly by the workspace) or for the flyout owned by the toolbox. If you
pass opt_own as true then only metrics for the simple flyout will be
returned, and it will return 0 for the width and height if the workspace
has a category toolbox instead of a simple toolbox.
Parameters
| Parameter | Type | Description |
|---|---|---|
opt_own? | boolean | Whether to only return the workspace's own flyout metrics. |
Returns
The width and height of the flyout.
Inherited from
MetricsManager.getFlyoutMetrics
getToolboxMetrics()
getToolboxMetrics(): ToolboxMetrics;
Defined in: packages/blockly/core/metrics_manager.ts:83
Gets the width, height and position of the toolbox on the workspace in pixel coordinates. Returns 0 for the width and height if the workspace has a simple toolbox instead of a category toolbox. To get the width and height of a simple toolbox, see (MetricsManager:class).getFlyoutMetrics.
Returns
The object with the width, height and position of the toolbox.
Inherited from
MetricsManager.getToolboxMetrics
getSvgMetrics()
getSvgMetrics(): Size;
Defined in: packages/blockly/core/metrics_manager.ts:101
Gets the width and height of the workspace's parent SVG element in pixel coordinates. This area includes the toolbox and the visible workspace area.
Returns
The width and height of the workspace's parent SVG element.
Inherited from
getAbsoluteMetrics()
getAbsoluteMetrics(): AbsoluteMetrics;
Defined in: packages/blockly/core/metrics_manager.ts:112
Gets the absolute left and absolute top in pixel coordinates. This is where the visible workspace starts in relation to the SVG container.
Returns
The absolute metrics for the workspace.
Inherited from
MetricsManager.getAbsoluteMetrics
getViewMetrics()
getViewMetrics(opt_getWorkspaceCoordinates?): ContainerRegion;
Defined in: packages/blockly/core/metrics_manager.ts:150
Gets the metrics for the visible workspace in either pixel or workspace coordinates. The visible workspace does not include the toolbox or flyout.
Parameters
| Parameter | Type | Description |
|---|---|---|
opt_getWorkspaceCoordinates? | boolean | True to get the view metrics in workspace coordinates, false to get them in pixel coordinates. |
Returns
The width, height, top and left of the viewport in either workspace coordinates or pixel coordinates.
Inherited from
getComputedFixedEdges_()
protected getComputedFixedEdges_(opt_viewMetrics?): FixedEdges;
Defined in: packages/blockly/core/metrics_manager.ts:227
Computes the fixed edges of the scroll area.
Parameters
| Parameter | Type | Description |
|---|---|---|
opt_viewMetrics? | ContainerRegion | The view metrics if they have been previously computed. Passing in null may cause the view metrics to be computed again, if it is needed. |
Returns
The fixed edges of the scroll area.
Inherited from
MetricsManager.getComputedFixedEdges_
getPaddedContent_()
protected getPaddedContent_(viewMetrics, contentMetrics): object;
Defined in: packages/blockly/core/metrics_manager.ts:259
Returns the content area with added padding.
Parameters
| Parameter | Type | Description |
|---|---|---|
viewMetrics | ContainerRegion | The view metrics. |
contentMetrics | ContainerRegion | The content metrics. |
Returns
object
The padded content area.
top
top: number;
bottom
bottom: number;
left
left: number;
right
right: number;
Inherited from
MetricsManager.getPaddedContent_
getUiMetrics()
getUiMetrics(): UiMetrics;
Defined in: packages/blockly/core/metrics_manager.ts:344
Returns common metrics used by UI elements.
Returns
The UI metrics.
Inherited from
getMetrics()
getMetrics(): Metrics;
Defined in: packages/blockly/core/metrics_manager.ts:387
Returns an object with all the metrics required to size scrollbars for a top level workspace. The following properties are computed: Coordinate system: pixel coordinates, -left, -up, +right, +down .viewHeight: Height of the visible portion of the workspace. .viewWidth: Width of the visible portion of the workspace. .contentHeight: Height of the content. .contentWidth: Width of the content. .scrollHeight: Height of the scroll area. .scrollWidth: Width of the scroll area. .svgHeight: Height of the Blockly div (the view + the toolbox, simple or otherwise), .svgWidth: Width of the Blockly div (the view + the toolbox, simple or otherwise), .viewTop: Top-edge of the visible portion of the workspace, relative to the workspace origin. .viewLeft: Left-edge of the visible portion of the workspace, relative to the workspace origin. .contentTop: Top-edge of the content, relative to the workspace origin. .contentLeft: Left-edge of the content relative to the workspace origin. .scrollTop: Top-edge of the scroll area, relative to the workspace origin. .scrollLeft: Left-edge of the scroll area relative to the workspace origin. .absoluteTop: Top-edge of the visible portion of the workspace, relative to the blocklyDiv. .absoluteLeft: Left-edge of the visible portion of the workspace, relative to the blocklyDiv. .toolboxWidth: Width of the toolbox, if it exists. Otherwise zero. .toolboxHeight: Height of the toolbox, if it exists. Otherwise zero. .flyoutWidth: Width of the flyout if it is always open. Otherwise zero. .flyoutHeight: Height of the flyout if it is always open. Otherwise zero. .toolboxPosition: Top, bottom, left or right. Use TOOLBOX_AT constants to compare.
Returns
Contains size and position metrics of a top level workspace.