Skip to content

Instantly share code, notes, and snippets.

@atom0s
Last active July 17, 2020 16:03
Show Gist options
  • Save atom0s/188283e6ff097f37fa31400f22ec8762 to your computer and use it in GitHub Desktop.
Save atom0s/188283e6ff097f37fa31400f22ec8762 to your computer and use it in GitHub Desktop.
--[[
* Copyright (c) 2011-2016 - Ashita Development Team
*
* Ashita is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Ashita is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Ashita. If not, see <http://www.gnu.org/licenses/>.
]]--
--[[
ImGui_Demo.cpp Example Converted To Lua by atom0s
You can see the original C++ version of this example here:
https://github.com/ocornut/imgui/blob/master/imgui_demo.cpp
Here is a list what is/isn't implemented in this example:
Test Window
- Menu : Implemented
- Help : Implemented
- Window Options : Implemented
- Widgets
- Trees : Implemented
- Collapsing Headers : Implemented
- Bullets : Implemented
- Colored Text : Implemented
- Word Wrapping : Partially Implemented
- UTF-8 Text : Partially Implemented
- Images : Not implemented.
- Selectables : Implemented
- Filtered Text Input : Implemented
- Multiline Text Input : Implemented
- Non-Grouped Examples : Implemented
- Range Widgets : Implemented
- Multi-Component Widgets : Implemented
- Vertical Sliders : Implemented
- Graphs Widgets : Not implemented.
- Layout : Not implemented.
- Popups & Modal Windows : Not implemented.
- Columns : Not implemented.
- Filtering : Not implemented.
- Keyboard, Mouse & Focus : Not implemented.
(Menu) Examples
- Main Menu Bar : Implemented
- Console : Implemented (With some customizations for Lua compatibility.)
- Log : Implemented (With some customizations for Lua compatibility.)
- Simple Layout : Implemented
- Property Editor : Implemented
- Long Text Display : Implemented (2nd test is not implemented.)
- Auto-resizing Window : Implemented
- Constrained-resizing Window : Implemented
- Simple Overlay : Implemented
- Manipulating Window Title : Implemented
- Custom Rendering : Not implemented. (Most of what this does is not exposed to Lua currently.)
(Menu) Help
- Metrics : Implemented (Uses internal C++ version for ease of use.)
- Style Editor : Implemented (Uses internal C++ version for ease of use.)
- About ImGui : Implemented
]]--
_addon.author = 'atom0s';
_addon.name = 'test';
_addon.version = '1.0';
require 'common'
require 'imguidef'
----------------------------------------------------------------------------------------------------
-- Lua tonumber Override (Allows Handling Boolean To Number)
----------------------------------------------------------------------------------------------------
local orig_tonumber = _G.tonumber;
_G.tonumber = function(num)
if (type(num) == 'boolean') then
if (num == true) then return 1; else return 0; end
else
return orig_tonumber(num);
end
end
----------------------------------------------------------------------------------------------------
-- Variables
----------------------------------------------------------------------------------------------------
local ShowExampleAppLog_lasttime = 0;
local ShowExampleAppLongText_lines = { };
local ShowTestWindow_tree_selection_mask = bit.lshift(1, 2);
local ShowTestWindow_togglebutton_clicked = false;
local variables =
{
-- ShowExampleAppAutoResize
['var_ShowExampleAppAutoResize_numberoflines'] = { nil, ImGuiVar_INT32 },
-- ShowExampleMenuFile
['var_ShowExampleMenuFile_menuitemenabled'] = { nil, ImGuiVar_BOOLCPP },
['var_ShowExampleMenuFile_menuslidervaluefloat'] = { nil, ImGuiVar_FLOAT },
['var_ShowExampleMenuFile_menuinputvaluefloat'] = { nil, ImGuiVar_FLOAT },
['var_ShowExampleMenuFile_menucombovalueint'] = { nil, ImGuiVar_INT32 },
-- ShowExampleAppConsole
['var_ShowExampleAppConsole_filter'] = { nil, ImGuiVar_CDSTRING, 255 },
['var_ShowExampleAppConsole_input'] = { nil, ImGuiVar_CDSTRING, 255 },
-- ShowExampleAppConstrainedResize
['var_ShowExampleAppConstrainedResize_resizetype'] = { nil, ImGuiVar_INT32 },
-- ShowExampleAppLayout
['var_ShowExampleAppLayout_selected'] = { nil, ImGuiVar_INT32 },
-- ShowExampleAppLog
['var_ShowExampleAppLog_filter'] = { nil, ImGuiVar_CDSTRING, 255 },
-- ShowExampleAppLongText
['var_ShowExampleAppLongText_testtype'] = { nil, ImGuiVar_INT32 },
-- ShowExampleAppPropertyEditor
['var_ShowExampleAppPropertyEditor_dummyfloat'] = { nil, ImGuiVar_FLOAT, 1 },
-- ShowTestWindow
['var_ShowTestWindow'] = { nil, ImGuiVar_BOOLCPP },
['var_ShowTestWindow_showmainmenubar'] = { nil, ImGuiVar_BOOLCPP },
['var_ShowTestWindow_showconsole'] = { nil, ImGuiVar_BOOLCPP },
['var_ShowTestWindow_showlog'] = { nil, ImGuiVar_BOOLCPP },
['var_ShowTestWindow_showlayout'] = { nil, ImGuiVar_BOOLCPP },
['var_ShowTestWindow_showpropertyeditor'] = { nil, ImGuiVar_BOOLCPP },
['var_ShowTestWindow_showlongtext'] = { nil, ImGuiVar_BOOLCPP },
['var_ShowTestWindow_showautoresize'] = { nil, ImGuiVar_BOOLCPP },
['var_ShowTestWindow_showconstrainedresize'] = { nil, ImGuiVar_BOOLCPP },
['var_ShowTestWindow_showfixedoverlay'] = { nil, ImGuiVar_BOOLCPP },
['var_ShowTestWindow_showmanipulatingwindowtitle'] = { nil, ImGuiVar_BOOLCPP },
['var_ShowTestWindow_showcustomrendering'] = { nil, ImGuiVar_BOOLCPP },
['var_ShowTestWindow_showstyleeditor'] = { nil, ImGuiVar_BOOLCPP },
['var_ShowTestWindow_showmetrics'] = { nil, ImGuiVar_BOOLCPP },
['var_ShowTestWindow_showabout'] = { nil, ImGuiVar_BOOLCPP },
['var_ShowTestWindow_no_titlebar'] = { nil, ImGuiVar_BOOLCPP },
['var_ShowTestWindow_no_border'] = { nil, ImGuiVar_BOOLCPP, true },
['var_ShowTestWindow_no_resize'] = { nil, ImGuiVar_BOOLCPP },
['var_ShowTestWindow_no_move'] = { nil, ImGuiVar_BOOLCPP },
['var_ShowTestWindow_no_scrollbar'] = { nil, ImGuiVar_BOOLCPP },
['var_ShowTestWindow_no_collapse'] = { nil, ImGuiVar_BOOLCPP },
['var_ShowTestWindow_no_menu'] = { nil, ImGuiVar_BOOLCPP },
['var_ShowTestWindow_tree_aligncurrentx'] = { nil, ImGuiVar_BOOLCPP },
['var_ShowTestWindow_closable_group'] = { nil, ImGuiVar_BOOLCPP },
['var_ShowTestWindow_selectable_1'] = { nil, ImGuiVar_BOOLCPP, false },
['var_ShowTestWindow_selectable_2'] = { nil, ImGuiVar_BOOLCPP, true },
['var_ShowTestWindow_selectable_3'] = { nil, ImGuiVar_BOOLCPP, false },
['var_ShowTestWindow_selectable_4'] = { nil, ImGuiVar_BOOLCPP, false },
['var_ShowTestWindow_selectable_5'] = { nil, ImGuiVar_BOOLCPP, false },
['var_ShowTestWindow_selectable_6'] = { nil, ImGuiVar_BOOLCPP, false },
['var_ShowTestWindow_selectable_7'] = { nil, ImGuiVar_BOOLCPP, false },
['var_ShowTestWindow_selectable_8'] = { nil, ImGuiVar_BOOLCPP, false },
['var_ShowTestWindow_selectable_9'] = { nil, ImGuiVar_BOOLCPP, false },
['var_ShowTestWindow_selectable_grid_0'] = { nil, ImGuiVar_BOOLCPP, true },
['var_ShowTestWindow_selectable_grid_1'] = { nil, ImGuiVar_BOOLCPP, false },
['var_ShowTestWindow_selectable_grid_2'] = { nil, ImGuiVar_BOOLCPP, false },
['var_ShowTestWindow_selectable_grid_3'] = { nil, ImGuiVar_BOOLCPP, false },
['var_ShowTestWindow_selectable_grid_4'] = { nil, ImGuiVar_BOOLCPP, false },
['var_ShowTestWindow_selectable_grid_5'] = { nil, ImGuiVar_BOOLCPP, true },
['var_ShowTestWindow_selectable_grid_6'] = { nil, ImGuiVar_BOOLCPP, false },
['var_ShowTestWindow_selectable_grid_7'] = { nil, ImGuiVar_BOOLCPP, false },
['var_ShowTestWindow_selectable_grid_8'] = { nil, ImGuiVar_BOOLCPP, false },
['var_ShowTestWindow_selectable_grid_9'] = { nil, ImGuiVar_BOOLCPP, false },
['var_ShowTestWindow_selectable_grid_10'] = { nil, ImGuiVar_BOOLCPP, true },
['var_ShowTestWindow_selectable_grid_11'] = { nil, ImGuiVar_BOOLCPP, false },
['var_ShowTestWindow_selectable_grid_12'] = { nil, ImGuiVar_BOOLCPP, false },
['var_ShowTestWindow_selectable_grid_13'] = { nil, ImGuiVar_BOOLCPP, false },
['var_ShowTestWindow_selectable_grid_14'] = { nil, ImGuiVar_BOOLCPP, false },
['var_ShowTestWindow_selectable_grid_15'] = { nil, ImGuiVar_BOOLCPP, true },
['var_ShowTestWindow_filteredtxt_def'] = { nil, ImGuiVar_CDSTRING, 64 },
['var_ShowTestWindow_filteredtxt_dec'] = { nil, ImGuiVar_CDSTRING, 64 },
['var_ShowTestWindow_filteredtxt_hex'] = { nil, ImGuiVar_CDSTRING, 64 },
['var_ShowTestWindow_filteredtxt_upper'] = { nil, ImGuiVar_CDSTRING, 64 },
['var_ShowTestWindow_filteredtxt_noblank'] = { nil, ImGuiVar_CDSTRING, 64 },
['var_ShowTestWindow_filteredtxt_imgui'] = { nil, ImGuiVar_CDSTRING, 64 },
['var_ShowTestWindow_filteredtxt_pass'] = { nil, ImGuiVar_CDSTRING, 64 },
['var_ShowTestWindow_multiline_readonly'] = { nil, ImGuiVar_BOOLCPP, false },
['var_ShowTestWindow_multiline_buffer'] = { nil, ImGuiVar_CDSTRING, 16384 },
['var_ShowTestWindow_radiobutton_example'] = { nil, ImGuiVar_INT32, 0 },
['var_ShowTestWindow_misc_combo1'] = { nil, ImGuiVar_INT32, 1 },
['var_ShowTestWindow_misc_combo2'] = { nil, ImGuiVar_INT32, -1 },
['var_ShowTestWindow_misc_str0'] = { nil, ImGuiVar_CDSTRING, 128 },
['var_ShowTestWindow_misc_i0'] = { nil, ImGuiVar_INT32, 123 },
['var_ShowTestWindow_misc_f0'] = { nil, ImGuiVar_FLOAT, 0.001 },
['var_ShowTestWindow_misc_vec4a'] = { nil, ImGuiVar_FLOATARRAY, 4 },
['var_ShowTestWindow_misc_i1'] = { nil, ImGuiVar_INT32, 50 },
['var_ShowTestWindow_misc_i2'] = { nil, ImGuiVar_INT32, 42 },
['var_ShowTestWindow_misc_f1'] = { nil, ImGuiVar_FLOAT, 1.0 },
['var_ShowTestWindow_misc_f2'] = { nil, ImGuiVar_FLOAT, 0.0067 },
['var_ShowTestWindow_misc_angle'] = { nil, ImGuiVar_FLOAT, 0.0 },
['var_ShowTestWindow_misc_color3'] = { nil, ImGuiVar_FLOATARRAY, 3 },
['var_ShowTestWindow_misc_color4'] = { nil, ImGuiVar_FLOATARRAY, 4 },
['var_ShowTestWindow_misc_list1'] = { nil, ImGuiVar_INT32, 1 },
['var_ShowTestWindow_misc_rangefb'] = { nil, ImGuiVar_FLOAT, 10.0 },
['var_ShowTestWindow_misc_rangefe'] = { nil, ImGuiVar_FLOAT, 90.0 },
['var_ShowTestWindow_misc_rangeib'] = { nil, ImGuiVar_INT32, 100 },
['var_ShowTestWindow_misc_rangeie'] = { nil, ImGuiVar_INT32, 1000 },
['var_ShowTestWindow_misc_vec4f'] = { nil, ImGuiVar_FLOATARRAY, 4 },
['var_ShowTestWindow_misc_vec4i'] = { nil, ImGuiVar_INT32ARRAY, 4 },
['var_ShowTestWindow_misc_vslideri'] = { nil, ImGuiVar_INT32, 0 },
['var_ShowTestWindow_misc_vsliderf'] = { nil, ImGuiVar_FLOAT, 0.4 },
};
----------------------------------------------------------------------------------------------------
-- func: ShowHelpMarker
-- desc: Shows a tooltip.
----------------------------------------------------------------------------------------------------
local function ShowHelpMarker(desc)
imgui.TextDisabled('(?)');
if (imgui.IsItemHovered()) then
imgui.SetTooltip(desc);
end
end
----------------------------------------------------------------------------------------------------
-- func: ShowUserGuide
-- desc: Shows the user guide.
----------------------------------------------------------------------------------------------------
local function ShowUserGuide()
imgui.BulletText("Double-click on title bar to collapse window.");
imgui.BulletText("Click and drag on lower right corner to resize window.");
imgui.BulletText("Click and drag on any empty space to move window.");
imgui.BulletText("Mouse Wheel to scroll.");
--if (imgui.GetIO().FontAllowUserScaling)
-- imgui.BulletText("CTRL+Mouse Wheel to zoom window contents.");
imgui.BulletText("TAB/SHIFT+TAB to cycle through keyboard editable fields.");
imgui.BulletText("CTRL+Click on a slider or drag box to input text.");
imgui.BulletText([[
While editing text:
- Hold SHIFT or use mouse to select text
- CTRL+Left/Right to word jump
- CTRL+A or double-click to select all
- CTRL+X,CTRL+C,CTRL+V clipboard
- CTRL+Z,CTRL+Y undo/redo
- ESCAPE to revert
- You can apply arithmetic operators +,*,/ on numerical values.
Use +- to subtract.]]);
end
----------------------------------------------------------------------------------------------------
-- desc: Console window implementation.
----------------------------------------------------------------------------------------------------
local Console =
{
Commands = { 'HELP', 'HISTORY', 'CLEAR', 'CLASSIFY' },
History = { 'test', 'test1', 'test2', 'test3' },
HistoryPos = -1,
Lines = { 'Welcome to ImGui!' },
ScrollToBottom = false,
ClearLog = function(self)
self.Lines = { }
self.ScrollToBottom = true;
end,
AddLog = function(self, str)
table.insert(self.Lines, str);
self.ScrollToBottom = true;
end,
Draw = function(self, title)
imgui.SetNextWindowSize(520, 600, ImGuiSetCond_FirstUseEver);
if (not imgui.Begin(title, variables['var_ShowTestWindow_showconsole'])) then
imgui.End();
return;
end
imgui.TextWrapped('This example implements a console with basic coloring, completion and history. A more elaborate implementation may want to store entries along with extra data such as timestamp, emitter, etc.');
imgui.TextWrapped('Enter \'HELP\' for help, press TAB to use text completion.');
if (imgui.SmallButton('Add Dummy Text')) then
self:AddLog(string.format('%d some text', #self.Lines));
self:AddLog('some more text');
self:AddLog('display very important message here!');
end
imgui.SameLine();
if (imgui.SmallButton('Add Dummy Error')) then
self:AddLog('[error] something went wrong');
end
imgui.SameLine();
if (imgui.SmallButton('Clear')) then
self:ClearLog();
end
imgui.SameLine();
if (imgui.SmallButton('Scroll To Bottom')) then
self.ScrollToBottom = true;
end
imgui.Separator();
imgui.PushStyleVar(ImGuiStyleVar_FramePadding, 0, 0);
imgui.InputText('Filter (\"incl,-excl\") (\"error\")', variables['var_ShowExampleAppConsole_filter'][1], 255);
imgui.PopStyleVar();
imgui.Separator();
imgui.BeginChild('ScrollingRegion', 0, -imgui.GetItemsLineHeightWithSpacing(), false, ImGuiWindowFlags_HorizontalScrollbar);
if (imgui.BeginPopupContextWindow()) then
if (imgui.Selectable('Clear')) then
self:ClearLog();
end
imgui.EndPopup();
end
imgui.PushStyleVar(ImGuiStyleVar_ItemSpacing, 4, 1);
for x = 1, #self.Lines do
local filter = imgui.GetVarValue(variables['var_ShowExampleAppConsole_filter'][1]);
local skip = false;
-- We use Text to draw each item separately to allow custom coloring..
-- Because of this we need to do custom filtering a little different..
local line = self.Lines[x];
if (filter ~= nil and #filter > 0) then
if (line:contains(filter) == false) then
skip = true;
end
end
if (skip == false) then
if (line:startswith('[error]')) then
imgui.PushStyleColor(ImGuiCol_Text, 1.0, 0.4, 0.4, 1.0);
elseif (line:startswith('# ')) then
imgui.PushStyleColor(ImGuiCol_Text, 1.0, 0.78, 0.58, 1.0);
else
imgui.PushStyleColor(ImGuiCol_Text, 1.0, 1.0, 1.0, 1.0);
end
imgui.TextUnformatted(line);
imgui.PopStyleColor();
end
end
if (self.ScrollToBottom) then
imgui.SetScrollHere();
end
self.ScrollToBottom = false;
imgui.PopStyleVar();
imgui.EndChild();
imgui.Separator();
-- Command-line
if (imgui.InputText('Input', variables['var_ShowExampleAppConsole_input'][1], 255, imgui.bor(ImGuiInputTextFlags_EnterReturnsTrue, ImGuiInputTextFlags_CallbackCompletion, ImGuiInputTextFlags_CallbackHistory), 'ConsoleInputCallback')) then
local cmd = imgui.GetVarValue(variables['var_ShowExampleAppConsole_input'][1]);
if (cmd ~= nil and #cmd > 0 and #cmd:trim() > 0) then
self:ExecCommand(cmd);
end
imgui.SetVarValue(variables['var_ShowExampleAppConsole_input'][1], '');
end
-- Demonstrate keeping auto focus on the input box
if (imgui.IsItemHovered() or (imgui.IsRootWindowOrAnyChildFocused() and imgui.IsAnyItemActive() == false and imgui.IsMouseClicked(0) == false)) then
imgui.SetKeyboardFocusHere(-1);
end
imgui.End();
end,
ExecCommand = function(self, cmd)
self:AddLog(string.format('# %s', cmd));
-- Insert into the history..
self.HistoryPos = -1;
table.insert(self.History, cmd);
-- Process command..
if (cmd:lower() == 'clear') then
self:ClearLog();
elseif (cmd:lower() == 'help') then
for _, v in pairs(self.Commands) do
self:AddLog(string.format('- %s', v));
end
elseif (cmd:lower() == 'history') then
for _, v in pairs(self.History) do
self:AddLog(string.format('- %s', v));
end
else
self:AddLog(string.format('Unknown command: \'%s\'\n', cmd));
end
end
};
----------------------------------------------------------------------------------------------------
-- func: ConsoleInputCallback
-- desc: Handles history and completion for the console window input.
----------------------------------------------------------------------------------------------------
function ConsoleInputCallback(data)
-- Walk the input history..
if (data.EventFlag == ImGuiInputTextFlags_CallbackHistory) then
local prev_history_pos = Console.HistoryPos;
if (data.EventKey == ImGuiKey_UpArrow) then
if (Console.HistoryPos == -1) then
Console.HistoryPos = #Console.History;
elseif (Console.HistoryPos > 0) then
Console.HistoryPos = Console.HistoryPos - 1;
if (Console.HistoryPos == 0) then
Console.HistoryPos = -1;
end
end
elseif (data.EventKey == ImGuiKey_DownArrow) then
if (Console.HistoryPos == -1) then
Console.HistoryPos = 1;
elseif (Console.HistoryPos <= #Console.History) then
Console.HistoryPos = Console.HistoryPos + 1;
if (Console.HistoryPos == #Console.History + 1) then
Console.HistoryPos = -1;
end
end
end
if (prev_history_pos ~= Console.HistoryPos) then
local history = '';
if (Console.HistoryPos >= 0) then
history = Console.History[Console.HistoryPos];
end
data.CursorPos = #history;
data.SelectionStart = #history;
data.SelectionEnd = #history;
data.BufTextLen = #history;
data.Buf = history;
data.BufDirty = true;
end
-- Auto-complete the input..
elseif (data.EventFlag == ImGuiInputTextFlags_CallbackCompletion) then
-- Get the current input..
local input = imgui.GetVarValue(variables['var_ShowExampleAppConsole_input'][1]);
-- Walk backward to find the start of the current word..
local word_start = data.CursorPos;
while word_start > 0 do
local c = string.sub(input, word_start - 1, word_start - 1);
if (c == ' ' or c == '\t' or c == ',' or c == ';') then
break;
end
word_start = word_start - 1;
end
local tocomplete = string.sub(input, word_start, -1):lower();
-- Find candidates we can complete from our command list..
local candidates = { };
for _, v in pairs(Console.Commands) do
if (v:lower():startswith(tocomplete, #tocomplete)) then
table.insert(candidates, v);
end
end
if (#candidates == 0) then
-- No matches..
Console:AddLog(string.format('No match for \'%.s\'!\n', tocomplete));
elseif (#candidates == 1) then
-- Single match, replace..
local new = '';
if (word_start == 0) then
new = candidates[1]:lower();
else
new = string.sub(input, 1, word_start - 1) .. candidates[1]:lower();
end
data.CursorPos = #new;
data.SelectionStart = #new;
data.SelectionEnd = #new;
data.BufTextLen = #new;
data.Buf = new;
data.BufDirty = true;
else
-- Multiple matches, walk the found candidates and find the furthest character placement
-- that the candidates match upto and alter the users input to that, then display all
-- found candidates that can be used.
local match_len = data.CursorPos - word_start;
while 1 == 1 do
local c = 0;
local all_candidates_matches = true;
for x = 1, #candidates do
if (all_candidates_matches) then
if (x == 1) then
c = string.sub(candidates[x], match_len + 1, match_len + 1):lower();
elseif (c ~= string.sub(candidates[x], match_len + 1, match_len + 1):lower()) then
all_candidates_matches = false;
end
end
end
if (all_candidates_matches == false) then
break;
end
match_len = match_len + 1;
end
if (match_len > 0) then
local new = '';
if (word_start == 0) then
new = string.sub(candidates[1], 1, match_len):lower();
else
new = string.sub(input, 1, word_start - 1) .. string.sub(candidates[1], 1, match_len):lower();
end
data.CursorPos = #new;
data.SelectionStart = #new;
data.SelectionEnd = #new;
data.BufTextLen = #new;
data.Buf = new;
data.BufDirty = true;
end
Console:AddLog('Possible matches:\n');
for x = 1, #candidates do
Console:AddLog(string.format('- %s\n', candidates[x]));
end
end
end
return 0;
end
----------------------------------------------------------------------------------------------------
-- func: ShowExampleAppConsole
-- desc: Shows the example console.
----------------------------------------------------------------------------------------------------
local function ShowExampleAppConsole()
Console:Draw('Example: Console');
end
----------------------------------------------------------------------------------------------------
-- desc: Log window implementation.
----------------------------------------------------------------------------------------------------
local Log =
{
Lines = { },
ScrollToBottom = false,
Clear = function(self)
self.Lines = { };
end,
AddLog = function(self, str)
table.insert(self.Lines, str);
self.ScrollToBottom = true;
end,
Draw = function(self, title)
imgui.SetNextWindowSize(500, 400, ImGuiSetCond_FirstUseEver);
imgui.Begin(title, variables['var_ShowTestWindow_showlog'][1]);
if (imgui.Button('Clear')) then
self:Clear();
end
imgui.SameLine();
local copy = imgui.Button('Copy');
imgui.SameLine();
-- Note: We can't use imgui filtering so lets do it ourself..
imgui.InputText('filter', variables['var_ShowExampleAppLog_filter'][1], 255);
imgui.Separator();
imgui.BeginChild('scrolling', 0, 0, false, ImGuiWindowFlags_HorizontalScrollbar);
if (copy) then
imgui.LogToClipboard();
end
local filter = imgui.GetVarValue(variables['var_ShowExampleAppLog_filter'][1]);
if (filter ~= nil and #filter > 0) then
-- Note: We can't use imgui filtering so lets do it ourself..
local filtered = { };
for k, v in pairs(self.Lines) do
if (v:contains(filter)) then
table.insert(filtered, v);
end
end
imgui.TextUnformatted(table.concat(filtered, ''));
else
imgui.TextUnformatted(table.concat(self.Lines, ''));
end
if (self.ScrollToBottom) then
imgui.SetScrollHere(1.0);
end
self.ScrollToBottom = false;
imgui.EndChild();
imgui.End();
end
};
----------------------------------------------------------------------------------------------------
-- func: ShowExampleAppLog
-- desc: Shows the example log.
----------------------------------------------------------------------------------------------------
local function ShowExampleAppLog()
local random_words = { 'system', 'info', 'warning', 'error', 'fatal', 'notice', 'log' };
local time = imgui.GetTime();
if (time - ShowExampleAppLog_lasttime >= 0.3) then
Log:AddLog(string.format('[%s] Hello, time is %.1f, rand() %d\n', random_words[math.random(1, #random_words)], time, math.random(1, 10000)));
ShowExampleAppLog_lasttime = time;
end
Log:Draw('Example: Log');
end
----------------------------------------------------------------------------------------------------
-- func: ShowExampleAppLayout
-- desc: Shows the example app layout.
----------------------------------------------------------------------------------------------------
local function ShowExampleAppLayout()
imgui.SetNextWindowSize(500, 440, ImGuiSetCond_FirstUseEver);
if (imgui.Begin('Example: Layout', variables['var_ShowTestWindow_showlayout'][1], ImGuiWindowFlags_MenuBar)) then
if (imgui.BeginMenuBar()) then
if (imgui.BeginMenu('File')) then
if (imgui.MenuItem('Close')) then
imgui.SetVarValue(variables['var_ShowTestWindow_showlayout'][1], false);
end
imgui.EndMenu();
end
imgui.EndMenuBar();
end
-- Left
imgui.BeginChild('left pane', 150, 0, true);
for x = 0, 100 do
local name = string.format('MyObject %d', x);
if (imgui.Selectable(name, imgui.GetVarValue(variables['var_ShowExampleAppLayout_selected'][1]) == x)) then
imgui.SetVarValue(variables['var_ShowExampleAppLayout_selected'][1], x);
end
end
imgui.EndChild();
imgui.SameLine();
-- Right
imgui.BeginGroup();
imgui.BeginChild('item view', 0, -imgui.GetItemsLineHeightWithSpacing());
imgui.Text(string.format('MyObject: %d', imgui.GetVarValue(variables['var_ShowExampleAppLayout_selected'][1])));
imgui.Separator();
imgui.TextWrapped('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ');
imgui.EndChild();
imgui.BeginChild('buttons');
if (imgui.Button('Revert')) then end
imgui.SameLine();
if (imgui.Button('Save')) then end
imgui.EndChild();
imgui.EndGroup();
end
imgui.End();
end
----------------------------------------------------------------------------------------------------
-- func: ShowExampleAppPropertyEditor
-- desc: Shows the example property editor.
----------------------------------------------------------------------------------------------------
local function ShowExampleAppPropertyEditor()
imgui.SetNextWindowSize(430, 450, ImGuiSetCond_FirstUseEver);
if (not imgui.Begin('Example: Property Editor', variables['var_ShowTestWindow_showpropertyeditor'][1])) then
imgui.End();
return;
end
ShowHelpMarker('This example shows how you may implement a property editor using two columns.\nAll objects/fields data are dummies here.\nRemember that in many simple cases, you can use ImGui::SameLine(xxx) to position\nyour cursor horizontally instead of using the Columns() API.');
imgui.PushStyleVar(ImGuiStyleVar_FramePadding, 2, 2);
imgui.Columns(2);
imgui.Separator();
------------------------------------------------------------------------------------------------
-- func: ShowDummyObject
-- desc: Displays some dummy property information.
------------------------------------------------------------------------------------------------
local function ShowDummyObject(prefix, uid)
imgui.PushID(uid);
imgui.AlignFirstTextHeightToWidgets();
local node_open = imgui.TreeNode('Object', string.format('%s_%u', prefix, uid));
imgui.NextColumn();
imgui.AlignFirstTextHeightToWidgets();
imgui.Text('my sailor is rich');
imgui.NextColumn();
if (node_open) then
for x = 0, 7 do
imgui.PushID(x);
if (x < 2) then
ShowDummyObject('Child', 424242);
else
imgui.AlignFirstTextHeightToWidgets();
imgui.Bullet();
imgui.Selectable(string.format('Field_%d', x));
imgui.NextColumn();
imgui.PushItemWidth(-1);
if (x >= 5) then
imgui.InputFloat('##value', variables['var_ShowExampleAppPropertyEditor_dummyfloat'][1], 1.0);
else
imgui.DragFloat('##value', variables['var_ShowExampleAppPropertyEditor_dummyfloat'][1], 0.01);
end
imgui.PopItemWidth();
imgui.NextColumn();
end
imgui.PopID();
end
imgui.TreePop();
end
imgui.PopID();
end
-- Iterate dummy objects with dummy members (all the same data)..
for x = 0, 2 do
ShowDummyObject('Object', x);
end
imgui.Columns(1);
imgui.Separator();
imgui.PopStyleVar();
imgui.End();
end
----------------------------------------------------------------------------------------------------
-- func: ShowExampleAppLongText
-- desc: Shows the example long text window.
----------------------------------------------------------------------------------------------------
local function ShowExampleAppLongText()
imgui.SetNextWindowSize(520, 600, ImGuiSetCond_FirstUseEver);
if (not imgui.Begin('Example: Long Text Display', variables['var_ShowTestWindow_showlongtext'][1])) then
imgui.End();
return;
end
imgui.Text('Printing unusually long amount of text.');
imgui.Combo('Test type', variables['var_ShowExampleAppLongText_testtype'][1], 'Single call to TextUnformatted()\0Multiple calls to Text(), clipped manually\0Multiple calls to Text(), not clipped\0\0');
imgui.Text(string.format('Buffer contents: %d lines, %d bytes', #ShowExampleAppLongText_lines, 0));
if (imgui.Button('Clear')) then
ShowExampleAppLongText_lines = { };
end
imgui.SameLine();
if (imgui.Button('Add 1000 Lines')) then
local lines = #ShowExampleAppLongText_lines;
for x = 0, 999 do
table.insert(ShowExampleAppLongText_lines, string.format('%d The quick brown fox jumps over the lazy dog\n', lines + x));
end
end
imgui.BeginChild('Log');
switch (imgui.GetVarValue(variables['var_ShowExampleAppLongText_testtype'][1])) : caseof {
-- Single call to TextUnformatted
[0] = function()
imgui.TextUnformatted(table.concat(ShowExampleAppLongText_lines, ''));
end,
-- Multiple text calls with ImGuiListClipper (not supported)..
[1] = function()
-- Note: ImGuiListClipper is not supported within Lua so this example is not available..
imgui.PushStyleVar(ImGuiStyleVar_ItemSpacing, 0, 0);
imgui.TextColored(1.0, 0.0, 0.0, 1.0, 'Warning: The methods used by this test are not supported.');
imgui.PopStyleVar();
end,
-- Multiple text calls with no clipping. (slow)
[2] = function()
for x = 0, #ShowExampleAppLongText_lines do
imgui.PushStyleVar(ImGuiStyleVar_ItemSpacing, 0, 0);
imgui.Text(string.format('%d The quick brown fox jumps over the lazy dog', x));
imgui.PopStyleVar();
end
end
};
imgui.EndChild();
imgui.End();
end
----------------------------------------------------------------------------------------------------
-- func: ShowExampleAppAutoResize
-- desc: Shows the example auto-resize window.
----------------------------------------------------------------------------------------------------
local function ShowExampleAppAutoResize()
if (imgui.Begin('Example: Auto-resizing window', variables['var_ShowTestWindow_showautoresize'][1], ImGuiWindowFlags_AlwaysAutoResize) == false) then
imgui.End();
return;
end
imgui.Text("Window will resize every-frame to the size of its content.\nNote that you probably don't want to query the window size to\noutput your content because that would create a feedback loop.");
imgui.SliderInt('Number of Lines', variables['var_ShowExampleAppAutoResize_numberoflines'][1], 1, 20);
for x = 0, imgui.GetVarValue(variables['var_ShowExampleAppAutoResize_numberoflines'][1]) do
imgui.Text(string.format('%sThis is line %d', string.rep(' ', x*4), x));
end
imgui.End();
end
----------------------------------------------------------------------------------------------------
-- func: CastToInt
-- desc: Mimics a C style casting from float to int. (Value is ceil'd down.)
----------------------------------------------------------------------------------------------------
function CastToInt(num)
--local mult = 10 ^ 0;
--return math.ceil(num * mult - 0.5) / mult;
return tonumber(string.format('%d', num));
end
----------------------------------------------------------------------------------------------------
-- func: SquareResizeConstraint
-- desc: Window constraint callback to enforce a square sized window.
----------------------------------------------------------------------------------------------------
function SquareResizeConstraint(data)
data.DesiredSize = ImVec2(math.max(data.DesiredSize.x, data.DesiredSize.y), math.max(data.DesiredSize.x, data.DesiredSize.y));
end
----------------------------------------------------------------------------------------------------
-- func: StepResizeConstraint
-- desc: Window constraint callback to enforce a step sized window.
----------------------------------------------------------------------------------------------------
function StepResizeConstraint(data)
local step = 100;
data.DesiredSize = ImVec2(CastToInt(data.DesiredSize.x / step + 0.5) * step, CastToInt(data.DesiredSize.y / step + 0.5) * step);
end
----------------------------------------------------------------------------------------------------
-- func: ShowExampleAppConstrainedResize
-- desc: Shows the example constrained resize window.
----------------------------------------------------------------------------------------------------
local function ShowExampleAppConstrainedResize()
switch (imgui.GetVarValue(variables['var_ShowExampleAppConstrainedResize_resizetype'][1])) : caseof {
-- Vertical only..
[0] = function()
imgui.SetNextWindowSizeConstraints(-1, 0, -1, FLT_MAX);
end,
-- Horizontal only..
[1] = function()
imgui.SetNextWindowSizeConstraints(0, -1, FLT_MAX, -1);
end,
-- Width > 100, Height > 100
[2] = function()
imgui.SetNextWindowSizeConstraints(100, 100, FLT_MAX, FLT_MAX);
end,
-- Width 300-400
[3] = function()
imgui.SetNextWindowSizeConstraints(300, 0, 400, FLT_MAX);
end,
-- Square resizing constraint
[4] = function()
imgui.SetNextWindowSizeConstraints(0, 0, FLT_MAX, FLT_MAX, 'SquareResizeConstraint');
end,
-- Step resizing constraint
[5] = function()
imgui.SetNextWindowSizeConstraints(0, 0, FLT_MAX, FLT_MAX, 'StepResizeConstraint');
end
};
if (imgui.Begin('Example: Constrained Resize', variables['var_ShowTestWindow_showconstrainedresize'][1])) then
local desc = 'Resize vertical only\0Resize horizontal only\0Width > 100, Height > 100\0Width 300-400\0Custom: Always Square\0Custom: Fixed Steps (100)\0\0';
imgui.Combo('Constraint', variables['var_ShowExampleAppConstrainedResize_resizetype'][1], desc);
if (imgui.Button('200x200')) then
imgui.SetWindowSize(200, 200);
end
imgui.SameLine();
if (imgui.Button('500x500')) then
imgui.SetWindowSize(500, 500);
end
imgui.SameLine();
if (imgui.Button('800x200')) then
imgui.SetWindowSize(800, 200);
end
for x = 0, 10 do
imgui.Text('Hello, sailor! Making this line long enough for the example.');
end
end
imgui.End();
end
----------------------------------------------------------------------------------------------------
-- func: ShowExampleAppFixedOverlay
-- desc: Shows the example fixed overlay.
----------------------------------------------------------------------------------------------------
local function ShowExampleAppFixedOverlay()
imgui.SetNextWindowPos(10, 10);
if (not imgui.Begin('Example: Fixed Overlay', variables['var_ShowTestWindow_showfixedoverlay'][1], 0, 0, 0.3, imgui.bor(ImGuiWindowFlags_NoTitleBar,ImGuiWindowFlags_NoResize,ImGuiWindowFlags_NoMove,ImGuiWindowFlags_NoSavedSettings))) then
imgui.End();
return;
end
imgui.Text('Simple overlay\non the top-left side of the screen.');
imgui.Separator();
imgui.Text(string.format('Mouse Position: (%.1f,%.1f)', imgui.io.MousePos.x, imgui.io.MousePos.y));
imgui.End();
end
----------------------------------------------------------------------------------------------------
-- func: ShowExampleAppManipulatingWindowTitle
-- desc: Shows the example manipulating window title windows.
----------------------------------------------------------------------------------------------------
local function ShowExampleAppManipulatingWindowTitle()
imgui.SetNextWindowPos(100, 100, ImGuiSetCond_FirstUseEver);
imgui.Begin('Same title as another window##1');
imgui.Text('This is window 1.\nMy title is the same as window 2, but my identifier is unique.');
imgui.End();
imgui.SetNextWindowPos(100, 200, ImGuiSetCond_FirstUseEver);
imgui.Begin('Same title as another window##2');
imgui.Text('This is window 2.\nMy title is the same as window 1, but my identifier is unique.');
imgui.End();
-- Using '###' to display a changing title but keep a static identifier..
local chars = "|/-\\";
local pos = bit.band(imgui.GetTime() / 0.25, 3) + 1;
local title = string.format('Animated title %s %f###AnimatedTitle', chars:sub(pos, pos), math.random());
imgui.SetNextWindowPos(100, 300, ImGuiSetCond_FirstUseEver);
imgui.Begin(title);
imgui.Text('This window has a changing title.');
imgui.End();
end
----------------------------------------------------------------------------------------------------
-- func: ShowExampleAppCustomRendering
-- desc: Shows the example custom rendering window.
----------------------------------------------------------------------------------------------------
local function ShowExampleAppCustomRendering()
-- Todo: Implement this when possible..
imgui.SetNextWindowSize(350, 560, ImGuiSetCond_FirstUseEver);
if (not imgui.Begin('Example: Custom Rendering', variables['var_ShowTestWindow_showcustomrendering'][1])) then
imgui.End();
return;
end
imgui.TextColored(1.0, 0.0, 0.0, 1.0, 'Warning: The methods used by this example are not exposed to Lua.');
imgui.End();
end
----------------------------------------------------------------------------------------------------
-- func: ShowExampleMenuFile
-- desc: Shows the example file menu.
----------------------------------------------------------------------------------------------------
local function ShowExampleMenuFile()
imgui.MenuItem('(dummy menu)', nil, false, false);
if (imgui.MenuItem('New')) then end
if (imgui.MenuItem('Open', 'CTRL+O')) then end
if (imgui.BeginMenu('Open Recent')) then
imgui.MenuItem('fish_hat.c');
imgui.MenuItem('fish_hat.inl');
imgui.MenuItem('fish_hat.h');
if (imgui.BeginMenu('More..')) then
imgui.MenuItem('Hello');
imgui.MenuItem('Sailor');
if (imgui.BeginMenu('Recurse..')) then
ShowExampleMenuFile();
imgui.EndMenu();
end
imgui.EndMenu();
end
imgui.EndMenu();
end
if (imgui.MenuItem('Save', 'CTRL+S')) then end
if (imgui.MenuItem('Save As..')) then end
imgui.Separator();
if (imgui.BeginMenu('Options')) then
imgui.MenuItem('Enabled', '', variables['var_ShowExampleMenuFile_menuitemenabled'][1]);
imgui.BeginChild('child', 0, 60, true);
for x = 0, 10 do
imgui.Text(string.format('Scrolling text %d', x));
end
imgui.EndChild();
imgui.SliderFloat('Value', variables['var_ShowExampleMenuFile_menuslidervaluefloat'][1], 0.0, 1.0);
imgui.InputFloat('Input', variables['var_ShowExampleMenuFile_menuinputvaluefloat'][1], 0.1);
imgui.Combo('Combo', variables['var_ShowExampleMenuFile_menucombovalueint'][1], 'Yes\0No\0Maybe\0\0');
imgui.EndMenu();
end
if (imgui.BeginMenu('Colors')) then
for x = 0, ImGuiCol_ModalWindowDarkening do
imgui.MenuItem(imgui.GetStyleColName(x));
end
imgui.EndMenu();
end
if (imgui.BeginMenu('Disabled', false)) then
print('Should not get here!');
end
if (imgui.MenuItem('Checked', nil, true)) then end
if (imgui.MenuItem('Quit', 'Alt+F4')) then end
end
----------------------------------------------------------------------------------------------------
-- func: ShowExampleAppMainMenuBar
-- desc: Shows the example main menu bar.
----------------------------------------------------------------------------------------------------
local function ShowExampleAppMainMenuBar()
if (imgui.BeginMainMenuBar()) then
if (imgui.BeginMenu('File')) then
ShowExampleMenuFile();
imgui.EndMenu();
end
if (imgui.BeginMenu('Edit')) then
if (imgui.MenuItem('Undo', 'CTRL+Z')) then end
if (imgui.MenuItem('Redo', 'CTRL+Y', false, false)) then end
imgui.Separator();
if (imgui.MenuItem('Cut', 'CTRL+X')) then end
if (imgui.MenuItem('Copy', 'CTRL+C')) then end
if (imgui.MenuItem('Paste', 'CTRL+V')) then end
imgui.EndMenu();
end
imgui.EndMainMenuBar();
end
end
----------------------------------------------------------------------------------------------------
-- func: FilterImGuiLetters
-- desc: Filters the incoming input for keys that match the word 'imgui'.
----------------------------------------------------------------------------------------------------
function FilterImGuiLetters(data)
if (data.EventChar < 256) then
if (string.contains('imgui', string.char(data.EventChar))) then
return 0;
end
end
return 1;
end
----------------------------------------------------------------------------------------------------
-- func: ShowTestWindow
-- desc: Shows the test window.
----------------------------------------------------------------------------------------------------
local function ShowTestWindow()
if (imgui.GetVarValue(variables['var_ShowTestWindow_showmainmenubar'][1])) then ShowExampleAppMainMenuBar(); end
if (imgui.GetVarValue(variables['var_ShowTestWindow_showconsole'][1])) then ShowExampleAppConsole(); end
if (imgui.GetVarValue(variables['var_ShowTestWindow_showlog'][1])) then ShowExampleAppLog(); end
if (imgui.GetVarValue(variables['var_ShowTestWindow_showlayout'][1])) then ShowExampleAppLayout(); end
if (imgui.GetVarValue(variables['var_ShowTestWindow_showpropertyeditor'][1])) then ShowExampleAppPropertyEditor(); end
if (imgui.GetVarValue(variables['var_ShowTestWindow_showlongtext'][1])) then ShowExampleAppLongText(); end
if (imgui.GetVarValue(variables['var_ShowTestWindow_showautoresize'][1])) then ShowExampleAppAutoResize(); end
if (imgui.GetVarValue(variables['var_ShowTestWindow_showconstrainedresize'][1])) then ShowExampleAppConstrainedResize(); end
if (imgui.GetVarValue(variables['var_ShowTestWindow_showfixedoverlay'][1])) then ShowExampleAppFixedOverlay(); end
if (imgui.GetVarValue(variables['var_ShowTestWindow_showmanipulatingwindowtitle'][1])) then ShowExampleAppManipulatingWindowTitle(); end
if (imgui.GetVarValue(variables['var_ShowTestWindow_showcustomrendering'][1])) then ShowExampleAppCustomRendering(); end
if (imgui.GetVarValue(variables['var_ShowTestWindow_showmetrics'][1])) then
imgui.ShowMetricsWindow(variables['var_ShowTestWindow_showmetrics'][1]);
end
if (imgui.GetVarValue(variables['var_ShowTestWindow_showstyleeditor'][1])) then
imgui.Begin('Style Editor', variables['var_ShowTestWindow_showstyleeditor'][1]);
imgui.ShowStyleEditor();
imgui.End();
end
if (imgui.GetVarValue(variables['var_ShowTestWindow_showabout'][1])) then
imgui.Begin("About ImGui", variables['var_ShowTestWindow_showabout'][1], ImGuiWindowFlags_AlwaysAutoResize);
imgui.Text(string.format("dear imgui, %s", imgui.GetVersion()));
imgui.Separator();
imgui.Text("By Omar Cornut and all github contributors.");
imgui.Text("ImGui is licensed under the MIT License, see LICENSE for more information.");
imgui.Text('ImGui Lua API / Bindings by atom0s');
imgui.End();
end
-- Demonstrate the various window flags. Typically you would just use the default..
local window_flags = 0;
if (imgui.GetVarValue(variables['var_ShowTestWindow_no_titlebar'][1]) == true) then
window_flags = bit.bor(window_flags, ImGuiWindowFlags_NoTitleBar);
end
if (imgui.GetVarValue(variables['var_ShowTestWindow_no_border'][1]) == false) then
window_flags = bit.bor(window_flags, ImGuiWindowFlags_ShowBorders);
end
if (imgui.GetVarValue(variables['var_ShowTestWindow_no_resize'][1]) == true) then
window_flags = bit.bor(window_flags, ImGuiWindowFlags_NoResize);
end
if (imgui.GetVarValue(variables['var_ShowTestWindow_no_move'][1]) == true) then
window_flags = bit.bor(window_flags, ImGuiWindowFlags_NoMove);
end
if (imgui.GetVarValue(variables['var_ShowTestWindow_no_scrollbar'][1]) == true) then
window_flags = bit.bor(window_flags, ImGuiWindowFlags_NoScrollbar);
end
if (imgui.GetVarValue(variables['var_ShowTestWindow_no_collapse'][1]) == true) then
window_flags = bit.bor(window_flags, ImGuiWindowFlags_NoCollapse);
end
if (imgui.GetVarValue(variables['var_ShowTestWindow_no_menu'][1]) == false) then
window_flags = bit.bor(window_flags, ImGuiWindowFlags_MenuBar);
end
imgui.SetNextWindowSize(550, 680, ImGuiSetCond_FirstUseEver);
if (imgui.Begin('ImGui Demo', variables['var_ShowTestWindow'][1], window_flags) == false) then
-- Early out if the window is collapsed, as an optimization..
imgui.End();
return;
end
imgui.PushItemWidth(-140);
imgui.Text('Dear ImGui says hello.');
-- Menu
if (imgui.BeginMenuBar()) then
if (imgui.BeginMenu("Menu")) then
ShowExampleMenuFile();
imgui.EndMenu();
end
if (imgui.BeginMenu("Examples")) then
imgui.MenuItem("Main menu bar", nil, variables['var_ShowTestWindow_showmainmenubar'][1]);
imgui.MenuItem("Console", nil, variables['var_ShowTestWindow_showconsole'][1]);
imgui.MenuItem("Log", nil, variables['var_ShowTestWindow_showlog'][1]);
imgui.MenuItem("Simple layout", nil, variables['var_ShowTestWindow_showlayout'][1]);
imgui.MenuItem("Property editor", nil, variables['var_ShowTestWindow_showpropertyeditor'][1]);
imgui.MenuItem("Long text display", nil, variables['var_ShowTestWindow_showlongtext'][1]);
imgui.MenuItem("Auto-resizing window", nil, variables['var_ShowTestWindow_showautoresize'][1]);
imgui.MenuItem("Constrained-resizing window", nil, variables['var_ShowTestWindow_showconstrainedresize'][1]);
imgui.MenuItem("Simple overlay", nil, variables['var_ShowTestWindow_showfixedoverlay'][1]);
imgui.MenuItem("Manipulating window title", nil, variables['var_ShowTestWindow_showmanipulatingwindowtitle'][1]);
imgui.MenuItem("Custom rendering", nil, variables['var_ShowTestWindow_showcustomrendering'][1]);
imgui.EndMenu();
end
if (imgui.BeginMenu("Help")) then
imgui.MenuItem("Metrics", nil, variables['var_ShowTestWindow_showmetrics'][1]);
imgui.MenuItem("Style Editor", nil, variables['var_ShowTestWindow_showstyleeditor'][1]);
imgui.MenuItem("About ImGui", nil, variables['var_ShowTestWindow_showabout'][1]);
imgui.EndMenu();
end
imgui.EndMenuBar();
end
-- User Guide
imgui.Spacing();
if (imgui.CollapsingHeader('Help')) then
imgui.TextWrapped('This window is being created by the ShowTestWindow() function. Please refer to the code for programming reference.\n\nUser Guide:');
ShowUserGuide();
end
-- Window Options
if (imgui.CollapsingHeader('Window Options')) then
imgui.Checkbox('No titlebar', variables['var_ShowTestWindow_no_titlebar'][1]);
imgui.SameLine(150);
imgui.Checkbox('No Border', variables['var_ShowTestWindow_no_border'][1]);
imgui.SameLine(300);
imgui.Checkbox('No Resize', variables['var_ShowTestWindow_no_resize'][1]);
imgui.Checkbox('No Move', variables['var_ShowTestWindow_no_move'][1]);
imgui.SameLine(150);
imgui.Checkbox('No Scrollbar', variables['var_ShowTestWindow_no_scrollbar'][1]);
imgui.SameLine(300);
imgui.Checkbox('No Collapse', variables['var_ShowTestWindow_no_collapse'][1]);
imgui.Checkbox('No Menu', variables['var_ShowTestWindow_no_menu'][1]);
-- Style
if (imgui.TreeNode('Style')) then
imgui.ShowStyleEditor();
imgui.TreePop();
end
-- Logging
if (imgui.TreeNode('Logging')) then
imgui.TextWrapped('The logging API redirects all text output so you can easily capture the content of a window or a block. Tree nodes can be automatically expanded. You can also call ImGui::LogText() to output directly to the log without a visual output.');
imgui.LogButtons();
imgui.TreePop();
end
end
-- Widgets
if (imgui.CollapsingHeader('Widgets')) then
-- Trees
if (imgui.TreeNode('Trees')) then
if (imgui.TreeNode('Basic Trees')) then
for x = 0, 4 do
if (imgui.TreeNode(tostring(x), string.format('Child %d', x))) then
imgui.Text('blah blah');
imgui.SameLine();
if (imgui.SmallButton('print')) then
print(string.format('Child %d was pressed!', x));
end
imgui.TreePop();
end
end
imgui.TreePop();
end
if (imgui.TreeNode('Advanced, With Selectable Nodes')) then
ShowHelpMarker('This is a more standard looking tree with selectable nodes.\nClick to select, CTRL+Click to toggle, click on arrows or double-click to open.');
imgui.Checkbox('Align Label With Current X Position', variables['var_ShowTestWindow_tree_aligncurrentx'][1]);
imgui.Text('Hello!');
if (imgui.GetVarValue(variables['var_ShowTestWindow_tree_aligncurrentx'][1]) == true) then
imgui.Unindent(imgui.GetTreeNodeToLabelSpacing());
end
local node_clicked = -1;
imgui.PushStyleVar(ImGuiStyleVar_IndentSpacing, imgui.GetFontSize() * 3);
for x = 0, 5 do
local isSelected = 0;
if (bit.band(ShowTestWindow_tree_selection_mask, bit.lshift(1, x)) > 0) then
isSelected = ImGuiTreeNodeFlags_Selected;
end
local node_flags = imgui.bor(ImGuiTreeNodeFlags_OpenOnArrow, ImGuiTreeNodeFlags_OpenOnDoubleClick, isSelected);
if (x < 3) then
local node_open = imgui.TreeNodeEx(tostring(x), node_flags, string.format('Selectable Node: %d', x));
if (imgui.IsItemClicked()) then
node_clicked = x;
end
if (node_open) then
imgui.Text('Blah Blah\nBlah Blah');
imgui.TreePop();
end
else
imgui.TreeNodeEx(tostring(x), imgui.bor(node_flags, ImGuiTreeNodeFlags_Leaf, ImGuiTreeNodeFlags_NoTreePushOnOpen), string.format('Selectable Leaf: %d', x));
if (imgui.IsItemClicked()) then
node_clicked = x;
end
end
end
-- Update selection state. (Process outside of tree loop to avoid visual inconsistencies during the clicking-frame.')
if (node_clicked ~= -1) then
if (imgui.io.KeyCtrl) then
-- CTRL+Click to toggle..
ShowTestWindow_tree_selection_mask = bit.bxor(ShowTestWindow_tree_selection_mask, bit.lshift(1, node_clicked));
else
-- Click to single select..
ShowTestWindow_tree_selection_mask = bit.lshift(1, node_clicked);
end
end
imgui.PopStyleVar();
if (imgui.GetVarValue(variables['var_ShowTestWindow_tree_aligncurrentx'][1]) == true) then
imgui.Indent(imgui.GetTreeNodeToLabelSpacing());
end
imgui.TreePop();
end
imgui.TreePop();
end
-- Collapsing Headers
if (imgui.TreeNode('Collapsing Headers')) then
if (imgui.CollapsingHeader('Header')) then
imgui.Checkbox('Enable Extra Group', variables['var_ShowTestWindow_closable_group'][1]);
for x = 0, 4 do
imgui.Text(string.format('Some Content %d', x));
end
end
if (imgui.CollapsingHeader('Header, With Close Button', variables['var_ShowTestWindow_closable_group'][1])) then
for x = 0, 4 do
imgui.Text(string.format('Mode Content %d', x));
end
end
imgui.TreePop();
end
-- Bullets
if (imgui.TreeNode('Bullets')) then
imgui.BulletText('Bullet Point 1');
imgui.BulletText('Bullet Point 2\nOn multiple lines');
imgui.Bullet();
imgui.Text('Bullet Point 3 (two calls)');
imgui.Bullet();
imgui.SmallButton('Button');
imgui.TreePop();
end
-- Colored Text
if (imgui.TreeNode('Colored Text')) then
imgui.TextColored(1.0, 0.0, 1.0, 1.0, 'Pink');
imgui.TextColored(1.0, 1.0, 0.0, 1.0, 'Yellow');
imgui.TextDisabled('Disabled');
imgui.TreePop();
end
-- Word Wrapping
if (imgui.TreeNode('Word Wrapping')) then
imgui.TextWrapped('This text should automatically wrap on the edge of the window. The current implementation for text wrapping follows simple rules suitable for English and possibly other languages.');
imgui.Spacing();
-- Todo: Possibly finish the other parts of this example.
-- Todo: At this time, GetWindowDrawList is not implemented.
imgui.TextColored(1.0, 1.0, 0.0, 1.0, 'Warning: Some examples could not be translated to Lua for this section!');
imgui.TreePop();
end
-- UTF-8 Text
if (imgui.TreeNode('UTF-8 Text')) then
-- Todo: Possibly finish the other parts of this example.
-- Todo: At this time, UTF-8 friendly font is not used.
imgui.TextColored(1.0, 1.0, 0.0, 1.0, 'Warning: Some examples could not be translated to Lua for this section!');
imgui.TreePop();
end
-- Images
if (imgui.TreeNode('Images')) then
-- Todo: Possibly finish the other parts of this example.
imgui.TextColored(1.0, 1.0, 0.0, 1.0, 'Warning: Some examples could not be translated to Lua for this section!');
imgui.TreePop();
end
-- Selectables
if (imgui.TreeNode('Selectables')) then
-- Basic
if (imgui.TreeNode('Basic')) then
imgui.Selectable('1. I am selectable', variables['var_ShowTestWindow_selectable_1'][1]);
imgui.Selectable('2. I am selectable', variables['var_ShowTestWindow_selectable_2'][1]);
imgui.Text('3. I am not selectable');
imgui.Selectable('4. I am selectable', variables['var_ShowTestWindow_selectable_3'][1]);
if (imgui.Selectable('5. I am double clickable', imgui.GetVarValue(variables['var_ShowTestWindow_selectable_4'][1]), ImGuiSelectableFlags_AllowDoubleClick)) then
if (imgui.IsMouseDoubleClicked(0)) then
imgui.SetVarValue(variables['var_ShowTestWindow_selectable_4'][1], not imgui.GetVarValue(variables['var_ShowTestWindow_selectable_4'][1]));
end
end
imgui.TreePop();
end
-- Rendering More Text
if (imgui.TreeNode('Rendering More Text Into Same Block')) then
imgui.Selectable('main.c', variables['var_ShowTestWindow_selectable_1'][1]);
imgui.SameLine(300);
imgui.Text(' 2,345 bytes');
imgui.Selectable('Hello.cpp', variables['var_ShowTestWindow_selectable_2'][1]);
imgui.SameLine(300);
imgui.Text('12,345 bytes');
imgui.Selectable('Hello.h', variables['var_ShowTestWindow_selectable_3'][1]);
imgui.SameLine(300);
imgui.Text(' 2,345 bytes');
imgui.TreePop();
end
-- In Columns
if (imgui.TreeNode('In Columns')) then
imgui.Columns(3, nil, false);
for x = 0, 8 do
if (imgui.Selectable(string.format('Item %d', x), variables['var_ShowTestWindow_selectable_' .. tostring(x + 1)][1])) then end
imgui.NextColumn();
end
imgui.Columns(1);
imgui.TreePop();
end
-- In Grid
if (imgui.TreeNode('In Grid')) then
for i = 0, 15 do
imgui.PushID(i);
if (imgui.Selectable('Sailor\n ' .. tostring(i), variables['var_ShowTestWindow_selectable_grid_' .. tostring(i)][1], 0, 50, 50)) then
local x = tonumber(string.format('%d', (i % 4)));
local y = tonumber(string.format('%d', (i / 4)));
if (x > 0) then
imgui.SetVarValue(variables['var_ShowTestWindow_selectable_grid_' .. tostring(i - 1)][1], not imgui.GetVarValue(variables['var_ShowTestWindow_selectable_grid_' .. tostring(i - 1)][1]));
end
if (x < 3) then
imgui.SetVarValue(variables['var_ShowTestWindow_selectable_grid_' .. tostring(i + 1)][1], not imgui.GetVarValue(variables['var_ShowTestWindow_selectable_grid_' .. tostring(i + 1)][1]));
end
if (y > 0) then
print(tostring(i-4));
imgui.SetVarValue(variables['var_ShowTestWindow_selectable_grid_' .. tostring(i - 4)][1], not imgui.GetVarValue(variables['var_ShowTestWindow_selectable_grid_' .. tostring(i - 4)][1]));
end
if (y < 3) then
imgui.SetVarValue(variables['var_ShowTestWindow_selectable_grid_' .. tostring(i + 4)][1], not imgui.GetVarValue(variables['var_ShowTestWindow_selectable_grid_' .. tostring(i + 4)][1]));
end
end
if ((i % 4) < 3) then
imgui.SameLine();
end
imgui.PopID();
end
imgui.TreePop();
end
imgui.TreePop();
end
-- Filtered Text Input
if (imgui.TreeNode('Filtered Text Input')) then
imgui.InputText('default', variables['var_ShowTestWindow_filteredtxt_def'][1], 64);
imgui.InputText('decimal', variables['var_ShowTestWindow_filteredtxt_dec'][1], 64, ImGuiInputTextFlags_CharsDecimal);
imgui.InputText('hexadecimal', variables['var_ShowTestWindow_filteredtxt_hex'][1], 64, imgui.bor(ImGuiInputTextFlags_CharsHexadecimal, ImGuiInputTextFlags_CharsUppercase));
imgui.InputText('uppercase', variables['var_ShowTestWindow_filteredtxt_upper'][1], 64, ImGuiInputTextFlags_CharsUppercase);
imgui.InputText('no blank', variables['var_ShowTestWindow_filteredtxt_noblank'][1], 64, ImGuiInputTextFlags_CharsNoBlank);
imgui.InputText('"imgui" letters', variables['var_ShowTestWindow_filteredtxt_imgui'][1], 64, ImGuiInputTextFlags_CallbackCharFilter, 'FilterImGuiLetters');
imgui.Text('Password Input');
imgui.InputText('password', variables['var_ShowTestWindow_filteredtxt_pass'][1], 64, imgui.bor(ImGuiInputTextFlags_Password, ImGuiInputTextFlags_CharsNoBlank));
imgui.SameLine();
ShowHelpMarker('Display all characters as \'*\'.\nDisable clipboard cut and copy.\nDisable logging.\n');
imgui.InputText('password (clear)', variables['var_ShowTestWindow_filteredtxt_pass'][1], 64, ImGuiInputTextFlags_CharsNoBlank);
imgui.TreePop();
end
-- Multiline Text Input
if (imgui.TreeNode('Multiline Text Input')) then
local isReadOnly = 0;
if (imgui.GetVarValue(variables['var_ShowTestWindow_multiline_readonly'][1]) == true) then
isReadOnly = ImGuiInputTextFlags_ReadOnly;
end
imgui.PushStyleVar(ImGuiStyleVar_FramePadding, 0, 0);
imgui.Checkbox('Read-only', variables['var_ShowTestWindow_multiline_readonly'][1]);
imgui.PopStyleVar();
imgui.InputTextMultiline('##source', variables['var_ShowTestWindow_multiline_buffer'][1], 16384, -1.0, imgui.GetTextLineHeight() * 16, imgui.bor(ImGuiInputTextFlags_AllowTabInput, isReadOnly));
imgui.TreePop();
end
-- Toggle Button
if (imgui.Button('Button')) then
print('Clicked');
ShowTestWindow_togglebutton_clicked = not ShowTestWindow_togglebutton_clicked;
end
if (ShowTestWindow_togglebutton_clicked) then
imgui.SameLine();
imgui.Text('Thanks for clicking me!');
end
-- Radio Buttons (Grouped)
imgui.RadioButton('radio a', variables['var_ShowTestWindow_radiobutton_example'][1], 0);
imgui.SameLine();
imgui.RadioButton('radio b', variables['var_ShowTestWindow_radiobutton_example'][1], 1);
imgui.SameLine();
imgui.RadioButton('radio c', variables['var_ShowTestWindow_radiobutton_example'][1], 2);
-- Colored Buttons
for x = 0, 6 do
if (x > 0) then
imgui.SameLine();
end
imgui.PushID(x);
local r, g, b = imgui.ColorConvertHSVtoRGB(x / 7.0, 0.6, 0.6);
imgui.PushStyleColor(ImGuiCol_Button, r, g, b, 1.0);
r, g, b = imgui.ColorConvertHSVtoRGB(x / 7.0, 0.7, 0.7);
imgui.PushStyleColor(ImGuiCol_ButtonHovered, r, g, b, 1.0);
r, g, b = imgui.ColorConvertHSVtoRGB(x / 7.0, 0.8, 0.8);
imgui.PushStyleColor(ImGuiCol_ButtonActive, r, g, b, 1.0);
imgui.Button('Click');
imgui.PopStyleColor(3);
imgui.PopID();
end
-- Tooltip
imgui.Text('Hover over me');
if (imgui.IsItemHovered()) then
imgui.SetTooltip('I am a tooltip');
end
imgui.SameLine();
imgui.Text('- or me');
if (imgui.IsItemHovered()) then
imgui.BeginTooltip();
imgui.Text('I am a fancy tooltip');
local arr = { 0.6, 0.1, 1.0, 0.5, 0.92, 0.1, 0.2 };
imgui.PlotLines('Curve', arr, #arr);
imgui.EndTooltip();
end
-- Misc Controls
imgui.Separator();
imgui.LabelText('label', 'Value');
-- Combo Boxes
imgui.Combo('combo', variables['var_ShowTestWindow_misc_combo1'][1], 'aaa\0bbb\0ccc\0ddd\0eee\0\0');
imgui.Combo('combo scroll', variables['var_ShowTestWindow_misc_combo2'][1], 'AAAA\0BBBB\0CCCC\0DDDD\0EEEE\0FFFF\0GGGG\0HHHH\0IIII\0JJJJ\0KKKK\0\0');
-- Misc Input Types
imgui.InputText('input text', variables['var_ShowTestWindow_misc_str0'][1], 128);
imgui.SameLine();
ShowHelpMarker('Hold SHIFT or use mouse to select text.\nCTRL+Left/Right to word jump.\nCTRL+A or double-click to select all.\nCTRL+X,CTRL+C,CTRL+V clipboard.\nCTRL+Z,CTRL+Y undo/redo.\nESCAPE to revert.\n');
imgui.InputInt('input int', variables['var_ShowTestWindow_misc_i0'][1]);
imgui.SameLine();
ShowHelpMarker('You can apply arithmetic operators +,*,/ on numerical values.\n e.g. [ 100 ], input \'*2\', result becomes [ 200 ]\nUse +- to subtract.\n');
imgui.InputFloat('input float', variables['var_ShowTestWindow_misc_f0'][1], 0.01, 1.0);
imgui.InputFloat3('input float3', variables['var_ShowTestWindow_misc_vec4a'][1]);
imgui.DragInt('drag int', variables['var_ShowTestWindow_misc_i1'][1], 1);
imgui.SameLine();
ShowHelpMarker('Click and drag to edit value.\nHold SHIFT/ALT for faster/slower edit.\nDouble-click or CTRL+click to input value.');
imgui.DragInt('drag int 0..100', variables['var_ShowTestWindow_misc_i2'][1], 1, 0, 100, '%.0f%%');
imgui.DragFloat('drag float', variables['var_ShowTestWindow_misc_f1'][1], 0.005);
imgui.DragFloat('drag small float', variables['var_ShowTestWindow_misc_f2'][1], 0.0001, 0.0, 0.0, '%.06f ns');
imgui.SliderInt('slider int', variables['var_ShowTestWindow_misc_i1'][1], -1, 3);
imgui.SameLine();
ShowHelpMarker('CTRL+Click to input value.');
imgui.SliderFloat('slider float', variables['var_ShowTestWindow_misc_f1'][1], 0.0, 1.0, 'ratio = %.3f');
imgui.SliderFloat('slider log float', variables['var_ShowTestWindow_misc_f2'][1], -10.0, 10.0, '%.4f', 3.0);
imgui.SliderAngle('slider angle', variables['var_ShowTestWindow_misc_angle'][1]);
-- Color Editors
imgui.ColorEdit3('color 1', variables['var_ShowTestWindow_misc_color3'][1]);
imgui.SameLine();
ShowHelpMarker('Click on the colored square to change edit mode.\nCTRL+click on individual component to input value.\n');
imgui.ColorEdit4('color 2', variables['var_ShowTestWindow_misc_color4'][1], true);
-- Listbox
imgui.ListBox('listbox\n(single select)', variables['var_ShowTestWindow_misc_list1'][1], 'Apple\0Banana\0Cherry\0Kiwi\0Mango\0Orange\0Pineapple\0Strawberry\0Watermelon\0\0', 4);
-- Range Widgets
if (imgui.TreeNode('Range Widgets')) then
imgui.Unindent();
imgui.DragFloatRange2('range', variables['var_ShowTestWindow_misc_rangefb'][1], variables['var_ShowTestWindow_misc_rangefe'][1], 0.25, 0.0, 100.0, 'Min: %.1f %%', 'Max: %.1f %%');
imgui.DragIntRange2('range int (no bounds)', variables['var_ShowTestWindow_misc_rangeib'][1], variables['var_ShowTestWindow_misc_rangeie'][1], 5, 0, 0, 'Min: %.0f units', 'Max: %.0f units');
imgui.Indent();
imgui.TreePop();
end
-- Multi-Component Widgets
if (imgui.TreeNode('Multi-Component Widgets')) then
imgui.Unindent();
imgui.InputFloat2('input float2', variables['var_ShowTestWindow_misc_vec4f'][1]);
imgui.DragFloat2('drag float2', variables['var_ShowTestWindow_misc_vec4f'][1], 0.01, 0.0, 1.0);
imgui.SliderFloat2('slider float2', variables['var_ShowTestWindow_misc_vec4f'][1], 0.0, 1.0);
imgui.DragInt2('drag int2', variables['var_ShowTestWindow_misc_vec4i'][1], 1, 0, 255);
imgui.InputInt2('input int2', variables['var_ShowTestWindow_misc_vec4i'][1]);
imgui.SliderInt2('slider int2', variables['var_ShowTestWindow_misc_vec4i'][1], 0, 255);
imgui.Spacing();
imgui.InputFloat3('input float3', variables['var_ShowTestWindow_misc_vec4f'][1]);
imgui.DragFloat3('drag float3', variables['var_ShowTestWindow_misc_vec4f'][1], 0.01, 0.0, 1.0);
imgui.SliderFloat3('slider float3', variables['var_ShowTestWindow_misc_vec4f'][1], 0.0, 1.0);
imgui.DragInt3('drag int3', variables['var_ShowTestWindow_misc_vec4i'][1], 1, 0, 255);
imgui.InputInt3('input int3', variables['var_ShowTestWindow_misc_vec4i'][1]);
imgui.SliderInt3('slider int3', variables['var_ShowTestWindow_misc_vec4i'][1], 0, 255);
imgui.Spacing();
imgui.InputFloat4('input float4', variables['var_ShowTestWindow_misc_vec4f'][1]);
imgui.DragFloat4('drag float4', variables['var_ShowTestWindow_misc_vec4f'][1], 0.01, 0.0, 1.0);
imgui.SliderFloat4('slider float4', variables['var_ShowTestWindow_misc_vec4f'][1], 0.0, 1.0);
imgui.DragInt4('drag int4', variables['var_ShowTestWindow_misc_vec4i'][1], 1, 0, 255);
imgui.InputInt4('input int4', variables['var_ShowTestWindow_misc_vec4i'][1]);
imgui.SliderInt4('slider int4', variables['var_ShowTestWindow_misc_vec4i'][1], 0, 255);
imgui.Indent();
imgui.TreePop();
end
-- Vertical Sliders
if (imgui.TreeNode('Vertical Sliders')) then
imgui.Unindent();
imgui.PushStyleVar(ImGuiStyleVar_ItemSpacing, 4, 4);
imgui.VSliderInt('##int', 18, 160, variables['var_ShowTestWindow_misc_vslideri'][1], 0, 5);
imgui.SameLine();
imgui.PushID('set1');
for x = 0, 6 do
if (x > 0) then
imgui.SameLine();
end
imgui.PushID(x);
local r, g, b = imgui.ColorConvertHSVtoRGB(x / 7.0, 0.5, 0.5);
imgui.PushStyleColor(ImGuiCol_FrameBg, r, g, b, 1.0);
r, g, b = imgui.ColorConvertHSVtoRGB(x / 7.0, 0.6, 0.5);
imgui.PushStyleColor(ImGuiCol_FrameBgHovered, r, g, b, 1.0);
r, g, b = imgui.ColorConvertHSVtoRGB(x / 7.0, 0.7, 0.5);
imgui.PushStyleColor(ImGuiCol_FrameBgActive, r, g, b, 1.0);
r, g, b = imgui.ColorConvertHSVtoRGB(x / 7.0, 0.9, 0.9);
imgui.PushStyleColor(ImGuiCol_SliderGrab, r, g, b, 1.0);
imgui.VSliderFloat('##v', 18, 160, variables['var_ShowTestWindow_misc_vsliderf'][1], 0.0, 1.0, '');
if (imgui.IsItemActive() or imgui.IsItemHovered()) then
imgui.SetTooltip(string.format('%.3f', imgui.GetVarValue(variables['var_ShowTestWindow_misc_vsliderf'][1])));
end
imgui.PopStyleColor(4);
imgui.PopID();
end
imgui.PopID(); -- set1
imgui.SameLine();
imgui.PushID('set2');
for nx = 0, 3 do
if (nx > 0) then
imgui.SameLine();
end
imgui.BeginGroup();
for ny = 0, 2 do
imgui.PushID(nx * 3 + ny);
imgui.VSliderFloat('##v', 18, (160.0 - (3 - 1) * 4) / 3, variables['var_ShowTestWindow_misc_vsliderf'][1], 0.0, 1.0, '');
if (imgui.IsItemActive() or imgui.IsItemHovered()) then
imgui.SetTooltip(string.format('%.3f', imgui.GetVarValue(variables['var_ShowTestWindow_misc_vsliderf'][1])));
end
imgui.PopID();
end
imgui.EndGroup();
end
imgui.PopID(); -- set2
imgui.SameLine();
imgui.PushID('set3');
for x = 0, 3 do
if (x > 0) then
imgui.SameLine();
end
imgui.PushID(x);
imgui.PushStyleVar(ImGuiStyleVar_GrabMinSize, 40);
imgui.VSliderFloat('##v', 40, 160, variables['var_ShowTestWindow_misc_vsliderf'][1], 0.0, 1.0, '%.2f\nsec');
imgui.PopStyleVar();
imgui.PopID();
end
imgui.PopID(); -- set3
imgui.PopStyleVar();
imgui.Indent();
imgui.TreePop();
end
end
-- Graphs Widgets
if (imgui.CollapsingHeader('Graphs Widgets')) then
imgui.TextColored(1.0, 0.0, 0.0, 1.0, 'Warning: This example is currently unfinished!');
end
-- Layout
if (imgui.CollapsingHeader('Layout')) then
imgui.TextColored(1.0, 0.0, 0.0, 1.0, 'Warning: This example is currently unfinished!');
end
-- Popups & Modal Windows
if (imgui.CollapsingHeader('Popups & Modal Windows')) then
imgui.TextColored(1.0, 0.0, 0.0, 1.0, 'Warning: This example is currently unfinished!');
end
-- Columns
if (imgui.CollapsingHeader('Columns')) then
imgui.TextColored(1.0, 0.0, 0.0, 1.0, 'Warning: This example is currently unfinished!');
end
-- Filtering
if (imgui.CollapsingHeader('Filtering')) then
imgui.TextColored(1.0, 0.0, 0.0, 1.0, 'Warning: This example is currently unfinished!');
end
-- Keyboard, Mouse & Focus
if (imgui.CollapsingHeader('Keyboard, Mouse & Focus')) then
imgui.TextColored(1.0, 0.0, 0.0, 1.0, 'Warning: This example is currently unfinished!');
end
-- Todo: Finish the other examples here..
-- Complete the window..
imgui.End();
end
----------------------------------------------------------------------------------------------------
-- func: load
-- desc: Called when the addon is loaded.
----------------------------------------------------------------------------------------------------
ashita.register_event('load', function()
-- Initialize the custom variables..
for k, v in pairs(variables) do
-- Create the variable..
if (v[2] >= ImGuiVar_CDSTRING) then
variables[k][1] = imgui.CreateVar(variables[k][2], variables[k][3]);
else
variables[k][1] = imgui.CreateVar(variables[k][2]);
end
-- Set a default value if present..
if (#v > 2 and v[2] < ImGuiVar_CDSTRING) then
imgui.SetVarValue(variables[k][1], variables[k][3]);
end
end
end);
----------------------------------------------------------------------------------------------------
-- func: unload
-- desc: Called when the addon is unloaded.
----------------------------------------------------------------------------------------------------
ashita.register_event('unload', function()
-- Cleanup the custom variables..
for k, v in pairs(variables) do
if (variables[k][1] ~= nil) then
imgui.DeleteVar(variables[k][1]);
end
variables[k][1] = nil;
end
end);
----------------------------------------------------------------------------------------------------
-- func: render
-- desc: Renders the addon objects.
----------------------------------------------------------------------------------------------------
ashita.register_event('render', function()
ShowTestWindow();
end);
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment