The imgui
namespace contains functions that are used to interact with the ImGui library. daochook offers a [nearly] full implementation of ImGui, adjusted to work nicer with Lua.
Due to how many functions are within ImGui, this documentation may remain ’lacking’ for a bit of time. However, some bits of information will be explained to help understand the changes made to the functions in order to make use of them in your addons.
Functions exposed by this namespace are accessed via the prefix: gui.
daochook includes a helper lib for addons that should be used when your addon will make use of imgui.require 'imgui';
When using the imgui
addon lib, you can instead directly access the ImGui functions via the imgui.
namespace.
daochook implements and makes use of ImGui v1.88. You can find info about it here:
https://github.com/ocornut/imgui
https://github.com/ocornut/imgui/tree/v1.88
The following changes are made to all ImGui functions that are exposed.
ImVec2(..)
parameter is instead, replaced with a table holding two numbers.ImVec3(..)
parameter is instead, replaced with a table holding three numbers.bool*
parameter is instead, replaced with a table holding a boolean property....
is not implemented, use the non-vararg variant of the function instead.va_list
is not implemented, use the non-vararg variant of the function instead.ImVec2(..)
will return two values instead.ImVec3(..)
will return three values instead.Some examples of these changes are as follows:
1-- Original:
2-- ImVec2 GetCursorScreenPos(void);
3
4-- Changed:
5local x, y = imgui.GetCursorScreenPos();
1-- Original:
2-- void PushStyleColor(ImGuiCol idx, const ImVec4& col);
3
4-- Changed:
5imgui.PushStyleColor(0, { 1.0, 1.0, 1.0, 1.0, });
1-- Original:
2-- ImU32 GetColorU32(const ImVec4& col);
3
4-- Changed:
5local color = imgui.GetColorU32({ 1.0, 1.0, 1.0, 1.0, });
1-- Original:
2-- bool Button(const char* label, const ImVec2& size = ImVec2(0, 0));
3
4-- Changed:
5if (imgui.Button('Derp')) then print('Derp clicked.'); end
6if (imgui.Button('Derp', { 25.0, 25.0, })) then print('Derp clicked.'); end
1-- Original:
2-- bool Checkbox(const char* label, bool* v);
3
4-- Changed:
5local window = T{
6 is_checked = T{ true, },
7};
8imgui.Checkbox('Derp', window.is_checked);