UNPKG

lazy-widgets

Version:

Typescript retained mode GUI for the HTML canvas API

46 lines (45 loc) 2.31 kB
import { CanvasViewport } from '../core/CanvasViewport.js'; import { Widget, type WidgetProperties } from './Widget.js'; import { Rect } from '../helpers/Rect.js'; import { WidgetEvent } from '../events/WidgetEvent.js'; import type { WidgetAutoXML } from '../xml/WidgetAutoXML.js'; import { BaseContainer } from './BaseContainer.js'; import { ClippedViewportRect } from '../core/BaseViewport.js'; /** * Similar to {@link Container}, but the child is painted to a * {@link CanvasViewport}. There is no reason to use this directly, but you can * if you have a niche reason for it. The intended use is to do effects on the * child by modifying how the canvas is painted in a base class. */ export declare class CanvasContainer<W extends Widget = Widget> extends BaseContainer<W> { static autoXML: WidgetAutoXML; /** Internal viewport for child widget. */ protected readonly internalViewport: CanvasViewport; constructor(child: W, properties?: Readonly<WidgetProperties>); protected handleEvent(event: WidgetEvent): Widget | null; protected handlePreLayoutUpdate(): void; finalizeBounds(): void; protected handleResolveDimensions(minWidth: number, maxWidth: number, minHeight: number, maxHeight: number): void; resolvePosition(x: number, y: number): void; protected handleAttachment(): void; protected handleDetachment(): void; /** * Paint the internal canvas to the parent viewport. Override this method if * you want to apply effects to the child widget. */ protected handleInternalCanvasPainting(clippedViewportRect: ClippedViewportRect): void; protected handlePainting(_dirtyRects: Array<Rect>): void; /** * Transform or discard a damage region from the child widget in the canvas. * Override this method if you have non-local effects, such as shadows. * * The damage region is a mutable reference; you are expected to transform * it if necessary. * * @returns `true` if the damage region should be propagated, or `false` otherwise */ protected handleCanvasDamage(_rect: Rect): boolean; propagateDirtyRect(rect: Rect): void; queryRect(rect: Rect, relativeTo?: Widget | null): Rect; queryPoint(x: number, y: number, relativeTo?: Widget | null): [x: number, y: number]; }