ImGui

For examples:
ImGui GitHub

Auto-generated documentation (might contain errors): ImGuiBindings

ImGui lua bindings can be used for creating custom windows and custom widgets.
All lua functions start with "imgui.". Due to ImGui being a c++ library there are certain restriction and rules that have to be followed.
Not everything is implemented, to see what is use the lua function: "imgui.ListImplemented()"
"imgui.SearchImplemented(Search Term)"

Rules

Lua bindings don't support formatting of functions like "ImGui::Text".
Lua bindings can return multiple values.
The first value is always the return value of the c++ function, but only if the function returns a value.
If the c++ function takes in a pointer to a value, that is meant to be changed inside the function, then the changed value is returned by the lua function.
If multiple pointers are taken in, then they are returned in order.

If an array of values is taken in and changed by the c++ function, then it is returned as an array. For example:

changed, array = imgui.SliderFloat2("Slider", array, 0.0, 5.0)

If a c++ function takes in or returns an "ImVec2", "ImVec4" or "ImRect", it is always converted to an array of numbers. So "ImVec2(2.0f, 50.5f)" would be "{ 2.0, 50.5 }" in lua.

Functions that take in an ImTextureID, like ImGui::Image, take in a path or URL to the image.

Most functions taking in a pointer to a struct or class, other then "ImVec2", "ImVec4" and "ImRect", are not supported.

All lua binding arguments can be left empty, and if left empty are set to default values. If the c++ function has default arguments, then the lua arguments are set to those.
If the c++ function has no default arguments, then they are set to predefined arguments, that should be considered unsafe.

If an "ImGui::BeginX" c++ function takes in a bool pointer, then a negative value can be used to "simulate" a nullptr.

GetIO and GetCurrentContext

All values in "ImGuiIO" and "ImGuiContext" have functions to get those values. Those functions can be accessed through the tables "imgui.io" or "imgui.context". If the value is a c++ array, then an index can be given as an argument. For example:

imgui.io.MouseClicked(0)

DrawList

The "ImDrawList"s can be accessed by using the tables "imgui.drawlist.window", "imgui.drawlist.foreground" or "imgui.drawlist.background", which contain most functions needed.

ImUtil

The table "imutil" contains a additional functions.

  • imutil.RichText(Text (string), Width (float))

  • imutil.PushFontSize(Size (float))

    • Pushes a font size to the stack. This will make most text following it bigger or smaller. A value of 1.1 would make the text 10% bigger. Remember to call imutil.PopFontSize() afterwards.
  • imutil.PopFontSize()

    • Pops the last font size value pushed to the stack.
  • imutil.AdjustX(X (float))

    • Multiplies the given value by the UI scale x.
  • imutil.AdjustY(Y (float))

    • Multiplies the given value by the UI scale y.
  • imutil.GetImageSize(Path (string)) -> Vec2

    • Returns the size of the given image.
  • imutil.ImageFitX(Path (string), Size (float))

    • Renders an image with a max width given.
  • imutil.ImageFitY(Path (string), Size (float))

    • Renders an image with a max height given.
  • imutil.ImageFitXOrY(Path (string), Size (float))

    • Renders an image that fits in a square of the given size.
  • imutil.ImageFitBest(Path (string), SizeX (float), SizeY (float))

    • Renders an image that fits in a rectangle of the given size.
  • imutil.Separator(Thickness (float))