UNPKG

lazy-widgets

Version:

Typescript retained mode GUI for the HTML canvas API

54 lines 1.54 kB
import { Widget } from '../widgets/Widget.js'; /** * A class for widgets which may have children. * * Overrides the {@link Widget#inheritedTheme} accessor so that inherited themes * are propagated to children. Also provides a getter for the amount of children * that this parent has, and is an iterable which iterates each child of this * parent. Child classes are responsible for implementing both the getter and * the iterator. * * Can be constrained to a specific type of children. * * See {@link MultiParent} and {@link SingleParent} for more specialised * versions. * * @category Widget */ export class Parent extends Widget { set inheritedTheme(theme) { super.inheritedTheme = theme; for (const child of this) { child.inheritedTheme = theme; } } get inheritedTheme() { return super.inheritedTheme; } handleAttachment() { for (const child of this) { child.attach(this._root, this._viewport, this); } } handleDetachment() { for (const child of this) { child.detach(); } } updateActiveState() { const changed = super.updateActiveState(); if (changed) { for (const child of this) { child.updateActiveState(); } } return changed; } finalizeBounds() { super.finalizeBounds(); for (const child of this) { child.finalizeBounds(); } } } //# sourceMappingURL=Parent.js.map