UNPKG

lazy-widgets

Version:

Typescript retained mode GUI for the HTML canvas API

59 lines (58 loc) 2.35 kB
import { LayeredContainer } from '../widgets/LayeredContainer.js'; import { type Widget } from '../widgets/Widget.js'; /** * Controls the visibility of a tooltip container (such as * {@link TooltipContainer}). Used for implementing tooltips, such as in * {@link Tooltip}, or to implement tooltip-like functionality, such as * dropdowns or context menus. */ export declare abstract class BaseTooltipController<W extends Widget, C extends Widget, O = void> { readonly tooltipWrapper: W; readonly tooltipContainer: C; /** The top-most container in the current UI tree */ protected topLayeredContainer: LayeredContainer | null; /** The currently created layer for the {@link Tooltip#tooltipWidget} */ private layer; constructor(tooltipWrapper: W, tooltipContainer: C); /** * Find the top-most layered container that is an ascendant of the * {@link BaseTooltipController#tooltipWrapper}. You must call this when the * wrapper widget is attached to a parent. * * Removes the current layer if there is any, and if the top-most layered * container changed. */ findTopLayeredContainer(): void; /** * Clear the top-most layered container. You must call this when the wrapper * widget is detached from a parent. * * Removes the current layer if there is any. */ clearTopLayeredContainer(): void; /** * Add a layer for the {@link TooltipController#tooltipContainer}. If there * is a layer and adding another one would succeed, remove the old one. * * @returns True if the layer was addedd successfully, or false if there was no top layered container. */ addLayer(_options: O): boolean; /** * Remove the layer of the {@link TooltipController#tooltipContainer} if * there is any. */ removeLayer(): void; get hasLayer(): boolean; /** * Update the {@link TooltipContainer#tooltipRect} of the * {@link TooltipController#tooltipContainer}. */ updateTooltipRect(): void; /** * Implementation for {@link BaseTooltipController#updateTooltipRect}. Must * be implemented by base class. * {@link BaseTooltipController#topLayeredContainer} is guaranteed to be set * when this method is called. */ protected abstract doTooltipRectUpdate(): void; }