lazy-widgets
Version:
Typescript retained mode GUI for the HTML canvas API
46 lines (45 loc) • 2.01 kB
TypeScript
import { type WidgetEvent } from '../events/WidgetEvent.js';
import { type Rect } from '../helpers/Rect.js';
import { type WidgetAutoXML } from '../xml/WidgetAutoXML.js';
import { Parent } from './Parent.js';
import { Widget, type WidgetProperties } from './Widget.js';
/**
* A {@link Parent} widget, similar to {@link PassthroughWidget}, which can
* optionally have a single child, or no child at all, and can transfer the
* child to other WidgetSlots.
*
* @category Widget
*/
export declare class WidgetSlot<W extends Widget = Widget> extends Parent<W> {
static autoXML: WidgetAutoXML;
private _child;
/**
* @param child - The optional single child of this widget. Can be changed later via either {@link WidgetSlot#child}, {@link WidgetSlot#transferChildTo} or {@link WidgetSlot#swapChildWith}.
*/
constructor(child?: W | null, properties?: Readonly<WidgetProperties>);
/** The current child in this slot. May be null if the slot is empty. */
get child(): W | null;
set child(child: W | null);
/**
* Transfer this widget's child to a new WidgetSlot. Note that, if this
* widget has no child, then the new slot will have its child removed.
*
* Does nothing if the new slot is this.
*/
transferChildTo(newSlot: WidgetSlot<W>): void;
/**
* Swap this widget's child with another WidgetSlot's child. Also works if
* either (or both) slots have no child.
*
* Does nothing if the other slot is this.
*/
swapChildWith(otherSlot: WidgetSlot<W>): void;
protected handleEvent(event: WidgetEvent): Widget | null;
protected handlePreLayoutUpdate(): void;
protected handlePostLayoutUpdate(): void;
protected handleResolveDimensions(minWidth: number, maxWidth: number, minHeight: number, maxHeight: number): void;
resolvePosition(x: number, y: number): void;
protected handlePainting(dirtyRects: Array<Rect>): void;
[Symbol.iterator](): Iterator<W>;
get childCount(): 1 | 0;
}