diff --git a/imgui.ts b/imgui.ts index 8b5038c..018af05 100644 --- a/imgui.ts +++ b/imgui.ts @@ -6,18 +6,1636 @@ export interface RGBA extends RGB { a: number; } import * as Bind from "./bind-imgui"; -export { Bind }; +//export { Bind }; -let bind: Bind.Module; -export default async function(value?: Partial): Promise { - return new Promise((resolve: () => void) => { - Bind.default(value).then((value: Bind.Module): void => { - bind = value; - resolve(); +let global_bind: Bind.Module; + +export class ImGui +{ + bind!: Bind.Module; + async initBinding(value?: Partial): Promise { + return new Promise((resolve: () => void) => { + Bind.default(value).then((value: Bind.Module): void => { + this.bind = value; + if (!global_bind) global_bind = value; + resolve(); + }); }); - }); + } + // #define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert)) + IMGUI_CHECKVERSION(): boolean { return this.DebugCheckVersionAndDataLayout(IMGUI_VERSION, this.bind.ImGuiIOSize, this.bind.ImGuiStyleSize, this.bind.ImVec2Size, this.bind.ImVec4Size, this.bind.ImDrawVertSize); } + // IMGUI_API ImGuiContext* CreateContext(ImFontAtlas* shared_font_atlas = NULL); + CreateContext(shared_font_atlas: ImFontAtlas | null = null): ImGuiContext | null { + const ctx: ImGuiContext = new ImGuiContext(this.bind.CreateContext()); + if (ImGuiContext.current_ctx === null) { + ImGuiContext.current_ctx = ctx; + } + return ctx; + } + // IMGUI_API void DestroyContext(ImGuiContext* ctx = NULL); // NULL = Destroy current context + DestroyContext(ctx: ImGuiContext | null = null): void { + if (ctx === null) { + ctx = ImGuiContext.current_ctx; + ImGuiContext.current_ctx = null; + } + this.bind.DestroyContext((ctx === null) ? null : ctx.native); + } + // IMGUI_API ImGuiContext* GetCurrentContext(); + GetCurrentContext(): ImGuiContext | null { + // const ctx_native: BindImGui.ImGuiContext | null = bind.GetCurrentContext(); + return ImGuiContext.current_ctx; + } + // IMGUI_API void SetCurrentContext(ImGuiContext* ctx); + SetCurrentContext(ctx: ImGuiContext | null): void { + this.bind.SetCurrentContext((ctx === null) ? null : ctx.native); + ImGuiContext.current_ctx = ctx; + } + + // IMGUI_API bool DebugCheckVersionAndDataLayout(const char* version_str, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_drawvert); + DebugCheckVersionAndDataLayout(version_str: string, sz_io: number, sz_style: number, sz_vec2: number, sz_vec4: number, sz_draw_vert: number): boolean { + return this.bind.DebugCheckVersionAndDataLayout(version_str, sz_io, sz_style, sz_vec2, sz_vec4, sz_draw_vert); + } + + // Main + // IMGUI_API ImGuiIO& GetIO(); + GetIO(): ImGuiIO { return new ImGuiIO(this.bind.GetIO()); } + // IMGUI_API ImGuiStyle& GetStyle(); + GetStyle(): ImGuiStyle { return new ImGuiStyle(this.bind.GetStyle()); } + // IMGUI_API void NewFrame(); // start a new ImGui frame, you can submit any command from this point until Render()/EndFrame(). + NewFrame(): void { this.bind.NewFrame(); } + // IMGUI_API void EndFrame(); // ends the ImGui frame. automatically called by Render(), so most likely don't need to ever call that yourself directly. If you don't need to render you may call EndFrame() but you'll have wasted CPU already. If you don't need to render, better to not create any imgui windows instead! + EndFrame(): void { this.bind.EndFrame(); } + // IMGUI_API void Render(); // ends the ImGui frame, finalize the draw data, then call your io.RenderDrawListsFn() function if set. + Render(): void { this.bind.Render(); } + // IMGUI_API ImDrawData* GetDrawData(); // same value as passed to your io.RenderDrawListsFn() function. valid after Render() and until the next call to NewFrame() + GetDrawData(): ImDrawData | null { + const draw_data: Bind.reference_ImDrawData | null = this.bind.GetDrawData(); + return (draw_data === null) ? null : new ImDrawData(draw_data); + } + + // Demo, Debug, Informations + // IMGUI_API void ShowDemoWindow(bool* p_open = NULL); // create demo/test window (previously called ShowTestWindow). demonstrate most ImGui features. call this to learn about the library! try to make it always available in your application! + ShowDemoWindow(p_open: Bind.ImScalar | null = null): void { this.bind.ShowDemoWindow(p_open); } + // IMGUI_API void ShowAboutWindow(bool* p_open = NULL); // create about window. display Dear ImGui version, credits and build/system information. + ShowAboutWindow(p_open: Bind.ImScalar | Bind.ImAccess | null = null): void { + if (p_open === null) { + this.bind.ShowAboutWindow(null); + } else if (Array.isArray(p_open)) { + this.bind.ShowAboutWindow(p_open); + } else { + const ref_open: Bind.ImScalar = [ p_open() ]; + this.bind.ShowAboutWindow(ref_open); + p_open(ref_open[0]); + } + } + // IMGUI_API void ShowMetricsWindow(bool* p_open = NULL); // create metrics window. display ImGui internals: draw commands (with individual draw calls and vertices), window list, basic internal state, etc. + ShowMetricsWindow(p_open: Bind.ImScalar | Bind.ImAccess | null = null): void { + if (p_open === null) { + this.bind.ShowMetricsWindow(null); + } else if (Array.isArray(p_open)) { + this.bind.ShowMetricsWindow(p_open); + } else { + const ref_open: Bind.ImScalar = [ p_open() ]; + this.bind.ShowMetricsWindow(ref_open); + p_open(ref_open[0]); + } + } + // IMGUI_API void ShowStyleEditor(ImGuiStyle* ref = NULL); // add style editor block (not a window). you can pass in a reference ImGuiStyle structure to compare to, revert to and save to (else it uses the default style) + ShowStyleEditor(ref: ImGuiStyle | null = null): void { + if (ref === null) { + this.bind.ShowStyleEditor(null); + } else if (ref.internal instanceof this.bind.ImGuiStyle) { + this.bind.ShowStyleEditor(ref.internal); + } else { + const native = new this.bind.ImGuiStyle(); + const wrap = new ImGuiStyle(native); + wrap.Copy(ref); + this.bind.ShowStyleEditor(native); + ref.Copy(wrap); + native.delete(); + } + } + // IMGUI_API bool ShowStyleSelector(const char* label); + ShowStyleSelector(label: string): boolean { return this.bind.ShowStyleSelector(label); } + // IMGUI_API void ShowFontSelector(const char* label); + ShowFontSelector(label: string): void { this.bind.ShowFontSelector(label); } + // IMGUI_API void ShowUserGuide(); // add basic help/info block (not a window): how to manipulate ImGui as a end-user (mouse/keyboard controls). + ShowUserGuide(): void { this.bind.ShowUserGuide(); } + // IMGUI_API const char* GetVersion(); + GetVersion(): string { return this.bind.GetVersion(); } + + // Styles + // IMGUI_API void StyleColorsClassic(ImGuiStyle* dst = NULL); + StyleColorsClassic(dst: ImGuiStyle | null = null): void { + if (dst === null) { + this.bind.StyleColorsClassic(null); + } else if (dst.internal instanceof this.bind.ImGuiStyle) { + this.bind.StyleColorsClassic(dst.internal); + } else { + const native = new this.bind.ImGuiStyle(); + const wrap = new ImGuiStyle(native); + wrap.Copy(dst); + this.bind.StyleColorsClassic(native); + dst.Copy(wrap); + native.delete(); + } + } + // IMGUI_API void StyleColorsDark(ImGuiStyle* dst = NULL); + StyleColorsDark(dst: ImGuiStyle | null = null): void { + if (dst === null) { + this.bind.StyleColorsDark(null); + } else if (dst.internal instanceof this.bind.ImGuiStyle) { + this.bind.StyleColorsDark(dst.internal); + } else { + const native = new this.bind.ImGuiStyle(); + const wrap = new ImGuiStyle(native); + wrap.Copy(dst); + this.bind.StyleColorsDark(native); + dst.Copy(wrap); + native.delete(); + } + } + // IMGUI_API void StyleColorsLight(ImGuiStyle* dst = NULL); + StyleColorsLight(dst: ImGuiStyle | null = null): void { + if (dst === null) { + this.bind.StyleColorsLight(null); + } else if (dst.internal instanceof this.bind.ImGuiStyle) { + this.bind.StyleColorsLight(dst.internal); + } else { + const native = new this.bind.ImGuiStyle(); + const wrap = new ImGuiStyle(native); + wrap.Copy(dst); + this.bind.StyleColorsLight(native); + dst.Copy(wrap); + native.delete(); + } + } + + // Window + // IMGUI_API bool Begin(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0); // push window to the stack and start appending to it. see .cpp for details. return false when window is collapsed, so you can early out in your code. 'bool* p_open' creates a widget on the upper-right to close the window (which sets your bool to false). + Begin(name: string, open: Bind.ImScalar | Bind.ImAccess | null = null, flags: ImGuiWindowFlags = 0): boolean { + if (open === null) { + return this.bind.Begin(name, null, flags); + } else if (Array.isArray(open)) { + return this.bind.Begin(name, open, flags); + } else { + const ref_open: Bind.ImScalar = [ open() ]; + const opened: boolean = this.bind.Begin(name, ref_open, flags); + open(ref_open[0]); + return opened; + } + } + // IMGUI_API void End(); // finish appending to current window, pop it off the window stack. + End(): void { this.bind.End(); } + // IMGUI_API bool BeginChild(const char* str_id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); // begin a scrolling region. size==0.0f: use remaining window size, size<0.0f: use remaining window size minus abs(size). size>0.0f: fixed size. each axis can use a different mode, e.g. ImVec2(0,400). + // IMGUI_API bool BeginChild(ImGuiID id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); // " + BeginChild(id: string | Bind.ImGuiID, size: Readonly = ImVec2.ZERO, border: boolean = false, extra_flags: ImGuiWindowFlags = 0): boolean { + return this.bind.BeginChild(id, size, border, extra_flags); + } + // IMGUI_API void EndChild(); + EndChild(): void { this.bind.EndChild(); } + // IMGUI_API ImVec2 GetContentRegionMax(); // current content boundaries (typically window boundaries including scrolling, or current column boundaries), in windows coordinates + GetContentRegionMax(out: Bind.interface_ImVec2 = new ImVec2()): typeof out { + return this.bind.GetContentRegionMax(out); + } + // IMGUI_API ImVec2 GetContentRegionAvail(); // == GetContentRegionMax() - GetCursorPos() + GetContentRegionAvail(out: Bind.interface_ImVec2 = new ImVec2()): typeof out { + return this.bind.GetContentRegionAvail(out); + } + // IMGUI_API float GetContentRegionAvailWidth(); // + GetContentRegionAvailWidth(): number { return this.bind.GetContentRegionAvailWidth(); } + // IMGUI_API ImVec2 GetWindowContentRegionMin(); // content boundaries min (roughly (0,0)-Scroll), in window coordinates + GetWindowContentRegionMin(out: Bind.interface_ImVec2 = new ImVec2()): typeof out { + return this.bind.GetWindowContentRegionMin(out); + } + // IMGUI_API ImVec2 GetWindowContentRegionMax(); // content boundaries max (roughly (0,0)+Size-Scroll) where Size can be override with SetNextWindowContentSize(), in window coordinates + GetWindowContentRegionMax(out: Bind.interface_ImVec2 = new ImVec2()): typeof out { + return this.bind.GetWindowContentRegionMax(out); + } + // IMGUI_API float GetWindowContentRegionWidth(); // + GetWindowContentRegionWidth(): number { return this.bind.GetWindowContentRegionWidth(); } + // IMGUI_API ImDrawList* GetWindowDrawList(); // get rendering command-list if you want to append your own draw primitives + GetWindowDrawList(): ImDrawList { + return new ImDrawList(this.bind.GetWindowDrawList()); + } + // IMGUI_API ImVec2 GetWindowPos(); // get current window position in screen space (useful if you want to do your own drawing via the DrawList api) + GetWindowPos(out: Bind.interface_ImVec2 = new ImVec2()): typeof out { + return this.bind.GetWindowPos(out); + } + // IMGUI_API ImVec2 GetWindowSize(); // get current window size + GetWindowSize(out: Bind.interface_ImVec2 = new ImVec2()): typeof out { + return this.bind.GetWindowSize(out); + } + // IMGUI_API float GetWindowWidth(); + GetWindowWidth(): number { return this.bind.GetWindowWidth(); } + // IMGUI_API float GetWindowHeight(); + GetWindowHeight(): number { return this.bind.GetWindowHeight(); } + // IMGUI_API bool IsWindowCollapsed(); + IsWindowCollapsed(): boolean { return this.bind.IsWindowCollapsed(); } + // IMGUI_API bool IsWindowAppearing(); + IsWindowAppearing(): boolean { return this.bind.IsWindowAppearing(); } + // IMGUI_API void SetWindowFontScale(float scale); // per-window font scale. Adjust IO.FontGlobalScale if you want to scale all windows + SetWindowFontScale(scale: number): void { this.bind.SetWindowFontScale(scale); } + + // IMGUI_API void SetNextWindowPos(const ImVec2& pos, ImGuiCond cond = 0, const ImVec2& pivot = ImVec2(0,0)); // set next window position. call before Begin(). use pivot=(0.5f,0.5f) to center on given point, etc. + SetNextWindowPos(pos: Readonly, cond: ImGuiCond = 0, pivot: Readonly = ImVec2.ZERO): void { + this.bind.SetNextWindowPos(pos, cond, pivot); + } + // IMGUI_API void SetNextWindowSize(const ImVec2& size, ImGuiCond cond = 0); // set next window size. set axis to 0.0f to force an auto-fit on this axis. call before Begin() + SetNextWindowSize(pos: Readonly, cond: ImGuiCond = 0): void { + this.bind.SetNextWindowSize(pos, cond); + } + // IMGUI_API void SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeConstraintCallback custom_callback = NULL, void* custom_callback_data = NULL); // set next window size limits. use -1,-1 on either X/Y axis to preserve the current size. Use callback to apply non-trivial programmatic constraints. + SetNextWindowSizeConstraints(size_min: Readonly, size_max: Readonly, custom_callback: ImGuiSizeConstraintCallback | null = null, custom_callback_data: any = null): void { + if (custom_callback) { + this.bind.SetNextWindowSizeConstraints(size_min, size_max, (data: Bind.reference_ImGuiSizeCallbackData): void => { + custom_callback(new ImGuiSizeCallbackData(data, custom_callback_data)); + }, null); + } else { + this.bind.SetNextWindowSizeConstraints(size_min, size_max, null, null); + } + } + // IMGUI_API void SetNextWindowContentSize(const ImVec2& size); // set next window content size (~ enforce the range of scrollbars). not including window decorations (title bar, menu bar, etc.). set an axis to 0.0f to leave it automatic. call before Begin() + SetNextWindowContentSize(size: Readonly): void { + this.bind.SetNextWindowContentSize(size); + } + // IMGUI_API void SetNextWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // set next window collapsed state. call before Begin() + SetNextWindowCollapsed(collapsed: boolean, cond: ImGuiCond = 0): void { + this.bind.SetNextWindowCollapsed(collapsed, cond); + } + // IMGUI_API void SetNextWindowFocus(); // set next window to be focused / front-most. call before Begin() + SetNextWindowFocus(): void { this.bind.SetNextWindowFocus(); } + // IMGUI_API void SetNextWindowBgAlpha(float alpha); // set next window background color alpha. helper to easily modify ImGuiCol_WindowBg/ChildBg/PopupBg. + SetNextWindowBgAlpha(alpha: number): void { this.bind.SetNextWindowBgAlpha(alpha); } + // IMGUI_API void SetWindowPos(const ImVec2& pos, ImGuiCond cond = 0); // (not recommended) set current window position - call within Begin()/End(). prefer using SetNextWindowPos(), as this may incur tearing and side-effects. + // IMGUI_API void SetWindowSize(const ImVec2& size, ImGuiCond cond = 0); // (not recommended) set current window size - call within Begin()/End(). set to ImVec2(0,0) to force an auto-fit. prefer using SetNextWindowSize(), as this may incur tearing and minor side-effects. + // IMGUI_API void SetWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // (not recommended) set current window collapsed state. prefer using SetNextWindowCollapsed(). + // IMGUI_API void SetWindowFocus(); // (not recommended) set current window to be focused / front-most. prefer using SetNextWindowFocus(). + // IMGUI_API void SetWindowPos(const char* name, const ImVec2& pos, ImGuiCond cond = 0); // set named window position. + // IMGUI_API void SetWindowSize(const char* name, const ImVec2& size, ImGuiCond cond = 0); // set named window size. set axis to 0.0f to force an auto-fit on this axis. + // IMGUI_API void SetWindowCollapsed(const char* name, bool collapsed, ImGuiCond cond = 0); // set named window collapsed state + // IMGUI_API void SetWindowFocus(const char* name); // set named window to be focused / front-most. use NULL to remove focus. + SetWindowPos(name_or_pos: string | Readonly, pos_or_cond: Readonly | ImGuiCond = 0, cond: ImGuiCond = 0): void { + if (typeof(name_or_pos) === "string") { + this.bind.SetWindowNamePos(name_or_pos, pos_or_cond as Readonly, cond); + return; + } else { + this.bind.SetWindowPos(name_or_pos, pos_or_cond as ImGuiCond); + } + } + SetWindowSize(name_or_size: string | Readonly, size_or_cond: Readonly | ImGuiCond = 0, cond: ImGuiCond = 0): void { + if (typeof(name_or_size) === "string") { + this.bind.SetWindowNamePos(name_or_size, size_or_cond as Readonly, cond); + } else { + this.bind.SetWindowSize(name_or_size, size_or_cond as ImGuiCond); + } + } + SetWindowCollapsed(name_or_collapsed: string | boolean, collapsed_or_cond: boolean | ImGuiCond = 0, cond: ImGuiCond = 0): void { + if (typeof(name_or_collapsed) === "string") { + this.bind.SetWindowNameCollapsed(name_or_collapsed, collapsed_or_cond as boolean, cond); + } else { + this.bind.SetWindowCollapsed(name_or_collapsed, collapsed_or_cond as ImGuiCond); + } + } + SetWindowFocus(name?: string): void { + if (typeof(name) === "string") { + this.bind.SetWindowNameFocus(name); + } else { + this.bind.SetWindowFocus(); + } + } + + // IMGUI_API float GetScrollX(); // get scrolling amount [0..GetScrollMaxX()] + GetScrollX(): number { return this.bind.GetScrollX(); } + // IMGUI_API float GetScrollY(); // get scrolling amount [0..GetScrollMaxY()] + GetScrollY(): number { return this.bind.GetScrollY(); } + // IMGUI_API float GetScrollMaxX(); // get maximum scrolling amount ~~ ContentSize.X - WindowSize.X + GetScrollMaxX(): number { return this.bind.GetScrollMaxX(); } + // IMGUI_API float GetScrollMaxY(); // get maximum scrolling amount ~~ ContentSize.Y - WindowSize.Y + GetScrollMaxY(): number { return this.bind.GetScrollMaxY(); } + // IMGUI_API void SetScrollX(float scroll_x); // set scrolling amount [0..GetScrollMaxX()] + SetScrollX(scroll_x: number): void { this.bind.SetScrollX(scroll_x); } + // IMGUI_API void SetScrollY(float scroll_y); // set scrolling amount [0..GetScrollMaxY()] + SetScrollY(scroll_y: number): void { this.bind.SetScrollY(scroll_y); } + // IMGUI_API void SetScrollHereY(float center_y_ratio = 0.5f); // adjust scrolling amount to make current cursor position visible. center_y_ratio=0.0: top, 0.5: center, 1.0: bottom. When using to make a "default/current item" visible, consider using SetItemDefaultFocus() instead. + SetScrollHereY(center_y_ratio: number = 0.5): void { + this.bind.SetScrollHereY(center_y_ratio); + } + // IMGUI_API void SetScrollFromPosY(float pos_y, float center_y_ratio = 0.5f); // adjust scrolling amount to make given position valid. use GetCursorPos() or GetCursorStartPos()+offset to get valid positions. + SetScrollFromPosY(pos_y: number, center_y_ratio: number = 0.5): void { + this.bind.SetScrollFromPosY(pos_y, center_y_ratio); + } + // IMGUI_API void SetStateStorage(ImGuiStorage* tree); // replace tree state storage with our own (if you want to manipulate it yourself, typically clear subsection of it) + // IMGUI_API ImGuiStorage* GetStateStorage(); + + // Parameters stacks (shared) + // IMGUI_API void PushFont(ImFont* font); // use NULL as a shortcut to push default font + PushFont(font: ImFont | null): void { this.bind.PushFont(font ? font.native : null); } + // IMGUI_API void PopFont(); + PopFont(): void { this.bind.PopFont(); } + // IMGUI_API void PushStyleColor(ImGuiCol idx, ImU32 col); + // IMGUI_API void PushStyleColor(ImGuiCol idx, const ImVec4& col); + PushStyleColor(idx: ImGuiCol, col: Bind.ImU32 | Readonly | Readonly): void { + if (col instanceof ImColor) { + this.bind.PushStyleColor(idx, col.Value); + } else { + this.bind.PushStyleColor(idx, col as (Bind.ImU32 | Readonly)); + } + } + // IMGUI_API void PopStyleColor(int count = 1); + PopStyleColor(count: number = 1): void { + this.bind.PopStyleColor(count); + } + // IMGUI_API void PushStyleVar(ImGuiStyleVar idx, float val); + // IMGUI_API void PushStyleVar(ImGuiStyleVar idx, const ImVec2& val); + PushStyleVar(idx: ImGuiStyleVar, val: number | Readonly): void { + this.bind.PushStyleVar(idx, val); + } + // IMGUI_API void PopStyleVar(int count = 1); + PopStyleVar(count: number = 1): void { + this.bind.PopStyleVar(count); + } + // IMGUI_API const ImVec4& GetStyleColorVec4(ImGuiCol idx); // retrieve style color as stored in ImGuiStyle structure. use to feed back into PushStyleColor(), otherwhise use GetColorU32() to get style color + style alpha. + GetStyleColorVec4(idx: ImGuiCol): Readonly { + return this.bind.GetStyleColorVec4(idx); + } + // IMGUI_API ImFont* GetFont(); // get current font + GetFont(): ImFont { + return new ImFont(this.bind.GetFont()); + } + // IMGUI_API float GetFontSize(); // get current font size (= height in pixels) of current font with current scale applied + GetFontSize(): number { return this.bind.GetFontSize(); } + // IMGUI_API ImVec2 GetFontTexUvWhitePixel(); // get UV coordinate for a while pixel, useful to draw custom shapes via the ImDrawList API + GetFontTexUvWhitePixel(out: Bind.interface_ImVec2 = new ImVec2()): typeof out { + return this.bind.GetFontTexUvWhitePixel(out); + } + // IMGUI_API ImU32 GetColorU32(ImGuiCol idx, float alpha_mul = 1.0f); // retrieve given style color with style alpha applied and optional extra alpha multiplier + // IMGUI_API ImU32 GetColorU32(const ImVec4& col); // retrieve given color with style alpha applied + // IMGUI_API ImU32 GetColorU32(ImU32 col); // retrieve given color with style alpha applied + GetColorU32(idx: ImGuiCol, alpha_mul?: number): Bind.ImU32; + GetColorU32(col: Readonly): Bind.ImU32; + GetColorU32(col: Bind.ImU32): Bind.ImU32; + GetColorU32(...args: any[]): Bind.ImU32 { + if (args.length === 1) { + if (typeof(args[0]) === "number") { + // TODO: ImGuiCol or ImU32 + const idx: ImGuiCol = args[0]; + return this.bind.GetColorU32_A(idx, 1.0); + } else { + const col: Readonly = args[0]; + return this.bind.GetColorU32_B(col); + } + } else { + const idx: ImGuiCol = args[0]; + const alpha_mul: number = args[1]; + return this.bind.GetColorU32_A(idx, alpha_mul); + } + } + + // Parameters stacks (current window) + // IMGUI_API void PushItemWidth(float item_width); // width of items for the common item+label case, pixels. 0.0f = default to ~2/3 of windows width, >0.0f: width in pixels, <0.0f align xx pixels to the right of window (so -1.0f always align width to the right side) + PushItemWidth(item_width: number): void { this.bind.PushItemWidth(item_width); } + // IMGUI_API void PopItemWidth(); + PopItemWidth(): void { this.bind.PopItemWidth(); } + // IMGUI_API float CalcItemWidth(); // width of item given pushed settings and current cursor position + CalcItemWidth(): number { return this.bind.CalcItemWidth(); } + // IMGUI_API void PushTextWrapPos(float wrap_pos_x = 0.0f); // word-wrapping for Text*() commands. < 0.0f: no wrapping; 0.0f: wrap to end of window (or column); > 0.0f: wrap at 'wrap_pos_x' position in window local space + PushTextWrapPos(wrap_pos_x: number = 0.0): void { + this.bind.PushTextWrapPos(wrap_pos_x); + } + // IMGUI_API void PopTextWrapPos(); + PopTextWrapPos(): void { this.bind.PopTextWrapPos(); } + // IMGUI_API void PushAllowKeyboardFocus(bool allow_keyboard_focus); // allow focusing using TAB/Shift-TAB, enabled by default but you can disable it for certain widgets + PushAllowKeyboardFocus(allow_keyboard_focus: boolean): void { this.bind.PushAllowKeyboardFocus(allow_keyboard_focus); } + // IMGUI_API void PopAllowKeyboardFocus(); + PopAllowKeyboardFocus(): void { this.bind.PopAllowKeyboardFocus(); } + // IMGUI_API void PushButtonRepeat(bool repeat); // in 'repeat' mode, Button*() functions return repeated true in a typematic manner (using io.KeyRepeatDelay/io.KeyRepeatRate setting). Note that you can call IsItemActive() after any Button() to tell if the button is held in the current frame. + PushButtonRepeat(repeat: boolean): void { this.bind.PushButtonRepeat(repeat); } + // IMGUI_API void PopButtonRepeat(); + PopButtonRepeat(): void { this.bind.PopButtonRepeat(); } + + // Cursor / Layout + // IMGUI_API void Separator(); // separator, generally horizontal. inside a menu bar or in horizontal layout mode, this becomes a vertical separator. + Separator(): void { this.bind.Separator(); } + // IMGUI_API void SameLine(float pos_x = 0.0f, float spacing_w = -1.0f); // call between widgets or groups to layout them horizontally + SameLine(pos_x: number = 0.0, spacing_w: number = -1.0): void { + this.bind.SameLine(pos_x, spacing_w); + } + // IMGUI_API void NewLine(); // undo a SameLine() + NewLine(): void { this.bind.NewLine(); } + // IMGUI_API void Spacing(); // add vertical spacing + Spacing(): void { this.bind.Spacing(); } + // IMGUI_API void Dummy(const ImVec2& size); // add a dummy item of given size + Dummy(size: Readonly): void { this.bind.Dummy(size); } + // IMGUI_API void Indent(float indent_w = 0.0f); // move content position toward the right, by style.IndentSpacing or indent_w if != 0 + Indent(indent_w: number = 0.0) { this.bind.Indent(indent_w); } + // IMGUI_API void Unindent(float indent_w = 0.0f); // move content position back to the left, by style.IndentSpacing or indent_w if != 0 + Unindent(indent_w: number = 0.0) { this.bind.Unindent(indent_w); } + // IMGUI_API void BeginGroup(); // lock horizontal starting position + capture group bounding box into one "item" (so you can use IsItemHovered() or layout primitives such as SameLine() on whole group, etc.) + BeginGroup(): void { this.bind.BeginGroup(); } + // IMGUI_API void EndGroup(); + EndGroup(): void { this.bind.EndGroup(); } + // IMGUI_API ImVec2 GetCursorPos(); // cursor position is relative to window position + GetCursorPos(out: Bind.interface_ImVec2 = new ImVec2()): typeof out { return this.bind.GetCursorPos(out); } + // IMGUI_API float GetCursorPosX(); // " + GetCursorPosX(): number { return this.bind.GetCursorPosX(); } + // IMGUI_API float GetCursorPosY(); // " + GetCursorPosY(): number { return this.bind.GetCursorPosY(); } + // IMGUI_API void SetCursorPos(const ImVec2& local_pos); // " + SetCursorPos(local_pos: Readonly): void { this.bind.SetCursorPos(local_pos); } + // IMGUI_API void SetCursorPosX(float x); // " + SetCursorPosX(x: number): void { this.bind.SetCursorPosX(x); } + // IMGUI_API void SetCursorPosY(float y); // " + SetCursorPosY(y: number): void { this.bind.SetCursorPosY(y); } + // IMGUI_API ImVec2 GetCursorStartPos(); // initial cursor position + GetCursorStartPos(out: Bind.interface_ImVec2 = new ImVec2()): typeof out { return this.bind.GetCursorStartPos(out); } + // IMGUI_API ImVec2 GetCursorScreenPos(); // cursor position in absolute screen coordinates [0..io.DisplaySize] (useful to work with ImDrawList API) + GetCursorScreenPos(out: Bind.interface_ImVec2 = new ImVec2()): typeof out { return this.bind.GetCursorScreenPos(out); } + // IMGUI_API void SetCursorScreenPos(const ImVec2& pos); // cursor position in absolute screen coordinates [0..io.DisplaySize] + SetCursorScreenPos(pos: Readonly): void { this.bind.SetCursorScreenPos(pos); } + // IMGUI_API void AlignTextToFramePadding(); // vertically align/lower upcoming text to FramePadding.y so that it will aligns to upcoming widgets (call if you have text on a line before regular widgets) + AlignTextToFramePadding(): void { this.bind.AlignTextToFramePadding(); } + // IMGUI_API float GetTextLineHeight(); // ~ FontSize + GetTextLineHeight(): number { return this.bind.GetTextLineHeight(); } + // IMGUI_API float GetTextLineHeightWithSpacing(); // ~ FontSize + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of text) + GetTextLineHeightWithSpacing(): number { return this.bind.GetTextLineHeightWithSpacing(); } + // IMGUI_API float GetFrameHeight(); // ~ FontSize + style.FramePadding.y * 2 + GetFrameHeight(): number { return this.bind.GetFrameHeight(); } + // IMGUI_API float GetFrameHeightWithSpacing(); // ~ FontSize + style.FramePadding.y * 2 + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of framed widgets) + GetFrameHeightWithSpacing(): number { return this.bind.GetFrameHeightWithSpacing(); } + + // Columns + // You can also use SameLine(pos_x) for simplified columns. The columns API is still work-in-progress and rather lacking. + // IMGUI_API void Columns(int count = 1, const char* id = NULL, bool border = true); + Columns(count: number = 1, id: string | null = null, border: boolean = true): void { + id = id || ""; + this.bind.Columns(count, id, border); + } + // IMGUI_API void NextColumn(); // next column, defaults to current row or next row if the current row is finished + NextColumn(): void { this.bind.NextColumn(); } + // IMGUI_API int GetColumnIndex(); // get current column index + GetColumnIndex(): number { return this.bind.GetColumnIndex(); } + // IMGUI_API float GetColumnWidth(int column_index = -1); // get column width (in pixels). pass -1 to use current column + GetColumnWidth(column_index: number = -1): number { + return this.bind.GetColumnWidth(column_index); + } + // IMGUI_API void SetColumnWidth(int column_index, float width); // set column width (in pixels). pass -1 to use current column + SetColumnWidth(column_index: number, width: number): void { this.bind.SetColumnWidth(column_index, width); } + // IMGUI_API float GetColumnOffset(int column_index = -1); // get position of column line (in pixels, from the left side of the contents region). pass -1 to use current column, otherwise 0..GetColumnsCount() inclusive. column 0 is typically 0.0f + GetColumnOffset(column_index: number = -1): number { + return this.bind.GetColumnOffset(column_index); + } + // IMGUI_API void SetColumnOffset(int column_index, float offset_x); // set position of column line (in pixels, from the left side of the contents region). pass -1 to use current column + SetColumnOffset(column_index: number, offset_x: number): void { this.bind.SetColumnOffset(column_index, offset_x); } + // IMGUI_API int GetColumnsCount(); + GetColumnsCount(): number { return this.bind.GetColumnsCount(); } + + // ID scopes + // If you are creating widgets in a loop you most likely want to push a unique identifier (e.g. object pointer, loop index) so ImGui can differentiate them. + // You can also use the "##foobar" syntax within widget label to distinguish them from each others. Read "A primer on the use of labels/IDs" in the FAQ for more details. + // IMGUI_API void PushID(const char* str_id); // push identifier into the ID stack. IDs are hash of the entire stack! + // IMGUI_API void PushID(const char* str_id_begin, const char* str_id_end); + // IMGUI_API void PushID(const void* ptr_id); + // IMGUI_API void PushID(int int_id); + PushID(id: string | number): void { this.bind.PushID(id); } + // IMGUI_API void PopID(); + PopID(): void { this.bind.PopID(); } + // IMGUI_API ImGuiID GetID(const char* str_id); // calculate unique ID (hash of whole ID stack + given parameter). e.g. if you want to query into ImGuiStorage yourself + // IMGUI_API ImGuiID GetID(const char* str_id_begin, const char* str_id_end); + // IMGUI_API ImGuiID GetID(const void* ptr_id); + GetID(id: string | number): Bind.ImGuiID { return this.bind.GetID(id); } + + // Widgets: Text + // IMGUI_API void TextUnformatted(const char* text, const char* text_end = NULL); // raw text without formatting. Roughly equivalent to Text("%s", text) but: A) doesn't require null terminated string if 'text_end' is specified, B) it's faster, no memory copy is done, no buffer size limits, recommended for long chunks of text. + TextUnformatted(text: string, text_end: number | null = null): void { this.bind.TextUnformatted(text_end !== null ? text.substring(0, text_end) : text); } + // IMGUI_API void Text(const char* fmt, ...) IM_FMTARGS(1); // simple formatted text + // IMGUI_API void TextV(const char* fmt, va_list args) IM_FMTLIST(1); + Text(fmt: string/*, ...args: any[]*/): void { this.bind.Text(fmt/*, ...args*/); } + // IMGUI_API void TextColored(const ImVec4& col, const char* fmt, ...) IM_FMTARGS(2); // shortcut for PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor(); + // IMGUI_API void TextColoredV(const ImVec4& col, const char* fmt, va_list args) IM_FMTLIST(2); + TextColored(col: Readonly | Readonly, fmt: string/*, ...args: any[]*/): void { + this.bind.TextColored((col instanceof ImColor) ? col.Value : col as Readonly, fmt/*, ...args*/); + } + // IMGUI_API void TextDisabled(const char* fmt, ...) IM_FMTARGS(1); // shortcut for PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]); Text(fmt, ...); PopStyleColor(); + // IMGUI_API void TextDisabledV(const char* fmt, va_list args) IM_FMTLIST(1); + TextDisabled(fmt: string/*, ...args: any[]*/): void { this.bind.TextDisabled(fmt/*, ...args*/); } + // IMGUI_API void TextWrapped(const char* fmt, ...) IM_FMTARGS(1); // shortcut for PushTextWrapPos(0.0f); Text(fmt, ...); PopTextWrapPos();. Note that this won't work on an auto-resizing window if there's no other widgets to extend the window width, yoy may need to set a size using SetNextWindowSize(). + // IMGUI_API void TextWrappedV(const char* fmt, va_list args) IM_FMTLIST(1); + TextWrapped(fmt: string/*, ...args: any[]*/): void { this.bind.TextWrapped(fmt/*, ...args*/); } + // IMGUI_API void LabelText(const char* label, const char* fmt, ...) IM_FMTARGS(2); // display text+label aligned the same way as value+label widgets + // IMGUI_API void LabelTextV(const char* label, const char* fmt, va_list args) IM_FMTLIST(2); + LabelText(label: string, fmt: string/*, ...args: any[]*/): void { this.bind.LabelText(label, fmt/*, ...args*/); } + // IMGUI_API void BulletText(const char* fmt, ...) IM_FMTARGS(1); // shortcut for Bullet()+Text() + // IMGUI_API void BulletTextV(const char* fmt, va_list args) IM_FMTLIST(1); + BulletText(fmt: string/*, ...args: any[]*/): void { this.bind.BulletText(fmt/*, ...args*/); } + // IMGUI_API void Bullet(); // draw a small circle and keep the cursor on the same line. advance cursor x position by GetTreeNodeToLabelSpacing(), same distance that TreeNode() uses + Bullet(): void { this.bind.Bullet(); } + + // Widgets: Main + // IMGUI_API bool Button(const char* label, const ImVec2& size = ImVec2(0,0)); // button + Button(label: string, size: Readonly = ImVec2.ZERO): boolean { + return this.bind.Button(label, size); + } + // IMGUI_API bool SmallButton(const char* label); // button with FramePadding=(0,0) to easily embed within text + SmallButton(label: string): boolean { return this.bind.SmallButton(label); } + // IMGUI_API bool ArrowButton(const char* str_id, ImGuiDir dir); // square button with an arrow shape + ArrowButton(str_id: string, dir: ImGuiDir): boolean { return this.bind.ArrowButton(str_id, dir); } + // IMGUI_API bool InvisibleButton(const char* str_id, const ImVec2& size); // button behavior without the visuals, useful to build custom behaviors using the public api (along with IsItemActive, IsItemHovered, etc.) + InvisibleButton(str_id: string, size: Readonly): boolean { + return this.bind.InvisibleButton(str_id, size); + } + // IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), const ImVec4& tint_col = ImVec4(1,1,1,1), const ImVec4& border_col = ImVec4(0,0,0,0)); + Image(user_texture_id: ImTextureID | null, size: Readonly, uv0: Readonly = ImVec2.ZERO, uv1: Readonly = ImVec2.UNIT, tint_col: Readonly = ImVec4.WHITE, border_col: Readonly = ImVec4.ZERO): void { + this.bind.Image(ImGuiContext.setTexture(user_texture_id), size, uv0, uv1, tint_col, border_col); + } + // IMGUI_API bool ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0,0,0,0), const ImVec4& tint_col = ImVec4(1,1,1,1)); // <0 frame_padding uses default frame padding settings. 0 for no padding + ImageButton(user_texture_id: ImTextureID | null, size: Readonly, uv0: Readonly = ImVec2.ZERO, uv1: Readonly = ImVec2.UNIT, frame_padding: number = -1, bg_col: Readonly = ImVec4.ZERO, tint_col: Readonly = ImVec4.WHITE): boolean { + return this.bind.ImageButton(ImGuiContext.setTexture(user_texture_id), size, uv0, uv1, frame_padding, bg_col, tint_col); + } + // IMGUI_API bool Checkbox(const char* label, bool* v); + Checkbox(label: string, v: Bind.ImScalar | Bind.ImAccess): boolean { + if (Array.isArray(v)) { + return this.bind.Checkbox(label, v); + } else { + const ref_v: Bind.ImScalar = [ v() ]; + const ret = this.bind.Checkbox(label, ref_v); + v(ref_v[0]); + return ret; + } + } + // IMGUI_API bool CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value); + CheckboxFlags(label: string, flags: Bind.ImAccess | Bind.ImScalar, flags_value: number): boolean { + if (Array.isArray(flags)) { + return this.bind.CheckboxFlags(label, flags, flags_value); + } else { + const ref_flags: Bind.ImScalar = [ flags() ]; + const ret = this.bind.CheckboxFlags(label, ref_flags, flags_value); + flags(ref_flags[0]); + return ret; + } + } + // IMGUI_API bool RadioButton(const char* label, bool active); + // IMGUI_API bool RadioButton(const char* label, int* v, int v_button); + RadioButton(label: string, active: boolean): boolean; + RadioButton(label: string, v: Bind.ImAccess | Bind.ImScalar, v_button: number): boolean; + RadioButton(label: string, ...args: any[]): boolean { + if (typeof(args[0]) === "boolean") { + const active: boolean = args[0]; + return this.bind.RadioButton_A(label, active); + } else { + const v: Bind.ImAccess | Bind.ImScalar = args[0]; + const v_button: number = args[1]; + const _v: Bind.ImScalar = Array.isArray(v) ? v : [ v() ]; + const ret = this.bind.RadioButton_B(label, _v, v_button); + if (!Array.isArray(v)) { v(_v[0]); } + return ret; + } + } + PlotLines(label: string, values: ArrayLike, values_count?: number, value_offset?: number, overlay_text?: string | null, scale_min?: number, scale_max?: number, graph_size?: Readonly, stride?: number): void; + PlotLines(label: string, values_getter: PlotLinesValueGetter, data: any, values_count?: number, value_offset?: number, overlay_text?: string | null, scale_min?: number, scale_max?: number, graph_size?: Readonly): void; + PlotLines(label: string, ...args: any[]): void { + if (Array.isArray(args[0])) { + const values: ArrayLike = args[0]; + const values_getter: PlotLinesValueGetter = (data: any, idx: number): number => values[idx * stride]; + const values_count: number = typeof(args[1]) === "number" ? args[1] : values.length; + const values_offset: number = typeof(args[2]) === "number" ? args[2] : 0; + const overlay_text: string | null = typeof(args[3]) === "string" ? args[3] : null; + const scale_min: number = typeof(args[4]) === "number" ? args[4] : Number.MAX_VALUE; + const scale_max: number = typeof(args[5]) === "number" ? args[5] : Number.MAX_VALUE; + const graph_size: Readonly = args[6] || ImVec2.ZERO; + const stride: number = typeof(args[7]) === "number" ? args[7] : 1; + this.bind.PlotLines(label, values_getter, null, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size); + } else { + const values_getter: PlotLinesValueGetter = args[0]; + const data: any = args[1]; + const values_count: number = args[2]; + const values_offset: number = typeof(args[3]) === "number" ? args[3] : 0; + const overlay_text: string | null = typeof(args[4]) === "string" ? args[4] : null; + const scale_min: number = typeof(args[5]) === "number" ? args[5] : Number.MAX_VALUE; + const scale_max: number = typeof(args[6]) === "number" ? args[6] : Number.MAX_VALUE; + const graph_size: Readonly = args[7] || ImVec2.ZERO; + this.bind.PlotLines(label, values_getter, data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size); + } + } + // IMGUI_API void PlotHistogram(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0), int stride = sizeof(float)); + // IMGUI_API void PlotHistogram(const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0)); + PlotHistogram(label: string, values: ArrayLike, values_count?: number, value_offset?: number, overlay_text?: string | null, scale_min?: number, scale_max?: number, graph_size?: Readonly, stride?: number): void; + PlotHistogram(label: string, values_getter: PlotHistogramValueGetter, data: any, values_count?: number, value_offset?: number, overlay_text?: string | null, scale_min?: number, scale_max?: number, graph_size?: Readonly): void; + PlotHistogram(label: string, ...args: any[]): void { + if (Array.isArray(args[0])) { + const values: ArrayLike = args[0]; + const values_getter: PlotHistogramValueGetter = (data: any, idx: number): number => values[idx * stride]; + const values_count: number = typeof(args[1]) === "number" ? args[1] : values.length; + const values_offset: number = typeof(args[2]) === "number" ? args[2] : 0; + const overlay_text: string | null = typeof(args[3]) === "string" ? args[3] : null; + const scale_min: number = typeof(args[4]) === "number" ? args[4] : Number.MAX_VALUE; + const scale_max: number = typeof(args[5]) === "number" ? args[5] : Number.MAX_VALUE; + const graph_size: Readonly = args[6] || ImVec2.ZERO; + const stride: number = typeof(args[7]) === "number" ? args[7] : 1; + this.bind.PlotHistogram(label, values_getter, null, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size); + } else { + const values_getter: PlotHistogramValueGetter = args[0]; + const data: any = args[1]; + const values_count: number = args[2]; + const values_offset: number = typeof(args[3]) === "number" ? args[3] : 0; + const overlay_text: string | null = typeof(args[4]) === "string" ? args[4] : null; + const scale_min: number = typeof(args[5]) === "number" ? args[5] : Number.MAX_VALUE; + const scale_max: number = typeof(args[6]) === "number" ? args[6] : Number.MAX_VALUE; + const graph_size: Readonly = args[7] || ImVec2.ZERO; + this.bind.PlotHistogram(label, values_getter, data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size); + } + } + // IMGUI_API void ProgressBar(float fraction, const ImVec2& size_arg = ImVec2(-1,0), const char* overlay = NULL); + ProgressBar(fraction: number, size_arg: Readonly = new ImVec2(-1, 0), overlay: string | null = null): void { + this.bind.ProgressBar(fraction, size_arg, overlay); + } + + // Widgets: Combo Box + // The new BeginCombo()/EndCombo() api allows you to manage your contents and selection state however you want it. + // The old Combo() api are helpers over BeginCombo()/EndCombo() which are kept available for convenience purpose. + // IMGUI_API bool BeginCombo(const char* label, const char* preview_value, ImGuiComboFlags flags = 0); + BeginCombo(label: string, preview_value: string | null = null, flags: ImGuiComboFlags = 0): boolean { + return this.bind.BeginCombo(label, preview_value, flags); + } + // IMGUI_API void EndCombo(); + EndCombo(): void { this.bind.EndCombo(); } + // IMGUI_API bool Combo(const char* label, int* current_item, const char* const items[], int items_count, int popup_max_height_in_items = -1); + // IMGUI_API bool Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int popup_max_height_in_items = -1); // Separate items with \0 within a string, end item-list with \0\0. e.g. "One\0Two\0Three\0" + // IMGUI_API bool Combo(const char* label, int* current_item, bool(*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int popup_max_height_in_items = -1); + Combo(label: string, current_item: Bind.ImAccess | Bind.ImScalar, items: string[], items_count?: number, popup_max_height_in_items?: number): boolean; + Combo(label: string, current_item: Bind.ImAccess | Bind.ImScalar, items_separated_by_zeros: string, popup_max_height_in_items?: number): boolean; + Combo(label: string, current_item: Bind.ImAccess | Bind.ImScalar, items_getter: ComboValueGetter, data: any, items_count: number, popup_max_height_in_items?: number): boolean; + Combo(label: string, current_item: Bind.ImAccess | Bind.ImScalar, ...args: any[]): boolean { + let ret = false; + const _current_item: Bind.ImScalar = Array.isArray(current_item) ? current_item : [ current_item() ]; + if (Array.isArray(args[0])) { + const items: string[] = args[0]; + const items_count = typeof(args[1]) === "number" ? args[1] : items.length; + const popup_max_height_in_items: number = typeof(args[2]) === "number" ? args[2] : -1; + const items_getter = (data: any, idx: number, out_text: [string]): boolean => { out_text[0] = items[idx]; return true; }; + ret = this.bind.Combo(label, _current_item, items_getter, null, items_count, popup_max_height_in_items); + } else if (typeof(args[0]) === "string") { + const items_separated_by_zeros: string = args[0] + const popup_max_height_in_items: number = typeof(args[1]) === "number" ? args[1] : -1; + const items: string[] = items_separated_by_zeros.replace(/^\0+|\0+$/g, "").split("\0"); + const items_count: number = items.length; + const items_getter = (data: any, idx: number, out_text: [string]): boolean => { out_text[0] = items[idx]; return true; }; + ret = this.bind.Combo(label, _current_item, items_getter, null, items_count, popup_max_height_in_items); + } else { + const items_getter: (data: any, idx: number, out_text: [string]) => boolean = args[0]; + const data: any = args[1]; + const items_count = args[2]; + const popup_max_height_in_items: number = typeof(args[3]) === "number" ? args[3] : -1; + ret = this.bind.Combo(label, _current_item, items_getter, data, items_count, popup_max_height_in_items); + } + if (!Array.isArray(current_item)) { current_item(_current_item[0]); } + return ret; + } + + // Widgets: Drags (tip: ctrl+click on a drag box to input with keyboard. manually input values aren't clamped, can go off-bounds) + // For all the Float2/Float3/Float4/Int2/Int3/Int4 versions of every functions, note that a 'float v[X]' function argument is the same as 'float* v', the array syntax is just a way to document the number of elements that are expected to be accessible. You can pass address of your first element out of a contiguous set, e.g. &myvector.x + // IMGUI_API bool DragFloat(const char* label, float* v, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", float power = 1.0f); // If v_min >= v_max we have no bound + DragFloat(label: string, v: Bind.ImAccess | Bind.ImScalar | XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, v_speed: number = 1.0, v_min: number = 0.0, v_max: number = 0.0, display_format: string | null = "%.3f", power: number = 1.0): boolean { + const _v = import_Scalar(v); + const ret = this.bind.DragFloat(label, _v, v_speed, v_min, v_max, display_format, power); + export_Scalar(_v, v); + return ret; + } + // IMGUI_API bool DragFloat2(const char* label, float v[2], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", float power = 1.0f); + DragFloat2(label: string, v: XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4 | ImVec2, v_speed: number = 1.0, v_min: number = 0.0, v_max: number = 0.0, display_format: string = "%.3f", power: number = 1.0): boolean { + const _v = import_Vector2(v); + const ret = this.bind.DragFloat2(label, _v, v_speed, v_min, v_max, display_format, power); + export_Vector2(_v, v); + return ret; + } + // IMGUI_API bool DragFloat3(const char* label, float v[3], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", float power = 1.0f); + DragFloat3(label: string, v: XYZ | XYZW | Bind.ImTuple3 | Bind.ImTuple4, v_speed: number = 1.0, v_min: number = 0.0, v_max: number = 0.0, display_format: string = "%.3f", power: number = 1.0): boolean { + const _v = import_Vector3(v); + const ret = this.bind.DragFloat3(label, _v, v_speed, v_min, v_max, display_format, power); + export_Vector3(_v, v); + return ret; + } + // IMGUI_API bool DragFloat4(const char* label, float v[4], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", float power = 1.0f); + DragFloat4(label: string, v: XYZW | Bind.ImTuple4 | ImVec4, v_speed: number = 1.0, v_min: number = 0.0, v_max: number = 0.0, display_format: string = "%.3f", power: number = 1.0): boolean { + const _v = import_Vector4(v); + const ret = this.bind.DragFloat4(label, _v, v_speed, v_min, v_max, display_format, power); + export_Vector4(_v, v); + return ret; + } + // IMGUI_API bool DragFloatRange2(const char* label, float* v_current_min, float* v_current_max, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", const char* display_format_max = NULL, float power = 1.0f); + DragFloatRange2(label: string, v_current_min: Bind.ImAccess | Bind.ImScalar | XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, v_current_max: Bind.ImAccess | Bind.ImScalar | XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, v_speed: number = 1.0, v_min: number = 0.0, v_max: number = 0.0, display_format: string = "%.3f", display_format_max: string | null = null, power: number = 1.0): boolean { + const _v_current_min = import_Scalar(v_current_min); + const _v_current_max = import_Scalar(v_current_max); + const ret = this.bind.DragFloatRange2(label, _v_current_min, _v_current_max, v_speed, v_min, v_max, display_format, display_format_max, power); + export_Scalar(_v_current_min, v_current_min); + export_Scalar(_v_current_max, v_current_max); + return ret; + } + // IMGUI_API bool DragInt(const char* label, int* v, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* display_format = "%d"); // If v_min >= v_max we have no bound + DragInt(label: string, v: Bind.ImAccess | Bind.ImScalar | XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, v_speed: number = 1.0, v_min: number = 0, v_max: number = 0, format: string = "%d"): boolean { + const _v = import_Scalar(v); + const ret = this.bind.DragInt(label, _v, v_speed, v_min, v_max, format); + export_Scalar(_v, v); + return ret; + } + // IMGUI_API bool DragInt2(const char* label, int v[2], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d"); + DragInt2(label: string, v: XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, v_speed: number = 1.0, v_min: number = 0, v_max: number = 0, format: string = "%d"): boolean { + const _v = import_Vector2(v); + const ret = this.bind.DragInt2(label, _v, v_speed, v_min, v_max, format); + export_Vector2(_v, v); + return ret; + } + // IMGUI_API bool DragInt3(const char* label, int v[3], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d"); + DragInt3(label: string, v: XYZ | XYZW | Bind.ImTuple3 | Bind.ImTuple4, v_speed: number = 1.0, v_min: number = 0, v_max: number = 0, format: string = "%d"): boolean { + const _v = import_Vector3(v); + const ret = this.bind.DragInt3(label, _v, v_speed, v_min, v_max, format); + export_Vector3(_v, v); + return ret; + } + // IMGUI_API bool DragInt4(const char* label, int v[4], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d"); + DragInt4(label: string, v: XYZW | Bind.ImTuple4, v_speed: number = 1.0, v_min: number = 0, v_max: number = 0, format: string = "%d"): boolean { + const _v = import_Vector4(v); + const ret = this.bind.DragInt4(label, _v, v_speed, v_min, v_max, format); + export_Vector4(_v, v); + return ret; + } + // IMGUI_API bool DragIntRange2(const char* label, int* v_current_min, int* v_current_max, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* display_format = "%.0f", const char* display_format_max = NULL); + DragIntRange2(label: string, v_current_min: Bind.ImAccess | Bind.ImScalar | XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, v_current_max: Bind.ImAccess | Bind.ImScalar | XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, v_speed: number = 1.0, v_min: number = 0, v_max: number = 0, format: string = "%d", format_max: string | null = null): boolean { + const _v_current_min = import_Scalar(v_current_min); + const _v_current_max = import_Scalar(v_current_max); + const ret = this.bind.DragIntRange2(label, _v_current_min, _v_current_max, v_speed, v_min, v_max, format, format_max); + export_Scalar(_v_current_min, v_current_min); + export_Scalar(_v_current_max, v_current_max); + return ret; + } + // IMGUI_API bool DragScalar(const char* label, ImGuiDataType data_type, void* v, float v_speed, const void* v_min = NULL, const void* v_max = NULL, const char* format = NULL, float power = 1.0f); + // IMGUI_API bool DragScalarN(const char* label, ImGuiDataType data_type, void* v, int components, float v_speed, const void* v_min = NULL, const void* v_max = NULL, const char* format = NULL, float power = 1.0f); + DragScalar(label: string, v: Int32Array | Uint32Array | Float32Array | Float64Array, v_speed: number, v_min: number | null = null, v_max: number | null = null, format: string | null = null, power: number = 1.0): boolean { + if (v instanceof Int32Array) { return this.bind.DragScalar(label, ImGuiDataType.S32, v, v_speed, v_min, v_max, format, power); } + if (v instanceof Uint32Array) { return this.bind.DragScalar(label, ImGuiDataType.U32, v, v_speed, v_min, v_max, format, power); } + // if (v instanceof Int64Array) { return this.bind.DragScalar(label, ImGuiDataType.S64, v, v_speed, v_min, v_max, format, power); } + // if (v instanceof Uint64Array) { return this.bind.DragScalar(label, ImGuiDataType.U64, v, v_speed, v_min, v_max, format, power); } + if (v instanceof Float32Array) { return this.bind.DragScalar(label, ImGuiDataType.Float, v, v_speed, v_min, v_max, format, power); } + if (v instanceof Float64Array) { return this.bind.DragScalar(label, ImGuiDataType.Double, v, v_speed, v_min, v_max, format, power); } + throw new Error(); + } + + // Widgets: Input with Keyboard + // IMGUI_API bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); + InputText(label: string, buf: ImStringBuffer | Bind.ImAccess | Bind.ImScalar, buf_size: number = buf instanceof ImStringBuffer ? buf.size : ImGuiInputTextDefaultSize, flags: ImGuiInputTextFlags = 0, callback: ImGuiInputTextCallback | null = null, user_data: any = null): boolean { + const _callback = callback && ((data: Bind.reference_ImGuiInputTextCallbackData): number => callback(new ImGuiInputTextCallbackData(data, user_data))) || null; + if (Array.isArray(buf)) { + return this.bind.InputText(label, buf, buf_size, flags, _callback, null); + } else if (buf instanceof ImStringBuffer) { + const ref_buf: Bind.ImScalar = [ buf.buffer ]; + const _buf_size: number = Math.min(buf_size, buf.size); + const ret: boolean = this.bind.InputText(label, ref_buf, _buf_size, flags, _callback, null); + buf.buffer = ref_buf[0]; + return ret; + } else { + const ref_buf: Bind.ImScalar = [ buf() ]; + const ret: boolean = this.bind.InputText(label, ref_buf, buf_size, flags, _callback, null); + buf(ref_buf[0]); + return ret; + } + } + // IMGUI_API bool InputTextMultiline(const char* label, char* buf, size_t buf_size, const ImVec2& size = ImVec2(0,0), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); + InputTextMultiline(label: string, buf: ImStringBuffer | Bind.ImAccess | Bind.ImScalar, buf_size: number = buf instanceof ImStringBuffer ? buf.size : ImGuiInputTextDefaultSize, size: Readonly = ImVec2.ZERO, flags: ImGuiInputTextFlags = 0, callback: ImGuiInputTextCallback | null = null, user_data: any = null): boolean { + const _callback = callback && ((data: Bind.reference_ImGuiInputTextCallbackData): number => callback(new ImGuiInputTextCallbackData(data, user_data))) || null; + if (Array.isArray(buf)) { + return this.bind.InputTextMultiline(label, buf, buf_size, size, flags, _callback, null); + } else if (buf instanceof ImStringBuffer) { + const ref_buf: Bind.ImScalar = [ buf.buffer ]; + const _buf_size: number = Math.min(buf_size, buf.size); + const ret: boolean = this.bind.InputTextMultiline(label, ref_buf, _buf_size, size, flags, _callback, null); + buf.buffer = ref_buf[0]; + return ret; + } else { + const ref_buf: Bind.ImScalar = [ buf() ]; + const ret: boolean = this.bind.InputTextMultiline(label, ref_buf, buf_size, size, flags, _callback, null); + buf(ref_buf[0]); + return ret; + } + } + // IMGUI_API bool InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, const char* format = "%.3f", ImGuiInputTextFlags extra_flags = 0); + InputFloat(label: string, v: Bind.ImAccess | Bind.ImScalar | XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, step: number = 0.0, step_fast: number = 0.0, format: string = "%.3f", extra_flags: ImGuiInputTextFlags = 0): boolean { + const _v = import_Scalar(v); + const ret = this.bind.InputFloat(label, _v, step, step_fast, format, extra_flags); + export_Scalar(_v, v); + return ret; + } + // IMGUI_API bool InputFloat2(const char* label, float v[2], const char* format = "%.3f", ImGuiInputTextFlags extra_flags = 0); + InputFloat2(label: string, v: XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, format: string = "%.3f", extra_flags: ImGuiInputTextFlags = 0): boolean { + const _v = import_Vector2(v); + const ret = this.bind.InputFloat2(label, _v, format, extra_flags); + export_Vector2(_v, v); + return ret; + } + // IMGUI_API bool InputFloat3(const char* label, float v[3], const char* format = "%.3f", ImGuiInputTextFlags extra_flags = 0); + InputFloat3(label: string, v: XYZ | XYZW | Bind.ImTuple3 | Bind.ImTuple4, format: string = "%.3f", extra_flags: ImGuiInputTextFlags = 0): boolean { + const _v = import_Vector3(v); + const ret = this.bind.InputFloat3(label, _v, format, extra_flags); + export_Vector3(_v, v); + return ret; + } + // IMGUI_API bool InputFloat4(const char* label, float v[4], const char* format = "%.3f", ImGuiInputTextFlags extra_flags = 0); + InputFloat4(label: string, v: XYZW | Bind.ImTuple4, format: string = "%.3f", extra_flags: ImGuiInputTextFlags = 0): boolean { + const _v = import_Vector4(v); + const ret = this.bind.InputFloat4(label, _v, format, extra_flags); + export_Vector4(_v, v); + return ret; + } + // IMGUI_API bool InputInt(const char* label, int* v, int step = 1, int step_fast = 100, ImGuiInputTextFlags extra_flags = 0); + InputInt(label: string, v: Bind.ImAccess | Bind.ImScalar | XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, step: number = 1, step_fast: number = 100, extra_flags: ImGuiInputTextFlags = 0): boolean { + const _v = import_Scalar(v); + const ret = this.bind.InputInt(label, _v, step, step_fast, extra_flags); + export_Scalar(_v, v); + return ret; + } + // IMGUI_API bool InputInt2(const char* label, int v[2], ImGuiInputTextFlags extra_flags = 0); + InputInt2(label: string, v: XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, extra_flags: ImGuiInputTextFlags = 0): boolean { + const _v = import_Vector2(v); + const ret = this.bind.InputInt2(label, _v, extra_flags); + export_Vector2(_v, v); + return ret; + } + // IMGUI_API bool InputInt3(const char* label, int v[3], ImGuiInputTextFlags extra_flags = 0); + InputInt3(label: string, v: XYZ | XYZW | Bind.ImTuple3 | Bind.ImTuple4, extra_flags: ImGuiInputTextFlags = 0): boolean { + const _v = import_Vector3(v); + const ret = this.bind.InputInt3(label, _v, extra_flags); + export_Vector3(_v, v); + return ret; + } + // IMGUI_API bool InputInt4(const char* label, int v[4], ImGuiInputTextFlags extra_flags = 0); + InputInt4(label: string, v: XYZW | Bind.ImTuple4, extra_flags: ImGuiInputTextFlags = 0): boolean { + const _v = import_Vector4(v); + const ret = this.bind.InputInt4(label, _v, extra_flags); + export_Vector4(_v, v); + return ret; + } + // IMGUI_API bool InputDouble(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, const char* format = "%.6f", ImGuiInputTextFlags extra_flags = 0); + InputDouble(label: string, v: Bind.ImAccess | Bind.ImScalar | XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, step: number = 0.0, step_fast: number = 0.0, format: string = "%.6f", extra_flags: ImGuiInputTextFlags = 0): boolean { + const _v = import_Scalar(v); + const ret = this.bind.InputDouble(label, _v, step, step_fast, format, extra_flags); + export_Scalar(_v, v); + return ret; + } + // IMGUI_API bool InputScalar(const char* label, ImGuiDataType data_type, void* v, const void* step = NULL, const void* step_fast = NULL, const char* format = NULL, ImGuiInputTextFlags extra_flags = 0); + // IMGUI_API bool InputScalarN(const char* label, ImGuiDataType data_type, void* v, int components, const void* step = NULL, const void* step_fast = NULL, const char* format = NULL, ImGuiInputTextFlags extra_flags = 0); + InputScalar(label: string, v: Int32Array | Uint32Array | Float32Array | Float64Array, step: number | null = null, step_fast: number | null = null, format: string | null = null, extra_flags: ImGuiInputTextFlags = 0): boolean { + if (v instanceof Int32Array) { return this.bind.InputScalar(label, ImGuiDataType.S32, v, step, step_fast, format, extra_flags); } + if (v instanceof Uint32Array) { return this.bind.InputScalar(label, ImGuiDataType.U32, v, step, step_fast, format, extra_flags); } + // if (v instanceof Int64Array) { return this.bind.InputScalar(label, ImGuiDataType.S64, v, step, step_fast, format, extra_flags); } + // if (v instanceof Uint64Array) { return this.bind.InputScalar(label, ImGuiDataType.U64, v, step, step_fast, format, extra_flags); } + if (v instanceof Float32Array) { return this.bind.InputScalar(label, ImGuiDataType.Float, v, step, step_fast, format, extra_flags); } + if (v instanceof Float64Array) { return this.bind.InputScalar(label, ImGuiDataType.Double, v, step, step_fast, format, extra_flags); } + throw new Error(); + } + + // Widgets: Sliders (tip: ctrl+click on a slider to input with keyboard. manually input values aren't clamped, can go off-bounds) + // IMGUI_API bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* format = "%.3f", float power = 1.0f); // adjust format to decorate the value with a prefix or a suffix for in-slider labels or unit display. Use power!=1.0 for logarithmic sliders + SliderFloat(label: string, v: Bind.ImAccess | Bind.ImScalar | XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, v_min: number, v_max: number, format: string = "%.3f", power: number = 1.0): boolean { + const _v = import_Scalar(v); + const ret = this.bind.SliderFloat(label, _v, v_min, v_max, format, power); + export_Scalar(_v, v); + return ret; + } + // IMGUI_API bool SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* format = "%.3f", float power = 1.0f); + SliderFloat2(label: string, v: XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4 | Bind.interface_ImVec2, v_min: number, v_max: number, format: string = "%.3f", power: number = 1.0): boolean { + const _v = import_Vector2(v); + const ret = this.bind.SliderFloat2(label, _v, v_min, v_max, format, power); + export_Vector2(_v, v); + return ret; + } + // IMGUI_API bool SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* format = "%.3f", float power = 1.0f); + SliderFloat3(label: string, v: XYZ | XYZW | Bind.ImTuple3 | Bind.ImTuple4, v_min: number, v_max: number, format: string = "%.3f", power: number = 1.0): boolean { + const _v = import_Vector3(v); + const ret = this.bind.SliderFloat3(label, _v, v_min, v_max, format, power); + export_Vector3(_v, v); + return ret; + } + // IMGUI_API bool SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* format = "%.3f", float power = 1.0f); + SliderFloat4(label: string, v: XYZW | Bind.ImTuple4 | XYZW, v_min: number, v_max: number, format: string = "%.3f", power: number = 1.0): boolean { + const _v = import_Vector4(v); + const ret = this.bind.SliderFloat4(label, _v, v_min, v_max, format, power); + export_Vector4(_v, v); + return ret; + } + // IMGUI_API bool SliderAngle(const char* label, float* v_rad, float v_degrees_min = -360.0f, float v_degrees_max = +360.0f); + SliderAngle(label: string, v_rad: Bind.ImAccess | Bind.ImScalar | XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, v_degrees_min: number = -360.0, v_degrees_max: number = +360.0): boolean { + const _v_rad = import_Scalar(v_rad); + const ret = this.bind.SliderAngle(label, _v_rad, v_degrees_min, v_degrees_max); + export_Scalar(_v_rad, v_rad); + return ret; + } + SliderAngle3(label: string, v_rad: XYZ | XYZW | Bind.ImTuple3 | Bind.ImTuple4, v_degrees_min: number = -360.0, v_degrees_max: number = +360.0): boolean { + const _v_rad = import_Vector3(v_rad); + _v_rad[0] = Math.floor(_v_rad[0] * 180 / Math.PI); + _v_rad[1] = Math.floor(_v_rad[1] * 180 / Math.PI); + _v_rad[2] = Math.floor(_v_rad[2] * 180 / Math.PI); + const ret = this.bind.SliderInt3(label, _v_rad, v_degrees_min, v_degrees_max, "%d deg"); + _v_rad[0] = _v_rad[0] * Math.PI / 180; + _v_rad[1] = _v_rad[1] * Math.PI / 180; + _v_rad[2] = _v_rad[2] * Math.PI / 180; + export_Vector3(_v_rad, v_rad); + return ret; + } + // IMGUI_API bool SliderInt(const char* label, int* v, int v_min, int v_max, const char* format = "%d"); + SliderInt(label: string, v: Bind.ImAccess | Bind.ImScalar | XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, v_min: number, v_max: number, format: string = "%d"): boolean { + const _v = import_Scalar(v); + const ret = this.bind.SliderInt(label, _v, v_min, v_max, format); + export_Scalar(_v, v); + return ret; + } + // IMGUI_API bool SliderInt2(const char* label, int v[2], int v_min, int v_max, const char* format = "%d"); + SliderInt2(label: string, v: XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, v_min: number, v_max: number, format: string = "%d"): boolean { + const _v = import_Vector2(v); + const ret = this.bind.SliderInt2(label, _v, v_min, v_max, format); + export_Vector2(_v, v); + return ret; + } + // IMGUI_API bool SliderInt3(const char* label, int v[3], int v_min, int v_max, const char* format = "%d"); + SliderInt3(label: string, v: XYZ | XYZW | Bind.ImTuple3 | Bind.ImTuple4, v_min: number, v_max: number, format: string = "%d"): boolean { + const _v = import_Vector3(v); + const ret = this.bind.SliderInt3(label, _v, v_min, v_max, format); + export_Vector3(_v, v); + return ret; + } + // IMGUI_API bool SliderInt4(const char* label, int v[4], int v_min, int v_max, const char* format = "%d"); + SliderInt4(label: string, v: XYZW | Bind.ImTuple4, v_min: number, v_max: number, format: string = "%d"): boolean { + const _v = import_Vector4(v); + const ret = this.bind.SliderInt4(label, _v, v_min, v_max, format); + export_Vector4(_v, v); + return ret; + } + // IMGUI_API bool SliderScalar(const char* label, ImGuiDataType data_type, void* v, const void* v_min, const void* v_max, const char* format = NULL, float power = 1.0f); + // IMGUI_API bool SliderScalarN(const char* label, ImGuiDataType data_type, void* v, int components, const void* v_min, const void* v_max, const char* format = NULL, float power = 1.0f); + SliderScalar(label: string, v: Int32Array | Uint32Array | Float32Array | Float64Array, v_min: number, v_max: number, format: string | null = null, power: number = 1.0): boolean { + if (v instanceof Int32Array) { return this.bind.SliderScalar(label, ImGuiDataType.S32, v, v_min, v_max, format, power); } + if (v instanceof Uint32Array) { return this.bind.SliderScalar(label, ImGuiDataType.U32, v, v_min, v_max, format, power); } + // if (v instanceof Int64Array) { return this.bind.SliderScalar(label, ImGuiDataType.S64, v, v_min, v_max, format, power); } + // if (v instanceof Uint64Array) { return this.bind.SliderScalar(label, ImGuiDataType.U64, v, v_min, v_max, format, power); } + if (v instanceof Float32Array) { return this.bind.SliderScalar(label, ImGuiDataType.Float, v, v_min, v_max, format, power); } + if (v instanceof Float64Array) { return this.bind.SliderScalar(label, ImGuiDataType.Double, v, v_min, v_max, format, power); } + throw new Error(); + } + // IMGUI_API bool VSliderFloat(const char* label, const ImVec2& size, float* v, float v_min, float v_max, const char* format = "%.3f", float power = 1.0f); + VSliderFloat(label: string, size: Readonly, v: Bind.ImAccess | Bind.ImScalar | XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, v_min: number, v_max: number, format: string = "%.3f", power: number = 1.0): boolean { + const _v = import_Scalar(v); + const ret = this.bind.VSliderFloat(label, size, _v, v_min, v_max, format, power); + export_Scalar(_v, v); + return ret; + } + // IMGUI_API bool VSliderInt(const char* label, const ImVec2& size, int* v, int v_min, int v_max, const char* format = "%d"); + VSliderInt(label: string, size: Readonly, v: Bind.ImAccess | Bind.ImScalar | XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, v_min: number, v_max: number, format: string = "%d"): boolean { + const _v = import_Scalar(v); + const ret = this.bind.VSliderInt(label, size, _v, v_min, v_max, format); + export_Scalar(_v, v); + return ret; + } + // IMGUI_API bool VSliderScalar(const char* label, const ImVec2& size, ImGuiDataType data_type, void* v, const void* v_min, const void* v_max, const char* format = NULL, float power = 1.0f); + VSliderScalar(label: string, size: Readonly, data_type: ImGuiDataType, v: Bind.ImAccess | Bind.ImScalar, v_min: number, v_max: number, format: string | null = null, power: number = 1.0): boolean { + if (v instanceof Int32Array) { return this.bind.VSliderScalar(label, size, ImGuiDataType.S32, v, v_min, v_max, format, power); } + if (v instanceof Uint32Array) { return this.bind.VSliderScalar(label, size, ImGuiDataType.U32, v, v_min, v_max, format, power); } + // if (v instanceof Int64Array) { return this.bind.VSliderScalar(label, size, ImGuiDataType.S64, v, v_min, v_max, format, power); } + // if (v instanceof Uint64Array) { return this.bind.VSliderScalar(label, size, ImGuiDataType.U64, v, v_min, v_max, format, power); } + if (v instanceof Float32Array) { return this.bind.VSliderScalar(label, size, ImGuiDataType.Float, v, v_min, v_max, format, power); } + if (v instanceof Float64Array) { return this.bind.VSliderScalar(label, size, ImGuiDataType.Double, v, v_min, v_max, format, power); } + throw new Error(); + } + + // Widgets: Color Editor/Picker (tip: the ColorEdit* functions have a little colored preview square that can be left-clicked to open a picker, and right-clicked to open an option menu.) + // Note that a 'float v[X]' function argument is the same as 'float* v', the array syntax is just a way to document the number of elements that are expected to be accessible. You can the pass the address of a first float element out of a contiguous structure, e.g. &myvector.x + // IMGUI_API bool ColorEdit3(const char* label, float col[3], ImGuiColorEditFlags flags = 0); + ColorEdit3(label: string, col: RGB | RGBA | Bind.ImTuple3 | Bind.ImTuple4 | Bind.interface_ImVec4, flags: ImGuiColorEditFlags = 0): boolean { + const _col = import_Color3(col); + const ret = this.bind.ColorEdit3(label, _col, flags); + export_Color3(_col, col); + return ret; + } + // IMGUI_API bool ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flags = 0); + ColorEdit4(label: string, col: RGBA | Bind.ImTuple4 | Bind.interface_ImVec4, flags: ImGuiColorEditFlags = 0): boolean { + const _col = import_Color4(col); + const ret = this.bind.ColorEdit4(label, _col, flags); + export_Color4(_col, col); + return ret; + } + // IMGUI_API bool ColorPicker3(const char* label, float col[3], ImGuiColorEditFlags flags = 0); + ColorPicker3(label: string, col: RGB | RGBA | Bind.ImTuple3 | Bind.ImTuple4 | Bind.interface_ImVec4, flags: ImGuiColorEditFlags = 0): boolean { + const _col = import_Color3(col); + const ret = this.bind.ColorPicker3(label, _col, flags); + export_Color3(_col, col); + return ret; + } + // IMGUI_API bool ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags flags = 0, const float* ref_col = NULL); + ColorPicker4(label: string, col: RGBA | Bind.ImTuple4 | Bind.interface_ImVec4, flags: ImGuiColorEditFlags = 0, ref_col: Bind.ImTuple4 | Bind.interface_ImVec4 | null = null): boolean { + const _col = import_Color4(col); + const _ref_col = ref_col ? import_Color4(ref_col) : null; + const ret = this.bind.ColorPicker4(label, _col, flags, _ref_col); + export_Color4(_col, col); + if (_ref_col && ref_col) { export_Color4(_ref_col, ref_col); } + return ret; + } + // IMGUI_API bool ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFlags flags = 0, ImVec2 size = ImVec2(0,0)); // display a colored square/button, hover for details, return true when pressed. + ColorButton(desc_id: string, col: Readonly, flags: ImGuiColorEditFlags = 0, size: Readonly = ImVec2.ZERO): boolean { + return this.bind.ColorButton(desc_id, col, flags, size); + } + // IMGUI_API void SetColorEditOptions(ImGuiColorEditFlags flags); // initialize current options (generally on application startup) if you want to select a default format, picker type, etc. User will be able to change many settings, unless you pass the _NoOptions flag to your calls. + SetColorEditOptions(flags: ImGuiColorEditFlags): void { + this.bind.SetColorEditOptions(flags); + } + + // Widgets: Trees + // IMGUI_API bool TreeNode(const char* label); // if returning 'true' the node is open and the tree id is pushed into the id stack. user is responsible for calling TreePop(). + // IMGUI_API bool TreeNode(const char* str_id, const char* fmt, ...) IM_FMTARGS(2); // read the FAQ about why and how to use ID. to align arbitrary text at the same level as a TreeNode() you can use Bullet(). + // IMGUI_API bool TreeNode(const void* ptr_id, const char* fmt, ...) IM_FMTARGS(2); // " + // IMGUI_API bool TreeNodeV(const char* str_id, const char* fmt, va_list args) IM_FMTLIST(2); + // IMGUI_API bool TreeNodeV(const void* ptr_id, const char* fmt, va_list args) IM_FMTLIST(2); + TreeNode(label: string): boolean; + TreeNode(label: string, fmt: string): boolean; + TreeNode(label: number, fmt: string): boolean; + TreeNode(...args: any[]): boolean { + if (typeof(args[0]) === "string") { + if (args.length === 1) { + const label: string = args[0]; + return this.bind.TreeNode_A(label); + } else { + const str_id: string = args[0]; + const fmt: string = args[1]; + return this.bind.TreeNode_B(str_id, fmt); + } + } else { + const ptr_id: number = args[0]; + const fmt: string = args[1]; + return this.bind.TreeNode_C(ptr_id, fmt); + } + } + // IMGUI_API bool TreeNodeEx(const char* label, ImGuiTreeNodeFlags flags = 0); + // IMGUI_API bool TreeNodeEx(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) IM_FMTARGS(3); + // IMGUI_API bool TreeNodeEx(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) IM_FMTARGS(3); + // IMGUI_API bool TreeNodeExV(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) IM_FMTLIST(3); + // IMGUI_API bool TreeNodeExV(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) IM_FMTLIST(3); + TreeNodeEx(label: string, flags?: ImGuiTreeNodeFlags): boolean; + TreeNodeEx(str_id: string, flags: ImGuiTreeNodeFlags, fmt: string): boolean; + TreeNodeEx(ptr_id: number, flags: ImGuiTreeNodeFlags, fmt: string): boolean; + TreeNodeEx(...args: any[]): boolean { + if (typeof(args[0]) === "string") { + if (args.length < 3) { + const label: string = args[0]; + const flags: ImGuiTreeNodeFlags = args[1] || 0; + return this.bind.TreeNodeEx_A(label, flags); + } else { + const str_id: string = args[0]; + const flags: ImGuiTreeNodeFlags = args[1]; + const fmt: string = args[2]; + return this.bind.TreeNodeEx_B(str_id, flags, fmt); + } + } else { + const ptr_id: number = args[0]; + const flags: ImGuiTreeNodeFlags = args[1]; + const fmt: string = args[2]; + return this.bind.TreeNodeEx_C(ptr_id, flags, fmt); + } + } + // IMGUI_API void TreePush(const char* str_id); // ~ Indent()+PushId(). Already called by TreeNode() when returning true, but you can call Push/Pop yourself for layout purpose + // IMGUI_API void TreePush(const void* ptr_id = NULL); // " + TreePush(str_id: string): void; + TreePush(ptr_id: number): void; + TreePush(...args: any[]): void { + if (typeof(args[0]) === "string") { + const str_id: string = args[0]; + this.bind.TreePush_A(str_id); + } else { + const ptr_id: number = args[0]; + this.bind.TreePush_B(ptr_id); + } + } + // IMGUI_API void TreePop(); // ~ Unindent()+PopId() + TreePop(): void { this.bind.TreePop(); } + // IMGUI_API void TreeAdvanceToLabelPos(); // advance cursor x position by GetTreeNodeToLabelSpacing() + TreeAdvanceToLabelPos(): void { this.bind.TreeAdvanceToLabelPos(); } + // IMGUI_API float GetTreeNodeToLabelSpacing(); // horizontal distance preceding label when using TreeNode*() or Bullet() == (g.FontSize + style.FramePadding.x*2) for a regular unframed TreeNode + GetTreeNodeToLabelSpacing(): number { return this.bind.GetTreeNodeToLabelSpacing(); } + // IMGUI_API void SetNextTreeNodeOpen(bool is_open, ImGuiCond cond = 0); // set next TreeNode/CollapsingHeader open state. + SetNextTreeNodeOpen(is_open: boolean, cond: ImGuiCond = 0): void { + this.bind.SetNextTreeNodeOpen(is_open, cond); + } + // IMGUI_API bool CollapsingHeader(const char* label, ImGuiTreeNodeFlags flags = 0); // if returning 'true' the header is open. doesn't indent nor push on ID stack. user doesn't have to call TreePop(). + // IMGUI_API bool CollapsingHeader(const char* label, bool* p_open, ImGuiTreeNodeFlags flags = 0); // when 'p_open' isn't NULL, display an additional small close button on upper right of the header + CollapsingHeader(label: string, flags?: ImGuiTreeNodeFlags): boolean; + CollapsingHeader(label: string, p_open: Bind.ImScalar | Bind.ImAccess, flags?: ImGuiTreeNodeFlags): boolean; + CollapsingHeader(label: string, ...args: any[]): boolean { + if (args.length === 0) { + return this.bind.CollapsingHeader_A(label, 0); + } else { + if (typeof(args[0]) === "number") { + const flags: ImGuiTreeNodeFlags = args[0]; + return this.bind.CollapsingHeader_A(label, flags); + } else { + const p_open: Bind.ImScalar | Bind.ImAccess = args[0]; + const flags: ImGuiTreeNodeFlags = args[1] || 0; + const ref_open: Bind.ImScalar = Array.isArray(p_open) ? p_open : [ p_open() ]; + const ret = this.bind.CollapsingHeader_B(label, ref_open, flags); + if (!Array.isArray(p_open)) { p_open(ref_open[0]); } + return ret; + } + } + } + + // Widgets: Selectable / Lists + // IMGUI_API bool Selectable(const char* label, bool selected = false, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0,0)); // size.x==0.0: use remaining width, size.x>0.0: specify width. size.y==0.0: use label height, size.y>0.0: specify height + // IMGUI_API bool Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0,0)); + Selectable(label: string, selected?: boolean, flags?: ImGuiSelectableFlags, size?: Readonly): boolean; + Selectable(label: string, p_selected: Bind.ImScalar | Bind.ImAccess, flags?: ImGuiSelectableFlags, size?: Readonly): boolean; + Selectable(label: string, ...args: any[]): boolean { + if (args.length === 0) { + return this.bind.Selectable_A(label, false, 0, ImVec2.ZERO); + } else { + if (typeof(args[0]) === "boolean") { + const selected: boolean = args[0]; + const flags: ImGuiSelectableFlags = args[1] || 0; + const size: Readonly = args[2] || ImVec2.ZERO; + return this.bind.Selectable_A(label, selected, flags, size); + } else { + const p_selected: Bind.ImScalar | Bind.ImAccess = args[0]; + const flags: ImGuiSelectableFlags = args[1] || 0; + const size: Readonly = args[2] || ImVec2.ZERO; + const ref_selected: Bind.ImScalar = Array.isArray(p_selected) ? p_selected : [ p_selected() ]; + const ret = this.bind.Selectable_B(label, ref_selected, flags, size); + if (!Array.isArray(p_selected)) { p_selected(ref_selected[0]); } + return ret; + } + } + } + // IMGUI_API bool ListBox(const char* label, int* current_item, const char* const* items, int items_count, int height_in_items = -1); + // IMGUI_API bool ListBox(const char* label, int* current_item, bool (*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int height_in_items = -1); + ListBox(label: string, current_item: Bind.ImAccess | Bind.ImScalar, items: string[], items_count?: number, height_in_items?: number): boolean; + ListBox(label: string, current_item: Bind.ImAccess | Bind.ImScalar, items_getter: ListBoxItemGetter, data: any, items_count: number, height_in_items?: number): boolean; + ListBox(label: string, current_item: Bind.ImAccess | Bind.ImScalar, ...args: any[]): boolean { + let ret: boolean = false; + const _current_item: Bind.ImScalar = Array.isArray(current_item) ? current_item : [ current_item() ]; + if (Array.isArray(args[0])) { + const items: string[] = args[0]; + const items_count: number = typeof(args[1]) === "number" ? args[1] : items.length; + const height_in_items: number = typeof(args[2]) === "number" ? args[2] : -1; + ret = this.bind.ListBox_A(label, _current_item, items, items_count, height_in_items); + } else { + const items_getter: ListBoxItemGetter = args[0]; + const data: any = args[1]; + const items_count: number = args[2]; + const height_in_items: number = typeof(args[3]) === "number" ? args[3] : -1; + ret = this.bind.ListBox_B(label, _current_item, items_getter, data, items_count, height_in_items); + } + if (!Array.isArray(current_item)) { current_item(_current_item[0]); } + return ret; + } + // IMGUI_API bool ListBoxHeader(const char* label, const ImVec2& size = ImVec2(0,0)); // use if you want to reimplement ListBox() will custom data or interactions. make sure to call ListBoxFooter() afterwards. + // IMGUI_API bool ListBoxHeader(const char* label, int items_count, int height_in_items = -1); // " + ListBoxHeader(label: string, size: Readonly): boolean; + ListBoxHeader(label: string, items_count: number, height_in_items?: number): boolean; + ListBoxHeader(label: string, ...args: any[]): boolean { + if (typeof(args[0]) === "object") { + const size: Readonly = args[0]; + return this.bind.ListBoxHeader_A(label, size); + } else { + const items_count: number = args[0]; + const height_in_items: number = typeof(args[1]) === "number" ? args[1] : -1; + return this.bind.ListBoxHeader_B(label, items_count, height_in_items); + } + } + // IMGUI_API void ListBoxFooter(); // terminate the scrolling region + ListBoxFooter(): void { + this.bind.ListBoxFooter(); + } + + // Widgets: Value() Helpers. Output single value in "name: value" format (tip: freely declare more in your code to handle your types. you can add functions to the ImGui namespace) + // IMGUI_API void Value(const char* prefix, bool b); + // IMGUI_API void Value(const char* prefix, int v); + // IMGUI_API void Value(const char* prefix, unsigned int v); + // IMGUI_API void Value(const char* prefix, float v, const char* float_format = NULL); + Value(prefix: string, b: boolean): void; + Value(prefix: string, v: number): void; + Value(prefix: string, v: number, float_format?: string | null): void; + Value(prefix: string, v: any): void; + Value(prefix: string, ...args: any[]): void { + if (typeof(args[0]) === "boolean") { + this.bind.Value_A(prefix, args[0]); + } else if (typeof(args[0]) === "number") { + if (Number.isInteger(args[0])) { + this.bind.Value_B(prefix, args[0]); + } else { + this.bind.Value_D(prefix, args[0], typeof(args[1]) === "string" ? args[1] : null); + } + } else { + this.bind.Text(prefix + String(args[0])); + } + } + + // Tooltips + // IMGUI_API void BeginTooltip(); // begin/append a tooltip window. to create full-featured tooltip (with any kind of contents). + BeginTooltip(): void { this.bind.BeginTooltip(); } + // IMGUI_API void EndTooltip(); + EndTooltip(): void { this.bind.EndTooltip(); } + // IMGUI_API void SetTooltip(const char* fmt, ...) IM_FMTARGS(1); // set text tooltip under mouse-cursor, typically use with ImGui::IsItemHovered(). overidde any previous call to SetTooltip(). + // IMGUI_API void SetTooltipV(const char* fmt, va_list args) IM_FMTLIST(1); + SetTooltip(fmt: string): void { + this.bind.SetTooltip(fmt); + } + + // Menus + // IMGUI_API bool BeginMainMenuBar(); // create and append to a full screen menu-bar. only call EndMainMenuBar() if this returns true! + BeginMainMenuBar(): boolean { return this.bind.BeginMainMenuBar(); } + // IMGUI_API void EndMainMenuBar(); + EndMainMenuBar(): void { this.bind.EndMainMenuBar(); } + // IMGUI_API bool BeginMenuBar(); // append to menu-bar of current window (requires ImGuiWindowFlags_MenuBar flag set on parent window). only call EndMenuBar() if this returns true! + BeginMenuBar(): boolean { return this.bind.BeginMenuBar(); } + // IMGUI_API void EndMenuBar(); + EndMenuBar(): void { this.bind.EndMenuBar(); } + // IMGUI_API bool BeginMenu(const char* label, bool enabled = true); // create a sub-menu entry. only call EndMenu() if this returns true! + BeginMenu(label: string, enabled: boolean = true): boolean { return this.bind.BeginMenu(label, enabled); } + // IMGUI_API void EndMenu(); + EndMenu(): void { this.bind.EndMenu(); } + // IMGUI_API bool MenuItem(const char* label, const char* shortcut = NULL, bool selected = false, bool enabled = true); // return true when activated. shortcuts are displayed for convenience but not processed by ImGui at the moment + // IMGUI_API bool MenuItem(const char* label, const char* shortcut, bool* p_selected, bool enabled = true); // return true when activated + toggle (*p_selected) if p_selected != NULL + MenuItem(label: string, shortcut?: string | null, selected?: boolean, enabled?: boolean): boolean; + MenuItem(label: string, shortcut: string | null, p_selected: Bind.ImScalar | Bind.ImAccess | null, enabled?: boolean): boolean; + MenuItem(label: string, ...args: any[]): boolean { + if (args.length === 0) { + return this.bind.MenuItem_A(label, null, false, true); + } else if (args.length === 1) { + const shortcut: string | null = args[0]; + return this.bind.MenuItem_A(label, shortcut, false, true); + } else { + const shortcut: string | null = args[0]; + if (typeof(args[1]) === "boolean") { + const selected: boolean = args[1]; + const enabled: boolean = typeof(args[2]) === "boolean" ? args[2] : true; + return this.bind.MenuItem_A(label, shortcut, selected, enabled); + } else { + const p_selected: Bind.ImScalar | Bind.ImAccess = args[1]; + const enabled: boolean = typeof(args[2]) === "boolean" ? args[2] : true; + const ref_selected: Bind.ImScalar = Array.isArray(p_selected) ? p_selected : [ p_selected() ]; + const ret = this.bind.MenuItem_B(label, shortcut, ref_selected, enabled); + if (!Array.isArray(p_selected)) { p_selected(ref_selected[0]); } + return ret; + } + } + } + + // Popups + // IMGUI_API void OpenPopup(const char* str_id); // call to mark popup as open (don't call every frame!). popups are closed when user click outside, or if CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block. By default, Selectable()/MenuItem() are calling CloseCurrentPopup(). Popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level). + OpenPopup(str_id: string): void { this.bind.OpenPopup(str_id); } + // IMGUI_API bool OpenPopupOnItemClick(const char* str_id = NULL, int mouse_button = 1); // helper to open popup when clicked on last item. return true when just opened. + OpenPopupOnItemClick(str_id: string | null = null, mouse_button: number = 1): boolean { + return this.bind.OpenPopupOnItemClick(str_id, mouse_button); + } + // IMGUI_API bool BeginPopup(const char* str_id); // return true if the popup is open, and you can start outputting to it. only call EndPopup() if BeginPopup() returned true! + BeginPopup(str_id: string): boolean { return this.bind.BeginPopup(str_id); } + // IMGUI_API bool BeginPopupModal(const char* name, bool* p_open = NULL, ImGuiWindowFlags extra_flags = 0); // modal dialog (block interactions behind the modal window, can't close the modal window by clicking outside) + BeginPopupModal(str_id: string = "", p_open: Bind.ImScalar | Bind.ImAccess | null = null, extra_flags: ImGuiWindowFlags = 0): boolean { + if (Array.isArray(p_open)) { + return this.bind.BeginPopupModal(str_id, p_open, extra_flags); + } else if (typeof(p_open) === "function") { + const _p_open: Bind.ImScalar = [ p_open() ]; + const ret = this.bind.BeginPopupModal(str_id, _p_open, extra_flags); + p_open(_p_open[0]); + return ret; + } else { + return this.bind.BeginPopupModal(str_id, null, extra_flags); + } + } + // IMGUI_API bool BeginPopupContextItem(const char* str_id = NULL, int mouse_button = 1); // helper to open and begin popup when clicked on last item. if you can pass a NULL str_id only if the previous item had an id. If you want to use that on a non-interactive item such as Text() you need to pass in an explicit ID here. read comments in .cpp! + BeginPopupContextItem(str_id: string | null = null, mouse_button: number = 1): boolean { + return this.bind.BeginPopupContextItem(str_id, mouse_button); + } + // IMGUI_API bool BeginPopupContextWindow(const char* str_id = NULL, int mouse_button = 1, bool also_over_items = true); // helper to open and begin popup when clicked on current window. + BeginPopupContextWindow(str_id: string | null = null, mouse_button: number = 1, also_over_items: boolean = true): boolean { + return this.bind.BeginPopupContextWindow(str_id, mouse_button, also_over_items); + } + // IMGUI_API bool BeginPopupContextVoid(const char* str_id = NULL, int mouse_button = 1); // helper to open and begin popup when clicked in void (where there are no imgui windows). + BeginPopupContextVoid(str_id: string | null = null, mouse_button: number = 1): boolean { + return this.bind.BeginPopupContextVoid(str_id, mouse_button); + } + // IMGUI_API void EndPopup(); + EndPopup(): void { this.bind.EndPopup(); } + // IMGUI_API bool IsPopupOpen(const char* str_id); // return true if the popup is open + IsPopupOpen(str_id: string): boolean { return this.bind.IsPopupOpen(str_id); } + // IMGUI_API void CloseCurrentPopup(); // close the popup we have begin-ed into. clicking on a MenuItem or Selectable automatically close the current popup. + CloseCurrentPopup(): void { this.bind.CloseCurrentPopup(); } + + // Tab Bars, Tabs + // [BETA API] API may evolve! + // IMGUI_API bool BeginTabBar(const char* str_id, ImGuiTabBarFlags flags = 0); // create and append into a TabBar + BeginTabBar(str_id: string, flags: ImGuiTabBarFlags = 0): boolean { return this.bind.BeginTabBar(str_id, flags); } + // IMGUI_API void EndTabBar(); // only call EndTabBar() if BeginTabBar() returns true! + EndTabBar(): void { this.bind.EndTabBar(); } + // IMGUI_API bool BeginTabItem(const char* label, bool* p_open = NULL, ImGuiTabItemFlags flags = 0);// create a Tab. Returns true if the Tab is selected. + BeginTabItem(label: string, p_open: Bind.ImScalar | Bind.ImAccess | null = null, flags: ImGuiTabItemFlags = 0): boolean { + // return this.bind.BeginTabItem(label, p_open, flags); + if (p_open === null) { + return this.bind.BeginTabItem(label, null, flags); + } else if (Array.isArray(p_open)) { + return this.bind.BeginTabItem(label, p_open, flags); + } else { + const ref_open: Bind.ImScalar = [ p_open() ]; + const ret = this.bind.BeginTabItem(label, ref_open, flags); + p_open(ref_open[0]); + return ret; + } + } + // IMGUI_API void EndTabItem(); // only call EndTabItem() if BeginTabItem() returns true! + EndTabItem(): void { this.bind.EndTabItem(); } + // IMGUI_API void SetTabItemClosed(const char* tab_or_docked_window_label); // notify TabBar or Docking system of a closed tab/window ahead (useful to reduce visual flicker on reorderable tab bars). For tab-bar: call after BeginTabBar() and before Tab submissions. Otherwise call with a window name. + SetTabItemClosed(tab_or_docked_window_label: string): void { this.bind.SetTabItemClosed(tab_or_docked_window_label); } + + // Logging/Capture: all text output from interface is captured to tty/file/clipboard. By default, tree nodes are automatically opened during logging. + // IMGUI_API void LogToTTY(int max_depth = -1); // start logging to tty + LogToTTY(max_depth: number = -1): void { + this.bind.LogToTTY(max_depth); + } + // IMGUI_API void LogToFile(int max_depth = -1, const char* filename = NULL); // start logging to file + LogToFile(max_depth: number = -1, filename: string | null = null): void { + this.bind.LogToFile(max_depth, filename); + } + // IMGUI_API void LogToClipboard(int max_depth = -1); // start logging to OS clipboard + LogToClipboard(max_depth: number = -1): void { + this.bind.LogToClipboard(max_depth); + } + // IMGUI_API void LogFinish(); // stop logging (close file, etc.) + LogFinish(): void { this.bind.LogFinish(); } + // IMGUI_API void LogButtons(); // helper to display buttons for logging to tty/file/clipboard + LogButtons(): void { this.bind.LogButtons(); } + // IMGUI_API void LogText(const char* fmt, ...) IM_FMTARGS(1); // pass text data straight to log (without being displayed) + LogText(fmt: string): void { + this.bind.LogText(fmt); + } + + _ImGui_DragDropPayload_data: {[key: string]: any} = {}; + // Drag and Drop + // [BETA API] Missing Demo code. API may evolve. + // IMGUI_API bool BeginDragDropSource(ImGuiDragDropFlags flags = 0); // call when the current item is active. If this return true, you can call SetDragDropPayload() + EndDragDropSource() + BeginDragDropSource(flags: ImGuiDragDropFlags = 0): boolean { + return this.bind.BeginDragDropSource(flags); + } + // IMGUI_API bool SetDragDropPayload(const char* type, const void* data, size_t size, ImGuiCond cond = 0);// type is a user defined string of maximum 8 characters. Strings starting with '_' are reserved for dear imgui internal types. Data is copied and held by imgui. + SetDragDropPayload(type: string, data: T, cond: ImGuiCond = 0): boolean { + this._ImGui_DragDropPayload_data[type] = data; + return this.bind.SetDragDropPayload(type, data, 0, cond); + } + // IMGUI_API void EndDragDropSource(); + EndDragDropSource(): void { + this.bind.EndDragDropSource(); + } + // IMGUI_API bool BeginDragDropTarget(); // call after submitting an item that may receive an item. If this returns true, you can call AcceptDragDropPayload() + EndDragDropTarget() + BeginDragDropTarget(): boolean { + return this.bind.BeginDragDropTarget(); + } + // IMGUI_API const ImGuiPayload* AcceptDragDropPayload(const char* type, ImGuiDragDropFlags flags = 0); // accept contents of a given type. If ImGuiDragDropFlags_AcceptBeforeDelivery is set you can peek into the payload before the mouse button is released. + AcceptDragDropPayload(type: string, flags: ImGuiDragDropFlags = 0): ImGuiPayload | null { + const data: T = this._ImGui_DragDropPayload_data[type]; + return this.bind.AcceptDragDropPayload(type, flags) ? { Data: data } : null; + } + // IMGUI_API void EndDragDropTarget(); + EndDragDropTarget(): void { + this.bind.EndDragDropTarget(); + } + + // Clipping + // IMGUI_API void PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_max, bool intersect_with_current_clip_rect); + PushClipRect(clip_rect_min: Readonly, clip_rect_max: Readonly, intersect_with_current_clip_rect: boolean): void { + this.bind.PushClipRect(clip_rect_min, clip_rect_max, intersect_with_current_clip_rect); + } + // IMGUI_API void PopClipRect(); + PopClipRect(): void { + this.bind.PopClipRect(); + } + + // Focus + // (FIXME: Those functions will be reworked after we merge the navigation branch + have a pass at focusing/tabbing features.) + // (Prefer using "SetItemDefaultFocus()" over "if (IsWindowAppearing()) SetScrollHere()" when applicable, to make your code more forward compatible when navigation branch is merged) + // IMGUI_API void SetItemDefaultFocus(); // make last item the default focused item of a window (WIP navigation branch only). Pleaase use instead of SetScrollHere(). + SetItemDefaultFocus(): void { this.bind.SetItemDefaultFocus(); } + // IMGUI_API void SetKeyboardFocusHere(int offset = 0); // focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget. Use -1 to access previous widget. + SetKeyboardFocusHere(offset: number = 0): void { + this.bind.SetKeyboardFocusHere(offset); + } + + // Utilities + // IMGUI_API bool IsItemHovered(ImGuiHoveredFlags flags = 0); // is the last item hovered? (and usable, aka not blocked by a popup, etc.). See ImGuiHoveredFlags for more options. + IsItemHovered(flags: ImGuiHoveredFlags = 0): boolean { + return this.bind.IsItemHovered(flags); + } + // IMGUI_API bool IsItemActive(); // is the last item active? (e.g. button being held, text field being edited- items that don't interact will always return false) + IsItemActive(): boolean { return this.bind.IsItemActive(); } + // IMGUI_API bool IsItemEdited(); // is the last item active? (e.g. button being held, text field being edited- items that don't interact will always return false) + IsItemEdited(): boolean { return this.bind.IsItemEdited(); } + // IMGUI_API bool IsItemFocused(); // is the last item focused for keyboard/gamepad navigation? + IsItemFocused(): boolean { return this.bind.IsItemFocused(); } + // IMGUI_API bool IsItemClicked(int mouse_button = 0); // is the last item clicked? (e.g. button/node just clicked on) + IsItemClicked(mouse_button: number = 0): boolean { + return this.bind.IsItemClicked(mouse_button); + } + // IMGUI_API bool IsItemVisible(); // is the last item visible? (aka not out of sight due to clipping/scrolling.) + IsItemVisible(): boolean { return this.bind.IsItemVisible(); } + // IMGUI_API bool IsItemDeactivated(); // was the last item just made inactive (item was previously active). Useful for Undo/Redo patterns with widgets that requires continuous editing. + IsItemDeactivated(): boolean { return this.bind.IsItemDeactivated(); } + // IMGUI_API bool IsItemDeactivatedAfterEdit(); // was the last item just made inactive and made a value change when it was active? (e.g. Slider/Drag moved). Useful for Undo/Redo patterns with widgets that requires continuous editing. Note that you may get false positives (some widgets such as Combo()/ListBox()/Selectable() will return true even when clicking an already selected item). + IsItemDeactivatedAfterEdit(): boolean { return this.bind.IsItemDeactivatedAfterEdit(); } + // IMGUI_API bool IsAnyItemHovered(); + IsAnyItemHovered(): boolean { return this.bind.IsAnyItemHovered(); } + // IMGUI_API bool IsAnyItemActive(); + IsAnyItemActive(): boolean { return this.bind.IsAnyItemActive(); } + // IMGUI_API bool IsAnyItemFocused(); + IsAnyItemFocused(): boolean { return this.bind.IsAnyItemFocused(); } + // IMGUI_API ImVec2 GetItemRectMin(); // get bounding rectangle of last item, in screen space + GetItemRectMin(out: Bind.interface_ImVec2 = new ImVec2()): typeof out { + return this.bind.GetItemRectMin(out); + } + // IMGUI_API ImVec2 GetItemRectMax(); // " + GetItemRectMax(out: Bind.interface_ImVec2 = new ImVec2()): typeof out { + return this.bind.GetItemRectMax(out); + } + // IMGUI_API ImVec2 GetItemRectSize(); // get size of last item, in screen space + GetItemRectSize(out: Bind.interface_ImVec2 = new ImVec2()): typeof out { + return this.bind.GetItemRectSize(out); + } + // IMGUI_API void SetItemAllowOverlap(); // allow last item to be overlapped by a subsequent item. sometimes useful with invisible buttons, selectables, etc. to catch unused area. + SetItemAllowOverlap(): void { this.bind.SetItemAllowOverlap(); } + // IMGUI_API bool IsWindowFocused(ImGuiFocusedFlags flags = 0); // is current window focused? or its root/child, depending on flags. see flags for options. + IsWindowFocused(flags: ImGuiFocusedFlags = 0): boolean { + return this.bind.IsWindowFocused(flags); + } + // IMGUI_API bool IsWindowHovered(ImGuiHoveredFlags flags = 0); // is current window hovered (and typically: not blocked by a popup/modal)? see flags for options. + IsWindowHovered(flags: ImGuiHoveredFlags = 0): boolean { + return this.bind.IsWindowHovered(flags); + } + // IMGUI_API bool IsRectVisible(const ImVec2& size); // test if rectangle (of given size, starting from cursor position) is visible / not clipped. + // IMGUI_API bool IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max); // test if rectangle (in screen space) is visible / not clipped. to perform coarse clipping on user's side. + IsRectVisible(size: Readonly): boolean; + IsRectVisible(rect_min: Readonly, rect_max: Readonly): boolean; + IsRectVisible(...args: any[]): boolean { + if (args.length === 1) { + const size: Readonly = args[0]; + return this.bind.IsRectVisible_A(size); + } else { + const rect_min: Readonly = args[0]; + const rect_max: Readonly = args[1]; + return this.bind.IsRectVisible_B(rect_min, rect_max); + } + } + // IMGUI_API float GetTime(); + GetTime(): number { return this.bind.GetTime(); } + // IMGUI_API int GetFrameCount(); + GetFrameCount(): number { return this.bind.GetFrameCount(); } + // IMGUI_API ImDrawList* GetOverlayDrawList(); // this draw list will be the last rendered one, useful to quickly draw overlays shapes/text + GetOverlayDrawList(): ImDrawList { + return new ImDrawList(this.bind.GetOverlayDrawList()); + } + // IMGUI_API ImDrawListSharedData* GetDrawListSharedData(); + GetDrawListSharedData(): ImDrawListSharedData { + return new ImDrawListSharedData(this.bind.GetDrawListSharedData()); + } + // IMGUI_API const char* GetStyleColorName(ImGuiCol idx); + GetStyleColorName(idx: ImGuiCol): string { return this.bind.GetStyleColorName(idx); } + // IMGUI_API ImVec2 CalcTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_double_hash = false, float wrap_width = -1.0f); + CalcTextSize(text: string, text_end: number | null = null, hide_text_after_double_hash: boolean = false, wrap_width: number = -1, out: Bind.interface_ImVec2 = new ImVec2()): typeof out { + return this.bind.CalcTextSize(text_end !== null ? text.substring(0, text_end) : text, hide_text_after_double_hash, wrap_width, out); + } + // IMGUI_API void CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end); // calculate coarse clipping for large list of evenly sized items. Prefer using the ImGuiListClipper higher-level helper if you can. + CalcListClipping(items_count: number, items_height: number, out_items_display_start: Bind.ImScalar, out_items_display_end: Bind.ImScalar): void { + return this.bind.CalcListClipping(items_count, items_height, out_items_display_start, out_items_display_end); + } + + // IMGUI_API bool BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags extra_flags = 0); // helper to create a child window / scrolling region that looks like a normal widget frame + BeginChildFrame(id: Bind.ImGuiID, size: Readonly, extra_flags: ImGuiWindowFlags = 0): boolean { + return this.bind.BeginChildFrame(id, size, extra_flags); + } + // IMGUI_API void EndChildFrame(); + EndChildFrame(): void { this.bind.EndChildFrame(); } + + // IMGUI_API ImVec4 ColorConvertU32ToFloat4(ImU32 in); + ColorConvertU32ToFloat4(in_: Bind.ImU32, out: Bind.interface_ImVec4 = new ImVec4()): typeof out { + return this.bind.ColorConvertU32ToFloat4(in_, out); + } + // IMGUI_API ImU32 ColorConvertFloat4ToU32(const ImVec4& in); + ColorConvertFloat4ToU32(in_: Readonly): Bind.ImU32 { + return this.bind.ColorConvertFloat4ToU32(in_); + } + // IMGUI_API void ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& out_s, float& out_v); + ColorConvertRGBtoHSV(r: number, g: number, b: number, out_h: Bind.ImScalar, out_s: Bind.ImScalar, out_v: Bind.ImScalar): void { this.bind.ColorConvertRGBtoHSV(r, g, b, out_h, out_s, out_v); } + // IMGUI_API void ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b); + ColorConvertHSVtoRGB(h: number, s: number, v: number, out_r: Bind.ImScalar, out_g: Bind.ImScalar, out_b: Bind.ImScalar): void { this.bind.ColorConvertHSVtoRGB(h, s, v, out_r, out_g, out_b); } + + // Inputs + // IMGUI_API int GetKeyIndex(ImGuiKey imgui_key); // map ImGuiKey_* values into user's key index. == io.KeyMap[key] + GetKeyIndex(imgui_key: ImGuiKey): number { + return this.bind.GetKeyIndex(imgui_key); + } + // IMGUI_API bool IsKeyDown(int user_key_index); // is key being held. == io.KeysDown[user_key_index]. note that imgui doesn't know the semantic of each entry of io.KeyDown[]. Use your own indices/enums according to how your backend/engine stored them into KeyDown[]! + IsKeyDown(user_key_index: number): boolean { + return this.bind.IsKeyDown(user_key_index); + } + // IMGUI_API bool IsKeyPressed(int user_key_index, bool repeat = true); // was key pressed (went from !Down to Down). if repeat=true, uses io.KeyRepeatDelay / KeyRepeatRate + IsKeyPressed(user_key_index: number, repeat: boolean = true): boolean { + return this.bind.IsKeyPressed(user_key_index, repeat); + } + // IMGUI_API bool IsKeyReleased(int user_key_index); // was key released (went from Down to !Down).. + IsKeyReleased(user_key_index: number): boolean { + return this.bind.IsKeyReleased(user_key_index); + } + // IMGUI_API int GetKeyPressedAmount(int key_index, float repeat_delay, float rate); // uses provided repeat rate/delay. return a count, most often 0 or 1 but might be >1 if RepeatRate is small enough that DeltaTime > RepeatRate + GetKeyPressedAmount(user_key_index: number, repeat_delay: number, rate: number): number { + return this.bind.GetKeyPressedAmount(user_key_index, repeat_delay, rate); + } + // IMGUI_API bool IsMouseDown(int button); // is mouse button held + IsMouseDown(button: number): boolean { + return this.bind.IsMouseDown(button); + } + // IMGUI_API bool IsMouseClicked(int button, bool repeat = false); // did mouse button clicked (went from !Down to Down) + IsMouseClicked(button: number, repeat: boolean = false): boolean { + return this.bind.IsMouseClicked(button, repeat); + } + // IMGUI_API bool IsMouseDoubleClicked(int button); // did mouse button double-clicked. a double-click returns false in IsMouseClicked(). uses io.MouseDoubleClickTime. + IsMouseDoubleClicked(button: number): boolean { + return this.bind.IsMouseDoubleClicked(button); + } + // IMGUI_API bool IsMouseReleased(int button); // did mouse button released (went from Down to !Down) + IsMouseReleased(button: number): boolean { + return this.bind.IsMouseReleased(button); + } + // IMGUI_API bool IsMouseDragging(int button = 0, float lock_threshold = -1.0f); // is mouse dragging. if lock_threshold < -1.0f uses io.MouseDraggingThreshold + IsMouseDragging(button: number = 0, lock_threshold: number = -1.0): boolean { + return this.bind.IsMouseDragging(button, lock_threshold); + } + // IMGUI_API bool IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip = true); // is mouse hovering given bounding rect (in screen space). clipped by current clipping settings. disregarding of consideration of focus/window ordering/blocked by a popup. + IsMouseHoveringRect(r_min: Readonly, r_max: Readonly, clip: boolean = true): boolean { + return this.bind.IsMouseHoveringRect(r_min, r_max, clip); + } + // IMGUI_API bool IsMousePosValid(const ImVec2* mouse_pos = NULL); // + IsMousePosValid(mouse_pos: Readonly | null = null): boolean { + return this.bind.IsMousePosValid(mouse_pos); + } + // IMGUI_API ImVec2 GetMousePos(); // shortcut to ImGui::GetIO().MousePos provided by user, to be consistent with other calls + GetMousePos(out: Bind.interface_ImVec2 = new ImVec2()): typeof out { + return this.bind.GetMousePos(out); + } + // IMGUI_API ImVec2 GetMousePosOnOpeningCurrentPopup(); // retrieve backup of mouse positioning at the time of opening popup we have BeginPopup() into + GetMousePosOnOpeningCurrentPopup(out: Bind.interface_ImVec2 = new ImVec2()): typeof out { + return this.bind.GetMousePosOnOpeningCurrentPopup(out); + } + // IMGUI_API ImVec2 GetMouseDragDelta(int button = 0, float lock_threshold = -1.0f); // dragging amount since clicking. if lock_threshold < -1.0f uses io.MouseDraggingThreshold + GetMouseDragDelta(button: number = 0, lock_threshold: number = -1.0, out: Bind.interface_ImVec2 = new ImVec2()): typeof out { + return this.bind.GetMouseDragDelta(button, lock_threshold, out); + } + // IMGUI_API void ResetMouseDragDelta(int button = 0); // + ResetMouseDragDelta(button: number = 0): void { + this.bind.ResetMouseDragDelta(button); + } + // IMGUI_API ImGuiMouseCursor GetMouseCursor(); // get desired cursor type, reset in ImGui::NewFrame(), this is updated during the frame. valid before Render(). If you use software rendering by setting io.MouseDrawCursor ImGui will render those for you + GetMouseCursor(): ImGuiMouseCursor { return this.bind.GetMouseCursor(); } + // IMGUI_API void SetMouseCursor(ImGuiMouseCursor type); // set desired cursor type + SetMouseCursor(type: ImGuiMouseCursor): void { this.bind.SetMouseCursor(type); } + // IMGUI_API void CaptureKeyboardFromApp(bool capture = true); // manually override io.WantCaptureKeyboard flag next frame (said flag is entirely left for your application handle). e.g. force capture keyboard when your widget is being hovered. + CaptureKeyboardFromApp(capture: boolean = true) { + return this.bind.CaptureKeyboardFromApp(capture); + } + // IMGUI_API void CaptureMouseFromApp(bool capture = true); // manually override io.WantCaptureMouse flag next frame (said flag is entirely left for your application handle). + CaptureMouseFromApp(capture: boolean = true): void { + this.bind.CaptureMouseFromApp(capture); + } + + // Clipboard Utilities (also see the LogToClipboard() function to capture or output text data to the clipboard) + // IMGUI_API const char* GetClipboardText(); + GetClipboardText(): string { return this.bind.GetClipboardText(); } + // IMGUI_API void SetClipboardText(const char* text); + SetClipboardText(text: string): void { this.bind.SetClipboardText(text); } + + // Settings/.Ini Utilities + // The disk functions are automatically called if io.IniFilename != NULL (default is "imgui.ini"). + // Set io.IniFilename to NULL to load/save manually. Read io.WantSaveIniSettings description about handling .ini saving manually. + // IMGUI_API void LoadIniSettingsFromDisk(const char* ini_filename); // call after CreateContext() and before the first call to NewFrame(). NewFrame() automatically calls LoadIniSettingsFromDisk(io.IniFilename). + LoadIniSettingsFromDisk(ini_filename: string): void { throw new Error(); } // TODO + // IMGUI_API void LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size=0); // call after CreateContext() and before the first call to NewFrame() to provide .ini data from your own data source. + LoadIniSettingsFromMemory(ini_data: string, ini_size: number = 0): void { this.bind.LoadIniSettingsFromMemory(ini_data); } + // IMGUI_API void SaveIniSettingsToDisk(const char* ini_filename); + SaveIniSettingsToDisk(ini_filename: string): void { throw new Error(); } // TODO + // IMGUI_API const char* SaveIniSettingsToMemory(size_t* out_ini_size = NULL); // return a zero-terminated string with the .ini data which you can save by your own mean. call when io.WantSaveIniSettings is set, then save data by your own mean and clear io.WantSaveIniSettings. + SaveIniSettingsToMemory(out_ini_size: Bind.ImScalar | null = null): string { return this.bind.SaveIniSettingsToMemory(); } + + // Memory Utilities + // All those functions are not reliant on the current context. + // If you reload the contents of imgui.cpp at runtime, you may need to call SetCurrentContext() + SetAllocatorFunctions() again. + // IMGUI_API void SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* user_data), void(*free_func)(void* ptr, void* user_data), void* user_data = NULL); + SetAllocatorFunctions(alloc_func: (sz: number, user_data: any) => number, free_func: (ptr: number, user_data: any) => void, user_data: any = null): void { + this.bind.SetAllocatorFunctions(alloc_func, free_func, user_data); + } + // IMGUI_API void* MemAlloc(size_t sz); + MemAlloc(sz: number): void { this.bind.MemAlloc(sz); } + // IMGUI_API void MemFree(void* ptr); + MemFree(ptr: any): void { this.bind.MemFree(ptr); } } -export { bind }; + +//export { bind }; function import_Scalar(sca: XY | XYZ | XYZW | Bind.ImAccess | Bind.ImScalar | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4 | Bind.interface_ImVec4): Bind.ImScalar { if (Array.isArray(sca)) { return [ sca[0] ]; } @@ -90,9 +1708,6 @@ export const IMGUI_VERSION: string = "1.67"; // bind.IMGUI_VERSION; export const IMGUI_VERSION_NUM: number = 16603; // bind.IMGUI_VERSION_NUM; -// #define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert)) -export function IMGUI_CHECKVERSION(): boolean { return DebugCheckVersionAndDataLayout(IMGUI_VERSION, bind.ImGuiIOSize, bind.ImGuiStyleSize, bind.ImVec2Size, bind.ImVec4Size, bind.ImDrawVertSize); } - export function IM_ASSERT(_EXPR: boolean | number): void { if (!_EXPR) { throw new Error(); } } export function IM_ARRAYSIZE(_ARR: ArrayLike | ImStringBuffer): number { @@ -720,8 +2335,10 @@ // Helper: Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]" export class ImGuiTextFilter { + imgui: ImGui; // IMGUI_API ImGuiTextFilter(const char* default_filter = ""); - constructor(default_filter: string = "") { + constructor(imgui:ImGui, default_filter: string = "") { + this.imgui = imgui; if (default_filter) { // ImStrncpy(InputBuf, default_filter, IM_ARRAYSIZE(InputBuf)); @@ -738,10 +2355,10 @@ // IMGUI_API bool Draw(const char* label = "Filter (inc,-exc)", float width = 0.0f); // Helper calling InputText+Build public Draw(label: string = "Filter (inc,-exc)", width: number = 0.0): boolean { if (width !== 0.0) - bind.PushItemWidth(width); - const value_changed: boolean = InputText(label, this.InputBuf, IM_ARRAYSIZE(this.InputBuf)); + this.imgui.bind.PushItemWidth(width); + const value_changed: boolean = this.imgui.InputText(label, this.InputBuf, IM_ARRAYSIZE(this.InputBuf)); if (width !== 0.0) - bind.PopItemWidth(); + this.imgui.bind.PopItemWidth(); if (value_changed) this.Build(); return value_changed; @@ -978,7 +2595,7 @@ } } // inline operator ImU32() const { return ImGui::ColorConvertFloat4ToU32(Value); } - public toImU32(): Bind.ImU32 { return ColorConvertFloat4ToU32(this.Value); } + public toImU32(): Bind.ImU32 { return global_bind.ColorConvertFloat4ToU32(this.Value); } // inline operator ImVec4() const { return Value; } public toImVec4(): ImVec4 { return this.Value; } @@ -988,7 +2605,7 @@ const ref_r: Bind.ImScalar = [ this.Value.x ]; const ref_g: Bind.ImScalar = [ this.Value.y ]; const ref_b: Bind.ImScalar = [ this.Value.z ]; - ColorConvertHSVtoRGB(h, s, v, ref_r, ref_g, ref_b); + global_bind.ColorConvertHSVtoRGB(h, s, v, ref_r, ref_g, ref_b); this.Value.x = ref_r[0]; this.Value.y = ref_g[0]; this.Value.z = ref_b[0]; @@ -1082,8 +2699,8 @@ // items_height: Use -1.0f to be calculated automatically on first step. Otherwise pass in the distance between your items, typically GetTextLineHeightWithSpacing() or GetFrameHeightWithSpacing(). // If you don't specify an items_height, you NEED to call Step(). If you specify items_height you may call the old Begin()/End() api directly, but prefer calling Step(). // ImGuiListClipper(int items_count = -1, float items_height = -1.0f) { Begin(items_count, items_height); } // NB: Begin() initialize every fields (as we allow user to call Begin/End multiple times on a same instance if they want). - constructor(items_count: number = -1, items_height: number = -1.0) { - this.native = new bind.ImGuiListClipper(items_count, items_height); + constructor(imgui: ImGui, items_count: number = -1, items_height: number = -1.0) { + this.native = new imgui.bind.ImGuiListClipper(items_count, items_height); } // ~ImGuiListClipper() { IM_ASSERT(ItemsCount == -1); } // Assert if user forgot to call End() or Step() until false. public delete(): void { @@ -1172,10 +2789,10 @@ // ImU32 col; public col: Uint32Array; - constructor(buffer: ArrayBuffer, byteOffset: number = 0) { - this.pos = new Float32Array(buffer, byteOffset + bind.ImDrawVertPosOffset, 2); - this.uv = new Float32Array(buffer, byteOffset + bind.ImDrawVertUVOffset, 2); - this.col = new Uint32Array(buffer, byteOffset + bind.ImDrawVertColOffset, 1); + constructor(imgui:ImGui, buffer: ArrayBuffer, byteOffset: number = 0) { + this.pos = new Float32Array(buffer, byteOffset + imgui.bind.ImDrawVertPosOffset, 2); + this.uv = new Float32Array(buffer, byteOffset + imgui.bind.ImDrawVertUVOffset, 2); + this.col = new Uint32Array(buffer, byteOffset + imgui.bind.ImDrawVertColOffset, 1); } } // #else @@ -1900,17 +3517,17 @@ this.Colors[i] = new ImVec4(); } const _this = new ImGuiStyle(this); - const native = new bind.ImGuiStyle(); + const native = new global_bind.ImGuiStyle(); const _that = new ImGuiStyle(native); _that.Copy(_this); - bind.StyleColorsClassic(native); + global_bind.StyleColorsClassic(native); _this.Copy(_that); native.delete(); } public ScaleAllSizes(scale_factor: number): void { const _this = new ImGuiStyle(this); - const native = new bind.ImGuiStyle(); + const native = new global_bind.ImGuiStyle(); const _that = new ImGuiStyle(native); _that.Copy(_this); native.ScaleAllSizes(scale_factor); @@ -2302,1618 +3919,9 @@ return index; } } -// IMGUI_API ImGuiContext* CreateContext(ImFontAtlas* shared_font_atlas = NULL); -export function CreateContext(shared_font_atlas: ImFontAtlas | null = null): ImGuiContext | null { - const ctx: ImGuiContext = new ImGuiContext(bind.CreateContext()); - if (ImGuiContext.current_ctx === null) { - ImGuiContext.current_ctx = ctx; - } - return ctx; -} -// IMGUI_API void DestroyContext(ImGuiContext* ctx = NULL); // NULL = Destroy current context -export function DestroyContext(ctx: ImGuiContext | null = null): void { - if (ctx === null) { - ctx = ImGuiContext.current_ctx; - ImGuiContext.current_ctx = null; - } - bind.DestroyContext((ctx === null) ? null : ctx.native); -} -// IMGUI_API ImGuiContext* GetCurrentContext(); -export function GetCurrentContext(): ImGuiContext | null { - // const ctx_native: BindImGui.ImGuiContext | null = bind.GetCurrentContext(); - return ImGuiContext.current_ctx; -} -// IMGUI_API void SetCurrentContext(ImGuiContext* ctx); -export function SetCurrentContext(ctx: ImGuiContext | null): void { - bind.SetCurrentContext((ctx === null) ? null : ctx.native); - ImGuiContext.current_ctx = ctx; -} - -// IMGUI_API bool DebugCheckVersionAndDataLayout(const char* version_str, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_drawvert); -export function DebugCheckVersionAndDataLayout(version_str: string, sz_io: number, sz_style: number, sz_vec2: number, sz_vec4: number, sz_draw_vert: number): boolean { - return bind.DebugCheckVersionAndDataLayout(version_str, sz_io, sz_style, sz_vec2, sz_vec4, sz_draw_vert); -} - -// Main -// IMGUI_API ImGuiIO& GetIO(); -export function GetIO(): ImGuiIO { return new ImGuiIO(bind.GetIO()); } -// IMGUI_API ImGuiStyle& GetStyle(); -export function GetStyle(): ImGuiStyle { return new ImGuiStyle(bind.GetStyle()); } -// IMGUI_API void NewFrame(); // start a new ImGui frame, you can submit any command from this point until Render()/EndFrame(). -export function NewFrame(): void { bind.NewFrame(); } -// IMGUI_API void EndFrame(); // ends the ImGui frame. automatically called by Render(), so most likely don't need to ever call that yourself directly. If you don't need to render you may call EndFrame() but you'll have wasted CPU already. If you don't need to render, better to not create any imgui windows instead! -export function EndFrame(): void { bind.EndFrame(); } -// IMGUI_API void Render(); // ends the ImGui frame, finalize the draw data, then call your io.RenderDrawListsFn() function if set. -export function Render(): void { bind.Render(); } -// IMGUI_API ImDrawData* GetDrawData(); // same value as passed to your io.RenderDrawListsFn() function. valid after Render() and until the next call to NewFrame() -export function GetDrawData(): ImDrawData | null { - const draw_data: Bind.reference_ImDrawData | null = bind.GetDrawData(); - return (draw_data === null) ? null : new ImDrawData(draw_data); -} - -// Demo, Debug, Informations -// IMGUI_API void ShowDemoWindow(bool* p_open = NULL); // create demo/test window (previously called ShowTestWindow). demonstrate most ImGui features. call this to learn about the library! try to make it always available in your application! -export function ShowDemoWindow(p_open: Bind.ImScalar | null = null): void { bind.ShowDemoWindow(p_open); } -// IMGUI_API void ShowAboutWindow(bool* p_open = NULL); // create about window. display Dear ImGui version, credits and build/system information. -export function ShowAboutWindow(p_open: Bind.ImScalar | Bind.ImAccess | null = null): void { - if (p_open === null) { - bind.ShowAboutWindow(null); - } else if (Array.isArray(p_open)) { - bind.ShowAboutWindow(p_open); - } else { - const ref_open: Bind.ImScalar = [ p_open() ]; - bind.ShowAboutWindow(ref_open); - p_open(ref_open[0]); - } -} -// IMGUI_API void ShowMetricsWindow(bool* p_open = NULL); // create metrics window. display ImGui internals: draw commands (with individual draw calls and vertices), window list, basic internal state, etc. -export function ShowMetricsWindow(p_open: Bind.ImScalar | Bind.ImAccess | null = null): void { - if (p_open === null) { - bind.ShowMetricsWindow(null); - } else if (Array.isArray(p_open)) { - bind.ShowMetricsWindow(p_open); - } else { - const ref_open: Bind.ImScalar = [ p_open() ]; - bind.ShowMetricsWindow(ref_open); - p_open(ref_open[0]); - } -} -// IMGUI_API void ShowStyleEditor(ImGuiStyle* ref = NULL); // add style editor block (not a window). you can pass in a reference ImGuiStyle structure to compare to, revert to and save to (else it uses the default style) -export function ShowStyleEditor(ref: ImGuiStyle | null = null): void { - if (ref === null) { - bind.ShowStyleEditor(null); - } else if (ref.internal instanceof bind.ImGuiStyle) { - bind.ShowStyleEditor(ref.internal); - } else { - const native = new bind.ImGuiStyle(); - const wrap = new ImGuiStyle(native); - wrap.Copy(ref); - bind.ShowStyleEditor(native); - ref.Copy(wrap); - native.delete(); - } -} -// IMGUI_API bool ShowStyleSelector(const char* label); -export function ShowStyleSelector(label: string): boolean { return bind.ShowStyleSelector(label); } -// IMGUI_API void ShowFontSelector(const char* label); -export function ShowFontSelector(label: string): void { bind.ShowFontSelector(label); } -// IMGUI_API void ShowUserGuide(); // add basic help/info block (not a window): how to manipulate ImGui as a end-user (mouse/keyboard controls). -export function ShowUserGuide(): void { bind.ShowUserGuide(); } -// IMGUI_API const char* GetVersion(); -export function GetVersion(): string { return bind.GetVersion(); } - -// Styles -// IMGUI_API void StyleColorsClassic(ImGuiStyle* dst = NULL); -export function StyleColorsClassic(dst: ImGuiStyle | null = null): void { - if (dst === null) { - bind.StyleColorsClassic(null); - } else if (dst.internal instanceof bind.ImGuiStyle) { - bind.StyleColorsClassic(dst.internal); - } else { - const native = new bind.ImGuiStyle(); - const wrap = new ImGuiStyle(native); - wrap.Copy(dst); - bind.StyleColorsClassic(native); - dst.Copy(wrap); - native.delete(); - } -} -// IMGUI_API void StyleColorsDark(ImGuiStyle* dst = NULL); -export function StyleColorsDark(dst: ImGuiStyle | null = null): void { - if (dst === null) { - bind.StyleColorsDark(null); - } else if (dst.internal instanceof bind.ImGuiStyle) { - bind.StyleColorsDark(dst.internal); - } else { - const native = new bind.ImGuiStyle(); - const wrap = new ImGuiStyle(native); - wrap.Copy(dst); - bind.StyleColorsDark(native); - dst.Copy(wrap); - native.delete(); - } -} -// IMGUI_API void StyleColorsLight(ImGuiStyle* dst = NULL); -export function StyleColorsLight(dst: ImGuiStyle | null = null): void { - if (dst === null) { - bind.StyleColorsLight(null); - } else if (dst.internal instanceof bind.ImGuiStyle) { - bind.StyleColorsLight(dst.internal); - } else { - const native = new bind.ImGuiStyle(); - const wrap = new ImGuiStyle(native); - wrap.Copy(dst); - bind.StyleColorsLight(native); - dst.Copy(wrap); - native.delete(); - } -} - -// Window -// IMGUI_API bool Begin(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0); // push window to the stack and start appending to it. see .cpp for details. return false when window is collapsed, so you can early out in your code. 'bool* p_open' creates a widget on the upper-right to close the window (which sets your bool to false). -export function Begin(name: string, open: Bind.ImScalar | Bind.ImAccess | null = null, flags: ImGuiWindowFlags = 0): boolean { - if (open === null) { - return bind.Begin(name, null, flags); - } else if (Array.isArray(open)) { - return bind.Begin(name, open, flags); - } else { - const ref_open: Bind.ImScalar = [ open() ]; - const opened: boolean = bind.Begin(name, ref_open, flags); - open(ref_open[0]); - return opened; - } -} -// IMGUI_API void End(); // finish appending to current window, pop it off the window stack. -export function End(): void { bind.End(); } -// IMGUI_API bool BeginChild(const char* str_id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); // begin a scrolling region. size==0.0f: use remaining window size, size<0.0f: use remaining window size minus abs(size). size>0.0f: fixed size. each axis can use a different mode, e.g. ImVec2(0,400). -// IMGUI_API bool BeginChild(ImGuiID id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); // " -export function BeginChild(id: string | Bind.ImGuiID, size: Readonly = ImVec2.ZERO, border: boolean = false, extra_flags: ImGuiWindowFlags = 0): boolean { - return bind.BeginChild(id, size, border, extra_flags); -} -// IMGUI_API void EndChild(); -export function EndChild(): void { bind.EndChild(); } -// IMGUI_API ImVec2 GetContentRegionMax(); // current content boundaries (typically window boundaries including scrolling, or current column boundaries), in windows coordinates -export function GetContentRegionMax(out: Bind.interface_ImVec2 = new ImVec2()): typeof out { - return bind.GetContentRegionMax(out); -} -// IMGUI_API ImVec2 GetContentRegionAvail(); // == GetContentRegionMax() - GetCursorPos() -export function GetContentRegionAvail(out: Bind.interface_ImVec2 = new ImVec2()): typeof out { - return bind.GetContentRegionAvail(out); -} -// IMGUI_API float GetContentRegionAvailWidth(); // -export function GetContentRegionAvailWidth(): number { return bind.GetContentRegionAvailWidth(); } -// IMGUI_API ImVec2 GetWindowContentRegionMin(); // content boundaries min (roughly (0,0)-Scroll), in window coordinates -export function GetWindowContentRegionMin(out: Bind.interface_ImVec2 = new ImVec2()): typeof out { - return bind.GetWindowContentRegionMin(out); -} -// IMGUI_API ImVec2 GetWindowContentRegionMax(); // content boundaries max (roughly (0,0)+Size-Scroll) where Size can be override with SetNextWindowContentSize(), in window coordinates -export function GetWindowContentRegionMax(out: Bind.interface_ImVec2 = new ImVec2()): typeof out { - return bind.GetWindowContentRegionMax(out); -} -// IMGUI_API float GetWindowContentRegionWidth(); // -export function GetWindowContentRegionWidth(): number { return bind.GetWindowContentRegionWidth(); } -// IMGUI_API ImDrawList* GetWindowDrawList(); // get rendering command-list if you want to append your own draw primitives -export function GetWindowDrawList(): ImDrawList { - return new ImDrawList(bind.GetWindowDrawList()); -} -// IMGUI_API ImVec2 GetWindowPos(); // get current window position in screen space (useful if you want to do your own drawing via the DrawList api) -export function GetWindowPos(out: Bind.interface_ImVec2 = new ImVec2()): typeof out { - return bind.GetWindowPos(out); -} -// IMGUI_API ImVec2 GetWindowSize(); // get current window size -export function GetWindowSize(out: Bind.interface_ImVec2 = new ImVec2()): typeof out { - return bind.GetWindowSize(out); -} -// IMGUI_API float GetWindowWidth(); -export function GetWindowWidth(): number { return bind.GetWindowWidth(); } -// IMGUI_API float GetWindowHeight(); -export function GetWindowHeight(): number { return bind.GetWindowHeight(); } -// IMGUI_API bool IsWindowCollapsed(); -export function IsWindowCollapsed(): boolean { return bind.IsWindowCollapsed(); } -// IMGUI_API bool IsWindowAppearing(); -export function IsWindowAppearing(): boolean { return bind.IsWindowAppearing(); } -// IMGUI_API void SetWindowFontScale(float scale); // per-window font scale. Adjust IO.FontGlobalScale if you want to scale all windows -export function SetWindowFontScale(scale: number): void { bind.SetWindowFontScale(scale); } - -// IMGUI_API void SetNextWindowPos(const ImVec2& pos, ImGuiCond cond = 0, const ImVec2& pivot = ImVec2(0,0)); // set next window position. call before Begin(). use pivot=(0.5f,0.5f) to center on given point, etc. -export function SetNextWindowPos(pos: Readonly, cond: ImGuiCond = 0, pivot: Readonly = ImVec2.ZERO): void { - bind.SetNextWindowPos(pos, cond, pivot); -} -// IMGUI_API void SetNextWindowSize(const ImVec2& size, ImGuiCond cond = 0); // set next window size. set axis to 0.0f to force an auto-fit on this axis. call before Begin() -export function SetNextWindowSize(pos: Readonly, cond: ImGuiCond = 0): void { - bind.SetNextWindowSize(pos, cond); -} -// IMGUI_API void SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeConstraintCallback custom_callback = NULL, void* custom_callback_data = NULL); // set next window size limits. use -1,-1 on either X/Y axis to preserve the current size. Use callback to apply non-trivial programmatic constraints. -export function SetNextWindowSizeConstraints(size_min: Readonly, size_max: Readonly, custom_callback: ImGuiSizeConstraintCallback | null = null, custom_callback_data: any = null): void { - if (custom_callback) { - bind.SetNextWindowSizeConstraints(size_min, size_max, (data: Bind.reference_ImGuiSizeCallbackData): void => { - custom_callback(new ImGuiSizeCallbackData(data, custom_callback_data)); - }, null); - } else { - bind.SetNextWindowSizeConstraints(size_min, size_max, null, null); - } -} -// IMGUI_API void SetNextWindowContentSize(const ImVec2& size); // set next window content size (~ enforce the range of scrollbars). not including window decorations (title bar, menu bar, etc.). set an axis to 0.0f to leave it automatic. call before Begin() -export function SetNextWindowContentSize(size: Readonly): void { - bind.SetNextWindowContentSize(size); -} -// IMGUI_API void SetNextWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // set next window collapsed state. call before Begin() -export function SetNextWindowCollapsed(collapsed: boolean, cond: ImGuiCond = 0): void { - bind.SetNextWindowCollapsed(collapsed, cond); -} -// IMGUI_API void SetNextWindowFocus(); // set next window to be focused / front-most. call before Begin() -export function SetNextWindowFocus(): void { bind.SetNextWindowFocus(); } -// IMGUI_API void SetNextWindowBgAlpha(float alpha); // set next window background color alpha. helper to easily modify ImGuiCol_WindowBg/ChildBg/PopupBg. -export function SetNextWindowBgAlpha(alpha: number): void { bind.SetNextWindowBgAlpha(alpha); } -// IMGUI_API void SetWindowPos(const ImVec2& pos, ImGuiCond cond = 0); // (not recommended) set current window position - call within Begin()/End(). prefer using SetNextWindowPos(), as this may incur tearing and side-effects. -// IMGUI_API void SetWindowSize(const ImVec2& size, ImGuiCond cond = 0); // (not recommended) set current window size - call within Begin()/End(). set to ImVec2(0,0) to force an auto-fit. prefer using SetNextWindowSize(), as this may incur tearing and minor side-effects. -// IMGUI_API void SetWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // (not recommended) set current window collapsed state. prefer using SetNextWindowCollapsed(). -// IMGUI_API void SetWindowFocus(); // (not recommended) set current window to be focused / front-most. prefer using SetNextWindowFocus(). -// IMGUI_API void SetWindowPos(const char* name, const ImVec2& pos, ImGuiCond cond = 0); // set named window position. -// IMGUI_API void SetWindowSize(const char* name, const ImVec2& size, ImGuiCond cond = 0); // set named window size. set axis to 0.0f to force an auto-fit on this axis. -// IMGUI_API void SetWindowCollapsed(const char* name, bool collapsed, ImGuiCond cond = 0); // set named window collapsed state -// IMGUI_API void SetWindowFocus(const char* name); // set named window to be focused / front-most. use NULL to remove focus. -export function SetWindowPos(name_or_pos: string | Readonly, pos_or_cond: Readonly | ImGuiCond = 0, cond: ImGuiCond = 0): void { - if (typeof(name_or_pos) === "string") { - bind.SetWindowNamePos(name_or_pos, pos_or_cond as Readonly, cond); - return; - } else { - bind.SetWindowPos(name_or_pos, pos_or_cond as ImGuiCond); - } -} -export function SetWindowSize(name_or_size: string | Readonly, size_or_cond: Readonly | ImGuiCond = 0, cond: ImGuiCond = 0): void { - if (typeof(name_or_size) === "string") { - bind.SetWindowNamePos(name_or_size, size_or_cond as Readonly, cond); - } else { - bind.SetWindowSize(name_or_size, size_or_cond as ImGuiCond); - } -} -export function SetWindowCollapsed(name_or_collapsed: string | boolean, collapsed_or_cond: boolean | ImGuiCond = 0, cond: ImGuiCond = 0): void { - if (typeof(name_or_collapsed) === "string") { - bind.SetWindowNameCollapsed(name_or_collapsed, collapsed_or_cond as boolean, cond); - } else { - bind.SetWindowCollapsed(name_or_collapsed, collapsed_or_cond as ImGuiCond); - } -} -export function SetWindowFocus(name?: string): void { - if (typeof(name) === "string") { - bind.SetWindowNameFocus(name); - } else { - bind.SetWindowFocus(); - } -} - -// IMGUI_API float GetScrollX(); // get scrolling amount [0..GetScrollMaxX()] -export function GetScrollX(): number { return bind.GetScrollX(); } -// IMGUI_API float GetScrollY(); // get scrolling amount [0..GetScrollMaxY()] -export function GetScrollY(): number { return bind.GetScrollY(); } -// IMGUI_API float GetScrollMaxX(); // get maximum scrolling amount ~~ ContentSize.X - WindowSize.X -export function GetScrollMaxX(): number { return bind.GetScrollMaxX(); } -// IMGUI_API float GetScrollMaxY(); // get maximum scrolling amount ~~ ContentSize.Y - WindowSize.Y -export function GetScrollMaxY(): number { return bind.GetScrollMaxY(); } -// IMGUI_API void SetScrollX(float scroll_x); // set scrolling amount [0..GetScrollMaxX()] -export function SetScrollX(scroll_x: number): void { bind.SetScrollX(scroll_x); } -// IMGUI_API void SetScrollY(float scroll_y); // set scrolling amount [0..GetScrollMaxY()] -export function SetScrollY(scroll_y: number): void { bind.SetScrollY(scroll_y); } -// IMGUI_API void SetScrollHereY(float center_y_ratio = 0.5f); // adjust scrolling amount to make current cursor position visible. center_y_ratio=0.0: top, 0.5: center, 1.0: bottom. When using to make a "default/current item" visible, consider using SetItemDefaultFocus() instead. -export function SetScrollHereY(center_y_ratio: number = 0.5): void { - bind.SetScrollHereY(center_y_ratio); -} -// IMGUI_API void SetScrollFromPosY(float pos_y, float center_y_ratio = 0.5f); // adjust scrolling amount to make given position valid. use GetCursorPos() or GetCursorStartPos()+offset to get valid positions. -export function SetScrollFromPosY(pos_y: number, center_y_ratio: number = 0.5): void { - bind.SetScrollFromPosY(pos_y, center_y_ratio); -} -// IMGUI_API void SetStateStorage(ImGuiStorage* tree); // replace tree state storage with our own (if you want to manipulate it yourself, typically clear subsection of it) -// IMGUI_API ImGuiStorage* GetStateStorage(); - -// Parameters stacks (shared) -// IMGUI_API void PushFont(ImFont* font); // use NULL as a shortcut to push default font -export function PushFont(font: ImFont | null): void { bind.PushFont(font ? font.native : null); } -// IMGUI_API void PopFont(); -export function PopFont(): void { bind.PopFont(); } -// IMGUI_API void PushStyleColor(ImGuiCol idx, ImU32 col); -// IMGUI_API void PushStyleColor(ImGuiCol idx, const ImVec4& col); -export function PushStyleColor(idx: ImGuiCol, col: Bind.ImU32 | Readonly | Readonly): void { - if (col instanceof ImColor) { - bind.PushStyleColor(idx, col.Value); - } else { - bind.PushStyleColor(idx, col as (Bind.ImU32 | Readonly)); - } -} -// IMGUI_API void PopStyleColor(int count = 1); -export function PopStyleColor(count: number = 1): void { - bind.PopStyleColor(count); -} -// IMGUI_API void PushStyleVar(ImGuiStyleVar idx, float val); -// IMGUI_API void PushStyleVar(ImGuiStyleVar idx, const ImVec2& val); -export function PushStyleVar(idx: ImGuiStyleVar, val: number | Readonly): void { - bind.PushStyleVar(idx, val); -} -// IMGUI_API void PopStyleVar(int count = 1); -export function PopStyleVar(count: number = 1): void { - bind.PopStyleVar(count); -} -// IMGUI_API const ImVec4& GetStyleColorVec4(ImGuiCol idx); // retrieve style color as stored in ImGuiStyle structure. use to feed back into PushStyleColor(), otherwhise use GetColorU32() to get style color + style alpha. -export function GetStyleColorVec4(idx: ImGuiCol): Readonly { - return bind.GetStyleColorVec4(idx); -} -// IMGUI_API ImFont* GetFont(); // get current font -export function GetFont(): ImFont { - return new ImFont(bind.GetFont()); -} -// IMGUI_API float GetFontSize(); // get current font size (= height in pixels) of current font with current scale applied -export function GetFontSize(): number { return bind.GetFontSize(); } -// IMGUI_API ImVec2 GetFontTexUvWhitePixel(); // get UV coordinate for a while pixel, useful to draw custom shapes via the ImDrawList API -export function GetFontTexUvWhitePixel(out: Bind.interface_ImVec2 = new ImVec2()): typeof out { - return bind.GetFontTexUvWhitePixel(out); -} -// IMGUI_API ImU32 GetColorU32(ImGuiCol idx, float alpha_mul = 1.0f); // retrieve given style color with style alpha applied and optional extra alpha multiplier -// IMGUI_API ImU32 GetColorU32(const ImVec4& col); // retrieve given color with style alpha applied -// IMGUI_API ImU32 GetColorU32(ImU32 col); // retrieve given color with style alpha applied -export function GetColorU32(idx: ImGuiCol, alpha_mul?: number): Bind.ImU32; -export function GetColorU32(col: Readonly): Bind.ImU32; -export function GetColorU32(col: Bind.ImU32): Bind.ImU32; -export function GetColorU32(...args: any[]): Bind.ImU32 { - if (args.length === 1) { - if (typeof(args[0]) === "number") { - // TODO: ImGuiCol or ImU32 - const idx: ImGuiCol = args[0]; - return bind.GetColorU32_A(idx, 1.0); - } else { - const col: Readonly = args[0]; - return bind.GetColorU32_B(col); - } - } else { - const idx: ImGuiCol = args[0]; - const alpha_mul: number = args[1]; - return bind.GetColorU32_A(idx, alpha_mul); - } -} - -// Parameters stacks (current window) -// IMGUI_API void PushItemWidth(float item_width); // width of items for the common item+label case, pixels. 0.0f = default to ~2/3 of windows width, >0.0f: width in pixels, <0.0f align xx pixels to the right of window (so -1.0f always align width to the right side) -export function PushItemWidth(item_width: number): void { bind.PushItemWidth(item_width); } -// IMGUI_API void PopItemWidth(); -export function PopItemWidth(): void { bind.PopItemWidth(); } -// IMGUI_API float CalcItemWidth(); // width of item given pushed settings and current cursor position -export function CalcItemWidth(): number { return bind.CalcItemWidth(); } -// IMGUI_API void PushTextWrapPos(float wrap_pos_x = 0.0f); // word-wrapping for Text*() commands. < 0.0f: no wrapping; 0.0f: wrap to end of window (or column); > 0.0f: wrap at 'wrap_pos_x' position in window local space -export function PushTextWrapPos(wrap_pos_x: number = 0.0): void { - bind.PushTextWrapPos(wrap_pos_x); -} -// IMGUI_API void PopTextWrapPos(); -export function PopTextWrapPos(): void { bind.PopTextWrapPos(); } -// IMGUI_API void PushAllowKeyboardFocus(bool allow_keyboard_focus); // allow focusing using TAB/Shift-TAB, enabled by default but you can disable it for certain widgets -export function PushAllowKeyboardFocus(allow_keyboard_focus: boolean): void { bind.PushAllowKeyboardFocus(allow_keyboard_focus); } -// IMGUI_API void PopAllowKeyboardFocus(); -export function PopAllowKeyboardFocus(): void { bind.PopAllowKeyboardFocus(); } -// IMGUI_API void PushButtonRepeat(bool repeat); // in 'repeat' mode, Button*() functions return repeated true in a typematic manner (using io.KeyRepeatDelay/io.KeyRepeatRate setting). Note that you can call IsItemActive() after any Button() to tell if the button is held in the current frame. -export function PushButtonRepeat(repeat: boolean): void { bind.PushButtonRepeat(repeat); } -// IMGUI_API void PopButtonRepeat(); -export function PopButtonRepeat(): void { bind.PopButtonRepeat(); } - -// Cursor / Layout -// IMGUI_API void Separator(); // separator, generally horizontal. inside a menu bar or in horizontal layout mode, this becomes a vertical separator. -export function Separator(): void { bind.Separator(); } -// IMGUI_API void SameLine(float pos_x = 0.0f, float spacing_w = -1.0f); // call between widgets or groups to layout them horizontally -export function SameLine(pos_x: number = 0.0, spacing_w: number = -1.0): void { - bind.SameLine(pos_x, spacing_w); -} -// IMGUI_API void NewLine(); // undo a SameLine() -export function NewLine(): void { bind.NewLine(); } -// IMGUI_API void Spacing(); // add vertical spacing -export function Spacing(): void { bind.Spacing(); } -// IMGUI_API void Dummy(const ImVec2& size); // add a dummy item of given size -export function Dummy(size: Readonly): void { bind.Dummy(size); } -// IMGUI_API void Indent(float indent_w = 0.0f); // move content position toward the right, by style.IndentSpacing or indent_w if != 0 -export function Indent(indent_w: number = 0.0) { bind.Indent(indent_w); } -// IMGUI_API void Unindent(float indent_w = 0.0f); // move content position back to the left, by style.IndentSpacing or indent_w if != 0 -export function Unindent(indent_w: number = 0.0) { bind.Unindent(indent_w); } -// IMGUI_API void BeginGroup(); // lock horizontal starting position + capture group bounding box into one "item" (so you can use IsItemHovered() or layout primitives such as SameLine() on whole group, etc.) -export function BeginGroup(): void { bind.BeginGroup(); } -// IMGUI_API void EndGroup(); -export function EndGroup(): void { bind.EndGroup(); } -// IMGUI_API ImVec2 GetCursorPos(); // cursor position is relative to window position -export function GetCursorPos(out: Bind.interface_ImVec2 = new ImVec2()): typeof out { return bind.GetCursorPos(out); } -// IMGUI_API float GetCursorPosX(); // " -export function GetCursorPosX(): number { return bind.GetCursorPosX(); } -// IMGUI_API float GetCursorPosY(); // " -export function GetCursorPosY(): number { return bind.GetCursorPosY(); } -// IMGUI_API void SetCursorPos(const ImVec2& local_pos); // " -export function SetCursorPos(local_pos: Readonly): void { bind.SetCursorPos(local_pos); } -// IMGUI_API void SetCursorPosX(float x); // " -export function SetCursorPosX(x: number): void { bind.SetCursorPosX(x); } -// IMGUI_API void SetCursorPosY(float y); // " -export function SetCursorPosY(y: number): void { bind.SetCursorPosY(y); } -// IMGUI_API ImVec2 GetCursorStartPos(); // initial cursor position -export function GetCursorStartPos(out: Bind.interface_ImVec2 = new ImVec2()): typeof out { return bind.GetCursorStartPos(out); } -// IMGUI_API ImVec2 GetCursorScreenPos(); // cursor position in absolute screen coordinates [0..io.DisplaySize] (useful to work with ImDrawList API) -export function GetCursorScreenPos(out: Bind.interface_ImVec2 = new ImVec2()): typeof out { return bind.GetCursorScreenPos(out); } -// IMGUI_API void SetCursorScreenPos(const ImVec2& pos); // cursor position in absolute screen coordinates [0..io.DisplaySize] -export function SetCursorScreenPos(pos: Readonly): void { bind.SetCursorScreenPos(pos); } -// IMGUI_API void AlignTextToFramePadding(); // vertically align/lower upcoming text to FramePadding.y so that it will aligns to upcoming widgets (call if you have text on a line before regular widgets) -export function AlignTextToFramePadding(): void { bind.AlignTextToFramePadding(); } -// IMGUI_API float GetTextLineHeight(); // ~ FontSize -export function GetTextLineHeight(): number { return bind.GetTextLineHeight(); } -// IMGUI_API float GetTextLineHeightWithSpacing(); // ~ FontSize + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of text) -export function GetTextLineHeightWithSpacing(): number { return bind.GetTextLineHeightWithSpacing(); } -// IMGUI_API float GetFrameHeight(); // ~ FontSize + style.FramePadding.y * 2 -export function GetFrameHeight(): number { return bind.GetFrameHeight(); } -// IMGUI_API float GetFrameHeightWithSpacing(); // ~ FontSize + style.FramePadding.y * 2 + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of framed widgets) -export function GetFrameHeightWithSpacing(): number { return bind.GetFrameHeightWithSpacing(); } - -// Columns -// You can also use SameLine(pos_x) for simplified columns. The columns API is still work-in-progress and rather lacking. -// IMGUI_API void Columns(int count = 1, const char* id = NULL, bool border = true); -export function Columns(count: number = 1, id: string | null = null, border: boolean = true): void { - id = id || ""; - bind.Columns(count, id, border); -} -// IMGUI_API void NextColumn(); // next column, defaults to current row or next row if the current row is finished -export function NextColumn(): void { bind.NextColumn(); } -// IMGUI_API int GetColumnIndex(); // get current column index -export function GetColumnIndex(): number { return bind.GetColumnIndex(); } -// IMGUI_API float GetColumnWidth(int column_index = -1); // get column width (in pixels). pass -1 to use current column -export function GetColumnWidth(column_index: number = -1): number { - return bind.GetColumnWidth(column_index); -} -// IMGUI_API void SetColumnWidth(int column_index, float width); // set column width (in pixels). pass -1 to use current column -export function SetColumnWidth(column_index: number, width: number): void { bind.SetColumnWidth(column_index, width); } -// IMGUI_API float GetColumnOffset(int column_index = -1); // get position of column line (in pixels, from the left side of the contents region). pass -1 to use current column, otherwise 0..GetColumnsCount() inclusive. column 0 is typically 0.0f -export function GetColumnOffset(column_index: number = -1): number { - return bind.GetColumnOffset(column_index); -} -// IMGUI_API void SetColumnOffset(int column_index, float offset_x); // set position of column line (in pixels, from the left side of the contents region). pass -1 to use current column -export function SetColumnOffset(column_index: number, offset_x: number): void { bind.SetColumnOffset(column_index, offset_x); } -// IMGUI_API int GetColumnsCount(); -export function GetColumnsCount(): number { return bind.GetColumnsCount(); } - -// ID scopes -// If you are creating widgets in a loop you most likely want to push a unique identifier (e.g. object pointer, loop index) so ImGui can differentiate them. -// You can also use the "##foobar" syntax within widget label to distinguish them from each others. Read "A primer on the use of labels/IDs" in the FAQ for more details. -// IMGUI_API void PushID(const char* str_id); // push identifier into the ID stack. IDs are hash of the entire stack! -// IMGUI_API void PushID(const char* str_id_begin, const char* str_id_end); -// IMGUI_API void PushID(const void* ptr_id); -// IMGUI_API void PushID(int int_id); -export function PushID(id: string | number): void { bind.PushID(id); } -// IMGUI_API void PopID(); -export function PopID(): void { bind.PopID(); } -// IMGUI_API ImGuiID GetID(const char* str_id); // calculate unique ID (hash of whole ID stack + given parameter). e.g. if you want to query into ImGuiStorage yourself -// IMGUI_API ImGuiID GetID(const char* str_id_begin, const char* str_id_end); -// IMGUI_API ImGuiID GetID(const void* ptr_id); -export function GetID(id: string | number): Bind.ImGuiID { return bind.GetID(id); } - -// Widgets: Text -// IMGUI_API void TextUnformatted(const char* text, const char* text_end = NULL); // raw text without formatting. Roughly equivalent to Text("%s", text) but: A) doesn't require null terminated string if 'text_end' is specified, B) it's faster, no memory copy is done, no buffer size limits, recommended for long chunks of text. -export function TextUnformatted(text: string, text_end: number | null = null): void { bind.TextUnformatted(text_end !== null ? text.substring(0, text_end) : text); } -// IMGUI_API void Text(const char* fmt, ...) IM_FMTARGS(1); // simple formatted text -// IMGUI_API void TextV(const char* fmt, va_list args) IM_FMTLIST(1); -export function Text(fmt: string/*, ...args: any[]*/): void { bind.Text(fmt/*, ...args*/); } -// IMGUI_API void TextColored(const ImVec4& col, const char* fmt, ...) IM_FMTARGS(2); // shortcut for PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor(); -// IMGUI_API void TextColoredV(const ImVec4& col, const char* fmt, va_list args) IM_FMTLIST(2); -export function TextColored(col: Readonly | Readonly, fmt: string/*, ...args: any[]*/): void { - bind.TextColored((col instanceof ImColor) ? col.Value : col as Readonly, fmt/*, ...args*/); -} -// IMGUI_API void TextDisabled(const char* fmt, ...) IM_FMTARGS(1); // shortcut for PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]); Text(fmt, ...); PopStyleColor(); -// IMGUI_API void TextDisabledV(const char* fmt, va_list args) IM_FMTLIST(1); -export function TextDisabled(fmt: string/*, ...args: any[]*/): void { bind.TextDisabled(fmt/*, ...args*/); } -// IMGUI_API void TextWrapped(const char* fmt, ...) IM_FMTARGS(1); // shortcut for PushTextWrapPos(0.0f); Text(fmt, ...); PopTextWrapPos();. Note that this won't work on an auto-resizing window if there's no other widgets to extend the window width, yoy may need to set a size using SetNextWindowSize(). -// IMGUI_API void TextWrappedV(const char* fmt, va_list args) IM_FMTLIST(1); -export function TextWrapped(fmt: string/*, ...args: any[]*/): void { bind.TextWrapped(fmt/*, ...args*/); } -// IMGUI_API void LabelText(const char* label, const char* fmt, ...) IM_FMTARGS(2); // display text+label aligned the same way as value+label widgets -// IMGUI_API void LabelTextV(const char* label, const char* fmt, va_list args) IM_FMTLIST(2); -export function LabelText(label: string, fmt: string/*, ...args: any[]*/): void { bind.LabelText(label, fmt/*, ...args*/); } -// IMGUI_API void BulletText(const char* fmt, ...) IM_FMTARGS(1); // shortcut for Bullet()+Text() -// IMGUI_API void BulletTextV(const char* fmt, va_list args) IM_FMTLIST(1); -export function BulletText(fmt: string/*, ...args: any[]*/): void { bind.BulletText(fmt/*, ...args*/); } -// IMGUI_API void Bullet(); // draw a small circle and keep the cursor on the same line. advance cursor x position by GetTreeNodeToLabelSpacing(), same distance that TreeNode() uses -export function Bullet(): void { bind.Bullet(); } - -// Widgets: Main -// IMGUI_API bool Button(const char* label, const ImVec2& size = ImVec2(0,0)); // button -export function Button(label: string, size: Readonly = ImVec2.ZERO): boolean { - return bind.Button(label, size); -} -// IMGUI_API bool SmallButton(const char* label); // button with FramePadding=(0,0) to easily embed within text -export function SmallButton(label: string): boolean { return bind.SmallButton(label); } -// IMGUI_API bool ArrowButton(const char* str_id, ImGuiDir dir); // square button with an arrow shape -export function ArrowButton(str_id: string, dir: ImGuiDir): boolean { return bind.ArrowButton(str_id, dir); } -// IMGUI_API bool InvisibleButton(const char* str_id, const ImVec2& size); // button behavior without the visuals, useful to build custom behaviors using the public api (along with IsItemActive, IsItemHovered, etc.) -export function InvisibleButton(str_id: string, size: Readonly): boolean { - return bind.InvisibleButton(str_id, size); -} -// IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), const ImVec4& tint_col = ImVec4(1,1,1,1), const ImVec4& border_col = ImVec4(0,0,0,0)); -export function Image(user_texture_id: ImTextureID | null, size: Readonly, uv0: Readonly = ImVec2.ZERO, uv1: Readonly = ImVec2.UNIT, tint_col: Readonly = ImVec4.WHITE, border_col: Readonly = ImVec4.ZERO): void { - bind.Image(ImGuiContext.setTexture(user_texture_id), size, uv0, uv1, tint_col, border_col); -} -// IMGUI_API bool ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0,0,0,0), const ImVec4& tint_col = ImVec4(1,1,1,1)); // <0 frame_padding uses default frame padding settings. 0 for no padding -export function ImageButton(user_texture_id: ImTextureID | null, size: Readonly, uv0: Readonly = ImVec2.ZERO, uv1: Readonly = ImVec2.UNIT, frame_padding: number = -1, bg_col: Readonly = ImVec4.ZERO, tint_col: Readonly = ImVec4.WHITE): boolean { - return bind.ImageButton(ImGuiContext.setTexture(user_texture_id), size, uv0, uv1, frame_padding, bg_col, tint_col); -} -// IMGUI_API bool Checkbox(const char* label, bool* v); -export function Checkbox(label: string, v: Bind.ImScalar | Bind.ImAccess): boolean { - if (Array.isArray(v)) { - return bind.Checkbox(label, v); - } else { - const ref_v: Bind.ImScalar = [ v() ]; - const ret = bind.Checkbox(label, ref_v); - v(ref_v[0]); - return ret; - } -} -// IMGUI_API bool CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value); -export function CheckboxFlags(label: string, flags: Bind.ImAccess | Bind.ImScalar, flags_value: number): boolean { - if (Array.isArray(flags)) { - return bind.CheckboxFlags(label, flags, flags_value); - } else { - const ref_flags: Bind.ImScalar = [ flags() ]; - const ret = bind.CheckboxFlags(label, ref_flags, flags_value); - flags(ref_flags[0]); - return ret; - } -} -// IMGUI_API bool RadioButton(const char* label, bool active); -// IMGUI_API bool RadioButton(const char* label, int* v, int v_button); -export function RadioButton(label: string, active: boolean): boolean; -export function RadioButton(label: string, v: Bind.ImAccess | Bind.ImScalar, v_button: number): boolean; -export function RadioButton(label: string, ...args: any[]): boolean { - if (typeof(args[0]) === "boolean") { - const active: boolean = args[0]; - return bind.RadioButton_A(label, active); - } else { - const v: Bind.ImAccess | Bind.ImScalar = args[0]; - const v_button: number = args[1]; - const _v: Bind.ImScalar = Array.isArray(v) ? v : [ v() ]; - const ret = bind.RadioButton_B(label, _v, v_button); - if (!Array.isArray(v)) { v(_v[0]); } - return ret; - } -} // IMGUI_API void PlotLines(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0), int stride = sizeof(float)); // IMGUI_API void PlotLines(const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0)); export type PlotLinesValueGetter = (data: any, idx: number) => number; -export function PlotLines(label: string, values: ArrayLike, values_count?: number, value_offset?: number, overlay_text?: string | null, scale_min?: number, scale_max?: number, graph_size?: Readonly, stride?: number): void; -export function PlotLines(label: string, values_getter: PlotLinesValueGetter, data: any, values_count?: number, value_offset?: number, overlay_text?: string | null, scale_min?: number, scale_max?: number, graph_size?: Readonly): void; -export function PlotLines(label: string, ...args: any[]): void { - if (Array.isArray(args[0])) { - const values: ArrayLike = args[0]; - const values_getter: PlotLinesValueGetter = (data: any, idx: number): number => values[idx * stride]; - const values_count: number = typeof(args[1]) === "number" ? args[1] : values.length; - const values_offset: number = typeof(args[2]) === "number" ? args[2] : 0; - const overlay_text: string | null = typeof(args[3]) === "string" ? args[3] : null; - const scale_min: number = typeof(args[4]) === "number" ? args[4] : Number.MAX_VALUE; - const scale_max: number = typeof(args[5]) === "number" ? args[5] : Number.MAX_VALUE; - const graph_size: Readonly = args[6] || ImVec2.ZERO; - const stride: number = typeof(args[7]) === "number" ? args[7] : 1; - bind.PlotLines(label, values_getter, null, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size); - } else { - const values_getter: PlotLinesValueGetter = args[0]; - const data: any = args[1]; - const values_count: number = args[2]; - const values_offset: number = typeof(args[3]) === "number" ? args[3] : 0; - const overlay_text: string | null = typeof(args[4]) === "string" ? args[4] : null; - const scale_min: number = typeof(args[5]) === "number" ? args[5] : Number.MAX_VALUE; - const scale_max: number = typeof(args[6]) === "number" ? args[6] : Number.MAX_VALUE; - const graph_size: Readonly = args[7] || ImVec2.ZERO; - bind.PlotLines(label, values_getter, data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size); - } -} -// IMGUI_API void PlotHistogram(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0), int stride = sizeof(float)); -// IMGUI_API void PlotHistogram(const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0)); export type PlotHistogramValueGetter = (data: any, idx: number) => number; -export function PlotHistogram(label: string, values: ArrayLike, values_count?: number, value_offset?: number, overlay_text?: string | null, scale_min?: number, scale_max?: number, graph_size?: Readonly, stride?: number): void; -export function PlotHistogram(label: string, values_getter: PlotHistogramValueGetter, data: any, values_count?: number, value_offset?: number, overlay_text?: string | null, scale_min?: number, scale_max?: number, graph_size?: Readonly): void; -export function PlotHistogram(label: string, ...args: any[]): void { - if (Array.isArray(args[0])) { - const values: ArrayLike = args[0]; - const values_getter: PlotHistogramValueGetter = (data: any, idx: number): number => values[idx * stride]; - const values_count: number = typeof(args[1]) === "number" ? args[1] : values.length; - const values_offset: number = typeof(args[2]) === "number" ? args[2] : 0; - const overlay_text: string | null = typeof(args[3]) === "string" ? args[3] : null; - const scale_min: number = typeof(args[4]) === "number" ? args[4] : Number.MAX_VALUE; - const scale_max: number = typeof(args[5]) === "number" ? args[5] : Number.MAX_VALUE; - const graph_size: Readonly = args[6] || ImVec2.ZERO; - const stride: number = typeof(args[7]) === "number" ? args[7] : 1; - bind.PlotHistogram(label, values_getter, null, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size); - } else { - const values_getter: PlotHistogramValueGetter = args[0]; - const data: any = args[1]; - const values_count: number = args[2]; - const values_offset: number = typeof(args[3]) === "number" ? args[3] : 0; - const overlay_text: string | null = typeof(args[4]) === "string" ? args[4] : null; - const scale_min: number = typeof(args[5]) === "number" ? args[5] : Number.MAX_VALUE; - const scale_max: number = typeof(args[6]) === "number" ? args[6] : Number.MAX_VALUE; - const graph_size: Readonly = args[7] || ImVec2.ZERO; - bind.PlotHistogram(label, values_getter, data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size); - } -} -// IMGUI_API void ProgressBar(float fraction, const ImVec2& size_arg = ImVec2(-1,0), const char* overlay = NULL); -export function ProgressBar(fraction: number, size_arg: Readonly = new ImVec2(-1, 0), overlay: string | null = null): void { - bind.ProgressBar(fraction, size_arg, overlay); -} - -// Widgets: Combo Box -// The new BeginCombo()/EndCombo() api allows you to manage your contents and selection state however you want it. -// The old Combo() api are helpers over BeginCombo()/EndCombo() which are kept available for convenience purpose. -// IMGUI_API bool BeginCombo(const char* label, const char* preview_value, ImGuiComboFlags flags = 0); -export function BeginCombo(label: string, preview_value: string | null = null, flags: ImGuiComboFlags = 0): boolean { - return bind.BeginCombo(label, preview_value, flags); -} -// IMGUI_API void EndCombo(); -export function EndCombo(): void { bind.EndCombo(); } -// IMGUI_API bool Combo(const char* label, int* current_item, const char* const items[], int items_count, int popup_max_height_in_items = -1); -// IMGUI_API bool Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int popup_max_height_in_items = -1); // Separate items with \0 within a string, end item-list with \0\0. e.g. "One\0Two\0Three\0" -// IMGUI_API bool Combo(const char* label, int* current_item, bool(*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int popup_max_height_in_items = -1); export type ComboValueGetter = (data: any, idx: number, out_text: [string]) => boolean; -export function Combo(label: string, current_item: Bind.ImAccess | Bind.ImScalar, items: string[], items_count?: number, popup_max_height_in_items?: number): boolean; -export function Combo(label: string, current_item: Bind.ImAccess | Bind.ImScalar, items_separated_by_zeros: string, popup_max_height_in_items?: number): boolean; -export function Combo(label: string, current_item: Bind.ImAccess | Bind.ImScalar, items_getter: ComboValueGetter, data: any, items_count: number, popup_max_height_in_items?: number): boolean; -export function Combo(label: string, current_item: Bind.ImAccess | Bind.ImScalar, ...args: any[]): boolean { - let ret = false; - const _current_item: Bind.ImScalar = Array.isArray(current_item) ? current_item : [ current_item() ]; - if (Array.isArray(args[0])) { - const items: string[] = args[0]; - const items_count = typeof(args[1]) === "number" ? args[1] : items.length; - const popup_max_height_in_items: number = typeof(args[2]) === "number" ? args[2] : -1; - const items_getter = (data: any, idx: number, out_text: [string]): boolean => { out_text[0] = items[idx]; return true; }; - ret = bind.Combo(label, _current_item, items_getter, null, items_count, popup_max_height_in_items); - } else if (typeof(args[0]) === "string") { - const items_separated_by_zeros: string = args[0] - const popup_max_height_in_items: number = typeof(args[1]) === "number" ? args[1] : -1; - const items: string[] = items_separated_by_zeros.replace(/^\0+|\0+$/g, "").split("\0"); - const items_count: number = items.length; - const items_getter = (data: any, idx: number, out_text: [string]): boolean => { out_text[0] = items[idx]; return true; }; - ret = bind.Combo(label, _current_item, items_getter, null, items_count, popup_max_height_in_items); - } else { - const items_getter: (data: any, idx: number, out_text: [string]) => boolean = args[0]; - const data: any = args[1]; - const items_count = args[2]; - const popup_max_height_in_items: number = typeof(args[3]) === "number" ? args[3] : -1; - ret = bind.Combo(label, _current_item, items_getter, data, items_count, popup_max_height_in_items); - } - if (!Array.isArray(current_item)) { current_item(_current_item[0]); } - return ret; -} - -// Widgets: Drags (tip: ctrl+click on a drag box to input with keyboard. manually input values aren't clamped, can go off-bounds) -// For all the Float2/Float3/Float4/Int2/Int3/Int4 versions of every functions, note that a 'float v[X]' function argument is the same as 'float* v', the array syntax is just a way to document the number of elements that are expected to be accessible. You can pass address of your first element out of a contiguous set, e.g. &myvector.x -// IMGUI_API bool DragFloat(const char* label, float* v, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", float power = 1.0f); // If v_min >= v_max we have no bound -export function DragFloat(label: string, v: Bind.ImAccess | Bind.ImScalar | XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, v_speed: number = 1.0, v_min: number = 0.0, v_max: number = 0.0, display_format: string | null = "%.3f", power: number = 1.0): boolean { - const _v = import_Scalar(v); - const ret = bind.DragFloat(label, _v, v_speed, v_min, v_max, display_format, power); - export_Scalar(_v, v); - return ret; -} -// IMGUI_API bool DragFloat2(const char* label, float v[2], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", float power = 1.0f); -export function DragFloat2(label: string, v: XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4 | ImVec2, v_speed: number = 1.0, v_min: number = 0.0, v_max: number = 0.0, display_format: string = "%.3f", power: number = 1.0): boolean { - const _v = import_Vector2(v); - const ret = bind.DragFloat2(label, _v, v_speed, v_min, v_max, display_format, power); - export_Vector2(_v, v); - return ret; -} -// IMGUI_API bool DragFloat3(const char* label, float v[3], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", float power = 1.0f); -export function DragFloat3(label: string, v: XYZ | XYZW | Bind.ImTuple3 | Bind.ImTuple4, v_speed: number = 1.0, v_min: number = 0.0, v_max: number = 0.0, display_format: string = "%.3f", power: number = 1.0): boolean { - const _v = import_Vector3(v); - const ret = bind.DragFloat3(label, _v, v_speed, v_min, v_max, display_format, power); - export_Vector3(_v, v); - return ret; -} -// IMGUI_API bool DragFloat4(const char* label, float v[4], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", float power = 1.0f); -export function DragFloat4(label: string, v: XYZW | Bind.ImTuple4 | ImVec4, v_speed: number = 1.0, v_min: number = 0.0, v_max: number = 0.0, display_format: string = "%.3f", power: number = 1.0): boolean { - const _v = import_Vector4(v); - const ret = bind.DragFloat4(label, _v, v_speed, v_min, v_max, display_format, power); - export_Vector4(_v, v); - return ret; -} -// IMGUI_API bool DragFloatRange2(const char* label, float* v_current_min, float* v_current_max, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", const char* display_format_max = NULL, float power = 1.0f); -export function DragFloatRange2(label: string, v_current_min: Bind.ImAccess | Bind.ImScalar | XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, v_current_max: Bind.ImAccess | Bind.ImScalar | XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, v_speed: number = 1.0, v_min: number = 0.0, v_max: number = 0.0, display_format: string = "%.3f", display_format_max: string | null = null, power: number = 1.0): boolean { - const _v_current_min = import_Scalar(v_current_min); - const _v_current_max = import_Scalar(v_current_max); - const ret = bind.DragFloatRange2(label, _v_current_min, _v_current_max, v_speed, v_min, v_max, display_format, display_format_max, power); - export_Scalar(_v_current_min, v_current_min); - export_Scalar(_v_current_max, v_current_max); - return ret; -} -// IMGUI_API bool DragInt(const char* label, int* v, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* display_format = "%d"); // If v_min >= v_max we have no bound -export function DragInt(label: string, v: Bind.ImAccess | Bind.ImScalar | XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, v_speed: number = 1.0, v_min: number = 0, v_max: number = 0, format: string = "%d"): boolean { - const _v = import_Scalar(v); - const ret = bind.DragInt(label, _v, v_speed, v_min, v_max, format); - export_Scalar(_v, v); - return ret; -} -// IMGUI_API bool DragInt2(const char* label, int v[2], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d"); -export function DragInt2(label: string, v: XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, v_speed: number = 1.0, v_min: number = 0, v_max: number = 0, format: string = "%d"): boolean { - const _v = import_Vector2(v); - const ret = bind.DragInt2(label, _v, v_speed, v_min, v_max, format); - export_Vector2(_v, v); - return ret; -} -// IMGUI_API bool DragInt3(const char* label, int v[3], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d"); -export function DragInt3(label: string, v: XYZ | XYZW | Bind.ImTuple3 | Bind.ImTuple4, v_speed: number = 1.0, v_min: number = 0, v_max: number = 0, format: string = "%d"): boolean { - const _v = import_Vector3(v); - const ret = bind.DragInt3(label, _v, v_speed, v_min, v_max, format); - export_Vector3(_v, v); - return ret; -} -// IMGUI_API bool DragInt4(const char* label, int v[4], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d"); -export function DragInt4(label: string, v: XYZW | Bind.ImTuple4, v_speed: number = 1.0, v_min: number = 0, v_max: number = 0, format: string = "%d"): boolean { - const _v = import_Vector4(v); - const ret = bind.DragInt4(label, _v, v_speed, v_min, v_max, format); - export_Vector4(_v, v); - return ret; -} -// IMGUI_API bool DragIntRange2(const char* label, int* v_current_min, int* v_current_max, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* display_format = "%.0f", const char* display_format_max = NULL); -export function DragIntRange2(label: string, v_current_min: Bind.ImAccess | Bind.ImScalar | XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, v_current_max: Bind.ImAccess | Bind.ImScalar | XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, v_speed: number = 1.0, v_min: number = 0, v_max: number = 0, format: string = "%d", format_max: string | null = null): boolean { - const _v_current_min = import_Scalar(v_current_min); - const _v_current_max = import_Scalar(v_current_max); - const ret = bind.DragIntRange2(label, _v_current_min, _v_current_max, v_speed, v_min, v_max, format, format_max); - export_Scalar(_v_current_min, v_current_min); - export_Scalar(_v_current_max, v_current_max); - return ret; -} -// IMGUI_API bool DragScalar(const char* label, ImGuiDataType data_type, void* v, float v_speed, const void* v_min = NULL, const void* v_max = NULL, const char* format = NULL, float power = 1.0f); -// IMGUI_API bool DragScalarN(const char* label, ImGuiDataType data_type, void* v, int components, float v_speed, const void* v_min = NULL, const void* v_max = NULL, const char* format = NULL, float power = 1.0f); -export function DragScalar(label: string, v: Int32Array | Uint32Array | Float32Array | Float64Array, v_speed: number, v_min: number | null = null, v_max: number | null = null, format: string | null = null, power: number = 1.0): boolean { - if (v instanceof Int32Array) { return bind.DragScalar(label, ImGuiDataType.S32, v, v_speed, v_min, v_max, format, power); } - if (v instanceof Uint32Array) { return bind.DragScalar(label, ImGuiDataType.U32, v, v_speed, v_min, v_max, format, power); } - // if (v instanceof Int64Array) { return bind.DragScalar(label, ImGuiDataType.S64, v, v_speed, v_min, v_max, format, power); } - // if (v instanceof Uint64Array) { return bind.DragScalar(label, ImGuiDataType.U64, v, v_speed, v_min, v_max, format, power); } - if (v instanceof Float32Array) { return bind.DragScalar(label, ImGuiDataType.Float, v, v_speed, v_min, v_max, format, power); } - if (v instanceof Float64Array) { return bind.DragScalar(label, ImGuiDataType.Double, v, v_speed, v_min, v_max, format, power); } - throw new Error(); -} - -// Widgets: Input with Keyboard -// IMGUI_API bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); -export function InputText(label: string, buf: ImStringBuffer | Bind.ImAccess | Bind.ImScalar, buf_size: number = buf instanceof ImStringBuffer ? buf.size : ImGuiInputTextDefaultSize, flags: ImGuiInputTextFlags = 0, callback: ImGuiInputTextCallback | null = null, user_data: any = null): boolean { - const _callback = callback && ((data: Bind.reference_ImGuiInputTextCallbackData): number => callback(new ImGuiInputTextCallbackData(data, user_data))) || null; - if (Array.isArray(buf)) { - return bind.InputText(label, buf, buf_size, flags, _callback, null); - } else if (buf instanceof ImStringBuffer) { - const ref_buf: Bind.ImScalar = [ buf.buffer ]; - const _buf_size: number = Math.min(buf_size, buf.size); - const ret: boolean = bind.InputText(label, ref_buf, _buf_size, flags, _callback, null); - buf.buffer = ref_buf[0]; - return ret; - } else { - const ref_buf: Bind.ImScalar = [ buf() ]; - const ret: boolean = bind.InputText(label, ref_buf, buf_size, flags, _callback, null); - buf(ref_buf[0]); - return ret; - } -} -// IMGUI_API bool InputTextMultiline(const char* label, char* buf, size_t buf_size, const ImVec2& size = ImVec2(0,0), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); -export function InputTextMultiline(label: string, buf: ImStringBuffer | Bind.ImAccess | Bind.ImScalar, buf_size: number = buf instanceof ImStringBuffer ? buf.size : ImGuiInputTextDefaultSize, size: Readonly = ImVec2.ZERO, flags: ImGuiInputTextFlags = 0, callback: ImGuiInputTextCallback | null = null, user_data: any = null): boolean { - const _callback = callback && ((data: Bind.reference_ImGuiInputTextCallbackData): number => callback(new ImGuiInputTextCallbackData(data, user_data))) || null; - if (Array.isArray(buf)) { - return bind.InputTextMultiline(label, buf, buf_size, size, flags, _callback, null); - } else if (buf instanceof ImStringBuffer) { - const ref_buf: Bind.ImScalar = [ buf.buffer ]; - const _buf_size: number = Math.min(buf_size, buf.size); - const ret: boolean = bind.InputTextMultiline(label, ref_buf, _buf_size, size, flags, _callback, null); - buf.buffer = ref_buf[0]; - return ret; - } else { - const ref_buf: Bind.ImScalar = [ buf() ]; - const ret: boolean = bind.InputTextMultiline(label, ref_buf, buf_size, size, flags, _callback, null); - buf(ref_buf[0]); - return ret; - } -} -// IMGUI_API bool InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, const char* format = "%.3f", ImGuiInputTextFlags extra_flags = 0); -export function InputFloat(label: string, v: Bind.ImAccess | Bind.ImScalar | XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, step: number = 0.0, step_fast: number = 0.0, format: string = "%.3f", extra_flags: ImGuiInputTextFlags = 0): boolean { - const _v = import_Scalar(v); - const ret = bind.InputFloat(label, _v, step, step_fast, format, extra_flags); - export_Scalar(_v, v); - return ret; -} -// IMGUI_API bool InputFloat2(const char* label, float v[2], const char* format = "%.3f", ImGuiInputTextFlags extra_flags = 0); -export function InputFloat2(label: string, v: XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, format: string = "%.3f", extra_flags: ImGuiInputTextFlags = 0): boolean { - const _v = import_Vector2(v); - const ret = bind.InputFloat2(label, _v, format, extra_flags); - export_Vector2(_v, v); - return ret; -} -// IMGUI_API bool InputFloat3(const char* label, float v[3], const char* format = "%.3f", ImGuiInputTextFlags extra_flags = 0); -export function InputFloat3(label: string, v: XYZ | XYZW | Bind.ImTuple3 | Bind.ImTuple4, format: string = "%.3f", extra_flags: ImGuiInputTextFlags = 0): boolean { - const _v = import_Vector3(v); - const ret = bind.InputFloat3(label, _v, format, extra_flags); - export_Vector3(_v, v); - return ret; -} -// IMGUI_API bool InputFloat4(const char* label, float v[4], const char* format = "%.3f", ImGuiInputTextFlags extra_flags = 0); -export function InputFloat4(label: string, v: XYZW | Bind.ImTuple4, format: string = "%.3f", extra_flags: ImGuiInputTextFlags = 0): boolean { - const _v = import_Vector4(v); - const ret = bind.InputFloat4(label, _v, format, extra_flags); - export_Vector4(_v, v); - return ret; -} -// IMGUI_API bool InputInt(const char* label, int* v, int step = 1, int step_fast = 100, ImGuiInputTextFlags extra_flags = 0); -export function InputInt(label: string, v: Bind.ImAccess | Bind.ImScalar | XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, step: number = 1, step_fast: number = 100, extra_flags: ImGuiInputTextFlags = 0): boolean { - const _v = import_Scalar(v); - const ret = bind.InputInt(label, _v, step, step_fast, extra_flags); - export_Scalar(_v, v); - return ret; -} -// IMGUI_API bool InputInt2(const char* label, int v[2], ImGuiInputTextFlags extra_flags = 0); -export function InputInt2(label: string, v: XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, extra_flags: ImGuiInputTextFlags = 0): boolean { - const _v = import_Vector2(v); - const ret = bind.InputInt2(label, _v, extra_flags); - export_Vector2(_v, v); - return ret; -} -// IMGUI_API bool InputInt3(const char* label, int v[3], ImGuiInputTextFlags extra_flags = 0); -export function InputInt3(label: string, v: XYZ | XYZW | Bind.ImTuple3 | Bind.ImTuple4, extra_flags: ImGuiInputTextFlags = 0): boolean { - const _v = import_Vector3(v); - const ret = bind.InputInt3(label, _v, extra_flags); - export_Vector3(_v, v); - return ret; -} -// IMGUI_API bool InputInt4(const char* label, int v[4], ImGuiInputTextFlags extra_flags = 0); -export function InputInt4(label: string, v: XYZW | Bind.ImTuple4, extra_flags: ImGuiInputTextFlags = 0): boolean { - const _v = import_Vector4(v); - const ret = bind.InputInt4(label, _v, extra_flags); - export_Vector4(_v, v); - return ret; -} -// IMGUI_API bool InputDouble(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, const char* format = "%.6f", ImGuiInputTextFlags extra_flags = 0); -export function InputDouble(label: string, v: Bind.ImAccess | Bind.ImScalar | XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, step: number = 0.0, step_fast: number = 0.0, format: string = "%.6f", extra_flags: ImGuiInputTextFlags = 0): boolean { - const _v = import_Scalar(v); - const ret = bind.InputDouble(label, _v, step, step_fast, format, extra_flags); - export_Scalar(_v, v); - return ret; -} -// IMGUI_API bool InputScalar(const char* label, ImGuiDataType data_type, void* v, const void* step = NULL, const void* step_fast = NULL, const char* format = NULL, ImGuiInputTextFlags extra_flags = 0); -// IMGUI_API bool InputScalarN(const char* label, ImGuiDataType data_type, void* v, int components, const void* step = NULL, const void* step_fast = NULL, const char* format = NULL, ImGuiInputTextFlags extra_flags = 0); -export function InputScalar(label: string, v: Int32Array | Uint32Array | Float32Array | Float64Array, step: number | null = null, step_fast: number | null = null, format: string | null = null, extra_flags: ImGuiInputTextFlags = 0): boolean { - if (v instanceof Int32Array) { return bind.InputScalar(label, ImGuiDataType.S32, v, step, step_fast, format, extra_flags); } - if (v instanceof Uint32Array) { return bind.InputScalar(label, ImGuiDataType.U32, v, step, step_fast, format, extra_flags); } - // if (v instanceof Int64Array) { return bind.InputScalar(label, ImGuiDataType.S64, v, step, step_fast, format, extra_flags); } - // if (v instanceof Uint64Array) { return bind.InputScalar(label, ImGuiDataType.U64, v, step, step_fast, format, extra_flags); } - if (v instanceof Float32Array) { return bind.InputScalar(label, ImGuiDataType.Float, v, step, step_fast, format, extra_flags); } - if (v instanceof Float64Array) { return bind.InputScalar(label, ImGuiDataType.Double, v, step, step_fast, format, extra_flags); } - throw new Error(); -} - -// Widgets: Sliders (tip: ctrl+click on a slider to input with keyboard. manually input values aren't clamped, can go off-bounds) -// IMGUI_API bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* format = "%.3f", float power = 1.0f); // adjust format to decorate the value with a prefix or a suffix for in-slider labels or unit display. Use power!=1.0 for logarithmic sliders -export function SliderFloat(label: string, v: Bind.ImAccess | Bind.ImScalar | XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, v_min: number, v_max: number, format: string = "%.3f", power: number = 1.0): boolean { - const _v = import_Scalar(v); - const ret = bind.SliderFloat(label, _v, v_min, v_max, format, power); - export_Scalar(_v, v); - return ret; -} -// IMGUI_API bool SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* format = "%.3f", float power = 1.0f); -export function SliderFloat2(label: string, v: XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4 | Bind.interface_ImVec2, v_min: number, v_max: number, format: string = "%.3f", power: number = 1.0): boolean { - const _v = import_Vector2(v); - const ret = bind.SliderFloat2(label, _v, v_min, v_max, format, power); - export_Vector2(_v, v); - return ret; -} -// IMGUI_API bool SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* format = "%.3f", float power = 1.0f); -export function SliderFloat3(label: string, v: XYZ | XYZW | Bind.ImTuple3 | Bind.ImTuple4, v_min: number, v_max: number, format: string = "%.3f", power: number = 1.0): boolean { - const _v = import_Vector3(v); - const ret = bind.SliderFloat3(label, _v, v_min, v_max, format, power); - export_Vector3(_v, v); - return ret; -} -// IMGUI_API bool SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* format = "%.3f", float power = 1.0f); -export function SliderFloat4(label: string, v: XYZW | Bind.ImTuple4 | XYZW, v_min: number, v_max: number, format: string = "%.3f", power: number = 1.0): boolean { - const _v = import_Vector4(v); - const ret = bind.SliderFloat4(label, _v, v_min, v_max, format, power); - export_Vector4(_v, v); - return ret; -} -// IMGUI_API bool SliderAngle(const char* label, float* v_rad, float v_degrees_min = -360.0f, float v_degrees_max = +360.0f); -export function SliderAngle(label: string, v_rad: Bind.ImAccess | Bind.ImScalar | XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, v_degrees_min: number = -360.0, v_degrees_max: number = +360.0): boolean { - const _v_rad = import_Scalar(v_rad); - const ret = bind.SliderAngle(label, _v_rad, v_degrees_min, v_degrees_max); - export_Scalar(_v_rad, v_rad); - return ret; -} -export function SliderAngle3(label: string, v_rad: XYZ | XYZW | Bind.ImTuple3 | Bind.ImTuple4, v_degrees_min: number = -360.0, v_degrees_max: number = +360.0): boolean { - const _v_rad = import_Vector3(v_rad); - _v_rad[0] = Math.floor(_v_rad[0] * 180 / Math.PI); - _v_rad[1] = Math.floor(_v_rad[1] * 180 / Math.PI); - _v_rad[2] = Math.floor(_v_rad[2] * 180 / Math.PI); - const ret = bind.SliderInt3(label, _v_rad, v_degrees_min, v_degrees_max, "%d deg"); - _v_rad[0] = _v_rad[0] * Math.PI / 180; - _v_rad[1] = _v_rad[1] * Math.PI / 180; - _v_rad[2] = _v_rad[2] * Math.PI / 180; - export_Vector3(_v_rad, v_rad); - return ret; -} -// IMGUI_API bool SliderInt(const char* label, int* v, int v_min, int v_max, const char* format = "%d"); -export function SliderInt(label: string, v: Bind.ImAccess | Bind.ImScalar | XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, v_min: number, v_max: number, format: string = "%d"): boolean { - const _v = import_Scalar(v); - const ret = bind.SliderInt(label, _v, v_min, v_max, format); - export_Scalar(_v, v); - return ret; -} -// IMGUI_API bool SliderInt2(const char* label, int v[2], int v_min, int v_max, const char* format = "%d"); -export function SliderInt2(label: string, v: XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, v_min: number, v_max: number, format: string = "%d"): boolean { - const _v = import_Vector2(v); - const ret = bind.SliderInt2(label, _v, v_min, v_max, format); - export_Vector2(_v, v); - return ret; -} -// IMGUI_API bool SliderInt3(const char* label, int v[3], int v_min, int v_max, const char* format = "%d"); -export function SliderInt3(label: string, v: XYZ | XYZW | Bind.ImTuple3 | Bind.ImTuple4, v_min: number, v_max: number, format: string = "%d"): boolean { - const _v = import_Vector3(v); - const ret = bind.SliderInt3(label, _v, v_min, v_max, format); - export_Vector3(_v, v); - return ret; -} -// IMGUI_API bool SliderInt4(const char* label, int v[4], int v_min, int v_max, const char* format = "%d"); -export function SliderInt4(label: string, v: XYZW | Bind.ImTuple4, v_min: number, v_max: number, format: string = "%d"): boolean { - const _v = import_Vector4(v); - const ret = bind.SliderInt4(label, _v, v_min, v_max, format); - export_Vector4(_v, v); - return ret; -} -// IMGUI_API bool SliderScalar(const char* label, ImGuiDataType data_type, void* v, const void* v_min, const void* v_max, const char* format = NULL, float power = 1.0f); -// IMGUI_API bool SliderScalarN(const char* label, ImGuiDataType data_type, void* v, int components, const void* v_min, const void* v_max, const char* format = NULL, float power = 1.0f); -export function SliderScalar(label: string, v: Int32Array | Uint32Array | Float32Array | Float64Array, v_min: number, v_max: number, format: string | null = null, power: number = 1.0): boolean { - if (v instanceof Int32Array) { return bind.SliderScalar(label, ImGuiDataType.S32, v, v_min, v_max, format, power); } - if (v instanceof Uint32Array) { return bind.SliderScalar(label, ImGuiDataType.U32, v, v_min, v_max, format, power); } - // if (v instanceof Int64Array) { return bind.SliderScalar(label, ImGuiDataType.S64, v, v_min, v_max, format, power); } - // if (v instanceof Uint64Array) { return bind.SliderScalar(label, ImGuiDataType.U64, v, v_min, v_max, format, power); } - if (v instanceof Float32Array) { return bind.SliderScalar(label, ImGuiDataType.Float, v, v_min, v_max, format, power); } - if (v instanceof Float64Array) { return bind.SliderScalar(label, ImGuiDataType.Double, v, v_min, v_max, format, power); } - throw new Error(); -} -// IMGUI_API bool VSliderFloat(const char* label, const ImVec2& size, float* v, float v_min, float v_max, const char* format = "%.3f", float power = 1.0f); -export function VSliderFloat(label: string, size: Readonly, v: Bind.ImAccess | Bind.ImScalar | XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, v_min: number, v_max: number, format: string = "%.3f", power: number = 1.0): boolean { - const _v = import_Scalar(v); - const ret = bind.VSliderFloat(label, size, _v, v_min, v_max, format, power); - export_Scalar(_v, v); - return ret; -} -// IMGUI_API bool VSliderInt(const char* label, const ImVec2& size, int* v, int v_min, int v_max, const char* format = "%d"); -export function VSliderInt(label: string, size: Readonly, v: Bind.ImAccess | Bind.ImScalar | XY | XYZ | XYZW | Bind.ImTuple2 | Bind.ImTuple3 | Bind.ImTuple4, v_min: number, v_max: number, format: string = "%d"): boolean { - const _v = import_Scalar(v); - const ret = bind.VSliderInt(label, size, _v, v_min, v_max, format); - export_Scalar(_v, v); - return ret; -} -// IMGUI_API bool VSliderScalar(const char* label, const ImVec2& size, ImGuiDataType data_type, void* v, const void* v_min, const void* v_max, const char* format = NULL, float power = 1.0f); -export function VSliderScalar(label: string, size: Readonly, data_type: ImGuiDataType, v: Bind.ImAccess | Bind.ImScalar, v_min: number, v_max: number, format: string | null = null, power: number = 1.0): boolean { - if (v instanceof Int32Array) { return bind.VSliderScalar(label, size, ImGuiDataType.S32, v, v_min, v_max, format, power); } - if (v instanceof Uint32Array) { return bind.VSliderScalar(label, size, ImGuiDataType.U32, v, v_min, v_max, format, power); } - // if (v instanceof Int64Array) { return bind.VSliderScalar(label, size, ImGuiDataType.S64, v, v_min, v_max, format, power); } - // if (v instanceof Uint64Array) { return bind.VSliderScalar(label, size, ImGuiDataType.U64, v, v_min, v_max, format, power); } - if (v instanceof Float32Array) { return bind.VSliderScalar(label, size, ImGuiDataType.Float, v, v_min, v_max, format, power); } - if (v instanceof Float64Array) { return bind.VSliderScalar(label, size, ImGuiDataType.Double, v, v_min, v_max, format, power); } - throw new Error(); -} - -// Widgets: Color Editor/Picker (tip: the ColorEdit* functions have a little colored preview square that can be left-clicked to open a picker, and right-clicked to open an option menu.) -// Note that a 'float v[X]' function argument is the same as 'float* v', the array syntax is just a way to document the number of elements that are expected to be accessible. You can the pass the address of a first float element out of a contiguous structure, e.g. &myvector.x -// IMGUI_API bool ColorEdit3(const char* label, float col[3], ImGuiColorEditFlags flags = 0); -export function ColorEdit3(label: string, col: RGB | RGBA | Bind.ImTuple3 | Bind.ImTuple4 | Bind.interface_ImVec4, flags: ImGuiColorEditFlags = 0): boolean { - const _col = import_Color3(col); - const ret = bind.ColorEdit3(label, _col, flags); - export_Color3(_col, col); - return ret; -} -// IMGUI_API bool ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flags = 0); -export function ColorEdit4(label: string, col: RGBA | Bind.ImTuple4 | Bind.interface_ImVec4, flags: ImGuiColorEditFlags = 0): boolean { - const _col = import_Color4(col); - const ret = bind.ColorEdit4(label, _col, flags); - export_Color4(_col, col); - return ret; -} -// IMGUI_API bool ColorPicker3(const char* label, float col[3], ImGuiColorEditFlags flags = 0); -export function ColorPicker3(label: string, col: RGB | RGBA | Bind.ImTuple3 | Bind.ImTuple4 | Bind.interface_ImVec4, flags: ImGuiColorEditFlags = 0): boolean { - const _col = import_Color3(col); - const ret = bind.ColorPicker3(label, _col, flags); - export_Color3(_col, col); - return ret; -} -// IMGUI_API bool ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags flags = 0, const float* ref_col = NULL); -export function ColorPicker4(label: string, col: RGBA | Bind.ImTuple4 | Bind.interface_ImVec4, flags: ImGuiColorEditFlags = 0, ref_col: Bind.ImTuple4 | Bind.interface_ImVec4 | null = null): boolean { - const _col = import_Color4(col); - const _ref_col = ref_col ? import_Color4(ref_col) : null; - const ret = bind.ColorPicker4(label, _col, flags, _ref_col); - export_Color4(_col, col); - if (_ref_col && ref_col) { export_Color4(_ref_col, ref_col); } - return ret; -} -// IMGUI_API bool ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFlags flags = 0, ImVec2 size = ImVec2(0,0)); // display a colored square/button, hover for details, return true when pressed. -export function ColorButton(desc_id: string, col: Readonly, flags: ImGuiColorEditFlags = 0, size: Readonly = ImVec2.ZERO): boolean { - return bind.ColorButton(desc_id, col, flags, size); -} -// IMGUI_API void SetColorEditOptions(ImGuiColorEditFlags flags); // initialize current options (generally on application startup) if you want to select a default format, picker type, etc. User will be able to change many settings, unless you pass the _NoOptions flag to your calls. -export function SetColorEditOptions(flags: ImGuiColorEditFlags): void { - bind.SetColorEditOptions(flags); -} - -// Widgets: Trees -// IMGUI_API bool TreeNode(const char* label); // if returning 'true' the node is open and the tree id is pushed into the id stack. user is responsible for calling TreePop(). -// IMGUI_API bool TreeNode(const char* str_id, const char* fmt, ...) IM_FMTARGS(2); // read the FAQ about why and how to use ID. to align arbitrary text at the same level as a TreeNode() you can use Bullet(). -// IMGUI_API bool TreeNode(const void* ptr_id, const char* fmt, ...) IM_FMTARGS(2); // " -// IMGUI_API bool TreeNodeV(const char* str_id, const char* fmt, va_list args) IM_FMTLIST(2); -// IMGUI_API bool TreeNodeV(const void* ptr_id, const char* fmt, va_list args) IM_FMTLIST(2); -export function TreeNode(label: string): boolean; -export function TreeNode(label: string, fmt: string): boolean; -export function TreeNode(label: number, fmt: string): boolean; -export function TreeNode(...args: any[]): boolean { - if (typeof(args[0]) === "string") { - if (args.length === 1) { - const label: string = args[0]; - return bind.TreeNode_A(label); - } else { - const str_id: string = args[0]; - const fmt: string = args[1]; - return bind.TreeNode_B(str_id, fmt); - } - } else { - const ptr_id: number = args[0]; - const fmt: string = args[1]; - return bind.TreeNode_C(ptr_id, fmt); - } -} -// IMGUI_API bool TreeNodeEx(const char* label, ImGuiTreeNodeFlags flags = 0); -// IMGUI_API bool TreeNodeEx(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) IM_FMTARGS(3); -// IMGUI_API bool TreeNodeEx(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) IM_FMTARGS(3); -// IMGUI_API bool TreeNodeExV(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) IM_FMTLIST(3); -// IMGUI_API bool TreeNodeExV(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) IM_FMTLIST(3); -export function TreeNodeEx(label: string, flags?: ImGuiTreeNodeFlags): boolean; -export function TreeNodeEx(str_id: string, flags: ImGuiTreeNodeFlags, fmt: string): boolean; -export function TreeNodeEx(ptr_id: number, flags: ImGuiTreeNodeFlags, fmt: string): boolean; -export function TreeNodeEx(...args: any[]): boolean { - if (typeof(args[0]) === "string") { - if (args.length < 3) { - const label: string = args[0]; - const flags: ImGuiTreeNodeFlags = args[1] || 0; - return bind.TreeNodeEx_A(label, flags); - } else { - const str_id: string = args[0]; - const flags: ImGuiTreeNodeFlags = args[1]; - const fmt: string = args[2]; - return bind.TreeNodeEx_B(str_id, flags, fmt); - } - } else { - const ptr_id: number = args[0]; - const flags: ImGuiTreeNodeFlags = args[1]; - const fmt: string = args[2]; - return bind.TreeNodeEx_C(ptr_id, flags, fmt); - } -} -// IMGUI_API void TreePush(const char* str_id); // ~ Indent()+PushId(). Already called by TreeNode() when returning true, but you can call Push/Pop yourself for layout purpose -// IMGUI_API void TreePush(const void* ptr_id = NULL); // " -export function TreePush(str_id: string): void; -export function TreePush(ptr_id: number): void; -export function TreePush(...args: any[]): void { - if (typeof(args[0]) === "string") { - const str_id: string = args[0]; - bind.TreePush_A(str_id); - } else { - const ptr_id: number = args[0]; - bind.TreePush_B(ptr_id); - } -} -// IMGUI_API void TreePop(); // ~ Unindent()+PopId() -export function TreePop(): void { bind.TreePop(); } -// IMGUI_API void TreeAdvanceToLabelPos(); // advance cursor x position by GetTreeNodeToLabelSpacing() -export function TreeAdvanceToLabelPos(): void { bind.TreeAdvanceToLabelPos(); } -// IMGUI_API float GetTreeNodeToLabelSpacing(); // horizontal distance preceding label when using TreeNode*() or Bullet() == (g.FontSize + style.FramePadding.x*2) for a regular unframed TreeNode -export function GetTreeNodeToLabelSpacing(): number { return bind.GetTreeNodeToLabelSpacing(); } -// IMGUI_API void SetNextTreeNodeOpen(bool is_open, ImGuiCond cond = 0); // set next TreeNode/CollapsingHeader open state. -export function SetNextTreeNodeOpen(is_open: boolean, cond: ImGuiCond = 0): void { - bind.SetNextTreeNodeOpen(is_open, cond); -} -// IMGUI_API bool CollapsingHeader(const char* label, ImGuiTreeNodeFlags flags = 0); // if returning 'true' the header is open. doesn't indent nor push on ID stack. user doesn't have to call TreePop(). -// IMGUI_API bool CollapsingHeader(const char* label, bool* p_open, ImGuiTreeNodeFlags flags = 0); // when 'p_open' isn't NULL, display an additional small close button on upper right of the header -export function CollapsingHeader(label: string, flags?: ImGuiTreeNodeFlags): boolean; -export function CollapsingHeader(label: string, p_open: Bind.ImScalar | Bind.ImAccess, flags?: ImGuiTreeNodeFlags): boolean; -export function CollapsingHeader(label: string, ...args: any[]): boolean { - if (args.length === 0) { - return bind.CollapsingHeader_A(label, 0); - } else { - if (typeof(args[0]) === "number") { - const flags: ImGuiTreeNodeFlags = args[0]; - return bind.CollapsingHeader_A(label, flags); - } else { - const p_open: Bind.ImScalar | Bind.ImAccess = args[0]; - const flags: ImGuiTreeNodeFlags = args[1] || 0; - const ref_open: Bind.ImScalar = Array.isArray(p_open) ? p_open : [ p_open() ]; - const ret = bind.CollapsingHeader_B(label, ref_open, flags); - if (!Array.isArray(p_open)) { p_open(ref_open[0]); } - return ret; - } - } -} - -// Widgets: Selectable / Lists -// IMGUI_API bool Selectable(const char* label, bool selected = false, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0,0)); // size.x==0.0: use remaining width, size.x>0.0: specify width. size.y==0.0: use label height, size.y>0.0: specify height -// IMGUI_API bool Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0,0)); -export function Selectable(label: string, selected?: boolean, flags?: ImGuiSelectableFlags, size?: Readonly): boolean; -export function Selectable(label: string, p_selected: Bind.ImScalar | Bind.ImAccess, flags?: ImGuiSelectableFlags, size?: Readonly): boolean; -export function Selectable(label: string, ...args: any[]): boolean { - if (args.length === 0) { - return bind.Selectable_A(label, false, 0, ImVec2.ZERO); - } else { - if (typeof(args[0]) === "boolean") { - const selected: boolean = args[0]; - const flags: ImGuiSelectableFlags = args[1] || 0; - const size: Readonly = args[2] || ImVec2.ZERO; - return bind.Selectable_A(label, selected, flags, size); - } else { - const p_selected: Bind.ImScalar | Bind.ImAccess = args[0]; - const flags: ImGuiSelectableFlags = args[1] || 0; - const size: Readonly = args[2] || ImVec2.ZERO; - const ref_selected: Bind.ImScalar = Array.isArray(p_selected) ? p_selected : [ p_selected() ]; - const ret = bind.Selectable_B(label, ref_selected, flags, size); - if (!Array.isArray(p_selected)) { p_selected(ref_selected[0]); } - return ret; - } - } -} -// IMGUI_API bool ListBox(const char* label, int* current_item, const char* const* items, int items_count, int height_in_items = -1); -// IMGUI_API bool ListBox(const char* label, int* current_item, bool (*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int height_in_items = -1); export type ListBoxItemGetter = (data: any, idx: number, out_text: [string]) => boolean; -export function ListBox(label: string, current_item: Bind.ImAccess | Bind.ImScalar, items: string[], items_count?: number, height_in_items?: number): boolean; -export function ListBox(label: string, current_item: Bind.ImAccess | Bind.ImScalar, items_getter: ListBoxItemGetter, data: any, items_count: number, height_in_items?: number): boolean; -export function ListBox(label: string, current_item: Bind.ImAccess | Bind.ImScalar, ...args: any[]): boolean { - let ret: boolean = false; - const _current_item: Bind.ImScalar = Array.isArray(current_item) ? current_item : [ current_item() ]; - if (Array.isArray(args[0])) { - const items: string[] = args[0]; - const items_count: number = typeof(args[1]) === "number" ? args[1] : items.length; - const height_in_items: number = typeof(args[2]) === "number" ? args[2] : -1; - ret = bind.ListBox_A(label, _current_item, items, items_count, height_in_items); - } else { - const items_getter: ListBoxItemGetter = args[0]; - const data: any = args[1]; - const items_count: number = args[2]; - const height_in_items: number = typeof(args[3]) === "number" ? args[3] : -1; - ret = bind.ListBox_B(label, _current_item, items_getter, data, items_count, height_in_items); - } - if (!Array.isArray(current_item)) { current_item(_current_item[0]); } - return ret; -} -// IMGUI_API bool ListBoxHeader(const char* label, const ImVec2& size = ImVec2(0,0)); // use if you want to reimplement ListBox() will custom data or interactions. make sure to call ListBoxFooter() afterwards. -// IMGUI_API bool ListBoxHeader(const char* label, int items_count, int height_in_items = -1); // " -export function ListBoxHeader(label: string, size: Readonly): boolean; -export function ListBoxHeader(label: string, items_count: number, height_in_items?: number): boolean; -export function ListBoxHeader(label: string, ...args: any[]): boolean { - if (typeof(args[0]) === "object") { - const size: Readonly = args[0]; - return bind.ListBoxHeader_A(label, size); - } else { - const items_count: number = args[0]; - const height_in_items: number = typeof(args[1]) === "number" ? args[1] : -1; - return bind.ListBoxHeader_B(label, items_count, height_in_items); - } -} -// IMGUI_API void ListBoxFooter(); // terminate the scrolling region -export function ListBoxFooter(): void { - bind.ListBoxFooter(); -} - -// Widgets: Value() Helpers. Output single value in "name: value" format (tip: freely declare more in your code to handle your types. you can add functions to the ImGui namespace) -// IMGUI_API void Value(const char* prefix, bool b); -// IMGUI_API void Value(const char* prefix, int v); -// IMGUI_API void Value(const char* prefix, unsigned int v); -// IMGUI_API void Value(const char* prefix, float v, const char* float_format = NULL); -export function Value(prefix: string, b: boolean): void; -export function Value(prefix: string, v: number): void; -export function Value(prefix: string, v: number, float_format?: string | null): void; -export function Value(prefix: string, v: any): void; -export function Value(prefix: string, ...args: any[]): void { - if (typeof(args[0]) === "boolean") { - bind.Value_A(prefix, args[0]); - } else if (typeof(args[0]) === "number") { - if (Number.isInteger(args[0])) { - bind.Value_B(prefix, args[0]); - } else { - bind.Value_D(prefix, args[0], typeof(args[1]) === "string" ? args[1] : null); - } - } else { - bind.Text(prefix + String(args[0])); - } -} - -// Tooltips -// IMGUI_API void BeginTooltip(); // begin/append a tooltip window. to create full-featured tooltip (with any kind of contents). -export function BeginTooltip(): void { bind.BeginTooltip(); } -// IMGUI_API void EndTooltip(); -export function EndTooltip(): void { bind.EndTooltip(); } -// IMGUI_API void SetTooltip(const char* fmt, ...) IM_FMTARGS(1); // set text tooltip under mouse-cursor, typically use with ImGui::IsItemHovered(). overidde any previous call to SetTooltip(). -// IMGUI_API void SetTooltipV(const char* fmt, va_list args) IM_FMTLIST(1); -export function SetTooltip(fmt: string): void { - bind.SetTooltip(fmt); -} - -// Menus -// IMGUI_API bool BeginMainMenuBar(); // create and append to a full screen menu-bar. only call EndMainMenuBar() if this returns true! -export function BeginMainMenuBar(): boolean { return bind.BeginMainMenuBar(); } -// IMGUI_API void EndMainMenuBar(); -export function EndMainMenuBar(): void { bind.EndMainMenuBar(); } -// IMGUI_API bool BeginMenuBar(); // append to menu-bar of current window (requires ImGuiWindowFlags_MenuBar flag set on parent window). only call EndMenuBar() if this returns true! -export function BeginMenuBar(): boolean { return bind.BeginMenuBar(); } -// IMGUI_API void EndMenuBar(); -export function EndMenuBar(): void { bind.EndMenuBar(); } -// IMGUI_API bool BeginMenu(const char* label, bool enabled = true); // create a sub-menu entry. only call EndMenu() if this returns true! -export function BeginMenu(label: string, enabled: boolean = true): boolean { return bind.BeginMenu(label, enabled); } -// IMGUI_API void EndMenu(); -export function EndMenu(): void { bind.EndMenu(); } -// IMGUI_API bool MenuItem(const char* label, const char* shortcut = NULL, bool selected = false, bool enabled = true); // return true when activated. shortcuts are displayed for convenience but not processed by ImGui at the moment -// IMGUI_API bool MenuItem(const char* label, const char* shortcut, bool* p_selected, bool enabled = true); // return true when activated + toggle (*p_selected) if p_selected != NULL -export function MenuItem(label: string, shortcut?: string | null, selected?: boolean, enabled?: boolean): boolean; -export function MenuItem(label: string, shortcut: string | null, p_selected: Bind.ImScalar | Bind.ImAccess | null, enabled?: boolean): boolean; -export function MenuItem(label: string, ...args: any[]): boolean { - if (args.length === 0) { - return bind.MenuItem_A(label, null, false, true); - } else if (args.length === 1) { - const shortcut: string | null = args[0]; - return bind.MenuItem_A(label, shortcut, false, true); - } else { - const shortcut: string | null = args[0]; - if (typeof(args[1]) === "boolean") { - const selected: boolean = args[1]; - const enabled: boolean = typeof(args[2]) === "boolean" ? args[2] : true; - return bind.MenuItem_A(label, shortcut, selected, enabled); - } else { - const p_selected: Bind.ImScalar | Bind.ImAccess = args[1]; - const enabled: boolean = typeof(args[2]) === "boolean" ? args[2] : true; - const ref_selected: Bind.ImScalar = Array.isArray(p_selected) ? p_selected : [ p_selected() ]; - const ret = bind.MenuItem_B(label, shortcut, ref_selected, enabled); - if (!Array.isArray(p_selected)) { p_selected(ref_selected[0]); } - return ret; - } - } -} - -// Popups -// IMGUI_API void OpenPopup(const char* str_id); // call to mark popup as open (don't call every frame!). popups are closed when user click outside, or if CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block. By default, Selectable()/MenuItem() are calling CloseCurrentPopup(). Popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level). -export function OpenPopup(str_id: string): void { bind.OpenPopup(str_id); } -// IMGUI_API bool OpenPopupOnItemClick(const char* str_id = NULL, int mouse_button = 1); // helper to open popup when clicked on last item. return true when just opened. -export function OpenPopupOnItemClick(str_id: string | null = null, mouse_button: number = 1): boolean { - return bind.OpenPopupOnItemClick(str_id, mouse_button); -} -// IMGUI_API bool BeginPopup(const char* str_id); // return true if the popup is open, and you can start outputting to it. only call EndPopup() if BeginPopup() returned true! -export function BeginPopup(str_id: string): boolean { return bind.BeginPopup(str_id); } -// IMGUI_API bool BeginPopupModal(const char* name, bool* p_open = NULL, ImGuiWindowFlags extra_flags = 0); // modal dialog (block interactions behind the modal window, can't close the modal window by clicking outside) -export function BeginPopupModal(str_id: string = "", p_open: Bind.ImScalar | Bind.ImAccess | null = null, extra_flags: ImGuiWindowFlags = 0): boolean { - if (Array.isArray(p_open)) { - return bind.BeginPopupModal(str_id, p_open, extra_flags); - } else if (typeof(p_open) === "function") { - const _p_open: Bind.ImScalar = [ p_open() ]; - const ret = bind.BeginPopupModal(str_id, _p_open, extra_flags); - p_open(_p_open[0]); - return ret; - } else { - return bind.BeginPopupModal(str_id, null, extra_flags); - } -} -// IMGUI_API bool BeginPopupContextItem(const char* str_id = NULL, int mouse_button = 1); // helper to open and begin popup when clicked on last item. if you can pass a NULL str_id only if the previous item had an id. If you want to use that on a non-interactive item such as Text() you need to pass in an explicit ID here. read comments in .cpp! -export function BeginPopupContextItem(str_id: string | null = null, mouse_button: number = 1): boolean { - return bind.BeginPopupContextItem(str_id, mouse_button); -} -// IMGUI_API bool BeginPopupContextWindow(const char* str_id = NULL, int mouse_button = 1, bool also_over_items = true); // helper to open and begin popup when clicked on current window. -export function BeginPopupContextWindow(str_id: string | null = null, mouse_button: number = 1, also_over_items: boolean = true): boolean { - return bind.BeginPopupContextWindow(str_id, mouse_button, also_over_items); -} -// IMGUI_API bool BeginPopupContextVoid(const char* str_id = NULL, int mouse_button = 1); // helper to open and begin popup when clicked in void (where there are no imgui windows). -export function BeginPopupContextVoid(str_id: string | null = null, mouse_button: number = 1): boolean { - return bind.BeginPopupContextVoid(str_id, mouse_button); -} -// IMGUI_API void EndPopup(); -export function EndPopup(): void { bind.EndPopup(); } -// IMGUI_API bool IsPopupOpen(const char* str_id); // return true if the popup is open -export function IsPopupOpen(str_id: string): boolean { return bind.IsPopupOpen(str_id); } -// IMGUI_API void CloseCurrentPopup(); // close the popup we have begin-ed into. clicking on a MenuItem or Selectable automatically close the current popup. -export function CloseCurrentPopup(): void { bind.CloseCurrentPopup(); } - -// Tab Bars, Tabs -// [BETA API] API may evolve! -// IMGUI_API bool BeginTabBar(const char* str_id, ImGuiTabBarFlags flags = 0); // create and append into a TabBar -export function BeginTabBar(str_id: string, flags: ImGuiTabBarFlags = 0): boolean { return bind.BeginTabBar(str_id, flags); } -// IMGUI_API void EndTabBar(); // only call EndTabBar() if BeginTabBar() returns true! -export function EndTabBar(): void { bind.EndTabBar(); } -// IMGUI_API bool BeginTabItem(const char* label, bool* p_open = NULL, ImGuiTabItemFlags flags = 0);// create a Tab. Returns true if the Tab is selected. -export function BeginTabItem(label: string, p_open: Bind.ImScalar | Bind.ImAccess | null = null, flags: ImGuiTabItemFlags = 0): boolean { - // return bind.BeginTabItem(label, p_open, flags); - if (p_open === null) { - return bind.BeginTabItem(label, null, flags); - } else if (Array.isArray(p_open)) { - return bind.BeginTabItem(label, p_open, flags); - } else { - const ref_open: Bind.ImScalar = [ p_open() ]; - const ret = bind.BeginTabItem(label, ref_open, flags); - p_open(ref_open[0]); - return ret; - } -} -// IMGUI_API void EndTabItem(); // only call EndTabItem() if BeginTabItem() returns true! -export function EndTabItem(): void { bind.EndTabItem(); } -// IMGUI_API void SetTabItemClosed(const char* tab_or_docked_window_label); // notify TabBar or Docking system of a closed tab/window ahead (useful to reduce visual flicker on reorderable tab bars). For tab-bar: call after BeginTabBar() and before Tab submissions. Otherwise call with a window name. -export function SetTabItemClosed(tab_or_docked_window_label: string): void { bind.SetTabItemClosed(tab_or_docked_window_label); } - -// Logging/Capture: all text output from interface is captured to tty/file/clipboard. By default, tree nodes are automatically opened during logging. -// IMGUI_API void LogToTTY(int max_depth = -1); // start logging to tty -export function LogToTTY(max_depth: number = -1): void { - bind.LogToTTY(max_depth); -} -// IMGUI_API void LogToFile(int max_depth = -1, const char* filename = NULL); // start logging to file -export function LogToFile(max_depth: number = -1, filename: string | null = null): void { - bind.LogToFile(max_depth, filename); -} -// IMGUI_API void LogToClipboard(int max_depth = -1); // start logging to OS clipboard -export function LogToClipboard(max_depth: number = -1): void { - bind.LogToClipboard(max_depth); -} -// IMGUI_API void LogFinish(); // stop logging (close file, etc.) -export function LogFinish(): void { bind.LogFinish(); } -// IMGUI_API void LogButtons(); // helper to display buttons for logging to tty/file/clipboard -export function LogButtons(): void { bind.LogButtons(); } -// IMGUI_API void LogText(const char* fmt, ...) IM_FMTARGS(1); // pass text data straight to log (without being displayed) -export function LogText(fmt: string): void { - bind.LogText(fmt); -} - -const _ImGui_DragDropPayload_data: {[key: string]: any} = {}; -// Drag and Drop -// [BETA API] Missing Demo code. API may evolve. -// IMGUI_API bool BeginDragDropSource(ImGuiDragDropFlags flags = 0); // call when the current item is active. If this return true, you can call SetDragDropPayload() + EndDragDropSource() -export function BeginDragDropSource(flags: ImGuiDragDropFlags = 0): boolean { - return bind.BeginDragDropSource(flags); -} -// IMGUI_API bool SetDragDropPayload(const char* type, const void* data, size_t size, ImGuiCond cond = 0);// type is a user defined string of maximum 8 characters. Strings starting with '_' are reserved for dear imgui internal types. Data is copied and held by imgui. -export function SetDragDropPayload(type: string, data: T, cond: ImGuiCond = 0): boolean { - _ImGui_DragDropPayload_data[type] = data; - return bind.SetDragDropPayload(type, data, 0, cond); -} -// IMGUI_API void EndDragDropSource(); -export function EndDragDropSource(): void { - bind.EndDragDropSource(); -} -// IMGUI_API bool BeginDragDropTarget(); // call after submitting an item that may receive an item. If this returns true, you can call AcceptDragDropPayload() + EndDragDropTarget() -export function BeginDragDropTarget(): boolean { - return bind.BeginDragDropTarget(); -} -// IMGUI_API const ImGuiPayload* AcceptDragDropPayload(const char* type, ImGuiDragDropFlags flags = 0); // accept contents of a given type. If ImGuiDragDropFlags_AcceptBeforeDelivery is set you can peek into the payload before the mouse button is released. -export function AcceptDragDropPayload(type: string, flags: ImGuiDragDropFlags = 0): ImGuiPayload | null { - const data: T = _ImGui_DragDropPayload_data[type]; - return bind.AcceptDragDropPayload(type, flags) ? { Data: data } : null; -} -// IMGUI_API void EndDragDropTarget(); -export function EndDragDropTarget(): void { - bind.EndDragDropTarget(); -} - -// Clipping -// IMGUI_API void PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_max, bool intersect_with_current_clip_rect); -export function PushClipRect(clip_rect_min: Readonly, clip_rect_max: Readonly, intersect_with_current_clip_rect: boolean): void { - bind.PushClipRect(clip_rect_min, clip_rect_max, intersect_with_current_clip_rect); -} -// IMGUI_API void PopClipRect(); -export function PopClipRect(): void { - bind.PopClipRect(); -} - -// Focus -// (FIXME: Those functions will be reworked after we merge the navigation branch + have a pass at focusing/tabbing features.) -// (Prefer using "SetItemDefaultFocus()" over "if (IsWindowAppearing()) SetScrollHere()" when applicable, to make your code more forward compatible when navigation branch is merged) -// IMGUI_API void SetItemDefaultFocus(); // make last item the default focused item of a window (WIP navigation branch only). Pleaase use instead of SetScrollHere(). -export function SetItemDefaultFocus(): void { bind.SetItemDefaultFocus(); } -// IMGUI_API void SetKeyboardFocusHere(int offset = 0); // focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget. Use -1 to access previous widget. -export function SetKeyboardFocusHere(offset: number = 0): void { - bind.SetKeyboardFocusHere(offset); -} - -// Utilities -// IMGUI_API bool IsItemHovered(ImGuiHoveredFlags flags = 0); // is the last item hovered? (and usable, aka not blocked by a popup, etc.). See ImGuiHoveredFlags for more options. -export function IsItemHovered(flags: ImGuiHoveredFlags = 0): boolean { - return bind.IsItemHovered(flags); -} -// IMGUI_API bool IsItemActive(); // is the last item active? (e.g. button being held, text field being edited- items that don't interact will always return false) -export function IsItemActive(): boolean { return bind.IsItemActive(); } -// IMGUI_API bool IsItemEdited(); // is the last item active? (e.g. button being held, text field being edited- items that don't interact will always return false) -export function IsItemEdited(): boolean { return bind.IsItemEdited(); } -// IMGUI_API bool IsItemFocused(); // is the last item focused for keyboard/gamepad navigation? -export function IsItemFocused(): boolean { return bind.IsItemFocused(); } -// IMGUI_API bool IsItemClicked(int mouse_button = 0); // is the last item clicked? (e.g. button/node just clicked on) -export function IsItemClicked(mouse_button: number = 0): boolean { - return bind.IsItemClicked(mouse_button); -} -// IMGUI_API bool IsItemVisible(); // is the last item visible? (aka not out of sight due to clipping/scrolling.) -export function IsItemVisible(): boolean { return bind.IsItemVisible(); } -// IMGUI_API bool IsItemDeactivated(); // was the last item just made inactive (item was previously active). Useful for Undo/Redo patterns with widgets that requires continuous editing. -export function IsItemDeactivated(): boolean { return bind.IsItemDeactivated(); } -// IMGUI_API bool IsItemDeactivatedAfterEdit(); // was the last item just made inactive and made a value change when it was active? (e.g. Slider/Drag moved). Useful for Undo/Redo patterns with widgets that requires continuous editing. Note that you may get false positives (some widgets such as Combo()/ListBox()/Selectable() will return true even when clicking an already selected item). -export function IsItemDeactivatedAfterEdit(): boolean { return bind.IsItemDeactivatedAfterEdit(); } -// IMGUI_API bool IsAnyItemHovered(); -export function IsAnyItemHovered(): boolean { return bind.IsAnyItemHovered(); } -// IMGUI_API bool IsAnyItemActive(); -export function IsAnyItemActive(): boolean { return bind.IsAnyItemActive(); } -// IMGUI_API bool IsAnyItemFocused(); -export function IsAnyItemFocused(): boolean { return bind.IsAnyItemFocused(); } -// IMGUI_API ImVec2 GetItemRectMin(); // get bounding rectangle of last item, in screen space -export function GetItemRectMin(out: Bind.interface_ImVec2 = new ImVec2()): typeof out { - return bind.GetItemRectMin(out); -} -// IMGUI_API ImVec2 GetItemRectMax(); // " -export function GetItemRectMax(out: Bind.interface_ImVec2 = new ImVec2()): typeof out { - return bind.GetItemRectMax(out); -} -// IMGUI_API ImVec2 GetItemRectSize(); // get size of last item, in screen space -export function GetItemRectSize(out: Bind.interface_ImVec2 = new ImVec2()): typeof out { - return bind.GetItemRectSize(out); -} -// IMGUI_API void SetItemAllowOverlap(); // allow last item to be overlapped by a subsequent item. sometimes useful with invisible buttons, selectables, etc. to catch unused area. -export function SetItemAllowOverlap(): void { bind.SetItemAllowOverlap(); } -// IMGUI_API bool IsWindowFocused(ImGuiFocusedFlags flags = 0); // is current window focused? or its root/child, depending on flags. see flags for options. -export function IsWindowFocused(flags: ImGuiFocusedFlags = 0): boolean { - return bind.IsWindowFocused(flags); -} -// IMGUI_API bool IsWindowHovered(ImGuiHoveredFlags flags = 0); // is current window hovered (and typically: not blocked by a popup/modal)? see flags for options. -export function IsWindowHovered(flags: ImGuiHoveredFlags = 0): boolean { - return bind.IsWindowHovered(flags); -} -// IMGUI_API bool IsRectVisible(const ImVec2& size); // test if rectangle (of given size, starting from cursor position) is visible / not clipped. -// IMGUI_API bool IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max); // test if rectangle (in screen space) is visible / not clipped. to perform coarse clipping on user's side. -export function IsRectVisible(size: Readonly): boolean; -export function IsRectVisible(rect_min: Readonly, rect_max: Readonly): boolean; -export function IsRectVisible(...args: any[]): boolean { - if (args.length === 1) { - const size: Readonly = args[0]; - return bind.IsRectVisible_A(size); - } else { - const rect_min: Readonly = args[0]; - const rect_max: Readonly = args[1]; - return bind.IsRectVisible_B(rect_min, rect_max); - } -} -// IMGUI_API float GetTime(); -export function GetTime(): number { return bind.GetTime(); } -// IMGUI_API int GetFrameCount(); -export function GetFrameCount(): number { return bind.GetFrameCount(); } -// IMGUI_API ImDrawList* GetOverlayDrawList(); // this draw list will be the last rendered one, useful to quickly draw overlays shapes/text -export function GetOverlayDrawList(): ImDrawList { - return new ImDrawList(bind.GetOverlayDrawList()); -} -// IMGUI_API ImDrawListSharedData* GetDrawListSharedData(); -export function GetDrawListSharedData(): ImDrawListSharedData { - return new ImDrawListSharedData(bind.GetDrawListSharedData()); -} -// IMGUI_API const char* GetStyleColorName(ImGuiCol idx); -export function GetStyleColorName(idx: ImGuiCol): string { return bind.GetStyleColorName(idx); } -// IMGUI_API ImVec2 CalcTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_double_hash = false, float wrap_width = -1.0f); -export function CalcTextSize(text: string, text_end: number | null = null, hide_text_after_double_hash: boolean = false, wrap_width: number = -1, out: Bind.interface_ImVec2 = new ImVec2()): typeof out { - return bind.CalcTextSize(text_end !== null ? text.substring(0, text_end) : text, hide_text_after_double_hash, wrap_width, out); -} -// IMGUI_API void CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end); // calculate coarse clipping for large list of evenly sized items. Prefer using the ImGuiListClipper higher-level helper if you can. -export function CalcListClipping(items_count: number, items_height: number, out_items_display_start: Bind.ImScalar, out_items_display_end: Bind.ImScalar): void { - return bind.CalcListClipping(items_count, items_height, out_items_display_start, out_items_display_end); -} - -// IMGUI_API bool BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags extra_flags = 0); // helper to create a child window / scrolling region that looks like a normal widget frame -export function BeginChildFrame(id: Bind.ImGuiID, size: Readonly, extra_flags: ImGuiWindowFlags = 0): boolean { - return bind.BeginChildFrame(id, size, extra_flags); -} -// IMGUI_API void EndChildFrame(); -export function EndChildFrame(): void { bind.EndChildFrame(); } - -// IMGUI_API ImVec4 ColorConvertU32ToFloat4(ImU32 in); -export function ColorConvertU32ToFloat4(in_: Bind.ImU32, out: Bind.interface_ImVec4 = new ImVec4()): typeof out { - return bind.ColorConvertU32ToFloat4(in_, out); -} -// IMGUI_API ImU32 ColorConvertFloat4ToU32(const ImVec4& in); -export function ColorConvertFloat4ToU32(in_: Readonly): Bind.ImU32 { - return bind.ColorConvertFloat4ToU32(in_); -} -// IMGUI_API void ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& out_s, float& out_v); -export function ColorConvertRGBtoHSV(r: number, g: number, b: number, out_h: Bind.ImScalar, out_s: Bind.ImScalar, out_v: Bind.ImScalar): void { bind.ColorConvertRGBtoHSV(r, g, b, out_h, out_s, out_v); } -// IMGUI_API void ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b); -export function ColorConvertHSVtoRGB(h: number, s: number, v: number, out_r: Bind.ImScalar, out_g: Bind.ImScalar, out_b: Bind.ImScalar): void { bind.ColorConvertHSVtoRGB(h, s, v, out_r, out_g, out_b); } - -// Inputs -// IMGUI_API int GetKeyIndex(ImGuiKey imgui_key); // map ImGuiKey_* values into user's key index. == io.KeyMap[key] -export function GetKeyIndex(imgui_key: ImGuiKey): number { - return bind.GetKeyIndex(imgui_key); -} -// IMGUI_API bool IsKeyDown(int user_key_index); // is key being held. == io.KeysDown[user_key_index]. note that imgui doesn't know the semantic of each entry of io.KeyDown[]. Use your own indices/enums according to how your backend/engine stored them into KeyDown[]! -export function IsKeyDown(user_key_index: number): boolean { - return bind.IsKeyDown(user_key_index); -} -// IMGUI_API bool IsKeyPressed(int user_key_index, bool repeat = true); // was key pressed (went from !Down to Down). if repeat=true, uses io.KeyRepeatDelay / KeyRepeatRate -export function IsKeyPressed(user_key_index: number, repeat: boolean = true): boolean { - return bind.IsKeyPressed(user_key_index, repeat); -} -// IMGUI_API bool IsKeyReleased(int user_key_index); // was key released (went from Down to !Down).. -export function IsKeyReleased(user_key_index: number): boolean { - return bind.IsKeyReleased(user_key_index); -} -// IMGUI_API int GetKeyPressedAmount(int key_index, float repeat_delay, float rate); // uses provided repeat rate/delay. return a count, most often 0 or 1 but might be >1 if RepeatRate is small enough that DeltaTime > RepeatRate -export function GetKeyPressedAmount(user_key_index: number, repeat_delay: number, rate: number): number { - return bind.GetKeyPressedAmount(user_key_index, repeat_delay, rate); -} -// IMGUI_API bool IsMouseDown(int button); // is mouse button held -export function IsMouseDown(button: number): boolean { - return bind.IsMouseDown(button); -} -// IMGUI_API bool IsMouseClicked(int button, bool repeat = false); // did mouse button clicked (went from !Down to Down) -export function IsMouseClicked(button: number, repeat: boolean = false): boolean { - return bind.IsMouseClicked(button, repeat); -} -// IMGUI_API bool IsMouseDoubleClicked(int button); // did mouse button double-clicked. a double-click returns false in IsMouseClicked(). uses io.MouseDoubleClickTime. -export function IsMouseDoubleClicked(button: number): boolean { - return bind.IsMouseDoubleClicked(button); -} -// IMGUI_API bool IsMouseReleased(int button); // did mouse button released (went from Down to !Down) -export function IsMouseReleased(button: number): boolean { - return bind.IsMouseReleased(button); -} -// IMGUI_API bool IsMouseDragging(int button = 0, float lock_threshold = -1.0f); // is mouse dragging. if lock_threshold < -1.0f uses io.MouseDraggingThreshold -export function IsMouseDragging(button: number = 0, lock_threshold: number = -1.0): boolean { - return bind.IsMouseDragging(button, lock_threshold); -} -// IMGUI_API bool IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip = true); // is mouse hovering given bounding rect (in screen space). clipped by current clipping settings. disregarding of consideration of focus/window ordering/blocked by a popup. -export function IsMouseHoveringRect(r_min: Readonly, r_max: Readonly, clip: boolean = true): boolean { - return bind.IsMouseHoveringRect(r_min, r_max, clip); -} -// IMGUI_API bool IsMousePosValid(const ImVec2* mouse_pos = NULL); // -export function IsMousePosValid(mouse_pos: Readonly | null = null): boolean { - return bind.IsMousePosValid(mouse_pos); -} -// IMGUI_API ImVec2 GetMousePos(); // shortcut to ImGui::GetIO().MousePos provided by user, to be consistent with other calls -export function GetMousePos(out: Bind.interface_ImVec2 = new ImVec2()): typeof out { - return bind.GetMousePos(out); -} -// IMGUI_API ImVec2 GetMousePosOnOpeningCurrentPopup(); // retrieve backup of mouse positioning at the time of opening popup we have BeginPopup() into -export function GetMousePosOnOpeningCurrentPopup(out: Bind.interface_ImVec2 = new ImVec2()): typeof out { - return bind.GetMousePosOnOpeningCurrentPopup(out); -} -// IMGUI_API ImVec2 GetMouseDragDelta(int button = 0, float lock_threshold = -1.0f); // dragging amount since clicking. if lock_threshold < -1.0f uses io.MouseDraggingThreshold -export function GetMouseDragDelta(button: number = 0, lock_threshold: number = -1.0, out: Bind.interface_ImVec2 = new ImVec2()): typeof out { - return bind.GetMouseDragDelta(button, lock_threshold, out); -} -// IMGUI_API void ResetMouseDragDelta(int button = 0); // -export function ResetMouseDragDelta(button: number = 0): void { - bind.ResetMouseDragDelta(button); -} -// IMGUI_API ImGuiMouseCursor GetMouseCursor(); // get desired cursor type, reset in ImGui::NewFrame(), this is updated during the frame. valid before Render(). If you use software rendering by setting io.MouseDrawCursor ImGui will render those for you -export function GetMouseCursor(): ImGuiMouseCursor { return bind.GetMouseCursor(); } -// IMGUI_API void SetMouseCursor(ImGuiMouseCursor type); // set desired cursor type -export function SetMouseCursor(type: ImGuiMouseCursor): void { bind.SetMouseCursor(type); } -// IMGUI_API void CaptureKeyboardFromApp(bool capture = true); // manually override io.WantCaptureKeyboard flag next frame (said flag is entirely left for your application handle). e.g. force capture keyboard when your widget is being hovered. -export function CaptureKeyboardFromApp(capture: boolean = true) { - return bind.CaptureKeyboardFromApp(capture); -} -// IMGUI_API void CaptureMouseFromApp(bool capture = true); // manually override io.WantCaptureMouse flag next frame (said flag is entirely left for your application handle). -export function CaptureMouseFromApp(capture: boolean = true): void { - bind.CaptureMouseFromApp(capture); -} - -// Clipboard Utilities (also see the LogToClipboard() function to capture or output text data to the clipboard) -// IMGUI_API const char* GetClipboardText(); -export function GetClipboardText(): string { return bind.GetClipboardText(); } -// IMGUI_API void SetClipboardText(const char* text); -export function SetClipboardText(text: string): void { bind.SetClipboardText(text); } - -// Settings/.Ini Utilities -// The disk functions are automatically called if io.IniFilename != NULL (default is "imgui.ini"). -// Set io.IniFilename to NULL to load/save manually. Read io.WantSaveIniSettings description about handling .ini saving manually. -// IMGUI_API void LoadIniSettingsFromDisk(const char* ini_filename); // call after CreateContext() and before the first call to NewFrame(). NewFrame() automatically calls LoadIniSettingsFromDisk(io.IniFilename). -export function LoadIniSettingsFromDisk(ini_filename: string): void { throw new Error(); } // TODO -// IMGUI_API void LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size=0); // call after CreateContext() and before the first call to NewFrame() to provide .ini data from your own data source. -export function LoadIniSettingsFromMemory(ini_data: string, ini_size: number = 0): void { bind.LoadIniSettingsFromMemory(ini_data); } -// IMGUI_API void SaveIniSettingsToDisk(const char* ini_filename); -export function SaveIniSettingsToDisk(ini_filename: string): void { throw new Error(); } // TODO -// IMGUI_API const char* SaveIniSettingsToMemory(size_t* out_ini_size = NULL); // return a zero-terminated string with the .ini data which you can save by your own mean. call when io.WantSaveIniSettings is set, then save data by your own mean and clear io.WantSaveIniSettings. -export function SaveIniSettingsToMemory(out_ini_size: Bind.ImScalar | null = null): string { return bind.SaveIniSettingsToMemory(); } - -// Memory Utilities -// All those functions are not reliant on the current context. -// If you reload the contents of imgui.cpp at runtime, you may need to call SetCurrentContext() + SetAllocatorFunctions() again. -// IMGUI_API void SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* user_data), void(*free_func)(void* ptr, void* user_data), void* user_data = NULL); -export function SetAllocatorFunctions(alloc_func: (sz: number, user_data: any) => number, free_func: (ptr: number, user_data: any) => void, user_data: any = null): void { - bind.SetAllocatorFunctions(alloc_func, free_func, user_data); -} -// IMGUI_API void* MemAlloc(size_t sz); -export function MemAlloc(sz: number): void { bind.MemAlloc(sz); } -// IMGUI_API void MemFree(void* ptr); -export function MemFree(ptr: any): void { bind.MemFree(ptr); }