Gui Namespace

The gui namespace contains functions that interact with the ImGui interface of Ashita. This allows addons to create rich user interfaces.

You can access these functions via:

ashita.gui.

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.

This will serve as a demo of how to use these functions:
https://gist.github.com/atom0s/188283e6ff097f37fa31400f22ec8762

It is important that when making use of the GUI functions, that your addon includes the script: 'imguidef'.
You can do this by adding the following line of code to the top of your addon:

require 'imguidef'

By including this helper file, this also exposes these GUI functions via a global 'imgui'. Instead of having to use 'ashita.gui.' before every call, instead you just need to use 'imgui.' instead. For example:

-- before
local hide = ashita.gui.GetHide();

-- after
local hide = imgui.GetHide();


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.

Please note, the following changes apply to ALL functions listed below:



Notes

InputText / InputTextMultiline - The callback, if present, should be a string that points to a callback function like this: - The callbacks data is a imgui.ImGuiTextEditCallbackData structure instance.

    if (imgui.InputText('test', test_text_input_buffer, 1024, imgui.bor(ImGuiInputTextFlags_EnterReturnsTrue,ImGuiInputTextFlags_CallbackCompletion,ImGuiInputTextFlags_CallbackHistory), 'test_callback')) then
        print('Enter was pressed!');
    end
    
    function test_callback(data)
        print('Callback was fired!');
        return 0;
    end

SetNextWindowSizeConstraints - The callback, if present, should be a string that points to a callback function like this: - The callbacks data is a imgui.ImGuiSizeConstraintCallbackData structure instance.

function SquareResizeConstraint(data)
    data.DesiredSize = ImVec2(math.max(data.DesiredSize.x, data.DesiredSize.y), math.max(data.DesiredSize.x, data.DesiredSize.y));    
end

imgui.SetNextWindowSizeConstraints(0, 0, float_max, float_max, 'SquareResizeConstraint');