Files
blockly/core/interfaces/i_metrics_manager.ts
Beka Westberg 9d5dcc6e46 fix: circular dependencies (#6281)
* chore: fix circular dependencies w/ static workspace funcs

* remove preserved imports that aren't currently necessary (probably)

* fix circular dependency with workspaces and block using stub

* fix dependency between variables and xml by moving function to utils

* add stub for trashcan as well

* fix line endings from rebase

* fix goog/base order

* add trashcan patch

* fix: types of compose and decompose in block

* fix: workspace naming in toolbox

* chore: add jsdoc

* chore: restore registry comments to better positions

* chore: remove implementations in goog.js

* chore: fix types of stubs

* chore: remove added AnyDuringMigration casts

* chore: remove modifications to xml and variables

* chore: format

* chore: remove event requirements in workspace comments

* chore: fix circular dependency with xml and workspace comments

* fixup remove ContextMenu import

* chore: fix dependency between mutator and workspace

* chore: break circular dependency between names and procedures

* chore: get tests to run?

* chore: pr comments'

* chore: fix stubbing field registry fromJson

* chore: fix spying on fire

* chore: fix stubbing parts of connection checker

* chore: fix stubbing dialog

* chore: fix stubbing style

* chore: fix spying on duplicate

* chore: fix stubbing variables

* chore: fix stubbing copy

* chore: fix stubbing in workspace

* chore: remove unnecessary stubs

* chore: fix formatting

* chore: fix other formatting

* chore: add backwards compatible static properties to workspace

* chore: move static type properties

* chore: move and comment stubs

* chore: add newlines at EOF

* chore: improve errors for monkey patched functions

* chore: update comment with a pointer to the doc

* chore: update comment with a pointer to the doc

* chore: format
2022-07-28 15:26:38 -07:00

147 lines
5.7 KiB
TypeScript

/**
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview The interface for a metrics manager.
*/
/**
* The interface for a metrics manager.
* @namespace Blockly.IMetricsManager
*/
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.IMetricsManager');
/* eslint-disable-next-line no-unused-vars */
// Unused import preserved for side-effects. Remove if unneeded.
// import '../metrics_manager.js';
/* eslint-disable-next-line no-unused-vars */
// Unused import preserved for side-effects. Remove if unneeded.
// import '../utils/metrics.js';
/* eslint-disable-next-line no-unused-vars */
// Unused import preserved for side-effects. Remove if unneeded.
// import '../utils/size.js';
/**
* Interface for a metrics manager.
* @alias Blockly.IMetricsManager
*/
export interface IMetricsManager {
/**
* Returns whether the scroll area has fixed edges.
* @return Whether the scroll area has fixed edges.
* @internal
*/
hasFixedEdges: AnyDuringMigration;
/**
* Returns the metrics for the scroll area of the workspace.
* @param opt_getWorkspaceCoordinates True to get the scroll metrics in
* workspace coordinates, false to get them in pixel coordinates.
* @param opt_viewMetrics 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.
* @param opt_contentMetrics 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.
* @return The metrics for the scroll container
*/
getScrollMetrics: AnyDuringMigration;
/**
* Gets the width and the height of the flyout on the workspace in pixel
* coordinates. Returns 0 for the width and height if the workspace has a
* category toolbox instead of a simple toolbox.
* @param opt_own Whether to only return the workspace's own flyout.
* @return The width and height of the flyout.
*/
getFlyoutMetrics: AnyDuringMigration;
/**
* 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 {@link getFlyoutMetrics}.
* @return The object with the width, height and position of the toolbox.
*/
getToolboxMetrics: AnyDuringMigration;
/**
* 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.
* @return The width and height of the workspace's parent SVG element.
*/
getSvgMetrics: AnyDuringMigration;
/**
* Gets the absolute left and absolute top in pixel coordinates.
* This is where the visible workspace starts in relation to the SVG
* container.
* @return The absolute metrics for the workspace.
*/
getAbsoluteMetrics: AnyDuringMigration;
/**
* Gets the metrics for the visible workspace in either pixel or workspace
* coordinates. The visible workspace does not include the toolbox or flyout.
* @param opt_getWorkspaceCoordinates True to get the view metrics in
* workspace coordinates, false to get them in pixel coordinates.
* @return The width, height, top and left of the viewport in either workspace
* coordinates or pixel coordinates.
*/
getViewMetrics: AnyDuringMigration;
/**
* 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).
* @param opt_getWorkspaceCoordinates True to get the content metrics in
* workspace coordinates, false to get them in pixel coordinates.
* @return The metrics for the content container.
*/
getContentMetrics: AnyDuringMigration;
/**
* 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.
* .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.
* .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.
* @return Contains size and position metrics of a top level workspace.
*/
getMetrics: AnyDuringMigration;
/**
* Returns common metrics used by UI elements.
* @return The UI metrics.
*/
getUiMetrics: AnyDuringMigration;
}