UNPKG

@mori2003/jsimgui

Version:

JavaScript bindings for Dear ImGui.

290 lines (289 loc) 12.1 kB
import { ReferenceStruct, ImVec2 } from "./imgui.js"; /** -> enum ImNodesCol_ */ export type ImNodesCol = number; /** -> enum ImNodesStyleVar_ */ export type ImNodesStyleVar = number; /** -> enum ImNodesStyleFlags_ */ export type ImNodesStyleFlags = number; /** -> enum ImNodesPinShape_ */ export type ImNodesPinShape = number; /** -> enum ImNodesAttributeFlags_ */ export type ImNodesAttributeFlags = number; /** -> enum ImNodesMiniMapLocation_ */ export type ImNodesMiniMapLocation = number; export declare const ImNodesCol: { readonly NodeBackground: 0; readonly NodeBackgroundHovered: 1; readonly NodeBackgroundSelected: 2; readonly NodeOutline: 3; readonly TitleBar: 4; readonly TitleBarHovered: 5; readonly TitleBarSelected: 6; readonly Link: 7; readonly LinkHovered: 8; readonly LinkSelected: 9; readonly Pin: 10; readonly PinHovered: 11; readonly BoxSelector: 12; readonly BoxSelectorOutline: 13; readonly GridBackground: 14; readonly GridLine: 15; readonly GridLinePrimary: 16; readonly MiniMapBackground: 17; readonly MiniMapBackgroundHovered: 18; readonly MiniMapOutline: 19; readonly MiniMapOutlineHovered: 20; readonly MiniMapNodeBackground: 21; readonly MiniMapNodeBackgroundHovered: 22; readonly MiniMapNodeBackgroundSelected: 23; readonly MiniMapNodeOutline: 24; readonly MiniMapLink: 25; readonly MiniMapLinkSelected: 26; readonly MiniMapCanvas: 27; readonly MiniMapCanvasOutline: 28; readonly COUNT: 29; }; export declare const ImNodesStyleVar: { readonly GridSpacing: 0; readonly NodeCornerRounding: 1; readonly NodePadding: 2; readonly NodeBorderThickness: 3; readonly LinkThickness: 4; readonly LinkLineSegmentsPerLength: 5; readonly LinkHoverDistance: 6; readonly PinCircleRadius: 7; readonly PinQuadSideLength: 8; readonly PinTriangleSideLength: 9; readonly PinLineThickness: 10; readonly PinHoverRadius: 11; readonly PinOffset: 12; readonly MiniMapPadding: 13; readonly MiniMapOffset: 14; readonly COUNT: 15; }; export declare const ImNodesStyleFlags: { readonly None: 0; readonly NodeOutline: number; readonly GridLines: number; readonly GridLinesPrimary: number; readonly GridSnapping: number; }; export declare const ImNodesPinShape: { readonly Circle: 0; readonly CircleFilled: 1; readonly Triangle: 2; readonly TriangleFilled: 3; readonly Quad: 4; readonly QuadFilled: 5; }; export declare const ImNodesAttributeFlags: { readonly None: 0; readonly EnableLinkDetachWithDragClick: number; readonly EnableLinkCreationOnSnap: number; }; export declare const ImNodesMiniMapLocation: { readonly BottomLeft: 0; readonly BottomRight: 1; readonly TopLeft: 2; readonly TopRight: 3; }; export declare class ImNodesContext extends ReferenceStruct { } export declare class ImNodesEditorContext extends ReferenceStruct { } export declare class ImNodesIO extends ReferenceStruct { get AltMouseButton(): number; set AltMouseButton(v: number); get AutoPanningSpeed(): number; set AutoPanningSpeed(v: number); } export declare class ImNodesStyle extends ReferenceStruct { get GridSpacing(): number; set GridSpacing(v: number); get NodeCornerRounding(): number; set NodeCornerRounding(v: number); get NodePadding(): ImVec2; set NodePadding(v: ImVec2); get NodeBorderThickness(): number; set NodeBorderThickness(v: number); get LinkThickness(): number; set LinkThickness(v: number); get LinkLineSegmentsPerLength(): number; set LinkLineSegmentsPerLength(v: number); get LinkHoverDistance(): number; set LinkHoverDistance(v: number); get PinCircleRadius(): number; set PinCircleRadius(v: number); get PinQuadSideLength(): number; set PinQuadSideLength(v: number); get PinTriangleSideLength(): number; set PinTriangleSideLength(v: number); get PinLineThickness(): number; set PinLineThickness(v: number); get PinHoverRadius(): number; set PinHoverRadius(v: number); get PinOffset(): number; set PinOffset(v: number); get MiniMapPadding(): ImVec2; set MiniMapPadding(v: ImVec2); get MiniMapOffset(): ImVec2; set MiniMapOffset(v: ImVec2); get Flags(): ImNodesStyleFlags; set Flags(v: ImNodesStyleFlags); get Colors(): number[]; set Colors(v: number[]); } export declare class ImNodes { static CreateContext(): ImNodesContext; static DestroyContext(ctx?: ImNodesContext | null): void; static GetCurrentContext(): ImNodesContext; static SetCurrentContext(ctx: ImNodesContext): void; static EditorContextCreate(): ImNodesEditorContext; static EditorContextFree(ctx: ImNodesEditorContext): void; static EditorContextSet(ctx: ImNodesEditorContext): void; static EditorContextGetPanning(): ImVec2; static EditorContextResetPanning(pos: ImVec2): void; static EditorContextMoveToNode(node_id: number): void; static GetIO(): ImNodesIO; /** * Returns the global style struct. See the struct declaration for default values. */ static GetStyle(): ImNodesStyle; /** * Style presets matching the dear imgui styles of the same name. If dest is NULL, the active * context's ImNodesStyle instance will be used as the destination. */ static StyleColorsDark(dest?: ImNodesStyle | null): void; static StyleColorsClassic(dest?: ImNodesStyle | null): void; static StyleColorsLight(dest?: ImNodesStyle | null): void; /** * The top-level function call. Call this before calling BeginNode/EndNode. Calling this function * will result the node editor grid workspace being rendered. */ static BeginNodeEditor(): void; static EndNodeEditor(): void; /** * Add a navigable minimap to the editor; call before EndNodeEditor after all * nodes and links have been specified */ static MiniMap(minimap_size_fraction?: number, location?: ImNodesMiniMapLocation): void; /** * Use PushColorStyle and PopColorStyle to modify ImNodesStyle::Colors mid-frame. */ static PushColorStyle(item: ImNodesCol, color: number): void; static PopColorStyle(): void; static PushStyleVar(style_item: ImNodesStyleVar, value: number): void; static PushStyleVarImVec2(style_item: ImNodesStyleVar, value: ImVec2): void; static PopStyleVar(count?: number): void; /** * id can be any positive or negative integer, but INT_MIN is currently reserved for internal use. */ static BeginNode(id: number): void; static EndNode(): void; static GetNodeDimensions(id: number): ImVec2; /** * Place your node title bar content (such as the node title, using ImGui::Text) between the * following function calls. These functions have to be called before adding any attributes, or the * layout of the node will be incorrect. */ static BeginNodeTitleBar(): void; static EndNodeTitleBar(): void; /** * Create an input attribute block. The pin is rendered on left side. */ static BeginInputAttribute(id: number, shape?: ImNodesPinShape): void; static EndInputAttribute(): void; /** * Create an output attribute block. The pin is rendered on the right side. */ static BeginOutputAttribute(id: number, shape?: ImNodesPinShape): void; static EndOutputAttribute(): void; /** * Create a static attribute block. A static attribute has no pin, and therefore can't be linked to * anything. However, you can still use IsAttributeActive() and IsAnyAttributeActive() to check for * attribute activity. */ static BeginStaticAttribute(id: number): void; static EndStaticAttribute(): void; /** * Push a single AttributeFlags value. By default, only AttributeFlags_None is set. */ static PushAttributeFlag(flag: ImNodesAttributeFlags): void; static PopAttributeFlag(): void; /** * Render a link between attributes. * The attributes ids used here must match the ids used in Begin(Input|Output)Attribute function * calls. The order of start_attr and end_attr doesn't make a difference for rendering the link. */ static Link(id: number, start_attribute_id: number, end_attribute_id: number): void; /** * Enable or disable the ability to click and drag a specific node. */ static SetNodeDraggable(node_id: number, draggable: boolean): void; static SetNodeScreenSpacePos(node_id: number, screen_space_pos: ImVec2): void; static SetNodeEditorSpacePos(node_id: number, editor_space_pos: ImVec2): void; static SetNodeGridSpacePos(node_id: number, grid_space_pos: ImVec2): void; static GetNodeScreenSpacePos(node_id: number): ImVec2; static GetNodeEditorSpacePos(node_id: number): ImVec2; static GetNodeGridSpacePos(node_id: number): ImVec2; /** * If ImNodesStyleFlags_GridSnapping is enabled, snap the specified node's origin to the grid. */ static SnapNodeToGrid(node_id: number): void; /** * Returns true if the current node editor canvas is being hovered over by the mouse, and is not * blocked by any other windows. */ static IsEditorHovered(): boolean; static IsNodeHovered(node_id: [number]): boolean; static IsLinkHovered(link_id: [number]): boolean; static IsPinHovered(attribute_id: [number]): boolean; static NumSelectedNodes(): number; static NumSelectedLinks(): number; static GetSelectedNodes(node_ids: number[]): void; static GetSelectedLinks(link_ids: number[]): void; static ClearNodeSelection(): void; static ClearLinkSelection(): void; static SelectNode(node_id: number): void; static ClearNodeSelectionID(node_id: number): void; static IsNodeSelected(node_id: number): boolean; static SelectLink(link_id: number): void; static ClearLinkSelectionID(link_id: number): void; static IsLinkSelected(link_id: number): boolean; /** * Was the previous attribute active? This will continuously return true while the left mouse button * is being pressed over the UI content of the attribute. */ static IsAttributeActive(): boolean; /** * Was any attribute active? If so, sets the active attribute id to the output function argument. */ static IsAnyAttributeActive(attribute_id?: [number] | null): boolean; /** * Did the user start dragging a new link from a pin? */ static IsLinkStarted(started_at_attribute_id: [number]): boolean; /** * Did the user drop the dragged link before attaching it to a pin? * There are two different kinds of situations to consider when handling this event: * 1) a link which is created at a pin and then dropped * 2) an existing link which is detached from a pin and then dropped * Use the including_detached_links flag to control whether this function triggers when the user * detaches a link and drops it. */ static IsLinkDropped(started_at_attribute_id?: [number] | null, including_detached_links?: boolean): boolean; /** * Did the user finish creating a new link? */ static IsLinkCreated(started_at_attribute_id?: [number] | null, ended_at_attribute_id?: [number] | null, created_from_snap?: [boolean] | null): boolean; static IsLinkCreatedEx(started_at_node_id?: [number] | null, started_at_attribute_id?: [number] | null, ended_at_node_id?: [number] | null, ended_at_attribute_id?: [number] | null, created_from_snap?: [boolean] | null): boolean; /** * Was an existing link detached from a pin by the user? The detached link's id is assigned to the * output argument link_id. */ static IsLinkDestroyed(link_id: [number]): boolean; static SaveCurrentEditorStateToIniString(): string; static SaveEditorStateToIniString(editor: ImNodesEditorContext): string; static LoadCurrentEditorStateFromIniString(data: string): void; static LoadEditorStateFromIniString(editor: ImNodesEditorContext, data: string): void; }