lazy-widgets
Version:
Typescript retained mode GUI for the HTML canvas API
105 lines (104 loc) • 3.98 kB
TypeScript
import { ClickHelper } from '../helpers/ClickHelper.js';
import { Widget, WidgetProperties } from './Widget.js';
import { WidgetEvent } from '../events/WidgetEvent.js';
import type { Bounds } from '../helpers/Bounds.js';
import type { Rect } from '../helpers/Rect.js';
import type { WidgetAutoXML } from '../xml/WidgetAutoXML.js';
import { type Box } from '../state/Box.js';
/**
* Optional Slider constructor properties.
*
* @category Widget
*/
export interface SliderProperties extends WidgetProperties {
/** Sets {@link Slider#snapIncrement}. */
snapIncrement?: number;
/** Sets {@link Slider#vertical}. */
vertical?: boolean;
}
/**
* A slider flexbox widget; can slide a numeric value from an inclusive minimum
* value to an inclusive maximum value, with optional snapping along set
* increments.
*
* Note that sliders can only be horizontal.
*
* @category Widget
*/
export declare class Slider extends Widget {
static autoXML: WidgetAutoXML;
/** See {@link Slider#minValue} */
private _minValue;
/** See {@link Slider#maxValue} */
private _maxValue;
/** See {@link Slider#snapIncrement} */
private _snapIncrement;
/** The helper for handling pointer clicks/drags */
protected clickHelper: ClickHelper;
/** Is this a vertical slider? */
protected readonly vertical: boolean;
/** The horizontal offset of the slider */
protected offsetX: number;
/** The vertical offset of the slider */
protected offsetY: number;
/** The actual width of the slider */
protected actualWidth: number;
/** The actual height of the slider */
protected actualHeight: number;
/** Is the keyboard focusing this widget? */
protected keyboardFocused: boolean;
/** The helper for keeping track of the slider value */
readonly variable: Box<number>;
/** The callback used for the {@link Slider#"variable"} */
private readonly callback;
/**
* The rectangle of the slider when the dragging started. Used to prevent
* glitchy behaviour when the slider is being used while the layout is
* changing. For internal use only.
*/
protected readonly dragBounds: Bounds;
constructor(variable?: Box<number>, minValue?: number, maxValue?: number, properties?: Readonly<SliderProperties>);
protected handleChange(): void;
protected handleAttachment(): void;
protected handleDetachment(): void;
protected activate(): void;
/** The slider's value */
set value(value: number);
get value(): number;
/**
* The slider's minimum value.
*
* Changing this does not cause the value to be clamped; clamping occurs on
* value changes.
*/
set minValue(minValue: number);
get minValue(): number;
/**
* The slider's maximum value.
*
* Changing this does not cause the value to be clamped; clamping occurs on
* value changes.
*/
set maxValue(maxValue: number);
get maxValue(): number;
/**
* The increments in which the slider changes value. If 0, there are no
* fixed increments.
*
* Changing this does not cause the value to changed to match the increment;
* rounding occurs on value changes.
*/
set snapIncrement(snapIncrement: number);
get snapIncrement(): number;
/** Clamp a value to this slider's min and max values */
protected clamp(value: number): number;
/** Set the slider's value, optionally using an observer group */
setValue(value: number, group?: unknown): void;
protected stepValue(add: boolean, incMul: number): void;
protected onThemeUpdated(property?: string | null): void;
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 handlePreLayoutUpdate(): void;
}