Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add the IFlyoutInflater interface. #8581

Open
wants to merge 3 commits into
base: rc/v12.0.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions core/interfaces/i_flyout_inflater.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import type {IBoundedElement} from './i_bounded_element.js';
import type {WorkspaceSvg} from '../workspace_svg.js';

export interface IFlyoutInflater {
/**
* Loads the object represented by the given state onto the workspace.
*
* Note that this method's interface is identical to that in ISerializer, to
* allow for code reuse.
*
* @param state A JSON representation of an element to inflate on the flyout.
* @param flyoutWorkspace The flyout's workspace, where the inflated element
* should be created. If the inflated element is an `IRenderedElement` it
* itself or the inflater should append it to the workspace; the flyout
* will not do so itself. The flyout is responsible for positioning the
* element, however.
* @returns The newly inflated flyout element.
*/
load(state: Object, flyoutWorkspace: WorkspaceSvg): IBoundedElement;

/**
* Returns the amount of spacing that should follow the element corresponding
* to the given JSON representation.
*
* @param state A JSON representation of the element preceding the gap.
* @param defaultGap The default gap for elements in this flyout.
* @returns The gap that should follow the given element.
*/
gapForElement(state: Object, defaultGap: number): number;

/**
* Disposes of the given element.
*
* If the element in question resides on the flyout workspace, it should remove
* itself. Implementers are not otherwise required to fully dispose of the
* element; it may be e.g. cached for performance purposes.
*
* @param element The flyout element to dispose of.
*/
disposeElement(element: IBoundedElement): void;
}
3 changes: 3 additions & 0 deletions core/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type {Abstract} from './events/events_abstract.js';
import type {Field} from './field.js';
import type {IConnectionChecker} from './interfaces/i_connection_checker.js';
import type {IFlyout} from './interfaces/i_flyout.js';
import type {IFlyoutInflater} from './interfaces/i_flyout_inflater.js';
import type {IMetricsManager} from './interfaces/i_metrics_manager.js';
import type {IIcon} from './interfaces/i_icon.js';
import type {Input} from './inputs/input.js';
Expand Down Expand Up @@ -99,6 +100,8 @@ export class Type<_T> {
'flyoutsHorizontalToolbox',
);

static FLYOUT_INFLATER = new Type<IFlyoutInflater>('flyoutInflater');

static METRICS_MANAGER = new Type<IMetricsManager>('metricsManager');

/**
Expand Down