253 lines
10 KiB
TypeScript
253 lines
10 KiB
TypeScript
|
|
/** @noResolution */
|
|
/** @noSelf */
|
|
declare module basalt {
|
|
|
|
interface Theme {
|
|
BaseFrameBG: number,
|
|
BaseFrameText: number,
|
|
FrameBG: number,
|
|
FrameText: number,
|
|
ButtonBG: number,
|
|
ButtonText: number,
|
|
CheckboxBG: number,
|
|
CheckboxText: number,
|
|
InputBG: number,
|
|
InputText: number,
|
|
TextfieldBG: number,
|
|
TextfieldText: number,
|
|
ListBG: number,
|
|
ListText: number,
|
|
MenubarBG: number,
|
|
MenubarText: number,
|
|
DropdownBG: number,
|
|
DropdownText: number,
|
|
RadioBG: number,
|
|
RadioText: number,
|
|
SelectionBG: number,
|
|
SelectionText: number,
|
|
GraphicBG: number,
|
|
ImageBG: number,
|
|
PaneBG: number,
|
|
ProgramBG: number,
|
|
ProgressbarBG: number,
|
|
ProgressbarText: number,
|
|
ProgressbarActiveBG: number,
|
|
ScrollbarBG: number,
|
|
ScrollbarText: number,
|
|
ScrollbarSymbolColor: number,
|
|
SliderBG: boolean,
|
|
SliderText: number,
|
|
SliderSymbolColor: number,
|
|
SwitchBG: number,
|
|
SwitchText: number,
|
|
LabelBG: boolean,
|
|
LabelText: number,
|
|
GraphBG: number,
|
|
GraphText: number,
|
|
}
|
|
|
|
function debug(...txt: string[]): void;
|
|
function autoUpdate(enabled?: boolean): void;
|
|
function stop(): void;
|
|
function stopUpdate(): void;
|
|
function addMonitor<T extends MonitorFrame>(): T;
|
|
function createFrame<T extends BaseFrame>(id?: string): T;
|
|
function setActiveFrame<T extends BaseFrame>(f: T): void;
|
|
function getFrame<T extends BaseFrame>(id: string): T;
|
|
function getActiveFrame<T extends BaseFrame>(): T;
|
|
function removeFrame(id: string): void;
|
|
function setTheme(theme: Theme): void;
|
|
function getTheme(s: string): number;
|
|
function setVariable<T>(k: string, v: T): void;
|
|
function getVariable<T>(k: string): T;
|
|
function getVersion(): string;
|
|
function isKeyDown(key: number): boolean;
|
|
function log(msg: string, prefix: "ERROR" | "WARN" | "INFO" | "DEBUG" | string): void;
|
|
function memory(): number;
|
|
function onEvent(fn: (event: string) => boolean): void;
|
|
function schedule(fn: <T>(v: T) => void): void;
|
|
function setMouseDragThrottle(throttle: number): void;
|
|
function setMouseMoveThrottle(throttle: number): void;
|
|
function setRenderingThrottle(throttle: number): void;
|
|
|
|
class Object {
|
|
enable(): void;
|
|
disable(): void;
|
|
getType(): string;
|
|
isType(t: string): boolean;
|
|
getName(): string;
|
|
getParent<T extends Object>(): T | null;
|
|
setParent<T extends Object, O extends Object>(p: T): O;
|
|
getZIndex(): number;
|
|
}
|
|
|
|
class VisualObject extends Object {
|
|
show<T extends VisualObject>(): T;
|
|
hide<T extends VisualObject>(): T;
|
|
setVisible(vis: boolean): boolean;
|
|
isVisible(): boolean;
|
|
setPosition<T extends VisualObject>(x: number|string, y: number|string, add?: boolean): T;
|
|
getPosition(): [number, number];
|
|
getX(): number;
|
|
getY(): number;
|
|
setSize<T extends VisualObject>(w: number|string, h: number|string): T;
|
|
getSize(): [number, number];
|
|
getWidth(): number;
|
|
getHeight(): number;
|
|
setBackground<T extends VisualObject>(color: number|false, symbol?: string, symbol_color?: number): T;
|
|
getBackground(): number|false;
|
|
setForeground<T extends VisualObject>(color: number|false): T;
|
|
getForeground(): number|false;
|
|
setTransparency<T extends VisualObject>(v: boolean): T;
|
|
setZIndex<T extends VisualObject>(i: number): T;
|
|
getAbsolutePosition(x?: number, y?: number): [number, number];
|
|
ignoreOffset<T extends VisualObject>(v: boolean): T;
|
|
isFocused(): boolean;
|
|
setShadow<T extends VisualObject>(v: number): T;
|
|
getShadow(): number|false;
|
|
setBorder<T extends VisualObject>(c: number, ...sides: string[]): T;
|
|
animatePosition<T extends VisualObject>(x: number, y: number, dur: number, offset?: number, mode?: string, fn?: () => void): T;
|
|
animateSize<T extends VisualObject>(w: number, h: number, dur: number, offset?: number, mode?: string, fn?: () => void): T;
|
|
animateOffset<T extends VisualObject>(x: number, y: number, dur: number, offset?: number, mode?: string, fn?: () => void): T;
|
|
addTexture<T extends VisualObject>(path: string, isAnimated: boolean): T;
|
|
setTextureMode<T extends VisualObject>(mode: string): T;
|
|
setInfiniteMode<T extends VisualObject>(v: boolean): T;
|
|
|
|
addDraw<T extends VisualObject>(id: string, fn: () => void, pos: number, where: number, imm: boolean): T;
|
|
addPreDraw<T extends VisualObject>(id: string, fn: () => void, pos: number, imm: boolean): T;
|
|
addPostDraw<T extends VisualObject>(id: string, fn: () => void, pos: number, imm: boolean): T;
|
|
setDrawState<T extends VisualObject>(id: string, state: boolean): T;
|
|
getDrawId(id: string): number;
|
|
addText<T extends VisualObject>(x: number, y: number, s: string): T;
|
|
addBg<T extends VisualObject>(x: number, y: number, c: string): T;
|
|
addFg<T extends VisualObject>(x: number, y: number, c: string): T;
|
|
addBlit<T extends VisualObject>(x: number, y: number, s: string, fg: string, bg: string): T;
|
|
addBox<T extends VisualObject>(x: number, y: number, w: number, h: number, s: string): T;
|
|
addBackgroundBox<T extends VisualObject>(x: number, y: number, w: number, h: number, c: number): T;
|
|
addForegroundBox<T extends VisualObject>(x: number, y: number, w: number, h: number, c: number): T;
|
|
|
|
addLabel<T extends Label>(): T;
|
|
addButton<T extends Button>(): T;
|
|
addGraph<T extends Graph>(): T;
|
|
// addScrollbar<T extends Scrollbar>(): T;
|
|
addImage<T extends Image>(): T;
|
|
addFrame<T extends Frame>(): T;
|
|
// addScrollableFrame<T extends ScrollableFrame>(): T;
|
|
// addInput<T extends Input>(): T;
|
|
// addDropdown<T extends Dropdown>(): T;
|
|
}
|
|
|
|
class ChangeableObject extends VisualObject {
|
|
setValue<T extends VisualObject>(v: any): T;
|
|
getValue<T>(): T;
|
|
}
|
|
|
|
class Container extends VisualObject {
|
|
addChild<T>(c: T): T;
|
|
getChild<T extends Container>(id: string): T;
|
|
getDeepChild<T extends Container>(id: string): T;
|
|
removeChild(id: string): boolean;
|
|
removeChildren<T extends Container>(): T;
|
|
updateZIndex<T extends Container, O extends Container>(which: O, idx: number): T;
|
|
setImportant<T extends Container>(id: string): T;
|
|
clearFocusedChild<T extends Container>(): T;
|
|
setFocusedObject<T extends Container, O extends Container>(o: O): T;
|
|
}
|
|
|
|
class BaseFrame extends Container {
|
|
getOffset(): [number, number];
|
|
setOffset<T extends BaseFrame>(x: number, y: number): T;
|
|
}
|
|
|
|
class MonitorFrame extends BaseFrame {
|
|
setMonitor<T extends MonitorFrame>(mon: string|Monitor): T;
|
|
setMonitorGroup<T extends MonitorFrame>(mon: (string|Monitor)[][]): T;
|
|
}
|
|
|
|
class Frame extends Container {
|
|
getOffset(): [number, number];
|
|
setOffset<T extends Frame>(x: number, y: number): T;
|
|
}
|
|
|
|
class ScrollableFrame extends Frame {
|
|
setDirection<T extends ScrollableFrame>(d: string): T;
|
|
}
|
|
|
|
type Justify = "flex-start" | "flex-end" | "center" | "space-between" | "space-around" | "space-evenly";
|
|
type Direction = "row" | "column";
|
|
class Flexbox extends ScrollableFrame {
|
|
setSpacing<T extends Flexbox>(s?: number): T;
|
|
getSpacing(): number;
|
|
setDirection<T extends Flexbox | ScrollableFrame>(d: Direction): T;
|
|
getDirection(): Direction;
|
|
setJustifyContent<T extends Flexbox>(s?: Justify): T;
|
|
getJustifyContent(): Justify;
|
|
setWrap<T extends Flexbox>(w: "wrap" | "nowrap"): T;
|
|
getWrap(): "wrap" | "nowrap";
|
|
updateLayout<T extends Flexbox>(): T;
|
|
addBreak<T extends Flexbox>(): T;
|
|
|
|
getFlexGrow(): number;
|
|
setFlexGrow<T extends Flexbox>(g: number): T;
|
|
getFlexShrink(): number;
|
|
setFlexShrink<T extends Flexbox>(g: number): T;
|
|
getFlexBasis(): number;
|
|
setFlexBasis<T extends Flexbox>(g: number): T;
|
|
}
|
|
|
|
type DraggingMap = [number, number, number, number];
|
|
|
|
class MovableFrame extends Frame {
|
|
setDraggingMap<T extends MovableFrame>(m: DraggingMap): T;
|
|
getDraggingMap(): DraggingMap;
|
|
}
|
|
|
|
class Button extends VisualObject {
|
|
setText<T extends VisualObject>(t: string): T;
|
|
setHorizontalAlign<T extends VisualObject>(a: "left" | "center" | "right"): T;
|
|
setVerticalAlign<T extends VisualObject>(a: "top" | "center" | "bottom"): T;
|
|
}
|
|
|
|
class Checkbox extends ChangeableObject {
|
|
setSymbol<T extends Checkbox>(s: string): T;
|
|
}
|
|
|
|
class Graph extends ChangeableObject {
|
|
setGraphColor<T extends Graph>(c: number): T;
|
|
setGraphSymbol<T extends Graph>(s: string): T;
|
|
getGraphSymbol(): string;
|
|
addDataPoint<T extends Graph>(v: number): T;
|
|
setMaxValue<T extends Graph>(v: number): T;
|
|
getMaxValue(): number;
|
|
setMinValue<T extends Graph>(v: number): T;
|
|
getMinValue(): number;
|
|
setGraphType<T extends Graph>(t: "scatter" | "line" | "bar"): T;
|
|
setMaxEntries<T extends Graph>(v: number): T;
|
|
getMaxEntries(): number;
|
|
}
|
|
|
|
|
|
class Image extends VisualObject {
|
|
loadImage<T extends Image>(p: string): T;
|
|
setImage(img: any, fmt: "nfp" | "bimg"): void;
|
|
usePalette<T extends Image>(change: boolean): T;
|
|
play<T extends Image>(p: boolean): T;
|
|
selectFrame<T extends Image>(idx: number): T;
|
|
loadImage<T extends Image>(p: string): T;
|
|
getMetadata(k: string): unknown;
|
|
setImageSize<T extends Image>(w: number, h: number): T;
|
|
getImageSize(): [number, number];
|
|
// TODO: finish this
|
|
}
|
|
|
|
class Label extends VisualObject {
|
|
setText<T extends Label>(t: string): T;
|
|
setFontSize<T extends Label>(s: number): T;
|
|
getFontSize(): number;
|
|
setTextAlign<T extends Label>(a: "left" | "center" | "right"): T;
|
|
}
|
|
}
|
|
|
|
export default basalt;
|