This shows you the differences between two versions of the page.
Next revision | Previous revision Last revision Both sides next revision | ||
addons:functions:imgui [2016/06/21 23:50] atom0s created |
addons:functions:imgui [2016/06/27 21:34] atom0s |
||
---|---|---|---|
Line 61: | Line 61: | ||
* <color green>void SetNextWindowPosCenter(ImGuiSetCond cond = 0);</color>\\ | * <color green>void SetNextWindowPosCenter(ImGuiSetCond cond = 0);</color>\\ | ||
* <color green>void SetNextWindowSize(const ImVec2& size, ImGuiSetCond cond = 0);</color>\\ | * <color green>void SetNextWindowSize(const ImVec2& size, ImGuiSetCond cond = 0);</color>\\ | ||
- | * <color red>void SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeConstraintCallback custom_callback = NULL, void* custom_callback_data = NULL);</color>\\ | + | * <color green>void SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeConstraintCallback custom_callback = NULL, void* custom_callback_data = NULL);</color>\\ |
- | * Not implemented currently. | + | * callback is implemented as a string. It is the name to a Lua function to call when the callback is invoked. (custom_callback_data is not implemented.) |
* <color green>void SetNextWindowContentSize(const ImVec2& size);</color>\\ | * <color green>void SetNextWindowContentSize(const ImVec2& size);</color>\\ | ||
* <color green>void SetNextWindowContentWidth(float width);</color>\\ | * <color green>void SetNextWindowContentWidth(float width);</color>\\ | ||
Line 178: | Line 178: | ||
* <color green>bool RadioButton(const char* label, int* v, int v_button);</color>\\ | * <color green>bool RadioButton(const char* label, int* v, int v_button);</color>\\ | ||
* <color red>bool Combo(const char* label, int* current_item, const char%%**%% items, int items_count, int height_in_items = -1);</color>\\ | * <color red>bool Combo(const char* label, int* current_item, const char%%**%% items, int items_count, int height_in_items = -1);</color>\\ | ||
- | * <color red>bool Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int height_in_items = -1);</color>\\ | + | * Not implemented currently. |
+ | * <color green>bool Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int height_in_items = -1);</color>\\ | ||
* <color red>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);</color>\\ | * <color red>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);</color>\\ | ||
* Not implemented currently. | * Not implemented currently. | ||
Line 185: | Line 186: | ||
* <color green>bool ColorEdit4(const char* label, float col[4], bool show_alpha = true);</color>\\ | * <color green>bool ColorEdit4(const char* label, float col[4], bool show_alpha = true);</color>\\ | ||
* <color green>void ColorEditMode(ImGuiColorEditMode mode);</color>\\ | * <color green>void ColorEditMode(ImGuiColorEditMode mode);</color>\\ | ||
- | * <color red>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));</color>\\ | + | * <color green>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));</color>\\ |
+ | * Implemented in a custom manner to support an array of float values, using a Lua table. Call is setup as: | ||
+ | * imgui.PlotLines(label, values_table, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size_x, graph_size_y, stride); | ||
+ | * Default values are still present starting at values_offset. | ||
* <color red>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));</color>\\ | * <color red>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));</color>\\ | ||
- | * <color red>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));</color>\\ | + | * <color green>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));</color>\\ |
+ | * Implemented in a custom manner to support an array of float values, using a Lua table. Call is setup as: | ||
+ | * imgui.PlotHistogram(label, values_table, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size_x, graph_size_y, stride); | ||
+ | * Default values are still present starting at values_offset. | ||
* <color red>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));</color>\\ | * <color red>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));</color>\\ | ||
* Not implemented currently. | * Not implemented currently. | ||
Line 204: | Line 211: | ||
* <color green>bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiTextEditCallback callback = NULL, void* user_data = NULL);</color>\\ | * <color green>bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiTextEditCallback callback = NULL, void* user_data = NULL);</color>\\ | ||
- | * callback and user_data are not implemented in Lua. | + | * callback is implemented as a string. It is the name to a Lua function to call when the callback is invoked. (user_data is not implemented.) |
* <color green>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);</color>\\ | * <color green>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);</color>\\ | ||
- | * callback and user_data are not implemented in Lua. | + | * callback is implemented as a string. It is the name to a Lua function to call when the callback is invoked. (user_data is not implemented.) |
* <color green>bool InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, int decimal_precision = -1, ImGuiInputTextFlags extra_flags = 0);</color>\\ | * <color green>bool InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, int decimal_precision = -1, ImGuiInputTextFlags extra_flags = 0);</color>\\ | ||
* <color green>bool InputFloat2(const char* label, float v[2], int decimal_precision = -1, ImGuiInputTextFlags extra_flags = 0);</color>\\ | * <color green>bool InputFloat2(const char* label, float v[2], int decimal_precision = -1, ImGuiInputTextFlags extra_flags = 0);</color>\\ | ||
Line 250: | Line 257: | ||
* <color green>bool Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0, 0));</color>\\ | * <color green>bool Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0, 0));</color>\\ | ||
* <color red>bool ListBox(const char* label, int* current_item, const char%%**%% items, int items_count, int height_in_items = -1);</color>\\ | * <color red>bool ListBox(const char* label, int* current_item, const char%%**%% items, int items_count, int height_in_items = -1);</color>\\ | ||
+ | * <color green>bool ListBox(const char* label, int* current_item, const char* items_separated_by_zeros, int height_in_items = -1);</color>\\ | ||
* <color red>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);</color>\\ | * <color red>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);</color>\\ | ||
* Not implemented currently. | * Not implemented currently. | ||
Line 381: | Line 389: | ||
* <color red>void SetCurrentContext(ImGuiContext* ctx);</color>\\ | * <color red>void SetCurrentContext(ImGuiContext* ctx);</color>\\ | ||
* Not implementing this function. | * Not implementing this function. | ||
+ | |||
+ | |||
+ | ----- | ||
+ | |||
+ | ===== 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. | ||
+ | |||
+ | <code lua> | ||
+ | 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 | ||
+ | </code> | ||
+ | |||
+ | **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. | ||
+ | |||
+ | <code lua> | ||
+ | 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'); | ||
+ | </code> |