UNPKG

lazy-widgets

Version:

Typescript retained mode GUI for the HTML canvas API

73 lines (72 loc) 3.05 kB
import { ButtonClickHelper } from '../helpers/ButtonClickHelper.js'; import { Widget } from './Widget.js'; import { WidgetEvent } from '../events/WidgetEvent.js'; import type { Box } from '../state/Box.js'; import type { Rect } from '../helpers/Rect.js'; import type { WidgetAutoXML } from '../xml/WidgetAutoXML.js'; import type { ClickableWidgetProperties } from './ClickableWidgetProperties.js'; /** * A radio button widget; used for selecting one of many options. Uses a shared * {@link Box} instance and expects the creation of multiple RadioButton * instances. * * @typeParam V - The type stored in the {@link RadioButton#"variable"}; when a radio button is clicked, the value inside the variable has this type. * * @category Widget */ export declare class RadioButton<V> extends Widget { static autoXML: WidgetAutoXML; /** Horizontal offset. */ private offsetX; /** Vertical offset. */ private offsetY; /** Actual length after resolving layout. */ private actualLength; /** The helper used for handling pointer clicks and enter presses */ protected clickHelper: ButtonClickHelper; /** The shared {@link Box} where the value is set */ readonly variable: Box<V>; /** * The value that will be used when the {@link RadioButton#"variable"} is * set */ protected value: V; /** The callback used for the {@link RadioButton#"variable"} */ private readonly callback; /** Was the radio button selected in the last paint? */ private _wasSelected; /** See {@link RadioButton#clickable} */ private _clickable; /** * @param variable - The shared variable that radio buttons will save the value to when selected. * @param value - The value that will be used to set the {@link RadioButton#"variable"} when the radio button is clicked */ constructor(variable: Box<V>, value: V, properties?: Readonly<ClickableWidgetProperties>); protected handleChange(): void; protected onThemeUpdated(property?: string | null): void; /** * Select this radio button. Sets the value in * {@link RadioButton#"variable"} to be {@link RadioButton#value} */ select(): void; /** * Is the radio button selected? Equivalent to checking if the value in the * {@link RadioButton#"variable"} is strictly equal to the * {@link RadioButton#value} */ get selected(): boolean; protected handleEvent(event: WidgetEvent): Widget | null; protected handleResolveDimensions(minWidth: number, maxWidth: number, minHeight: number, maxHeight: number): void; finalizeBounds(): void; protected handlePainting(_dirtyRects: Array<Rect>): void; protected handleAttachment(): void; protected handleDetachment(): void; protected activate(): void; /** * Is the radio button clickable? True by default. Used for disabling the * radio button without hiding it. */ get clickable(): boolean; set clickable(clickable: boolean); protected handlePreLayoutUpdate(): void; }