OverlayManager

See source code
Table of contents
class OverlayManager {}

Constructor

Constructs a new instance of the OverlayManager class

Parameters

NameDescription

editor

Editor;

Properties

editor

readonly
readonly editor: Editor;

Methods

getActiveOverlayEntries( )

Reactive list of active overlay utils paired with the overlays they produced for the current editor state, in paint order (ascending zIndex). Both the hit-test and render paths read from this single cached scan instead of each re-deriving the active set. Active utils are included even when their getOverlays() returns an empty array, since render() may still draw non-interactive UI (e.g. the selection bounding box during brushing).

getActiveOverlayEntries(): TLOverlayEntry[];

getCurrentOverlays( )

Reactively computed list of all currently active overlays, in paint order.

getCurrentOverlays(): TLOverlay[];

getHoveredOverlay( )

getHoveredOverlay(): null | TLOverlay;

getHoveredOverlayId( )

getHoveredOverlayId(): null | string;

getOverlayAtPoint( )

Hit test all active overlays at a given page point. Returns the topmost overlay whose geometry contains the point, or null. Utils are walked from highest zIndex to lowest so the overlay painted on top also wins the hit test. Within a util, overlays are walked in array order: the first overlay whose geometry contains the point wins, so utils should place highest-priority overlays first in getOverlays. Interactive overlays (those with geometry) are checked; non-interactive are skipped.

getOverlayAtPoint(point: VecLike, margin?: number): null | TLOverlay;

Parameters

NameDescription

point

VecLike;

Point in page coordinates

margin

number;

Hit test margin

Returns

null | TLOverlay;

getOverlayGeometry( )

Get hit-test geometry for an overlay, cached by overlay identity. Lets hit-testing on a pointermove storm skip the per-overlay geometry allocation that OverlayUtil.getGeometry would otherwise do on every call.

getOverlayGeometry(overlay: TLOverlay): Geometry2d | null;

Parameters

NameDescription

overlay

Returns

Geometry2d | null;

getOverlayUtil( )

Get an overlay util by type string, overlay instance, or by passing a util class as a generic parameter for type-safe lookup.

getOverlayUtil<T extends OverlayUtil>(
  type: T extends OverlayUtil<infer O> ? O["type"] : string,
): T;

Example

const util = editor.overlays.getOverlayUtil("brush");
const util = editor.overlays.getOverlayUtil<BrushOverlayUtil>("brush");
const util = editor.overlays.getOverlayUtil(myOverlay);

Parameters

NameDescription

type

T extends OverlayUtil<infer O>
  ? O["type"]
  : string;

Returns

T;

getOverlayUtilsInZOrder( )

Returns all registered overlay utils in paint order (ascending zIndex). Utils with the same zIndex preserve their registration order.

getOverlayUtilsInZOrder(): OverlayUtil[];

setHoveredOverlay( )

setHoveredOverlay(id: null | string): void;

Parameters

NameDescription

id

null | string;

Returns

void;

Prev
Mat
Next
OverlayUtil