The gui namespace contains functions that interact with the ImGui interface of Ashita. This allows addons to create rich user interfaces.
Because of the nature of these functions and the amount of functions that exist, I do not plan to create full documentation for each function. You can find an example of the ImGui demo application ported to an Ashita addon here instead.
Most of the calls are straight-forward and used as they are in C++. However, some of them had to have minor changes to work with Lua's types and lack of pointers. The following is a list of how things are implemented.
bool Begin(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0);
bool Begin(const char* name, bool* p_open, const ImVec2& size_on_first_use, float bg_alpha = -1.0f, ImGuiWindowFlags flags = 0);
void End(void);
bool BeginChild(const char* str_id, const ImVec2& size = ImVec2(0, 0), bool border = false, ImGuiWindowFlags extra_flags = 0);
bool BeginChild(ImGuiID id, const ImVec2& size = ImVec2(0, 0), bool border = false, ImGuiWindowFlags extra_flags = 0);
void EndChild(void);
ImVec2 GetContentRegionMax(void);
ImVec2 GetContentRegionAvail(void);
float GetContentRegionAvailWidth(void);
ImVec2 GetWindowContentRegionMin(void);
ImVec2 GetWindowContentRegionMax(void);
float GetWindowContentRegionWidth(void);
ImDrawList* GetWindowDrawList(void);
ImVec2 GetWindowPos(void);
ImVec2 GetWindowSize(void);
float GetWindowWidth(void);
float GetWindowHeight(void);
bool IsWindowCollapsed(void);
void SetWindowFontScale(float scale);
void SetNextWindowPos(const ImVec2& pos, ImGuiSetCond cond = 0);
void SetNextWindowPosCenter(ImGuiSetCond cond = 0);
void SetNextWindowSize(const ImVec2& size, ImGuiSetCond cond = 0);
void SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeConstraintCallback custom_callback = NULL, void* custom_callback_data = NULL);
void SetNextWindowContentSize(const ImVec2& size);
void SetNextWindowContentWidth(float width);
void SetNextWindowCollapsed(bool collapsed, ImGuiSetCond cond = 0);
void SetNextWindowFocus(void);
void SetWindowPos(const ImVec2& pos, ImGuiSetCond cond = 0);
void SetWindowSize(const ImVec2& size, ImGuiSetCond cond = 0);
void SetWindowCollapsed(bool collapsed, ImGuiSetCond cond = 0);
void SetWindowFocus(void);
void SetWindowPos(const char* name, const ImVec2& pos, ImGuiSetCond cond = 0);
void SetWindowSize(const char* name, const ImVec2& size, ImGuiSetCond cond = 0);
void SetWindowCollapsed(const char* name, bool collapsed, ImGuiSetCond cond = 0);
void SetWindowFocus(const char* name);
void Text(const char* fmt, …);
void TextV(const char* fmt, va_list args);
void TextColored(const ImVec4& col, const char* fmt, …);
void TextColoredV(const ImVec4& col, const char* fmt, va_list args);
void TextDisabled(const char* fmt, …);
void TextDisabledV(const char* fmt, va_list args);
void TextWrapped(const char* fmt, …);
void TextWrappedV(const char* fmt, va_list args);
void TextUnformatted(const char* text, const char* text_end = NULL);
void LabelText(const char* label, const char* fmt, …);
void LabelTextV(const char* label, const char* fmt, va_list args);
void Bullet(void);
void BulletText(const char* fmt, …);
void BulletTextV(const char* fmt, va_list args);
bool Button(const char* label, const ImVec2& size = ImVec2(0, 0));
bool SmallButton(const char* label);
bool InvisibleButton(const char* str_id, const ImVec2& size);
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));
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));
bool Checkbox(const char* label, bool* v);
bool CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value);
bool RadioButton(const char* label, bool active);
bool RadioButton(const char* label, int* v, int v_button);
bool Combo(const char* label, int* current_item, const char** items, int items_count, int height_in_items = -1);
bool Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int height_in_items = -1);
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 height_in_items = -1);
bool ColorButton(const ImVec4& col, bool small_height = false, bool outline_border = true);
bool ColorEdit3(const char* label, float col[3]);
bool ColorEdit4(const char* label, float col[4], bool show_alpha = true);
void ColorEditMode(ImGuiColorEditMode mode);
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));
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));
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));
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));
void ProgressBar(float fraction, const ImVec2& size_arg = ImVec2(-1, 0), const char* overlay = NULL);
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);
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);
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);
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);
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);
bool DragInt(const char* label, int* v, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* display_format = “%.0f”);
bool DragInt2(const char* label, int v[2], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* display_format = “%.0f”);
bool DragInt3(const char* label, int v[3], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* display_format = “%.0f”);
bool DragInt4(const char* label, int v[4], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* display_format = “%.0f”);
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);
bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiTextEditCallback callback = NULL, void* user_data = NULL);
bool InputTextMultiline(const char* label, char* buf, size_t buf_size, const ImVec2& size = ImVec2(0, 0), ImGuiInputTextFlags flags = 0, ImGuiTextEditCallback callback = NULL, void* user_data = NULL);
bool InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, int decimal_precision = -1, ImGuiInputTextFlags extra_flags = 0);
bool InputFloat2(const char* label, float v[2], int decimal_precision = -1, ImGuiInputTextFlags extra_flags = 0);
bool InputFloat3(const char* label, float v[3], int decimal_precision = -1, ImGuiInputTextFlags extra_flags = 0);
bool InputFloat4(const char* label, float v[4], int decimal_precision = -1, ImGuiInputTextFlags extra_flags = 0);
bool InputInt(const char* label, int* v, int step = 1, int step_fast = 100, ImGuiInputTextFlags extra_flags = 0);
bool InputInt2(const char* label, int v[2], ImGuiInputTextFlags extra_flags = 0);
bool InputInt3(const char* label, int v[3], ImGuiInputTextFlags extra_flags = 0);
bool InputInt4(const char* label, int v[4], ImGuiInputTextFlags extra_flags = 0);
bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* display_format = “%.3f”, float power = 1.0f);
bool SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* display_format = “%.3f”, float power = 1.0f);
bool SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* display_format = “%.3f”, float power = 1.0f);
bool SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* display_format = “%.3f”, float power = 1.0f);
bool SliderAngle(const char* label, float* v_rad, float v_degrees_min = -360.0f, float v_degrees_max = +360.0f);
bool SliderInt(const char* label, int* v, int v_min, int v_max, const char* display_format = “%.0f”);
bool SliderInt2(const char* label, int v[2], int v_min, int v_max, const char* display_format = “%.0f”);
bool SliderInt3(const char* label, int v[3], int v_min, int v_max, const char* display_format = “%.0f”);
bool SliderInt4(const char* label, int v[4], int v_min, int v_max, const char* display_format = “%.0f”);
bool VSliderFloat(const char* label, const ImVec2& size, float* v, float v_min, float v_max, const char* display_format = “%.3f”, float power = 1.0f);
bool VSliderInt(const char* label, const ImVec2& size, int* v, int v_min, int v_max, const char* display_format = “%.0f”);
bool TreeNode(const char* label);
bool TreeNode(const char* str_id, const char* fmt, …);
bool TreeNode(const void* ptr_id, const char* fmt, …);
bool TreeNodeV(const char* str_id, const char* fmt, va_list args);
bool TreeNodeV(const void* ptr_id, const char* fmt, va_list args);
bool TreeNodeEx(const char* label, ImGuiTreeNodeFlags flags = 0);
bool TreeNodeEx(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, …);
bool TreeNodeEx(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, …);
bool TreeNodeExV(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args);
bool TreeNodeExV(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args);
void TreePush(const char* str_id = NULL);
void TreePush(const void* ptr_id = NULL);
void TreePop(void);
void TreeAdvanceToLabelPos(void);
float GetTreeNodeToLabelSpacing(void);
void SetNextTreeNodeOpen(bool is_open, ImGuiSetCond cond = 0);
bool CollapsingHeader(const char* label, ImGuiTreeNodeFlags flags = 0);
bool CollapsingHeader(const char* label, bool* p_open, ImGuiTreeNodeFlags flags = 0);
bool Selectable(const char* label, bool selected = false, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0, 0));
bool Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0, 0));
bool ListBox(const char* label, int* current_item, const char** items, int items_count, int height_in_items = -1);
bool ListBox(const char* label, int* current_item, const char* items_separated_by_zeros, int height_in_items = -1);
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);
bool ListBoxHeader(const char* label, const ImVec2& size = ImVec2(0, 0));
bool ListBoxHeader(const char* label, int items_count, int height_in_items = -1);
void ListBoxFooter(void);
bool IsItemHovered(void);
bool IsItemHoveredRect(void);
bool IsItemActive(void);
bool IsItemClicked(int mouse_button = 0);
bool IsItemVisible(void);
bool IsAnyItemHovered(void);
bool IsAnyItemActive(void);
ImVec2 GetItemRectMin(void);
ImVec2 GetItemRectMax(void);
ImVec2 GetItemRectSize(void);
void SetItemAllowOverlap(void);
bool IsWindowHovered(void);
bool IsWindowFocused(void);
bool IsRootWindowFocused(void);
bool IsRootWindowOrAnyChildFocused(void);
bool IsRootWindowOrAnyChildHovered(void);
bool IsRectVisible(const ImVec2& size);
bool IsPosHoveringAnyWindow(const ImVec2& pos);
float GetTime(void);
int GetFrameCount(void);
const char* GetStyleColName(ImGuiCol idx);
ImVec2 CalcItemRectClosestPoint(const ImVec2& pos, bool on_edge = false, float outward = +0.0f);
ImVec2 CalcTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_double_hash = false, float wrap_width = -1.0f);
void CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end);
int GetKeyIndex(ImGuiKey key);
bool IsKeyDown(int key_index);
bool IsKeyPressed(int key_index, bool repeat = true);
bool IsKeyReleased(int key_index);
bool IsMouseDown(int button);
bool IsMouseClicked(int button, bool repeat = false);
bool IsMouseDoubleClicked(int button);
bool IsMouseReleased(int button);
bool IsMouseHoveringWindow(void);
bool IsMouseHoveringAnyWindow(void);
bool IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip = true);
bool IsMouseDragging(int button = 0, float lock_threshold = -1.0f);
ImVec2 GetMousePos(void);
ImVec2 GetMousePosOnOpeningCurrentPopup(void);
ImVec2 GetMouseDragDelta(int button = 0, float lock_threshold = -1.0f);
void ResetMouseDragDelta(int button = 0);
ImGuiMouseCursor GetMouseCursor(void);
void SetMouseCursor(ImGuiMouseCursor type);
void CaptureKeyboardFromApp(bool capture = true);
void CaptureMouseFromApp(bool capture = true);