This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
addons:functions:gui [2017/04/21 22:05] atom0s |
addons:functions:gui [2017/04/22 00:10] (current) |
||
---|---|---|---|
Line 4: | Line 4: | ||
You can access these functions via: | You can access these functions via: | ||
- | <code lua>ashita.gui.</code> | + | <sxh lua>ashita.gui.</sxh> |
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. | 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. | ||
Line 14: | Line 14: | ||
It is important that when making use of the GUI functions, that your addon includes the script: 'imguidef'.\\ | 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:\\ | You can do this by adding the following line of code to the top of your addon:\\ | ||
- | <code lua>require 'imguidef'</code> | + | <sxh lua>require 'imguidef'</sxh> |
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:\\ | 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:\\ | ||
- | <code lua> | + | <sxh lua> |
-- before | -- before | ||
local hide = ashita.gui.GetHide(); | local hide = ashita.gui.GetHide(); | ||
Line 23: | Line 23: | ||
-- after | -- after | ||
local hide = imgui.GetHide(); | local hide = imgui.GetHide(); | ||
- | </code> | + | </sxh> |
</WRAP> | </WRAP> | ||
Line 418: | Line 418: | ||
- The callbacks data is a [[imgui.ImGuiTextEditCallbackData]] structure instance. | - The callbacks data is a [[imgui.ImGuiTextEditCallbackData]] structure instance. | ||
- | <code lua> | + | <sxh lua> |
if (imgui.InputText('test', test_text_input_buffer, 1024, imgui.bor(ImGuiInputTextFlags_EnterReturnsTrue,ImGuiInputTextFlags_CallbackCompletion,ImGuiInputTextFlags_CallbackHistory), 'test_callback')) then | if (imgui.InputText('test', test_text_input_buffer, 1024, imgui.bor(ImGuiInputTextFlags_EnterReturnsTrue,ImGuiInputTextFlags_CallbackCompletion,ImGuiInputTextFlags_CallbackHistory), 'test_callback')) then | ||
print('Enter was pressed!'); | print('Enter was pressed!'); | ||
Line 427: | Line 427: | ||
return 0; | return 0; | ||
end | end | ||
- | </code> | + | </sxh> |
**SetNextWindowSizeConstraints** - The callback, if present, should be a string that points to a callback function like this: | **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. | - The callbacks data is a [[imgui.ImGuiSizeConstraintCallbackData]] structure instance. | ||
- | <code lua> | + | <sxh lua> |
function SquareResizeConstraint(data) | function SquareResizeConstraint(data) | ||
data.DesiredSize = ImVec2(math.max(data.DesiredSize.x, data.DesiredSize.y), math.max(data.DesiredSize.x, data.DesiredSize.y)); | data.DesiredSize = ImVec2(math.max(data.DesiredSize.x, data.DesiredSize.y), math.max(data.DesiredSize.x, data.DesiredSize.y)); | ||
Line 438: | Line 438: | ||
imgui.SetNextWindowSizeConstraints(0, 0, float_max, float_max, 'SquareResizeConstraint'); | imgui.SetNextWindowSizeConstraints(0, 0, float_max, float_max, 'SquareResizeConstraint'); | ||
- | </code> | + | </sxh> |