lazy-widgets
Version:
Typescript retained mode GUI for the HTML canvas API
56 lines (55 loc) • 2.33 kB
TypeScript
import { Parent } from './Parent.js';
import type { Widget, WidgetProperties } from '../widgets/Widget.js';
/**
* A specialised version of the {@link Parent} class for parents with any amount
* of children and public access to modifying this list of children.
*
* Can be constrained to a specific type of children.
*
* @category Widget
*/
export declare abstract class MultiParent<W extends Widget = Widget> extends Parent<W> {
/**
* This widget's children. Note that this is marked as readonly so that it
* cannot be accidentally replaced with a new array. This way, references to
* this array are always valid. If you want to clear this array, set the
* length to zero instead of creating a new instance. readonly still means
* that you can add/remove elements to/from the array.
*/
protected readonly _children: Array<W>;
constructor(children: Array<W>, properties?: Readonly<WidgetProperties>);
[Symbol.iterator](): Iterator<W>;
get childCount(): number;
/**
* Add child(ren) to this widget.
*
* {@link Widget#_layoutDirty} is set to true and each child's
* {@link Widget#inheritedTheme} is set so that new children inherit this
* widget's theme.
*
* Calls {@link Widget#markWholeAsDirty}.
*
* @param children - If this is a widget, then it is pushed to {@link MultiParent#_children}. If this is an array of widgets, then each widget is pushed to {@link MultiParent#_children}.
* @returns Returns this so that the method is chainable.
*/
add(children: W | Array<W>): this;
/**
* Remove child(ren) from this widget.
*
* Calls {@link Widget#markWholeAsDirty} and sets
* {@link Widget#_layoutDirty} to true.
*
* @param children - If this is a widget, then it is removed from {@link MultiParent#_children}. If this is an array of widgets, then each widget is removed from {@link MultiParent#_children}.
* @returns Returns this so that the method is chainable.
*/
remove(children: W | Array<W>): this;
/**
* Remove all children from this widget.
*
* Calls {@link Widget#markWholeAsDirty} and sets
* {@link Widget#_layoutDirty} to true.
*
* @returns Returns this so that the method is chainable.
*/
clearChildren(): this;
}