RigsofRods
Soft-body Physics Simulation
ImGuiAngelscript.cpp
Go to the documentation of this file.
1 /*
2  This source file is part of Rigs of Rods
3  Copyright 2005-2012 Pierre-Michel Ricordel
4  Copyright 2007-2012 Thomas Fischer
5  Copyright 2013-2022 Petr Ohlidal
6 
7  For more information, see http://www.rigsofrods.org/
8 
9  Rigs of Rods is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License version 3, as
11  published by the Free Software Foundation.
12 
13  Rigs of Rods is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
26 
27 #include "OgreImGui.h"
28 #include "scriptarray/scriptarray.h"
29 #include "ScriptEngine.h"
30 
31 #include <angelscript.h>
32 #include <Ogre.h>
33 #include <string>
34 
35 using namespace AngelScript;
36 using namespace Ogre;
37 using namespace std;
38 
39 float ImGuiPlotLinesScriptValueGetterFunc(void* data, int index)
40 {
41  CScriptArray* array_obj = static_cast<CScriptArray*>(data);
42  void* value_raw = array_obj->At(index);
43  if (value_raw == nullptr)
44  {
45  return 0.f; // out of bounds
46  }
47  else
48  {
49  return *static_cast<float*>(value_raw);
50  }
51 }
52 
53 void RoR::RegisterImGuiBindings(AngelScript::asIScriptEngine* engine)
54 {
55  // ENUMS (global namespace)
56 
57 
58  engine->RegisterEnum("ImGuiStyleVar");
59  engine->RegisterEnumValue("ImGuiStyleVar", "ImGuiStyleVar_Alpha", ImGuiStyleVar_Alpha); // float Alpha
60  engine->RegisterEnumValue("ImGuiStyleVar", "ImGuiStyleVar_WindowPadding", ImGuiStyleVar_WindowPadding); // ImVec2 WindowPadding
61  engine->RegisterEnumValue("ImGuiStyleVar", "ImGuiStyleVar_WindowRounding", ImGuiStyleVar_WindowRounding); // float WindowRounding
62  engine->RegisterEnumValue("ImGuiStyleVar", "ImGuiStyleVar_WindowBorderSize", ImGuiStyleVar_WindowBorderSize); // float WindowBorderSize
63  engine->RegisterEnumValue("ImGuiStyleVar", "ImGuiStyleVar_WindowMinSize", ImGuiStyleVar_WindowMinSize); // ImVec2 WindowMinSize
64  engine->RegisterEnumValue("ImGuiStyleVar", "ImGuiStyleVar_WindowTitleAlign", ImGuiStyleVar_WindowTitleAlign); // ImVec2 WindowTitleAlign
65  engine->RegisterEnumValue("ImGuiStyleVar", "ImGuiStyleVar_ChildRounding", ImGuiStyleVar_ChildRounding); // float ChildRounding
66  engine->RegisterEnumValue("ImGuiStyleVar", "ImGuiStyleVar_ChildBorderSize", ImGuiStyleVar_ChildBorderSize); // float ChildBorderSize
67  engine->RegisterEnumValue("ImGuiStyleVar", "ImGuiStyleVar_PopupRounding", ImGuiStyleVar_PopupRounding); // float PopupRounding
68  engine->RegisterEnumValue("ImGuiStyleVar", "ImGuiStyleVar_PopupBorderSize", ImGuiStyleVar_PopupBorderSize); // float PopupBorderSize
69  engine->RegisterEnumValue("ImGuiStyleVar", "ImGuiStyleVar_FramePadding", ImGuiStyleVar_FramePadding); // ImVec2 FramePadding
70  engine->RegisterEnumValue("ImGuiStyleVar", "ImGuiStyleVar_FrameRounding", ImGuiStyleVar_FrameRounding); // float FrameRounding
71  engine->RegisterEnumValue("ImGuiStyleVar", "ImGuiStyleVar_FrameBorderSize", ImGuiStyleVar_FrameBorderSize); // float FrameBorderSize
72  engine->RegisterEnumValue("ImGuiStyleVar", "ImGuiStyleVar_ItemSpacing", ImGuiStyleVar_ItemSpacing); // ImVec2 ItemSpacing
73  engine->RegisterEnumValue("ImGuiStyleVar", "ImGuiStyleVar_ItemInnerSpacing", ImGuiStyleVar_ItemInnerSpacing); // ImVec2 ItemInnerSpacing
74  engine->RegisterEnumValue("ImGuiStyleVar", "ImGuiStyleVar_IndentSpacing", ImGuiStyleVar_IndentSpacing); // float IndentSpacing
75  engine->RegisterEnumValue("ImGuiStyleVar", "ImGuiStyleVar_ScrollbarSize", ImGuiStyleVar_ScrollbarSize); // float ScrollbarSize
76  engine->RegisterEnumValue("ImGuiStyleVar", "ImGuiStyleVar_ScrollbarRounding", ImGuiStyleVar_ScrollbarRounding); // float ScrollbarRounding
77  engine->RegisterEnumValue("ImGuiStyleVar", "ImGuiStyleVar_GrabMinSize", ImGuiStyleVar_GrabMinSize); // float GrabMinSize
78  engine->RegisterEnumValue("ImGuiStyleVar", "ImGuiStyleVar_GrabRounding", ImGuiStyleVar_GrabRounding); // float GrabRounding
79  engine->RegisterEnumValue("ImGuiStyleVar", "ImGuiStyleVar_TabRounding", ImGuiStyleVar_TabRounding); // float TabRounding
80  engine->RegisterEnumValue("ImGuiStyleVar", "ImGuiStyleVar_ButtonTextAlign", ImGuiStyleVar_ButtonTextAlign); // ImVec2 ButtonTextAlign
81  engine->RegisterEnumValue("ImGuiStyleVar", "ImGuiStyleVar_SelectableTextAlign", ImGuiStyleVar_SelectableTextAlign); // ImVec2 SelectableTextAlign
82 
83  engine->RegisterEnum("ImGuiWindowFlags");
84  engine->RegisterEnumValue("ImGuiWindowFlags", "ImGuiWindowFlags_None", ImGuiWindowFlags_None);
85  engine->RegisterEnumValue("ImGuiWindowFlags", "ImGuiWindowFlags_NoTitleBar", ImGuiWindowFlags_NoTitleBar);
86  engine->RegisterEnumValue("ImGuiWindowFlags", "ImGuiWindowFlags_NoResize", ImGuiWindowFlags_NoResize);
87  engine->RegisterEnumValue("ImGuiWindowFlags", "ImGuiWindowFlags_NoMove", ImGuiWindowFlags_NoMove);
88  engine->RegisterEnumValue("ImGuiWindowFlags", "ImGuiWindowFlags_NoScrollbar", ImGuiWindowFlags_NoScrollbar);
89  engine->RegisterEnumValue("ImGuiWindowFlags", "ImGuiWindowFlags_NoScrollWithMouse", ImGuiWindowFlags_NoScrollWithMouse);
90  engine->RegisterEnumValue("ImGuiWindowFlags", "ImGuiWindowFlags_NoCollapse", ImGuiWindowFlags_NoCollapse);
91  engine->RegisterEnumValue("ImGuiWindowFlags", "ImGuiWindowFlags_AlwaysAutoResize", ImGuiWindowFlags_AlwaysAutoResize);
92  engine->RegisterEnumValue("ImGuiWindowFlags", "ImGuiWindowFlags_NoBackground", ImGuiWindowFlags_NoBackground);
93  engine->RegisterEnumValue("ImGuiWindowFlags", "ImGuiWindowFlags_NoSavedSettings", ImGuiWindowFlags_NoSavedSettings);
94  engine->RegisterEnumValue("ImGuiWindowFlags", "ImGuiWindowFlags_NoMouseInputs", ImGuiWindowFlags_NoMouseInputs);
95  engine->RegisterEnumValue("ImGuiWindowFlags", "ImGuiWindowFlags_MenuBar", ImGuiWindowFlags_MenuBar);
96  engine->RegisterEnumValue("ImGuiWindowFlags", "ImGuiWindowFlags_HorizontalScrollbar", ImGuiWindowFlags_HorizontalScrollbar);
97  engine->RegisterEnumValue("ImGuiWindowFlags", "ImGuiWindowFlags_NoFocusOnAppearing", ImGuiWindowFlags_NoFocusOnAppearing);
98  engine->RegisterEnumValue("ImGuiWindowFlags", "ImGuiWindowFlags_NoBringToFrontOnFocus", ImGuiWindowFlags_NoBringToFrontOnFocus);
99  engine->RegisterEnumValue("ImGuiWindowFlags", "ImGuiWindowFlags_AlwaysVerticalScrollbar", ImGuiWindowFlags_AlwaysVerticalScrollbar);
100  engine->RegisterEnumValue("ImGuiWindowFlags", "ImGuiWindowFlags_AlwaysHorizontalScrollbar", ImGuiWindowFlags_AlwaysHorizontalScrollbar);
101  engine->RegisterEnumValue("ImGuiWindowFlags", "ImGuiWindowFlags_AlwaysUseWindowPadding", ImGuiWindowFlags_AlwaysUseWindowPadding);
102  engine->RegisterEnumValue("ImGuiWindowFlags", "ImGuiWindowFlags_NoNavInputs", ImGuiWindowFlags_NoNavInputs);
103  engine->RegisterEnumValue("ImGuiWindowFlags", "ImGuiWindowFlags_NoNavFocus", ImGuiWindowFlags_NoNavFocus);
104  engine->RegisterEnumValue("ImGuiWindowFlags", "ImGuiWindowFlags_UnsavedDocument", ImGuiWindowFlags_UnsavedDocument);
105  engine->RegisterEnumValue("ImGuiWindowFlags", "ImGuiWindowFlags_NoNav", ImGuiWindowFlags_NoNav);
106  engine->RegisterEnumValue("ImGuiWindowFlags", "ImGuiWindowFlags_NoDecoration", ImGuiWindowFlags_NoDecoration);
107  engine->RegisterEnumValue("ImGuiWindowFlags", "ImGuiWindowFlags_NoInputs", ImGuiWindowFlags_NoInputs);
108 
109  // Enumeration for PushStyleColor() / PopStyleColor()
110  engine->RegisterEnum("ImGuiCol");
111  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_Text" , ImGuiCol_Text);
112  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_TextDisabled" , ImGuiCol_TextDisabled);
113  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_WindowBg" , ImGuiCol_WindowBg);
114  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_ChildBg" , ImGuiCol_ChildBg);
115  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_PopupBg" , ImGuiCol_PopupBg);
116  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_Border" , ImGuiCol_Border);
117  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_BorderShadow" , ImGuiCol_BorderShadow);
118  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_FrameBg" , ImGuiCol_FrameBg);
119  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_FrameBgHovered" , ImGuiCol_FrameBgHovered);
120  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_FrameBgActive" , ImGuiCol_FrameBgActive);
121  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_TitleBg" , ImGuiCol_TitleBg);
122  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_TitleBgActive" , ImGuiCol_TitleBgActive);
123  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_TitleBgCollapsed" , ImGuiCol_TitleBgCollapsed);
124  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_MenuBarBg" , ImGuiCol_MenuBarBg);
125  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_ScrollbarBg" , ImGuiCol_ScrollbarBg);
126  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_ScrollbarGrab" , ImGuiCol_ScrollbarGrab);
127  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_ScrollbarGrabHovered" , ImGuiCol_ScrollbarGrabHovered);
128  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_ScrollbarGrabActive" , ImGuiCol_ScrollbarGrabActive);
129  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_CheckMark" , ImGuiCol_CheckMark);
130  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_SliderGrab" , ImGuiCol_SliderGrab);
131  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_SliderGrabActive" , ImGuiCol_SliderGrabActive);
132  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_Button" , ImGuiCol_Button);
133  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_ButtonHovered" , ImGuiCol_ButtonHovered);
134  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_ButtonActive" , ImGuiCol_ButtonActive);
135  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_Header" , ImGuiCol_Header);
136  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_HeaderHovered" , ImGuiCol_HeaderHovered);
137  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_HeaderActive" , ImGuiCol_HeaderActive);
138  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_Separator" , ImGuiCol_Separator);
139  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_SeparatorHovered" , ImGuiCol_SeparatorHovered);
140  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_SeparatorActive" , ImGuiCol_SeparatorActive);
141  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_ResizeGrip" , ImGuiCol_ResizeGrip);
142  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_ResizeGripHovered" , ImGuiCol_ResizeGripHovered);
143  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_ResizeGripActive" , ImGuiCol_ResizeGripActive);
144  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_Tab" , ImGuiCol_Tab);
145  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_TabHovered" , ImGuiCol_TabHovered);
146  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_TabActive" , ImGuiCol_TabActive);
147  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_TabUnfocused" , ImGuiCol_TabUnfocused);
148  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_TabUnfocusedActive" , ImGuiCol_TabUnfocusedActive);
149  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_PlotLines" , ImGuiCol_PlotLines);
150  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_PlotLinesHovered" , ImGuiCol_PlotLinesHovered);
151  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_PlotHistogram" , ImGuiCol_PlotHistogram);
152  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_PlotHistogramHovered" , ImGuiCol_PlotHistogramHovered);
153  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_TextSelectedBg" , ImGuiCol_TextSelectedBg);
154  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_DragDropTarget" , ImGuiCol_DragDropTarget);
155  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_NavHighlight" , ImGuiCol_NavHighlight);
156  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_NavWindowingHighlight" , ImGuiCol_NavWindowingHighlight);
157  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_NavWindowingDimBg" , ImGuiCol_NavWindowingDimBg);
158  engine->RegisterEnumValue("ImGuiCol", "ImGuiCol_ModalWindowDimBg" , ImGuiCol_ModalWindowDimBg);
159 
160  engine->RegisterEnum("ImGuiCond");
161  engine->RegisterEnumValue("ImGuiCond", "ImGuiCond_Always", ImGuiCond_Always);
162  engine->RegisterEnumValue("ImGuiCond", "ImGuiCond_Once", ImGuiCond_Once); // Set the variable once per runtime session (only the first call with succeed)
163  engine->RegisterEnumValue("ImGuiCond", "ImGuiCond_FirstUseEver", ImGuiCond_FirstUseEver); // Set the variable if the object/window has no persistently saved data (no entry in .ini file)
164  engine->RegisterEnumValue("ImGuiCond", "ImGuiCond_Appearing", ImGuiCond_Appearing); // Set the variable if the object/window is appearing after being hidden/inactive (or the first time)
165 
166  engine->RegisterEnum("ImGuiTabBarFlags");
167  engine->RegisterEnumValue("ImGuiTabBarFlags", "ImGuiTabBarFlags_None", ImGuiTabBarFlags_None);
168  engine->RegisterEnumValue("ImGuiTabBarFlags", "ImGuiTabBarFlags_Reorderable", ImGuiTabBarFlags_Reorderable); // // Allow manually dragging tabs to re-order them + New tabs are appended at the end of list
169  engine->RegisterEnumValue("ImGuiTabBarFlags", "ImGuiTabBarFlags_AutoSelectNewTabs", ImGuiTabBarFlags_AutoSelectNewTabs); // // Automatically select new tabs when they appear
170  engine->RegisterEnumValue("ImGuiTabBarFlags", "ImGuiTabBarFlags_TabListPopupButton", ImGuiTabBarFlags_TabListPopupButton); // // Disable buttons to open the tab list popup
171  engine->RegisterEnumValue("ImGuiTabBarFlags", "ImGuiTabBarFlags_NoCloseWithMiddleMouseButton", ImGuiTabBarFlags_NoCloseWithMiddleMouseButton); // // Disable behavior of closing tabs (that are submitted with p_open != NULL) with middle mouse button. You can still repro this behavior on user's side with if (IsItemHovered() && IsMouseClicked(2)) *p_open = false.
172  engine->RegisterEnumValue("ImGuiTabBarFlags", "ImGuiTabBarFlags_NoTabListScrollingButtons", ImGuiTabBarFlags_NoTabListScrollingButtons); // // Disable scrolling buttons (apply when fitting policy is ImGuiTabBarFlags_FittingPolicyScroll)
173  engine->RegisterEnumValue("ImGuiTabBarFlags", "ImGuiTabBarFlags_NoTooltip", ImGuiTabBarFlags_NoTooltip); // // Disable tooltips when hovering a tab
174  engine->RegisterEnumValue("ImGuiTabBarFlags", "ImGuiTabBarFlags_FittingPolicyResizeDown", ImGuiTabBarFlags_FittingPolicyResizeDown); // // Resize tabs when they don't fit
175  engine->RegisterEnumValue("ImGuiTabBarFlags", "ImGuiTabBarFlags_FittingPolicyScroll", ImGuiTabBarFlags_FittingPolicyScroll); // // Add scroll buttons when tabs don't fit
176  engine->RegisterEnumValue("ImGuiTabBarFlags", "ImGuiTabBarFlags_FittingPolicyMask_", ImGuiTabBarFlags_FittingPolicyMask_); // ImGuiTabBarFlags_FittingPolicyResizeDown | ImGuiTabBarFlags_FittingPolicyScroll,
177  engine->RegisterEnumValue("ImGuiTabBarFlags", "ImGuiTabBarFlags_FittingPolicyDefault_", ImGuiTabBarFlags_FittingPolicyDefault_); // ImGuiTabBarFlags_FittingPolicyResizeDown
178 
179  engine->RegisterEnum("ImGuiTabItemFlags");
180  engine->RegisterEnumValue("ImGuiTabItemFlags", "ImGuiTabItemFlags_None", ImGuiTabItemFlags_None);
181  engine->RegisterEnumValue("ImGuiTabItemFlags", "ImGuiTabItemFlags_UnsavedDocument", ImGuiTabItemFlags_UnsavedDocument); // // Append '*' to title without affecting the ID, as a convenience to avoid using the ### operator. Also: tab is selected on closure and closure is deferred by one frame to allow code to undo it without flicker.
182  engine->RegisterEnumValue("ImGuiTabItemFlags", "ImGuiTabItemFlags_SetSelected", ImGuiTabItemFlags_SetSelected); // // Trigger flag to programmatically make the tab selected when calling BeginTabItem()
183  engine->RegisterEnumValue("ImGuiTabItemFlags", "ImGuiTabItemFlags_NoCloseWithMiddleMouseButton", ImGuiTabItemFlags_NoCloseWithMiddleMouseButton); // // Disable behavior of closing tabs (that are submitted with p_open != NULL) with middle mouse button. You can still repro this behavior on user's side with if (IsItemHovered() && IsMouseClicked(2)) *p_open = false.
184  engine->RegisterEnumValue("ImGuiTabItemFlags", "ImGuiTabItemFlags_NoPushId", ImGuiTabItemFlags_NoPushId); // // Don't call PushID(tab->ID)/PopID() on BeginTabItem()/EndTabItem()
185 
186 
187  // ImDrawList object (global namespace)
188  engine->RegisterObjectType("ImDrawList", sizeof(ImDrawList), asOBJ_REF | asOBJ_NOCOUNT);
189  engine->RegisterObjectMethod("ImDrawList", "void AddLine(const vector2&in p1, const vector2&in p2, const color&in col, float thickness = 1.f)", asFUNCTIONPR([](ImDrawList* drawlist, Ogre::Vector2 const& p1, Ogre::Vector2 const& p2, Ogre::ColourValue const& col, float thickness) { drawlist->AddLine(ImVec2(p1.x, p1.y), ImVec2(p2.x, p2.y), ImColor(col.r, col.g, col.b, col.a), thickness); }, (ImDrawList * , Ogre::Vector2 const& , Ogre::Vector2 const& , Ogre::ColourValue const& , float ), void), asCALL_CDECL_OBJFIRST);
190  engine->RegisterObjectMethod("ImDrawList", "void AddTriangle(const vector2&in p1, const vector2&in p2, const vector2&in p3, const color&in col, float thickness = 1.f)", asFUNCTIONPR([](ImDrawList* drawlist, Ogre::Vector2 const& p1, Ogre::Vector2 const& p2, Ogre::Vector2 const& p3, Ogre::ColourValue const& col, float thickness) { drawlist->AddTriangle(ImVec2(p1.x, p1.y), ImVec2(p2.x, p2.y), ImVec2(p3.x, p3.y), ImColor(col.r, col.g, col.b, col.a), thickness); }, (ImDrawList*, Ogre::Vector2 const&, Ogre::Vector2 const&, Ogre::Vector2 const&, Ogre::ColourValue const&, float), void), asCALL_CDECL_OBJFIRST);
191  engine->RegisterObjectMethod("ImDrawList", "void AddTriangleFilled(const vector2&in p1, const vector2&in p2, const vector2&in p3, const color&in col)", asFUNCTIONPR([](ImDrawList* drawlist, Ogre::Vector2 const& p1, Ogre::Vector2 const& p2, Ogre::Vector2 const& p3, Ogre::ColourValue const& col) { drawlist->AddTriangleFilled(ImVec2(p1.x, p1.y), ImVec2(p2.x, p2.y), ImVec2(p3.x, p3.y), ImColor(col.r, col.g, col.b, col.a)); }, (ImDrawList*, Ogre::Vector2 const&, Ogre::Vector2 const&, Ogre::Vector2 const&, Ogre::ColourValue const&), void), asCALL_CDECL_OBJFIRST);
192  engine->RegisterObjectMethod("ImDrawList", "void AddRect(const vector2&in p_min, const vector2&in p_max, const color&in col, float rounding = 0.0f, int rounding_corners = 15, float thickness = 1.f)", asFUNCTIONPR([](ImDrawList* drawlist, Ogre::Vector2 const& p1, Ogre::Vector2 const& p2, Ogre::ColourValue const& col, float rounding, int rounding_corners, float thickness) { drawlist->AddRect(ImVec2(p1.x, p1.y), ImVec2(p2.x, p2.y), ImColor(col.r, col.g, col.b, col.a), rounding, rounding_corners, thickness); }, (ImDrawList * drawlist, Ogre::Vector2 const& , Ogre::Vector2 const& , Ogre::ColourValue const& , float , int , float ), void), asCALL_CDECL_OBJFIRST);
193  engine->RegisterObjectMethod("ImDrawList", "void AddRectFilled(const vector2&in p_min, const vector2&in p_max, const color&in col, float rounding = 0.0f, int rounding_corners = 15)", asFUNCTIONPR([](ImDrawList* drawlist, Ogre::Vector2 const& p1, Ogre::Vector2 const& p2, Ogre::ColourValue const& col, float rounding, int rounding_corners) { drawlist->AddRectFilled(ImVec2(p1.x, p1.y), ImVec2(p2.x, p2.y), ImColor(col.r, col.g, col.b, col.a), rounding, rounding_corners); }, (ImDrawList * drawlist, Ogre::Vector2 const&, Ogre::Vector2 const&, Ogre::ColourValue const&, float, int), void), asCALL_CDECL_OBJFIRST);
194  engine->RegisterObjectMethod("ImDrawList", "void AddCircle(const vector2&in center, float radius, const color&in col, int num_segments = 12, float thickness = 1.f)", asFUNCTIONPR([](ImDrawList* drawlist, Ogre::Vector2 const& center, float radius, Ogre::ColourValue const& col, int num_segments, float thickness) { drawlist->AddCircle(ImVec2(center.x, center.y), radius, ImColor(col.r, col.g, col.b, col.a), num_segments, thickness); }, (ImDrawList*, Ogre::Vector2 const&, float, Ogre::ColourValue const&, int, float), void), asCALL_CDECL_OBJFIRST);
195  engine->RegisterObjectMethod("ImDrawList", "void AddCircleFilled(const vector2&in center, float radius, const color&in col, int num_segments = 12)", asFUNCTIONPR([](ImDrawList* drawlist, Ogre::Vector2 const& center, float radius, Ogre::ColourValue const& col, int num_segments) { drawlist->AddCircleFilled(ImVec2(center.x, center.y), radius, ImColor(col.r, col.g, col.b, col.a), num_segments); }, (ImDrawList*, Ogre::Vector2 const&, float, Ogre::ColourValue const&, int), void), asCALL_CDECL_OBJFIRST);
196  engine->RegisterObjectMethod("ImDrawList", "void AddText(const vector2&in pos, const color&in col, const string&in text)", asFUNCTIONPR([](ImDrawList* drawlist, Ogre::Vector2 const& pos, Ogre::ColourValue const& col, std::string const& text) { drawlist->AddText(ImVec2(pos.x, pos.y), ImColor(col.r, col.g, col.b, col.a), text.c_str()); }, (ImDrawList * drawlist, Ogre::Vector2 const&, Ogre::ColourValue const&, std::string const&), void), asCALL_CDECL_OBJFIRST);
197  engine->RegisterObjectMethod("ImDrawList", "void AddImage(const Ogre::TexturePtr&in tex, const vector2&in p_min, const vector2&in p_max, const vector2&in uv_min, const vector2&in uv_max, const color&in col)", asFUNCTIONPR([](ImDrawList* drawlist, Ogre::TexturePtr const& tex, Ogre::Vector2 const& p_min, Ogre::Vector2 const& p_max, Ogre::Vector2 const& uv_min, Ogre::Vector2 const& uv_max, Ogre::ColourValue const& col) { drawlist->AddImage((ImTextureID)tex->getHandle(), ImVec2(p_min.x, p_min.y), ImVec2(p_max.x, p_max.y), ImVec2(uv_min.x, uv_min.y), ImVec2(uv_max.x, uv_max.y), ImColor(col.r, col.g, col.b, col.a)); }, (ImDrawList*, Ogre::TexturePtr const&, Ogre::Vector2 const&, Ogre::Vector2 const&, Ogre::Vector2 const&, Ogre::Vector2 const&, Ogre::ColourValue const&), void), asCALL_CDECL_OBJFIRST);
198  // FUNCTIONS (namespace ImGui)
199  engine->SetDefaultNamespace("ImGui");
200 
201  // > Windows
202  engine->RegisterGlobalFunction("bool Begin(const string&in, bool&inout, int=0)", asFUNCTIONPR([](const string& name, bool& opened, int flags) { return ImGui::Begin(name.c_str(), &opened, flags); }, (const string&, bool&, int), bool), asCALL_CDECL);
203  engine->RegisterGlobalFunction("void End()", asFUNCTIONPR(ImGui::End, (), void), asCALL_CDECL);
204 
205  // > Child windows
206  engine->RegisterGlobalFunction("bool BeginChild(const string&in, const vector2&in=vector2(0,0), bool=false, int=0)", asFUNCTIONPR([](const string& name, const Ogre::Vector2& size, bool border, int flags) { return ImGui::BeginChild(name.c_str(), ImVec2(size.x, size.y), border, flags); }, (const string&, const Ogre::Vector2&, bool, int), bool), asCALL_CDECL);
207  engine->RegisterGlobalFunction("bool BeginChild(uint, const vector2&in=vector2(0,0), bool=false, int=0)", asFUNCTIONPR([](ImGuiID id, const Ogre::Vector2& size, bool border, int flags) { return ImGui::BeginChild(id, ImVec2(size.x, size.y), border, flags); }, (ImGuiID, const Ogre::Vector2&, bool, int), bool), asCALL_CDECL);
208  engine->RegisterGlobalFunction("void EndChild()", asFUNCTIONPR(ImGui::EndChild, (), void), asCALL_CDECL);
209  engine->RegisterGlobalFunction("ImDrawList@ GetWindowDrawList()", asFUNCTIONPR(ImGui::GetWindowDrawList, (), ImDrawList*), asCALL_CDECL);
210  engine->RegisterGlobalFunction("void PushStyleVar(int index, float val)", asFUNCTIONPR([](int index, float val) { ImGui::PushStyleVar(index,val); }, (int, float), void), asCALL_CDECL);
211  engine->RegisterGlobalFunction("void PushStyleVar(int index, const vector2&in val)", asFUNCTIONPR([](int index, const Ogre::Vector2& val) { ImGui::PushStyleVar(index, ImVec2(val.x, val.y)); }, (int, const Ogre::Vector2 &), void), asCALL_CDECL);
212  engine->RegisterGlobalFunction("void PopStyleVar(int count = 1)", asFUNCTION(ImGui::PopStyleVar), asCALL_CDECL);
213  engine->RegisterGlobalFunction("void PushStyleColor(int index, const color&in color)", asFUNCTIONPR([](int index, Ogre::ColourValue const& col) { ImGui::PushStyleColor(index, (ImU32)ImColor(col.r, col.g, col.b, col.a)); }, (int, Ogre::ColourValue const&), void), asCALL_CDECL);
214  engine->RegisterGlobalFunction("void PopStyleColor(int count = 1)", asFUNCTIONPR(ImGui::PopStyleColor, (int), void), asCALL_CDECL);
215  engine->RegisterGlobalFunction("void SetNextItemWidth(float)", asFUNCTIONPR(ImGui::SetNextItemWidth, (float), void), asCALL_CDECL);
216  engine->RegisterGlobalFunction("void SetNextItemOpen(bool, ImGuiCond)", asFUNCTIONPR(ImGui::SetNextItemOpen, (bool, int), void), asCALL_CDECL);
217 
218  engine->RegisterGlobalFunction("vector2 GetContentRegionMax()", asFUNCTIONPR([]() {
219  auto v = ImGui::GetContentRegionMax(); return Vector2(v.x, v.y); }, (), Vector2), asCALL_CDECL);
220  engine->RegisterGlobalFunction("vector2 GetContentRegionAvail()", asFUNCTIONPR([]() {
221  auto v = ImGui::GetContentRegionAvail(); return Vector2(v.x, v.y); }, (), Vector2), asCALL_CDECL);
222  engine->RegisterGlobalFunction("float GetContentRegionAvailWidth()", asFUNCTIONPR(ImGui::GetContentRegionAvailWidth, (), float), asCALL_CDECL);
223  engine->RegisterGlobalFunction("vector2 GetWindowContentRegionMin()", asFUNCTIONPR([]() {
224  auto v = ImGui::GetWindowContentRegionMin(); return Vector2(v.x, v.y); }, (), Vector2), asCALL_CDECL);
225  engine->RegisterGlobalFunction("vector2 GetWindowContentRegionMax()", asFUNCTIONPR([]() {
226  auto v = ImGui::GetWindowContentRegionMax(); return Vector2(v.x, v.y); }, (), Vector2), asCALL_CDECL);
227  engine->RegisterGlobalFunction("float GetWindowRegionWidth()", asFUNCTIONPR(ImGui::GetWindowContentRegionWidth, (), float), asCALL_CDECL);
228 
229  engine->RegisterGlobalFunction("vector2 GetWindowPos()", asFUNCTIONPR([]() {
230  auto v = ImGui::GetWindowPos(); return Vector2(v.x, v.y); }, (), Vector2), asCALL_CDECL);
231  engine->RegisterGlobalFunction("vector2 GetWindowSize()", asFUNCTIONPR([]() {
232  auto v = ImGui::GetWindowSize(); return Vector2(v.x, v.y); }, (), Vector2), asCALL_CDECL);
233  engine->RegisterGlobalFunction("float GetWindowWedth()", asFUNCTIONPR(ImGui::GetWindowWidth, (), float), asCALL_CDECL);
234  engine->RegisterGlobalFunction("float GetWindowHeight()", asFUNCTIONPR(ImGui::GetWindowHeight, (), float), asCALL_CDECL);
235  engine->RegisterGlobalFunction("bool IsWindowCollapsed()", asFUNCTIONPR(ImGui::IsWindowCollapsed, (), bool), asCALL_CDECL);
236  // engine->RegisterGlobalFunction("bool IsWindowAppearing()", asFUNCTIONPR(ImGui::IsWindowAppearing, (), bool), asCALL_CDECL);
237  engine->RegisterGlobalFunction("void SetWindowFontScale(float)", asFUNCTIONPR(ImGui::SetWindowFontScale, (float), void), asCALL_CDECL);
238 
239  engine->RegisterGlobalFunction("void SetNextWindowPos(vector2)", asFUNCTIONPR([](Vector2 v) {
240  ImGui::SetNextWindowPos(ImVec2(v.x, v.y)); }, (Vector2), void), asCALL_CDECL);
241  engine->RegisterGlobalFunction("void SetNextWindowSize(vector2)", asFUNCTIONPR([](Vector2 v) {
242  ImGui::SetNextWindowSize(ImVec2(v.x, v.y)); }, (Vector2), void), asCALL_CDECL);
243  engine->RegisterGlobalFunction("void SetNextWindowContentSize(vector2)", asFUNCTIONPR([](Vector2 v) {
244  ImGui::SetNextWindowContentSize(ImVec2(v.x, v.y)); }, (Vector2), void), asCALL_CDECL);
245  engine->RegisterGlobalFunction("void SetNextWindowCollapsed(bool)", asFUNCTIONPR([](bool v) {
246  ImGui::SetNextWindowCollapsed(v); }, (bool), void), asCALL_CDECL);
247  engine->RegisterGlobalFunction("void SetNextWindowFocus()", asFUNCTIONPR([]() {
248  ImGui::SetNextWindowFocus(); }, (), void), asCALL_CDECL);
249  engine->RegisterGlobalFunction("void SetWindowPos(vector2)", asFUNCTIONPR([](Vector2 v) {
250  ImGui::SetWindowPos(ImVec2(v.x, v.y)); }, (Vector2), void), asCALL_CDECL);
251  engine->RegisterGlobalFunction("void SetWindowSize(vector2)", asFUNCTIONPR([](Vector2 v) {
252  ImGui::SetWindowSize(ImVec2(v.x, v.y)); }, (Vector2), void), asCALL_CDECL);
253  engine->RegisterGlobalFunction("void SetWindowCollapsed(bool)", asFUNCTIONPR([](bool v) {
254  ImGui::SetWindowCollapsed(v); }, (bool), void), asCALL_CDECL);
255  engine->RegisterGlobalFunction("void SetWindowFocus()", asFUNCTIONPR([]() { ImGui::SetWindowFocus(); }, (), void), asCALL_CDECL);
256 
257  engine->RegisterGlobalFunction("void SetWindowPos(const string&in, vector2)", asFUNCTIONPR([](const string& name, Vector2 v) {
258  ImGui::SetWindowPos(name.c_str(), ImVec2(v.x, v.y)); }, (const string&, Vector2), void), asCALL_CDECL);
259  engine->RegisterGlobalFunction("void SetWindowSize(const string&in, vector2)", asFUNCTIONPR([](const string& name, Vector2 v) {
260  ImGui::SetWindowSize(name.c_str(), ImVec2(v.x, v.y)); }, (const string&, Vector2), void), asCALL_CDECL);
261  engine->RegisterGlobalFunction("void SetWindowCollapsed(const string&in, bool)", asFUNCTIONPR([](const string& name, bool v) {
262  ImGui::SetWindowCollapsed(name.c_str(), v); }, (const string&, bool), void), asCALL_CDECL);
263  engine->RegisterGlobalFunction("void SetWindowFocus(const string&in)", asFUNCTIONPR([](const string& v) {
264  ImGui::SetWindowFocus(v.c_str()); }, (const string&), void), asCALL_CDECL);
265 
266  engine->RegisterGlobalFunction("float GetScrollX()", asFUNCTIONPR(ImGui::GetScrollX, (), float), asCALL_CDECL);
267  engine->RegisterGlobalFunction("float GetScrollY()", asFUNCTIONPR(ImGui::GetScrollY, (), float), asCALL_CDECL);
268  engine->RegisterGlobalFunction("float GetScrollMaxX()", asFUNCTIONPR(ImGui::GetScrollMaxX, (), float), asCALL_CDECL);
269  engine->RegisterGlobalFunction("float GetScrollMaxY()", asFUNCTIONPR(ImGui::GetScrollMaxY, (), float), asCALL_CDECL);
270  engine->RegisterGlobalFunction("void SetScrollX(float)", asFUNCTIONPR(ImGui::SetScrollX, (float), void), asCALL_CDECL);
271  engine->RegisterGlobalFunction("void SetScrollY(float)", asFUNCTIONPR(ImGui::SetScrollY, (float), void), asCALL_CDECL);
272  engine->RegisterGlobalFunction("void SetScrollHere(float = 0.5f)", asFUNCTIONPR(ImGui::SetScrollHere, (float), void), asCALL_CDECL);
273  engine->RegisterGlobalFunction("void SetScrollFromPosY(float, float = 0.5f)", asFUNCTIONPR(ImGui::SetScrollFromPosY, (float,float), void), asCALL_CDECL);
274 
275  engine->RegisterGlobalFunction("void Separator()", asFUNCTIONPR(ImGui::Separator, (), void), asCALL_CDECL);
276  engine->RegisterGlobalFunction("void SameLine(float = 0.0f, float = -1.0f)", asFUNCTIONPR(ImGui::SameLine, (float,float), void), asCALL_CDECL);
277  engine->RegisterGlobalFunction("void NewLine()", asFUNCTIONPR(ImGui::NewLine, (), void), asCALL_CDECL);
278  engine->RegisterGlobalFunction("void Spacing()", asFUNCTIONPR(ImGui::Spacing, (), void), asCALL_CDECL);
279  engine->RegisterGlobalFunction("void Dummy(vector2)", asFUNCTIONPR([](Vector2 v) { ImGui::Dummy(ImVec2(v.x, v.y)); }, (Vector2), void), asCALL_CDECL);
280  engine->RegisterGlobalFunction("void Indent(float = 0.0f)", asFUNCTIONPR(ImGui::Indent, (float), void), asCALL_CDECL);
281  engine->RegisterGlobalFunction("void Unindent(float = 0.0f)", asFUNCTIONPR(ImGui::Unindent, (float), void), asCALL_CDECL);
282  engine->RegisterGlobalFunction("void BeginGroup()", asFUNCTIONPR(ImGui::BeginGroup, (), void), asCALL_CDECL);
283  engine->RegisterGlobalFunction("void EndGroup()", asFUNCTIONPR(ImGui::EndGroup, (), void), asCALL_CDECL);
284  engine->RegisterGlobalFunction("vector2 GetCursorPos()", asFUNCTIONPR([]() { auto v = ImGui::GetCursorPos(); return Vector2(v.x, v.y); }, (), Vector2), asCALL_CDECL);
285  engine->RegisterGlobalFunction("float GetCursorPosX()", asFUNCTIONPR(ImGui::GetCursorPosX, (), float), asCALL_CDECL);
286  engine->RegisterGlobalFunction("float GetCursorPosY()", asFUNCTIONPR(ImGui::GetCursorPosY, (), float), asCALL_CDECL);
287  engine->RegisterGlobalFunction("void SetCursorPos(vector2)", asFUNCTIONPR([](Vector2 v) { ImGui::SetCursorPos(ImVec2(v.x, v.y)); }, (Vector2), void), asCALL_CDECL);
288  engine->RegisterGlobalFunction("void SetCursorPosX(float)", asFUNCTIONPR(ImGui::SetCursorPosX, (float), void), asCALL_CDECL);
289  engine->RegisterGlobalFunction("void SetCursorPosY(float)", asFUNCTIONPR(ImGui::SetCursorPosY, (float), void), asCALL_CDECL);
290  engine->RegisterGlobalFunction("vector2 GetCursorStartPos()", asFUNCTIONPR([]() { auto v = ImGui::GetCursorStartPos(); return Vector2(v.x, v.y); }, (), Vector2), asCALL_CDECL);
291  engine->RegisterGlobalFunction("vector2 GetCursorScreenPos()", asFUNCTIONPR([]() { auto v = ImGui::GetCursorScreenPos(); return Vector2(v.x, v.y); }, (), Vector2), asCALL_CDECL);
292  engine->RegisterGlobalFunction("void SetCursorScreenPos(vector2)", asFUNCTIONPR([](Vector2 v) { ImGui::SetCursorScreenPos(ImVec2(v.x, v.y)); }, (Vector2), void), asCALL_CDECL);
293  engine->RegisterGlobalFunction("void AlignTextToFramePadding()", asFUNCTIONPR(ImGui::AlignTextToFramePadding, (), void), asCALL_CDECL);
294  engine->RegisterGlobalFunction("float GetTextLineHeight()", asFUNCTIONPR(ImGui::GetTextLineHeight, (), float), asCALL_CDECL);
295  engine->RegisterGlobalFunction("float GetTextLineHeightWithSpacing()", asFUNCTIONPR(ImGui::GetTextLineHeightWithSpacing, (), float), asCALL_CDECL);
296  // engine->RegisterGlobalFunction("float GetFrameHeight()", asFUNCTIONPR(ImGui::GetFrameHeight, (), float), asCALL_CDECL);
297  // engine->RegisterGlobalFunction("float GetFrameHeightWithSpacing()", asFUNCTIONPR(ImGui::GetFrameHeightWithSpacing, (), float), asCALL_CDECL);
298 
299  // Columns (considered legacy in latest versions - superseded by Tables!)
300  engine->RegisterGlobalFunction("void Columns(int = 1, const string&in = string(), bool = true)", asFUNCTIONPR([](int a, const string& b, bool c) {
301  ImGui::Columns(a, b.c_str(), c); }, (int, const string&, bool), void), asCALL_CDECL);
302  engine->RegisterGlobalFunction("void NextColumn()", asFUNCTIONPR([]() { ImGui::NextColumn(); }, (), void), asCALL_CDECL);
303  engine->RegisterGlobalFunction("int GetColumnIndex()", asFUNCTIONPR([]() { return ImGui::GetColumnIndex(); }, (), int), asCALL_CDECL);
304  engine->RegisterGlobalFunction("float GetColumnWidth(int = -1)", asFUNCTIONPR([](int a) { return ImGui::GetColumnWidth(a); }, (int), float), asCALL_CDECL);
305  // engine->RegisterGlobalFunction("void SetColumnWidth(int, float)", asFUNCTIONPR([](int a, float b) { ImGui::SetColumnWidth(a, b); }, (int,float), void), asCALL_CDECL);
306  engine->RegisterGlobalFunction("float GetColumnOffset(int = -1)", asFUNCTIONPR([](int a) { return ImGui::GetColumnOffset(a); }, (int), float), asCALL_CDECL);
307  engine->RegisterGlobalFunction("void SetColumnOffset(int, float)", asFUNCTIONPR([](int a, float b) { ImGui::SetColumnOffset(a, b); }, (int,float), void), asCALL_CDECL);
308  engine->RegisterGlobalFunction("int GetColumnsCount()", asFUNCTIONPR([]() { return ImGui::GetColumnsCount(); }, (), int), asCALL_CDECL);
309 
310 
311  // Tab bars, tabs
312  engine->RegisterGlobalFunction("bool BeginTabBar(const string&in, int = 0)", asFUNCTIONPR([](const string& str_id, ImGuiTabBarFlags flags) { return ImGui::BeginTabBar(str_id.c_str(), flags); }, (const string&, ImGuiTabBarFlags), bool), asCALL_CDECL);
313  engine->RegisterGlobalFunction("void EndTabBar()", asFUNCTION(ImGui::EndTabBar), asCALL_CDECL);
314  // BeginTabItem() without X close button.
315  engine->RegisterGlobalFunction("bool BeginTabItem(const string&in, int = 0)", asFUNCTIONPR([](const string& label, ImGuiTabItemFlags flags) { return ImGui::BeginTabItem(label.c_str(), nullptr, flags); }, (const string&, ImGuiTabItemFlags), bool), asCALL_CDECL);
316  // BeginTabItem() with X close button.
317  engine->RegisterGlobalFunction("bool BeginTabItem(const string&in, bool&inout, int = 0)", asFUNCTIONPR([](const string& label, bool& p_open, ImGuiTabItemFlags flags) { return ImGui::BeginTabItem(label.c_str(), &p_open, flags); }, (const string&, bool&, ImGuiTabItemFlags), bool), asCALL_CDECL);
318  engine->RegisterGlobalFunction("void EndTabItem()", asFUNCTION(ImGui::EndTabItem), asCALL_CDECL);
319  //engine->RegisterGlobalFunction("bool TabItemButton(const string&in, ImGuiTabItemFlags = 0)", asFUNCTIONPR([](const string& label, ImGuiTabItemFlags flags) { return ImGui::TabItemButton(label.c_str(), flags); }, (const string&, ImGuiTabItemFlags), bool), asCALL_CDECL);
320  engine->RegisterGlobalFunction("void SetTabItemClosed(const string&in)", asFUNCTIONPR([](const string& tab_or_docked_window_label) { ImGui::SetTabItemClosed(tab_or_docked_window_label.c_str()); }, (const string&), void), asCALL_CDECL);
321 
322 
323  // ID scopes
324  engine->RegisterGlobalFunction("void PushID(const string&in)", asFUNCTIONPR([](const string& n) { ImGui::PushID(n.c_str()); }, (const string&), void), asCALL_CDECL);
325  engine->RegisterGlobalFunction("void PushID(int int_id)", asFUNCTIONPR([](int id) { ImGui::PushID(id); }, (int), void), asCALL_CDECL);
326  engine->RegisterGlobalFunction("void PopID()", asFUNCTIONPR(ImGui::PopID, (), void), asCALL_CDECL);
327  engine->RegisterGlobalFunction("uint GetID(const string&in)", asFUNCTIONPR([](const string& n) { return ImGui::GetID(n.c_str()); }, (const string&), unsigned), asCALL_CDECL);
328 
329  // Widgets: Text
330  engine->RegisterGlobalFunction("void Text(const string&in)", asFUNCTIONPR([](const string& n) {
331  ImGui::Text(n.c_str());
332  }, (const string&), void), asCALL_CDECL);
333  engine->RegisterGlobalFunction("void TextDisabled(const string&in)", asFUNCTIONPR([](const string& n) {
334  ImGui::TextDisabled(n.c_str());
335  }, (const string&), void), asCALL_CDECL);
336  engine->RegisterGlobalFunction("void TextColored(color col, const string&in)", asFUNCTIONPR([](ColourValue c, const string& n) {
337  ImGui::TextColored(ImVec4(c.r, c.g, c.b, c.a), n.c_str());
338  }, (ColourValue, const string&), void), asCALL_CDECL);
339  engine->RegisterGlobalFunction("void TextWrapped(const string&in)", asFUNCTIONPR([](const string& n) {
340  ImGui::TextWrapped(n.c_str()); }, (const string&), void), asCALL_CDECL);
341  engine->RegisterGlobalFunction("void LabelText(const string&in, const string&in)", asFUNCTIONPR([](const string& l, const string& n) {
342  ImGui::LabelText(l.c_str(), n.c_str()); }, (const string&, const string&), void), asCALL_CDECL);
343  engine->RegisterGlobalFunction("void Bullet()", asFUNCTIONPR(ImGui::Bullet, (), void), asCALL_CDECL);
344  engine->RegisterGlobalFunction("void BulletText(const string&in)", asFUNCTIONPR([](const string& n) {
345  ImGui::BulletText(n.c_str()); }, (const string&), void), asCALL_CDECL);
346 
347  // Widgets: Main
348  engine->RegisterGlobalFunction("bool Button(const string&in, vector2 = vector2(0,0))", asFUNCTIONPR([](const string& n, Vector2 v) {
349  return ImGui::Button(n.c_str(), ImVec2(v.x, v.y));
350  }, (const string&, Vector2), bool), asCALL_CDECL);
351  engine->RegisterGlobalFunction("bool SmallButton(const string&in)", asFUNCTIONPR([](const string& n) {
352  return ImGui::SmallButton(n.c_str()); }, (const string&), bool), asCALL_CDECL);
353  engine->RegisterGlobalFunction("bool InvisibleButton(const string&in, vector2)", asFUNCTIONPR([](const string& id, Vector2 v) {
354  return ImGui::InvisibleButton(id.c_str(), ImVec2(v.x, v.y)); }, (const string&, Vector2), bool), asCALL_CDECL);
355  engine->RegisterGlobalFunction("void Image(const Ogre::TexturePtr&in, vector2)", asFUNCTIONPR([](Ogre::TexturePtr const& tex, Vector2 v) {
356  ImGui::Image((ImTextureID)tex->getHandle(), ImVec2(v.x, v.y));
357  }, (Ogre::TexturePtr const&, Vector2), void), asCALL_CDECL);
358  engine->RegisterGlobalFunction("bool Checkbox(const string&in, bool&inout)", asFUNCTIONPR([](const string& n, bool& v) {
359  return ImGui::Checkbox(n.c_str(), &v); }, (const string&, bool&), bool), asCALL_CDECL);
360  engine->RegisterGlobalFunction("bool CheckboxFlags(const string&in, uint&inout, uint)", asFUNCTIONPR([](const string& n, unsigned& f, unsigned v) {
361  return ImGui::CheckboxFlags(n.c_str(), &f, v); }, (const string&, unsigned&, unsigned), bool), asCALL_CDECL);
362  engine->RegisterGlobalFunction("bool RadioButton(const string&in, bool)", asFUNCTIONPR([](const string& n, bool v) {
363  return ImGui::RadioButton(n.c_str(), v); }, (const string&, bool), bool), asCALL_CDECL);
364  engine->RegisterGlobalFunction("bool RadioButton(const string&in, int&inout, int)", asFUNCTIONPR([](const string& n, int& v, int vv) {
365  return ImGui::RadioButton(n.c_str(), &v, vv); }, (const string&, int&, int), bool), asCALL_CDECL);
366  engine->RegisterGlobalFunction("void ProgressBar(float, vector2=vector2(-1,0), const string&in = \"\")", asFUNCTIONPR([](float v, Ogre::Vector2 size, const string& overlay) {
367  ImGui::ProgressBar(v, ImVec2(size.x, size.y), (overlay != "")?overlay.c_str():nullptr); }, (float, Ogre::Vector2, const string&), void), asCALL_CDECL);
368 
369 
370  // Widgets: Combo Box
371  // engine->RegisterGlobalFunction("bool BeginCombo(const string&in, const string&in, int = 0)", asFUNCTIONPR([](const string& id, const string& prevItem, int flags) { return ImGui::BeginCombo(id.c_str(), prevItem.c_str(), flags); }, (const string&, const string&, int), bool), asCALL_CDECL);
372  // engine->RegisterGlobalFunction("void EndCombo()", asFUNCTIONPR(ImGui::EndCombo, (), void), asCALL_CDECL);
373  /*
374  static char imgui_comboItem[4096];
375  engine->RegisterGlobalFunction("bool Combo(const string&in, int&inout, const Array<string>@+)", asFUNCTIONPR([](const string& lbl, int& index, const CScriptArray* items) {
376  memset(imgui_comboItem, 0, sizeof(char) * 4096);
377  unsigned offset = 0;
378  for (unsigned i = 0; i < items->GetSize(); ++i)
379  {
380  string* str = ((string*)items->At(i));
381  strcpy(imgui_comboItem + offset, str->c_str());
382  offset += str->length() + 1;
383  }
384  return ImGui::Combo(lbl.c_str(), &index, imgui_comboItem, -1);
385  }, (const string&, int&, const CScriptArray*), bool), asCALL_CDECL);
386  */
387  // Widgets: Drags
388  engine->RegisterGlobalFunction("bool DragFloat(const string&in, float&inout, float = 1.0f, float = 0.0f, float = 0.0f)", asFUNCTIONPR([](const string& n, float& v, float speed, float mn, float mx) {
389  return ImGui::DragFloat(n.c_str(), &v, speed, mn, mx); }, (const string&, float&, float, float, float), bool), asCALL_CDECL);
390  engine->RegisterGlobalFunction("bool DragFloat2(const string&in, vector2&inout)", asFUNCTIONPR([](const string& n, Vector2& v) {
391  return ImGui::DragFloat2(n.c_str(), &v.x); }, (const string&, Vector2&), bool), asCALL_CDECL);
392  engine->RegisterGlobalFunction("bool DragFloat3(const string&in, vector3&inout)", asFUNCTIONPR([](const string& n, Vector3& v) {
393  return ImGui::DragFloat3(n.c_str(), &v.x); }, (const string&, Vector3&), bool), asCALL_CDECL);
394  /* --- TODO: Register Vector4
395  engine->RegisterGlobalFunction("bool DragFloat4(const string&in, Vector4&inout)", asFUNCTIONPR([](const string& n, Vector4& v) {
396  return ImGui::DragFloat4(n.c_str(), &v.x); }, (const string&, Vector4&), bool), asCALL_CDECL);
397  engine->RegisterGlobalFunction("bool DragInt(const string&in, int&inout, int = 0, int = 0)", asFUNCTIONPR([](const string& n, int& v, int mn, int mx) {
398  return ImGui::DragInt(n.c_str(), &v, 1.0f, mn, mx); }, (const string&, int&, int, int), bool), asCALL_CDECL);
399  engine->RegisterGlobalFunction("bool DragInt2(const string&in, IntVector2&inout, int = 0, int = 0)", asFUNCTIONPR([](const string& n, IntVector2& v, int mn, int mx) {
400  return ImGui::DragInt2(n.c_str(), &v.x, 1.0f, mn, mx); }, (const string&, IntVector2&, int,int), bool), asCALL_CDECL);
401  engine->RegisterGlobalFunction("bool DragInt3(const string&in, IntVector3&inout, int = 0, int = 0)", asFUNCTIONPR([](const string& n, IntVector3& v, int mn, int mx) {
402  return ImGui::DragInt3(n.c_str(), &v.x, 1.0f, mn, mx); }, (const string&, IntVector3&, int,int), bool), asCALL_CDECL);
403  */
404  engine->RegisterGlobalFunction("bool DragFloatRange2(const string&in, float&inout, float&inout, float = 0.0f, float = 1.0f)", asFUNCTIONPR([](const string& n, float& v0, float&v1, float mn, float mx) {
405  return ImGui::DragFloatRange2(n.c_str(), &v0, &v1, 1.0f, mn, mx); }, (const string&, float&, float&, float, float), bool), asCALL_CDECL);
406  engine->RegisterGlobalFunction("bool DragIntRange2(const string&in, int&inout, int&inout, int, int)", asFUNCTIONPR([](const string& n, int& v0, int&v1, int mn, int mx) {
407  return ImGui::DragIntRange2(n.c_str(), &v0, &v1, 1.0f, mn, mx); }, (const string&, int&, int&, int, int), bool), asCALL_CDECL);
408 
409  // Widgets: Input with Keyboard
410  static char imgui_text_buffer[4096]; // shared with multiple widgets
411  engine->RegisterGlobalFunction("bool InputText(const string&in, string&inout)", asFUNCTIONPR([](const string& id, string& val) {
412  memset(imgui_text_buffer, 0, sizeof(char) * 4096);
413  strcpy(imgui_text_buffer, val.c_str());
414  if (ImGui::InputText(id.c_str(), imgui_text_buffer, 4096))
415  {
416  val = imgui_text_buffer;
417  return true;
418  }
419  return false;
420  }, (const string&, string&), bool), asCALL_CDECL);
421  engine->RegisterGlobalFunction("bool InputTextMultiline(const string&in, string&inout, const vector2&in = vector2(0,0))", asFUNCTIONPR([](const string& id, string& val, const Ogre::Vector2& size) {
422  return ImGui::InputTextMultiline(id.c_str(), (char*)val.data(), val.size(), ImVec2(size.x, size.y));
423  }, (const string&, string&, const Ogre::Vector2&), bool), asCALL_CDECL);
424  engine->RegisterGlobalFunction("bool InputFloat(const string&, float&inout)", asFUNCTIONPR([](const string& id, float& val) {
425  return ImGui::InputFloat(id.c_str(), &val); }, (const string&, float&), bool), asCALL_CDECL);
426  engine->RegisterGlobalFunction("bool InputFloat2(const string&, vector2&inout)", asFUNCTIONPR([](const string& id, Vector2& val) {
427  return ImGui::InputFloat2(id.c_str(), &val.x); }, (const string&, Vector2&), bool), asCALL_CDECL);
428  engine->RegisterGlobalFunction("bool InputFloat3(const string&, vector3&inout)", asFUNCTIONPR([](const string& id, Vector3& val) {
429  return ImGui::InputFloat3(id.c_str(), &val.x); }, (const string&, Vector3&),bool), asCALL_CDECL);
430  /* --- TODO: Register Vector4
431  engine->RegisterGlobalFunction("bool InputFloat4(const string&, Vector4&inout)", asFUNCTIONPR([](const string& id, Vector4& val) {
432  return ImGui::InputFloat4(id.c_str(), &val.x_); }, (const string&, Vector4&),bool), asCALL_CDECL);
433  */
434  engine->RegisterGlobalFunction("bool InputInt(const string&, int&inout)", asFUNCTIONPR([](const string& id, int& val) {
435  return ImGui::InputInt(id.c_str(), &val); }, (const string&, int&), bool), asCALL_CDECL);
436  /*
437  engine->RegisterGlobalFunction("bool InputInt2(const string&, IntVector2&inout)", asFUNCTIONPR([](const string& id, IntVector2& val) {
438  return ImGui::InputInt2(id.c_str(), &val.x_); }, (const string&, IntVector2&),bool), asCALL_CDECL);
439  engine->RegisterGlobalFunction("bool InputInt3(const string&, IntVector3&inout)", asFUNCTIONPR([](const string& id, IntVector3& val) {
440  return ImGui::InputInt3(id.c_str(), &val.x_); }, (const string&, IntVector3&), bool), asCALL_CDECL);
441  */
442 
443  // Widgets: Sliders (tip: ctrl+click on a slider to input with keyboard. manually input values aren't clamped, can go off-bounds)
444  engine->RegisterGlobalFunction("bool SliderFloat(const string&in, float&inout, float = 0.0f, float = 0.0f)", asFUNCTIONPR([](const string& n, float& v, float mn, float mx) {
445  return ImGui::SliderFloat(n.c_str(), &v, mn, mx); }, (const string&, float&, float,float), bool), asCALL_CDECL);
446  engine->RegisterGlobalFunction("bool SliderFloat2(const string&in, vector2&inout, float, float)", asFUNCTIONPR([](const string& n, Vector2& v, float mn, float mx) {
447  return ImGui::SliderFloat2(n.c_str(), &v.x, mn, mx); }, (const string&, Vector2&, float,float),bool), asCALL_CDECL);
448  engine->RegisterGlobalFunction("bool SliderFloat3(const string&in, vector3&inout, float, float)", asFUNCTIONPR([](const string& n, Vector3& v, float mn, float mx) {
449  return ImGui::SliderFloat3(n.c_str(), &v.x, mn, mx); }, (const string&, Vector3&, float,float),bool), asCALL_CDECL);
450  engine->RegisterGlobalFunction("bool SliderInt(const string&in, int&inout, int = 0, int = 0)", asFUNCTIONPR([](const string& n, int& v, int mn, int mx) {
451  return ImGui::SliderInt(n.c_str(), &v, mn, mx); }, (const string&, int&, int, int), bool), asCALL_CDECL);
452 /* --- TODO: Register Vector4
453  engine->RegisterGlobalFunction("bool SliderFloat4(const string&in, Vector4&inout, float, float)", asFUNCTIONPR([](const string& n, Vector4& v, float mn, float mx) {
454  return ImGui::SliderFloat4(n.c_str(), &v.x, mn, mx); }, (const string&, Vector4&,float,float),bool), asCALL_CDECL);
455 
456  engine->RegisterGlobalFunction("bool SliderInt2(const string&in, IntVector2&inout, int = 0, int = 0)", asFUNCTIONPR([](const string& n, IntVector2& v, int mn, int mx) {
457  return ImGui::SliderInt2(n.c_str(), &v.x, mn, mx); }, (const string&, IntVector2&, int,int),bool), asCALL_CDECL);
458  engine->RegisterGlobalFunction("bool SliderInt3(const string&in, IntVector3&inout, int = 0, int = 0)", asFUNCTIONPR([](const string& n, IntVector3& v, int mn, int mx) {
459  return ImGui::SliderInt3(n.c_str(), &v.x, mn, mx); }, (const string&, IntVector3&, int,int),bool), asCALL_CDECL);
460  */
461 
462  // Widgets: Color Editor/Picker
463  engine->RegisterGlobalFunction("bool ColorEdit3(const string&in, color&inout)", asFUNCTIONPR([](const string& id, ColourValue& val) {
464  Vector3 v(val.r, val.g, val.b);
465  if (ImGui::ColorEdit3(id.c_str(), &v.x))
466  {
467  val = ColourValue(v.x, v.y, v.z);
468  return true;
469  }
470  return false;
471  }, (const string&, ColourValue&),bool), asCALL_CDECL);
472  engine->RegisterGlobalFunction("bool ColorEdit4(const string&in, color&inout)", asFUNCTIONPR([](const string& id, ColourValue& val) {
473  Vector4 v(val.r, val.g, val.b, val.a);
474  if (ImGui::ColorEdit4(id.c_str(), &v.x))
475  {
476  val = ColourValue(v.x, v.y, v.z, v.w);
477  return true;
478  }
479  return false;
480  }, (const string&, ColourValue&),bool), asCALL_CDECL);
481  /* engine->RegisterGlobalFunction("bool ColorPicker3(const string&in, color&inout)", asFUNCTIONPR([](const string& id, ColourValue& val) {
482  Vector3 v(val.r, val.g, val.b);
483  if (ImGui::ColorPicker3(id.c_str(), &v.x))
484  {
485  val = ColourValue(v.x, v.y, v.z);
486  return true;
487  }
488  return false;
489  }, (const string&, ColourValue&),bool), asCALL_CDECL);
490  engine->RegisterGlobalFunction("bool ColorPicker4(const string&in, color&inout)", asFUNCTIONPR([](const string& id, ColourValue& val) {
491  Vector4 v(val.r, val.g, val.b, val.a);
492  if (ImGui::ColorPicker4(id.c_str(), &v.x))
493  {
494  val = ColourValue(v.x, v.y, v.z, v.w);
495  return true;
496  }
497  return false;
498  }, (const string&, ColourValue&),bool), asCALL_CDECL);*/
499  engine->RegisterGlobalFunction("bool ColorButton(const string&in, color)", asFUNCTIONPR([](const string& id, ColourValue val) {
500  Vector4 v(val.r, val.g, val.b, val.a);
501  ImVec4 vv(v.x, v.y, v.z, v.w);
502  return ImGui::ColorButton(id.c_str(), vv);
503  }, (const string&, ColourValue), bool), asCALL_CDECL);
504 
505  // Widgets: Trees
506  engine->RegisterGlobalFunction("bool TreeNode(const string&in)", asFUNCTIONPR([](const string& id) { return ImGui::TreeNode(id.c_str()); }, (const string&), bool), asCALL_CDECL);
507  engine->RegisterGlobalFunction("void TreePush(const string&in)", asFUNCTIONPR([](const string& id) { ImGui::TreePush(id.c_str()); }, (const string&), void), asCALL_CDECL);
508  engine->RegisterGlobalFunction("void TreePop()", asFUNCTIONPR(ImGui::TreePop, (), void), asCALL_CDECL);
509  engine->RegisterGlobalFunction("void TreeAdvanceToLabelPos()", asFUNCTIONPR(ImGui::TreeAdvanceToLabelPos, (), void), asCALL_CDECL);
510  engine->RegisterGlobalFunction("float GetTreeNodeToLabelSpacing()", asFUNCTIONPR(ImGui::GetTreeNodeToLabelSpacing, (), float), asCALL_CDECL);
511  engine->RegisterGlobalFunction("void SetNextTreeNodeOpen(bool)", asFUNCTIONPR([](bool val) { ImGui::SetNextTreeNodeOpen(val); }, (bool), void), asCALL_CDECL);
512  engine->RegisterGlobalFunction("bool CollapsingHeader(const string&in)", asFUNCTIONPR([](const string& n) { return ImGui::CollapsingHeader(n.c_str()); }, (const string&), bool), asCALL_CDECL);
513  engine->RegisterGlobalFunction("bool CollapsingHeader(const string&in, bool&inout)", asFUNCTIONPR([](const string& n, bool& v) { return ImGui::CollapsingHeader(n.c_str(), &v); }, (const string&, bool&), bool), asCALL_CDECL);
514 
515  // Widgets: Selectable / Lists
516  engine->RegisterGlobalFunction("bool Selectable(const string&in, bool = false)", asFUNCTIONPR([](const string& n, bool v) { return ImGui::Selectable(n.c_str(), v); }, (const string&, bool), bool), asCALL_CDECL);
517  engine->RegisterGlobalFunction("bool ListBoxHeader(const string&in)", asFUNCTIONPR([](const string& n) { return ImGui::ListBoxHeader(n.c_str()); }, (const string&), bool), asCALL_CDECL);
518 
519  // Values
520  engine->RegisterGlobalFunction("void Value(const string&in, bool)", asFUNCTIONPR([](const string& n, bool v) { ImGui::Value(n.c_str(), v); }, (const string&, bool), void), asCALL_CDECL);
521  engine->RegisterGlobalFunction("void Value(const string&in, int)", asFUNCTIONPR([](const string& n, int v) { ImGui::Value(n.c_str(), v); }, (const string&, int), void), asCALL_CDECL);
522  engine->RegisterGlobalFunction("void Value(const string&in, uint)", asFUNCTIONPR([](const string& n, unsigned v) { ImGui::Value(n.c_str(), v);}, (const string&, unsigned), void), asCALL_CDECL);
523  engine->RegisterGlobalFunction("void Value(const string&in, float)", asFUNCTIONPR([](const string& n, float v) { ImGui::Value(n.c_str(), v); }, (const string&, float), void), asCALL_CDECL);
524 
525  // Tooltips
526  engine->RegisterGlobalFunction("void BeginTooltip()", asFUNCTIONPR(ImGui::BeginTooltip , (), void), asCALL_CDECL);
527  engine->RegisterGlobalFunction("void EndTooltip()", asFUNCTIONPR(ImGui::EndTooltip , (), void), asCALL_CDECL);
528  engine->RegisterGlobalFunction("void SetTooltip(const string&in)", asFUNCTIONPR([](const string& t) { ImGui::SetTooltip(t.c_str()); }, (const string&), void), asCALL_CDECL);
529 
530  // Menus
531  engine->RegisterGlobalFunction("bool BeginMainMenuBar()", asFUNCTIONPR([]() { return ImGui::BeginMainMenuBar(); }, (), bool), asCALL_CDECL);
532  engine->RegisterGlobalFunction("void EndMainMenuBar()", asFUNCTIONPR([]() { ImGui::EndMainMenuBar(); }, (), void), asCALL_CDECL);
533  engine->RegisterGlobalFunction("bool BeginMenuBar()", asFUNCTIONPR([]() { return ImGui::BeginMenuBar(); }, (), bool), asCALL_CDECL);
534  engine->RegisterGlobalFunction("void EndMenuBar()", asFUNCTIONPR([]() { ImGui::EndMenuBar(); }, (), void), asCALL_CDECL);
535  engine->RegisterGlobalFunction("bool BeginMenu(const string&in, bool = true)", asFUNCTIONPR([](const string& a, bool b) {
536  return ImGui::BeginMenu(a.c_str(), b); }, (const string&, bool), bool), asCALL_CDECL);
537  engine->RegisterGlobalFunction("void EndMenu()", asFUNCTIONPR([]() { ImGui::EndMenu(); }, (), void), asCALL_CDECL);
538  engine->RegisterGlobalFunction("bool MenuItem(const string&in, const string&in = string(), bool = false, bool = true)", asFUNCTIONPR([](const string& a, const string& b, bool c, bool d) {
539  return ImGui::MenuItem(a.c_str(), b.c_str(), c, d); }, (const string&, const string&, bool, bool), bool), asCALL_CDECL);
540  engine->RegisterGlobalFunction("bool MenuItem(const string&in, const string&in, bool &inout, bool = true)", asFUNCTIONPR([](const string& a, const string& b, bool& c, bool d) {
541  return ImGui::MenuItem(a.c_str(), b.c_str(), &c, d); }, (const string&, const string&, bool&, bool), bool), asCALL_CDECL);
542 
543  // Popups
544  engine->RegisterGlobalFunction("void OpenPopup(const string&in)", asFUNCTIONPR([](const string& a) { ImGui::OpenPopup(a.c_str()); }, (const string&), void), asCALL_CDECL);
545  /* engine->RegisterGlobalFunction("bool BeginPopup(const string&in, int = 0)", asFUNCTIONPR([](const string& a, int b) {
546  return ImGui::BeginPopup(a.c_str(), (ImGuiWindowFlags)b); }, (const string&, int), bool), asCALL_CDECL);*/ // FIXME: update imgui!
547  engine->RegisterGlobalFunction("bool BeginPopup(const string&in, int = 0)", asFUNCTIONPR([](const string& a, int b) {
548  return ImGui::BeginPopup(a.c_str()); }, (const string&, int), bool), asCALL_CDECL);
549  engine->RegisterGlobalFunction("bool BeginPopupContextItem(const string&in = string(), int = 1)", asFUNCTIONPR([](const string& a, int b) {
550  return ImGui::BeginPopupContextItem(a.c_str(), b); }, (const string&, int), bool), asCALL_CDECL);
551  engine->RegisterGlobalFunction("bool BeginPopupContextWindow(const string&in = string(), int = 1, bool = true)", asFUNCTIONPR([](const string& a, int b, bool c) {
552  return ImGui::BeginPopupContextWindow(a.c_str(), b, c); }, (const string&, int, bool), bool), asCALL_CDECL); // FIXME: update imgui! -- swapped args
553  engine->RegisterGlobalFunction("bool BeginPopupContextVoid(const string&in = string(), int = 1)", asFUNCTIONPR([](const string& a, int b) {
554  return ImGui::BeginPopupContextVoid(a.c_str(), b); }, (const string&, int), bool), asCALL_CDECL);
555  engine->RegisterGlobalFunction("bool BeginPopupModal(const string&in, bool &inout = null, int = 0)", asFUNCTIONPR([](const string& a, bool& b, int c) {
556  return ImGui::BeginPopupModal(a.c_str(), &b, (ImGuiWindowFlags)c); }, (const string&, bool&, int), bool), asCALL_CDECL);
557  engine->RegisterGlobalFunction("void EndPopup()", asFUNCTIONPR([]() { ImGui::EndPopup(); }, (), void), asCALL_CDECL);
558 /* engine->RegisterGlobalFunction("bool OpenPopupOnItemClick(const string&in = string(), int = 1)", asFUNCTIONPR([](const string& a, int b) {
559  return ImGui::OpenPopupOnItemClick(a.c_str(), b); }, (const string&, int), bool), asCALL_CDECL);*/ // FIXME: update imgui!
560  /* engine->RegisterGlobalFunction("bool IsPopupOpen(const string&in)", asFUNCTIONPR([](const string& a) {
561  return ImGui::IsPopupOpen(a.c_str()); }, (const string&), bool), asCALL_CDECL); */ // FIXME: update imgui!
562  engine->RegisterGlobalFunction("void CloseCurrentPopup()", asFUNCTIONPR([]() { ImGui::CloseCurrentPopup(); }, (), void), asCALL_CDECL);
563 
564  // Clip-rects
565  engine->RegisterGlobalFunction("void PushClipRect(const vector2&, const vector2&, bool)", asFUNCTIONPR([](const Vector2& a, const Vector2& b, bool c) {
566  ImGui::PushClipRect(ImVec2(a.x, a.y), ImVec2(b.x, b.y), c); }, (const Vector2&, const Vector2&, bool), void), asCALL_CDECL);
567  engine->RegisterGlobalFunction("void PopClipRect()", asFUNCTIONPR([]() { ImGui::PopClipRect(); }, (), void), asCALL_CDECL);
568 
569  // Focus
570  /* engine->RegisterGlobalFunction("void SetItemDefaultFocus()", asFUNCTIONPR([]() { ImGui::SetItemDefaultFocus(); }, (), void), asCALL_CDECL); */ // TODO update imgui
571  engine->RegisterGlobalFunction("void SetKeyboardFocusHere(int = 0)", asFUNCTIONPR([](int a) { ImGui::SetKeyboardFocusHere(a); }, (int), void), asCALL_CDECL);
572 
573  // Utilities
574  engine->RegisterGlobalFunction("bool IsItemHovered(int = 0)", asFUNCTIONPR([](int a) { return ImGui::IsItemHovered(); }, (int), bool), asCALL_CDECL); // TODO: update imgui -- flags omitted
575  engine->RegisterGlobalFunction("bool IsItemActive()", asFUNCTIONPR([]() { return ImGui::IsItemActive(); }, (), bool), asCALL_CDECL);
576  engine->RegisterGlobalFunction("bool IsItemClicked(int = 0)", asFUNCTIONPR([](int a) { return ImGui::IsItemClicked(a); }, (int), bool), asCALL_CDECL);
577  engine->RegisterGlobalFunction("bool IsItemVisible()", asFUNCTIONPR([]() { return ImGui::IsItemVisible(); }, (), bool), asCALL_CDECL);
578  engine->RegisterGlobalFunction("bool IsAnyItemHovered()", asFUNCTIONPR([]() { return ImGui::IsAnyItemHovered(); }, (), bool), asCALL_CDECL);
579  engine->RegisterGlobalFunction("bool IsAnyItemActive()", asFUNCTIONPR([]() { return ImGui::IsAnyItemActive(); }, (), bool), asCALL_CDECL);
580  engine->RegisterGlobalFunction("vector2 GetItemRectMin()", asFUNCTIONPR([]() { auto v = ImGui::GetItemRectMin(); return Vector2(v.x, v.y); }, (), Vector2), asCALL_CDECL);
581  engine->RegisterGlobalFunction("vector2 GetItemRectMax()", asFUNCTIONPR([]() { auto v = ImGui::GetItemRectMax(); return Vector2(v.x, v.y); }, (), Vector2), asCALL_CDECL);
582  engine->RegisterGlobalFunction("vector2 GetItemRectSize()", asFUNCTIONPR([]() { auto v = ImGui::GetItemRectSize(); return Vector2(v.x, v.y); }, (), Vector2), asCALL_CDECL);
583  engine->RegisterGlobalFunction("void SetItemAllowOverlap()", asFUNCTIONPR([]() { ImGui::SetItemAllowOverlap(); }, (), void), asCALL_CDECL);
584  engine->RegisterGlobalFunction("bool IsWindowFocused(int = 0)", asFUNCTIONPR([](int a) { return ImGui::IsWindowFocused(); }, (int), bool), asCALL_CDECL); // TODO: update imgui -- flags omitted
585  engine->RegisterGlobalFunction("bool IsWindowHovered(int = 0)", asFUNCTIONPR([](int a) { return ImGui::IsWindowHovered(); }, (int), bool), asCALL_CDECL); // TODO: update imgui -- flags omitted
586  engine->RegisterGlobalFunction("bool IsRectVisible(const vector2&)", asFUNCTIONPR([](const Vector2& a) { return ImGui::IsRectVisible(ImVec2(a.x, a.y)); }, (const Vector2&), bool), asCALL_CDECL);
587  engine->RegisterGlobalFunction("bool IsRectVisible(const vector2&, const vector2&)", asFUNCTIONPR([](const Vector2& a, const Vector2& b) { return ImGui::IsRectVisible(ImVec2(a.x, a.y), ImVec2(b.x, b.y)); }, (const Vector2&, const Vector2&), bool), asCALL_CDECL);
588  engine->RegisterGlobalFunction("float GetTime()", asFUNCTIONPR([]() { return (float)ImGui::GetTime(); }, (), float), asCALL_CDECL);
589  engine->RegisterGlobalFunction("int GetFrameCount()", asFUNCTIONPR([]() { return ImGui::GetFrameCount(); }, (), int), asCALL_CDECL);
590 
591  engine->RegisterGlobalFunction("vector2 CalcTextSize(const string&in, bool hide_text_after_double_hash = false, float wrap_width = -1.0f)", asFUNCTIONPR([](const string& a, bool c, float d) {
592  auto v = ImGui::CalcTextSize(a.c_str(), nullptr, c, d); return Vector2(v.x, v.y); }, (const string&, bool, float), Vector2), asCALL_CDECL);
593  engine->RegisterGlobalFunction("void CalcListClipping(int, float, int&inout, int&inout)", asFUNCTIONPR([](int a, float b, int& c, int& d) {
594  ImGui::CalcListClipping(a, b, &c, &d); }, (int,float,int&,int&), void), asCALL_CDECL);
595  engine->RegisterGlobalFunction("bool BeginChildFrame(uint, const vector2&, int = 0)", asFUNCTIONPR([](unsigned a, const Vector2& b, int c) {
596  return ImGui::BeginChildFrame(a, ImVec2(b.x,b.y), (ImGuiWindowFlags)c); }, (unsigned, const Vector2&, int), bool), asCALL_CDECL);
597  engine->RegisterGlobalFunction("void EndChildFrame()", asFUNCTIONPR([]() { ImGui::EndChildFrame(); }, (), void), asCALL_CDECL);
598 
599  engine->RegisterGlobalFunction("int GetKeyIndex(int)", asFUNCTIONPR([](int a) { return ImGui::GetKeyIndex((ImGuiKey)a); }, (int), int), asCALL_CDECL);
600  engine->RegisterGlobalFunction("bool IsKeyDown(int)", asFUNCTIONPR([](int a) { return ImGui::IsKeyDown(a); }, (int), bool), asCALL_CDECL);
601  engine->RegisterGlobalFunction("bool IsKeyPressed(int, bool = true)", asFUNCTIONPR([](int a, bool b) { return ImGui::IsKeyPressed(a, b); }, (int,bool), bool), asCALL_CDECL);
602  engine->RegisterGlobalFunction("bool IsKeyReleased(int)", asFUNCTIONPR([](int a) { return ImGui::IsKeyReleased(a); }, (int), bool), asCALL_CDECL);
603  /*engine->RegisterGlobalFunction("int GetKeyPressedAmount(int, float, float)", asFUNCTIONPR([](int a, float b, float c) { return ImGui::GetKeyPressedAmount(a, b, c); }, (int,float,float), int), asCALL_CDECL);*/ // FIXME update imgui
604  engine->RegisterGlobalFunction("bool IsMouseDown(int)", asFUNCTIONPR([](int a) { return ImGui::IsMouseDown(a); }, (int), bool), asCALL_CDECL);
605  engine->RegisterGlobalFunction("bool IsMouseClicked(int, bool = false)", asFUNCTIONPR([](int a, bool b) { return ImGui::IsMouseClicked(a, b); }, (int,bool), bool), asCALL_CDECL);
606  engine->RegisterGlobalFunction("bool IsMouseDoubleClicked(int)", asFUNCTIONPR([](int a) { return ImGui::IsMouseDoubleClicked(a); }, (int), bool), asCALL_CDECL);
607  engine->RegisterGlobalFunction("bool IsMouseReleased(int)", asFUNCTIONPR([](int a) { return ImGui::IsMouseReleased(a); }, (int), bool), asCALL_CDECL);
608  engine->RegisterGlobalFunction("bool IsMouseDragging(int = 0, float = -1.0f)", asFUNCTIONPR([](int a, float b) { return ImGui::IsMouseDragging(a, b); }, (int, float), bool), asCALL_CDECL);
609  engine->RegisterGlobalFunction("bool IsMouseHoveringRect(const vector2&in, const vector2&in, bool = true)", asFUNCTIONPR([](const Vector2& a, const Vector2& b, bool c) { return ImGui::IsMouseHoveringRect(ImVec2(a.x, a.y), ImVec2(b.x, b.y), c); }, (const Vector2&, const Vector2&, bool), bool), asCALL_CDECL);
610  /* engine->RegisterGlobalFunction("bool IsMousePosValid(const Vector2&in)", asFUNCTIONPR([](const Vector2& a) { auto v = ImVec2(a.x, a.y); return ImGui::IsMousePosValid(&v); }, (const Vector2&), bool), asCALL_CDECL); */ // FIXME update imgui
611  engine->RegisterGlobalFunction("vector2 GetMousePos()", asFUNCTIONPR([]() { auto v = ImGui::GetMousePos(); return Vector2(v.x, v.y); }, (), Vector2), asCALL_CDECL);
612  engine->RegisterGlobalFunction("vector2 GetMousePosOnOpeningCurrentPopup()", asFUNCTIONPR([]() { auto v = ImGui::GetMousePosOnOpeningCurrentPopup(); return Vector2(v.x, v.y); }, (), Vector2), asCALL_CDECL);
613  engine->RegisterGlobalFunction("vector2 GetMouseDragDelta(int = 0, float = -1.0f)", asFUNCTIONPR([](int a, float b) { auto v = ImGui::GetMouseDragDelta(a, b); return Vector2(v.x, v.y); }, (int,float), Vector2), asCALL_CDECL);
614  engine->RegisterGlobalFunction("void ResetMouseDragDelta(int = 0)", asFUNCTIONPR([](int a) { ImGui::ResetMouseDragDelta(a); }, (int), void), asCALL_CDECL);
615  engine->RegisterGlobalFunction("int GetMouseCursor()", asFUNCTIONPR([]() { return ImGui::GetMouseCursor(); }, (), int), asCALL_CDECL);
616  engine->RegisterGlobalFunction("void SetMouseCursor(int)", asFUNCTIONPR([](ImGuiMouseCursor a) { ImGui::SetMouseCursor(a); }, (int), void), asCALL_CDECL);
617  engine->RegisterGlobalFunction("void CaptureKeyboardFromApp(bool = true)", asFUNCTIONPR([](bool a) { ImGui::CaptureKeyboardFromApp(a); }, (bool), void), asCALL_CDECL);
618  engine->RegisterGlobalFunction("void CaptureMouseFromApp(bool = true)", asFUNCTIONPR([](bool a) { ImGui::CaptureMouseFromApp(a); }, (bool), void), asCALL_CDECL);
619 
620 
621  engine->RegisterGlobalFunction("string GetClipboardText()", asFUNCTIONPR([]() { return string(ImGui::GetClipboardText()); }, (), string), asCALL_CDECL);
622  engine->RegisterGlobalFunction("void SetClipboardText(const string&in)", asFUNCTIONPR([](const string& a) { ImGui::SetClipboardText(a.c_str()); }, (const string&), void), asCALL_CDECL);
623 
624  // Data plotting - we wrap the 'getter func' variant to resemble the 'float*' variant.
625  // 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));
626  engine->RegisterGlobalFunction("void PlotLines(const string&in label, array<float>&in values, int values_count, int values_offset = 0, const string&in overlay_text = string(), float scale_min = FLT_MAX, float scale_max = FLT_MAX, vector2 graph_size = vector2(0,0))",
627  asFUNCTIONPR([](const string& label, CScriptArray* values, int values_count, int values_offset, const string& overlay_text, float scale_min, float scale_max, Vector2 graph_size)
628  { ImGui::PlotLines(label.c_str(), &ImGuiPlotLinesScriptValueGetterFunc, values, values_count, values_offset, overlay_text.c_str(), scale_min, scale_max, ImVec2(graph_size.x, graph_size.y)); },
629  (const string&, CScriptArray*, int, int, const string&, float, float, Vector2), void), asCALL_CDECL);
630 
631  engine->SetDefaultNamespace("");
632 }
633 
OgreImGui.h
ScriptEngine.h
ImGuiPlotLinesScriptValueGetterFunc
float ImGuiPlotLinesScriptValueGetterFunc(void *data, int index)
Definition: ImGuiAngelscript.cpp:39
RoR::RegisterImGuiBindings
void RegisterImGuiBindings(AngelScript::asIScriptEngine *engine)
defined in ImGuiAngelscript.cpp
Definition: ImGuiAngelscript.cpp:53
Ogre
Definition: ExtinguishableFireAffector.cpp:35