Cytopia  0.3
A city building simulation game
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ImGuiAngelscript.cxx File Reference
#include "imgui.h"
#include "scriptarray/scriptarray.h"
#include "ScriptEngine.hxx"
#include <angelscript.h>
#include <string>
+ Include dependency graph for ImGuiAngelscript.cxx:

Go to the source code of this file.

Functions

static void ImVec2DefaultConstructor (ImVec2 *self)
 
static void ImVec2CopyConstructor (const ImVec2 &other, ImVec2 *self)
 
static void ImVec2InitConstructor (float x, float y, ImVec2 *self)
 
static void ImVec2InitConstructorScaler (float s, ImVec2 *self)
 
void registerImVec2 (asIScriptEngine *engine)
 
void registerImGuiBindings (asIScriptEngine *engine)
 

Detailed Description

Function Documentation

◆ ImVec2CopyConstructor()

static void ImVec2CopyConstructor ( const ImVec2 &  other,
ImVec2 *  self 
)
static

Definition at line 17 of file ImGuiAngelscript.cxx.

17 { new (self) ImVec2(other); }
+ Here is the caller graph for this function:

◆ ImVec2DefaultConstructor()

static void ImVec2DefaultConstructor ( ImVec2 *  self)
static

Definition at line 15 of file ImGuiAngelscript.cxx.

15 { new (self) ImVec2(); }
+ Here is the caller graph for this function:

◆ ImVec2InitConstructor()

static void ImVec2InitConstructor ( float  x,
float  y,
ImVec2 *  self 
)
static

Definition at line 19 of file ImGuiAngelscript.cxx.

19 { new (self) ImVec2(x, y); }
+ Here is the caller graph for this function:

◆ ImVec2InitConstructorScaler()

static void ImVec2InitConstructorScaler ( float  s,
ImVec2 *  self 
)
static

Definition at line 21 of file ImGuiAngelscript.cxx.

21 { new (self) ImVec2(s, s); }
+ Here is the caller graph for this function:

◆ registerImGuiBindings()

void registerImGuiBindings ( asIScriptEngine *  engine)

Definition at line 61 of file ImGuiAngelscript.cxx.

62 {
63  engine->SetDefaultNamespace("ImGui");
64 
65  engine->RegisterGlobalFunction("bool Begin(const string&in, bool, int=0)",
66  asFUNCTIONPR([](const string &name, bool opened, int flags)
67  { return ImGui::Begin(name.c_str(), &opened, flags); },
68  (const string &, bool, int), bool),
69  asCALL_CDECL);
70  engine->RegisterGlobalFunction("void End()", asFUNCTIONPR(ImGui::End, (), void), asCALL_CDECL);
71  engine->RegisterGlobalFunction(
72  "bool BeginChild(const string&in)",
73  asFUNCTIONPR([](const string &name) { return ImGui::Begin(name.c_str()); }, (const string &), bool), asCALL_CDECL);
74  engine->RegisterGlobalFunction("void EndChild()", asFUNCTIONPR(ImGui::EndChild, (), void), asCALL_CDECL);
75 
76  engine->RegisterGlobalFunction("ImVec2 GetContentRegionMax()",
77  asFUNCTIONPR(
78  []()
79  {
80  auto v = ImGui::GetContentRegionMax();
81  return ImVec2(v.x, v.y);
82  },
83  (), ImVec2),
84  asCALL_CDECL);
85  engine->RegisterGlobalFunction("ImVec2 GetContentRegionAvail()",
86  asFUNCTIONPR(
87  []()
88  {
89  auto v = ImGui::GetContentRegionAvail();
90  return ImVec2(v.x, v.y);
91  },
92  (), ImVec2),
93  asCALL_CDECL);
94  // engine->RegisterGlobalFunction("float GetContentRegionAvailWidth()", asFUNCTIONPR(ImGui::GetContentRegionAvailWidth, (), float), asCALL_CDECL);
95  engine->RegisterGlobalFunction("ImVec2 GetWindowContentRegionMin()",
96  asFUNCTIONPR(
97  []()
98  {
99  auto v = ImGui::GetWindowContentRegionMin();
100  return ImVec2(v.x, v.y);
101  },
102  (), ImVec2),
103  asCALL_CDECL);
104  engine->RegisterGlobalFunction("ImVec2 GetWindowContentRegionMax()",
105  asFUNCTIONPR(
106  []()
107  {
108  auto v = ImGui::GetWindowContentRegionMax();
109  return ImVec2(v.x, v.y);
110  },
111  (), ImVec2),
112  asCALL_CDECL);
113  engine->RegisterGlobalFunction("float GetWindowRegionWidth()", asFUNCTIONPR(ImGui::GetWindowContentRegionWidth, (), float),
114  asCALL_CDECL);
115 
116  engine->RegisterGlobalFunction("ImVec2 GetWindowPos()",
117  asFUNCTIONPR(
118  []()
119  {
120  auto v = ImGui::GetWindowPos();
121  return ImVec2(v.x, v.y);
122  },
123  (), ImVec2),
124  asCALL_CDECL);
125  engine->RegisterGlobalFunction("ImVec2 GetWindowSize()",
126  asFUNCTIONPR(
127  []()
128  {
129  auto v = ImGui::GetWindowSize();
130  return ImVec2(v.x, v.y);
131  },
132  (), ImVec2),
133  asCALL_CDECL);
134  engine->RegisterGlobalFunction("float GetWindowWedth()", asFUNCTIONPR(ImGui::GetWindowWidth, (), float), asCALL_CDECL);
135  engine->RegisterGlobalFunction("float GetWindowHeight()", asFUNCTIONPR(ImGui::GetWindowHeight, (), float), asCALL_CDECL);
136  engine->RegisterGlobalFunction("bool IsWindowCollapsed()", asFUNCTIONPR(ImGui::IsWindowCollapsed, (), bool), asCALL_CDECL);
137  // engine->RegisterGlobalFunction("bool IsWindowAppearing()", asFUNCTIONPR(ImGui::IsWindowAppearing, (), bool), asCALL_CDECL);
138  engine->RegisterGlobalFunction("void SetWindowFontScale(float)", asFUNCTIONPR(ImGui::SetWindowFontScale, (float), void),
139  asCALL_CDECL);
140 
141  engine->RegisterGlobalFunction("void SetNextWindowPos(ImVec2)",
142  asFUNCTIONPR([](ImVec2 v) { ImGui::SetNextWindowPos(ImVec2(v.x, v.y)); }, (ImVec2), void),
143  asCALL_CDECL);
144  engine->RegisterGlobalFunction("void SetNextWindowSize(ImVec2)",
145  asFUNCTIONPR([](ImVec2 v) { ImGui::SetNextWindowSize(ImVec2(v.x, v.y)); }, (ImVec2), void),
146  asCALL_CDECL);
147  engine->RegisterGlobalFunction(
148  "void SetNextWindowContentSize(ImVec2)",
149  asFUNCTIONPR([](ImVec2 v) { ImGui::SetNextWindowContentSize(ImVec2(v.x, v.y)); }, (ImVec2), void), asCALL_CDECL);
150  engine->RegisterGlobalFunction("void SetNextWindowCollapsed(bool)",
151  asFUNCTIONPR([](bool v) { ImGui::SetNextWindowCollapsed(v); }, (bool), void), asCALL_CDECL);
152  engine->RegisterGlobalFunction("void SetNextWindowFocus()", asFUNCTIONPR([]() { ImGui::SetNextWindowFocus(); }, (), void),
153  asCALL_CDECL);
154  engine->RegisterGlobalFunction("void SetWindowPos(ImVec2)",
155  asFUNCTIONPR([](ImVec2 v) { ImGui::SetWindowPos(ImVec2(v.x, v.y)); }, (ImVec2), void),
156  asCALL_CDECL);
157  engine->RegisterGlobalFunction("void SetWindowSize(ImVec2)",
158  asFUNCTIONPR([](ImVec2 v) { ImGui::SetWindowSize(ImVec2(v.x, v.y)); }, (ImVec2), void),
159  asCALL_CDECL);
160  engine->RegisterGlobalFunction("void SetWindowCollapsed(bool)",
161  asFUNCTIONPR([](bool v) { ImGui::SetWindowCollapsed(v); }, (bool), void), asCALL_CDECL);
162  engine->RegisterGlobalFunction("void SetWindowFocus()", asFUNCTIONPR([]() { ImGui::SetWindowFocus(); }, (), void),
163  asCALL_CDECL);
164 
165  engine->RegisterGlobalFunction("void SetWindowPos(const string&in, ImVec2)",
166  asFUNCTIONPR([](const string &name, ImVec2 v)
167  { ImGui::SetWindowPos(name.c_str(), ImVec2(v.x, v.y)); },
168  (const string &, ImVec2), void),
169  asCALL_CDECL);
170  engine->RegisterGlobalFunction("void SetWindowSize(const string&in, ImVec2)",
171  asFUNCTIONPR([](const string &name, ImVec2 v)
172  { ImGui::SetWindowSize(name.c_str(), ImVec2(v.x, v.y)); },
173  (const string &, ImVec2), void),
174  asCALL_CDECL);
175  engine->RegisterGlobalFunction(
176  "void SetWindowCollapsed(const string&in, bool)",
177  asFUNCTIONPR([](const string &name, bool v) { ImGui::SetWindowCollapsed(name.c_str(), v); }, (const string &, bool), void),
178  asCALL_CDECL);
179  engine->RegisterGlobalFunction("void SetWindowFocus(const string&in)",
180  asFUNCTIONPR([](const string &v) { ImGui::SetWindowFocus(v.c_str()); }, (const string &), void),
181  asCALL_CDECL);
182 
183  engine->RegisterGlobalFunction("float GetScrollX()", asFUNCTIONPR(ImGui::GetScrollX, (), float), asCALL_CDECL);
184  engine->RegisterGlobalFunction("float GetScrollY()", asFUNCTIONPR(ImGui::GetScrollY, (), float), asCALL_CDECL);
185  engine->RegisterGlobalFunction("float GetScrollMaxX()", asFUNCTIONPR(ImGui::GetScrollMaxX, (), float), asCALL_CDECL);
186  engine->RegisterGlobalFunction("float GetScrollMaxY()", asFUNCTIONPR(ImGui::GetScrollMaxY, (), float), asCALL_CDECL);
187  engine->RegisterGlobalFunction("void SetScrollX(float)", asFUNCTIONPR(ImGui::SetScrollX, (float), void), asCALL_CDECL);
188  engine->RegisterGlobalFunction("void SetScrollY(float)", asFUNCTIONPR(ImGui::SetScrollY, (float), void), asCALL_CDECL);
189  // engine->RegisterGlobalFunction("void SetScrollHere(float = 0.5f)", asFUNCTIONPR(ImGui::SetScrollHere, (float), void), asCALL_CDECL);
190  engine->RegisterGlobalFunction("void SetScrollFromPosY(float, float = 0.5f)",
191  asFUNCTIONPR(ImGui::SetScrollFromPosY, (float, float), void), asCALL_CDECL);
192 
193  engine->RegisterGlobalFunction("void Separator()", asFUNCTIONPR(ImGui::Separator, (), void), asCALL_CDECL);
194  engine->RegisterGlobalFunction("void SameLine(float = 0.0f, float = -1.0f)",
195  asFUNCTIONPR(ImGui::SameLine, (float, float), void), asCALL_CDECL);
196  engine->RegisterGlobalFunction("void NewLine()", asFUNCTIONPR(ImGui::NewLine, (), void), asCALL_CDECL);
197  engine->RegisterGlobalFunction("void Spacing()", asFUNCTIONPR(ImGui::Spacing, (), void), asCALL_CDECL);
198  engine->RegisterGlobalFunction("void Dummy(ImVec2)",
199  asFUNCTIONPR([](ImVec2 v) { ImGui::Dummy(ImVec2(v.x, v.y)); }, (ImVec2), void), asCALL_CDECL);
200  engine->RegisterGlobalFunction("void Indent(float = 0.0f)", asFUNCTIONPR(ImGui::Indent, (float), void), asCALL_CDECL);
201  engine->RegisterGlobalFunction("void Unindent(float = 0.0f)", asFUNCTIONPR(ImGui::Unindent, (float), void), asCALL_CDECL);
202  engine->RegisterGlobalFunction("void BeginGroup()", asFUNCTIONPR(ImGui::BeginGroup, (), void), asCALL_CDECL);
203  engine->RegisterGlobalFunction("void EndGroup()", asFUNCTIONPR(ImGui::EndGroup, (), void), asCALL_CDECL);
204  engine->RegisterGlobalFunction("ImVec2 GetCursorPos()",
205  asFUNCTIONPR(
206  []()
207  {
208  auto v = ImGui::GetCursorPos();
209  return ImVec2(v.x, v.y);
210  },
211  (), ImVec2),
212  asCALL_CDECL);
213  engine->RegisterGlobalFunction("float GetCursorPosX()", asFUNCTIONPR(ImGui::GetCursorPosX, (), float), asCALL_CDECL);
214  engine->RegisterGlobalFunction("float GetCursorPosY()", asFUNCTIONPR(ImGui::GetCursorPosY, (), float), asCALL_CDECL);
215  engine->RegisterGlobalFunction("void SetCursorPos(ImVec2)",
216  asFUNCTIONPR([](ImVec2 v) { ImGui::SetCursorPos(ImVec2(v.x, v.y)); }, (ImVec2), void),
217  asCALL_CDECL);
218  engine->RegisterGlobalFunction("void SetCursorPosX(float)", asFUNCTIONPR(ImGui::SetCursorPosX, (float), void), asCALL_CDECL);
219  engine->RegisterGlobalFunction("void SetCursorPosY(float)", asFUNCTIONPR(ImGui::SetCursorPosY, (float), void), asCALL_CDECL);
220  engine->RegisterGlobalFunction("ImVec2 GetCursorStartPos()",
221  asFUNCTIONPR(
222  []()
223  {
224  auto v = ImGui::GetCursorStartPos();
225  return ImVec2(v.x, v.y);
226  },
227  (), ImVec2),
228  asCALL_CDECL);
229  engine->RegisterGlobalFunction("ImVec2 GetCursorScreenPos()",
230  asFUNCTIONPR(
231  []()
232  {
233  auto v = ImGui::GetCursorScreenPos();
234  return ImVec2(v.x, v.y);
235  },
236  (), ImVec2),
237  asCALL_CDECL);
238  engine->RegisterGlobalFunction("void SetCursorScreenPos(ImVec2)",
239  asFUNCTIONPR([](ImVec2 v) { ImGui::SetCursorScreenPos(ImVec2(v.x, v.y)); }, (ImVec2), void),
240  asCALL_CDECL);
241  // engine->RegisterGlobalFunction("void AlignTextToFramePadding()", asFUNCTIONPR(ImGui::AlignTextToFramePadding, (), void), asCALL_CDECL);
242  engine->RegisterGlobalFunction("float GetTextLineHeight()", asFUNCTIONPR(ImGui::GetTextLineHeight, (), float), asCALL_CDECL);
243  engine->RegisterGlobalFunction("float GetTextLineHeightWithSpacing()",
244  asFUNCTIONPR(ImGui::GetTextLineHeightWithSpacing, (), float), asCALL_CDECL);
245  // engine->RegisterGlobalFunction("float GetFrameHeight()", asFUNCTIONPR(ImGui::GetFrameHeight, (), float), asCALL_CDECL);
246  // engine->RegisterGlobalFunction("float GetFrameHeightWithSpacing()", asFUNCTIONPR(ImGui::GetFrameHeightWithSpacing, (), float), asCALL_CDECL);
247 
248  // Columns
249  engine->RegisterGlobalFunction("void Columns(int = 1, const string&in = string(), bool = true)",
250  asFUNCTIONPR([](int a, const string &b, bool c)
251  { ImGui::Columns(a, b.empty() ? b.c_str() : 0x0, c); },
252  (int, const string &, bool), void),
253  asCALL_CDECL);
254  engine->RegisterGlobalFunction("void NextColumn()", asFUNCTIONPR([]() { ImGui::NextColumn(); }, (), void), asCALL_CDECL);
255  engine->RegisterGlobalFunction("int GetColumnIndex()", asFUNCTIONPR([]() { return ImGui::GetColumnIndex(); }, (), int),
256  asCALL_CDECL);
257  engine->RegisterGlobalFunction("float GetColumnWidth(int = -1)",
258  asFUNCTIONPR([](int a) { return ImGui::GetColumnWidth(a); }, (int), float), asCALL_CDECL);
259  // engine->RegisterGlobalFunction("void SetColumnWidth(int, float)", asFUNCTIONPR([](int a, float b) { ImGui::SetColumnWidth(a, b); }, (int,float), void), asCALL_CDECL);
260  engine->RegisterGlobalFunction("float GetColumnOffset(int = -1)",
261  asFUNCTIONPR([](int a) { return ImGui::GetColumnOffset(a); }, (int), float), asCALL_CDECL);
262  engine->RegisterGlobalFunction("void SetColumnOffset(int, float)",
263  asFUNCTIONPR([](int a, float b) { ImGui::SetColumnOffset(a, b); }, (int, float), void),
264  asCALL_CDECL);
265  engine->RegisterGlobalFunction("int GetColumnsCount()", asFUNCTIONPR([]() { return ImGui::GetColumnsCount(); }, (), int),
266  asCALL_CDECL);
267 
268  // ID scopes
269  engine->RegisterGlobalFunction("void PushID(const string&in)",
270  asFUNCTIONPR([](const string &n) { ImGui::PushID(n.c_str()); }, (const string &), void),
271  asCALL_CDECL);
272  engine->RegisterGlobalFunction("void PushID(int int_id)", asFUNCTIONPR([](int id) { ImGui::PushID(id); }, (int), void),
273  asCALL_CDECL);
274  engine->RegisterGlobalFunction("void PopID()", asFUNCTIONPR(ImGui::PopID, (), void), asCALL_CDECL);
275  engine->RegisterGlobalFunction(
276  "uint GetID(const string&in)",
277  asFUNCTIONPR([](const string &n) { return ImGui::GetID(n.c_str()); }, (const string &), unsigned), asCALL_CDECL);
278 
279  // Widgets: Text
280  engine->RegisterGlobalFunction("void Text(const string&in)",
281  asFUNCTIONPR([](const string &n) { ImGui::Text(n.c_str()); }, (const string &), void),
282  asCALL_CDECL);
283  engine->RegisterGlobalFunction("void TextDisabled(const string&in)",
284  asFUNCTIONPR([](const string &n) { ImGui::TextDisabled(n.c_str()); }, (const string &), void),
285  asCALL_CDECL);
286  // engine->RegisterGlobalFunction("void TextColored(color col, const string&in)",
287  // asFUNCTIONPR([](ColourValue c, const string &n)
288  // { ImGui::TextColored(ImVec4(c.r, c.g, c.b, c.a), n.c_str()); },
289  // (ColourValue, const string &), void),
290  // asCALL_CDECL);
291  engine->RegisterGlobalFunction("void TextWrapped(const string&in)",
292  asFUNCTIONPR([](const string &n) { ImGui::TextWrapped(n.c_str()); }, (const string &), void),
293  asCALL_CDECL);
294  engine->RegisterGlobalFunction("void LabelText(const string&in, const string&in)",
295  asFUNCTIONPR([](const string &l, const string &n) { ImGui::LabelText(l.c_str(), n.c_str()); },
296  (const string &, const string &), void),
297  asCALL_CDECL);
298  engine->RegisterGlobalFunction("void Bullet()", asFUNCTIONPR(ImGui::Bullet, (), void), asCALL_CDECL);
299  engine->RegisterGlobalFunction("void BulletText(const string&in)",
300  asFUNCTIONPR([](const string &n) { ImGui::BulletText(n.c_str()); }, (const string &), void),
301  asCALL_CDECL);
302 
303  // Widgets: Main
304  engine->RegisterGlobalFunction("bool Button(const string&in, ImVec2 = ImVec2(0,0))",
305  asFUNCTIONPR([](const string &n, ImVec2 v)
306  { return ImGui::Button(n.c_str(), ImVec2(v.x, v.y)); },
307  (const string &, ImVec2), bool),
308  asCALL_CDECL);
309  engine->RegisterGlobalFunction(
310  "bool SmallButton(const string&in)",
311  asFUNCTIONPR([](const string &n) { return ImGui::SmallButton(n.c_str()); }, (const string &), bool), asCALL_CDECL);
312  engine->RegisterGlobalFunction("bool InvisibleButton(const string&in, ImVec2)",
313  asFUNCTIONPR([](const string &id, ImVec2 v)
314  { return ImGui::InvisibleButton(id.c_str(), ImVec2(v.x, v.y)); },
315  (const string &, ImVec2), bool),
316  asCALL_CDECL);
317  // engine->RegisterGlobalFunction("void Image(const TexturePtr&in, ImVec2)",
318  // asFUNCTIONPR([](TexturePtr const &tex, ImVec2 v)
319  // { ImGui::Image((ImTextureID)tex->getHandle(), ImVec2(v.x, v.y)); },
320  // (TexturePtr const &, ImVec2), void),
321  // asCALL_CDECL);
322  engine->RegisterGlobalFunction(
323  "bool Checkbox(const string&in, bool&inout)",
324  asFUNCTIONPR([](const string &n, bool &v) { return ImGui::Checkbox(n.c_str(), &v); }, (const string &, bool &), bool),
325  asCALL_CDECL);
326  engine->RegisterGlobalFunction("bool CheckboxFlags(const string&in, uint&inout, uint)",
327  asFUNCTIONPR([](const string &n, unsigned &f, unsigned v)
328  { return ImGui::CheckboxFlags(n.c_str(), &f, v); },
329  (const string &, unsigned &, unsigned), bool),
330  asCALL_CDECL);
331  engine->RegisterGlobalFunction(
332  "bool RadioButton(const string&in, bool)",
333  asFUNCTIONPR([](const string &n, bool v) { return ImGui::RadioButton(n.c_str(), v); }, (const string &, bool), bool),
334  asCALL_CDECL);
335  engine->RegisterGlobalFunction("bool RadioButton(const string&in, int&inout, int)",
336  asFUNCTIONPR([](const string &n, int &v, int vv)
337  { return ImGui::RadioButton(n.c_str(), &v, vv); },
338  (const string &, int &, int), bool),
339  asCALL_CDECL);
340  engine->RegisterGlobalFunction("void ProgressBar(float)", asFUNCTIONPR([](float v) { ImGui::ProgressBar(v); }, (float), void),
341  asCALL_CDECL);
342 
343  // Widgets: Combo Box
344  // 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);
345  // engine->RegisterGlobalFunction("void EndCombo()", asFUNCTIONPR(ImGui::EndCombo, (), void), asCALL_CDECL);
346  /*
347  static char imgui_comboItem[4096];
348  engine->RegisterGlobalFunction("bool Combo(const string&in, int&inout, const Array<string>@+)", asFUNCTIONPR([](const string& lbl, int& index, const CScriptArray* items) {
349  memset(imgui_comboItem, 0, sizeof(char) * 4096);
350  unsigned offset = 0;
351  for (unsigned i = 0; i < items->GetSize(); ++i)
352  {
353  string* str = ((string*)items->At(i));
354  strcpy(imgui_comboItem + offset, str->c_str());
355  offset += str->length() + 1;
356  }
357  return ImGui::Combo(lbl.c_str(), &index, imgui_comboItem, -1);
358  }, (const string&, int&, const CScriptArray*), bool), asCALL_CDECL);
359  */
360  // Widgets: Drags
361  engine->RegisterGlobalFunction("bool DragFloat(const string&in, float&inout, float = 1.0f, float = 0.0f, float = 0.0f)",
362  asFUNCTIONPR([](const string &n, float &v, float speed, float mn, float mx)
363  { return ImGui::DragFloat(n.c_str(), &v, speed, mn, mx); },
364  (const string &, float &, float, float, float), bool),
365  asCALL_CDECL);
366  engine->RegisterGlobalFunction("bool DragFloat2(const string&in, ImVec2&inout)",
367  asFUNCTIONPR([](const string &n, ImVec2 &v) { return ImGui::DragFloat2(n.c_str(), &v.x); },
368  (const string &, ImVec2 &), bool),
369  asCALL_CDECL);
370  // engine->RegisterGlobalFunction("bool DragFloat3(const string&in, vector3&inout)", asFUNCTIONPR([](const string& n, Vector3& v) {
371  // return ImGui::DragFloat3(n.c_str(), &v.x); }, (const string&, Vector3&), bool), asCALL_CDECL);
372  /* --- TODO: Register Vector4
373  engine->RegisterGlobalFunction("bool DragFloat4(const string&in, Vector4&inout)", asFUNCTIONPR([](const string& n, Vector4& v) {
374  return ImGui::DragFloat4(n.c_str(), &v.x); }, (const string&, Vector4&), bool), asCALL_CDECL);
375  engine->RegisterGlobalFunction("bool DragInt(const string&in, int&inout, int = 0, int = 0)", asFUNCTIONPR([](const string& n, int& v, int mn, int mx) {
376  return ImGui::DragInt(n.c_str(), &v, 1.0f, mn, mx); }, (const string&, int&, int, int), bool), asCALL_CDECL);
377  engine->RegisterGlobalFunction("bool DragInt2(const string&in, IntImVec2&inout, int = 0, int = 0)", asFUNCTIONPR([](const string& n, IntImVec2& v, int mn, int mx) {
378  return ImGui::DragInt2(n.c_str(), &v.x, 1.0f, mn, mx); }, (const string&, IntImVec2&, int,int), bool), asCALL_CDECL);
379  engine->RegisterGlobalFunction("bool DragInt3(const string&in, IntVector3&inout, int = 0, int = 0)", asFUNCTIONPR([](const string& n, IntVector3& v, int mn, int mx) {
380  return ImGui::DragInt3(n.c_str(), &v.x, 1.0f, mn, mx); }, (const string&, IntVector3&, int,int), bool), asCALL_CDECL);
381  */
382  engine->RegisterGlobalFunction("bool DragFloatRange2(const string&in, float&inout, float&inout, float = 0.0f, float = 1.0f)",
383  asFUNCTIONPR([](const string &n, float &v0, float &v1, float mn, float mx)
384  { return ImGui::DragFloatRange2(n.c_str(), &v0, &v1, 1.0f, mn, mx); },
385  (const string &, float &, float &, float, float), bool),
386  asCALL_CDECL);
387  engine->RegisterGlobalFunction("bool DragIntRange2(const string&in, int&inout, int&inout, int, int)",
388  asFUNCTIONPR([](const string &n, int &v0, int &v1, int mn, int mx)
389  { return ImGui::DragIntRange2(n.c_str(), &v0, &v1, 1.0f, mn, mx); },
390  (const string &, int &, int &, int, int), bool),
391  asCALL_CDECL);
392 
393  // Widgets: Input with Keyboard
394  static char imgui_text_buffer[4096]; // shared with multiple widgets
395  engine->RegisterGlobalFunction("bool InputText(const string&in, string&inout)",
396  asFUNCTIONPR(
397  [](const string &id, string &val)
398  {
399  memset(imgui_text_buffer, 0, sizeof(char) * 4096);
400  strcpy(imgui_text_buffer, val.c_str());
401  if (ImGui::InputText(id.c_str(), imgui_text_buffer, 4096))
402  {
403  val = imgui_text_buffer;
404  return true;
405  }
406  return false;
407  },
408  (const string &, string &), bool),
409  asCALL_CDECL);
410  engine->RegisterGlobalFunction("bool InputTextMultiline(const string&in, string&inout)",
411  asFUNCTIONPR(
412  [](const string &id, string &val)
413  {
414  memset(imgui_text_buffer, 0, sizeof(char) * 4096);
415  strcpy(imgui_text_buffer, val.c_str());
416  if (ImGui::InputTextMultiline(id.c_str(), imgui_text_buffer, 4096))
417  {
418  val = imgui_text_buffer;
419  return true;
420  }
421  return false;
422  },
423  (const string &, string &), bool),
424  asCALL_CDECL);
425  engine->RegisterGlobalFunction("bool InputFloat(const string&, float&inout)",
426  asFUNCTIONPR([](const string &id, float &val) { return ImGui::InputFloat(id.c_str(), &val); },
427  (const string &, float &), bool),
428  asCALL_CDECL);
429  engine->RegisterGlobalFunction("bool InputFloat2(const string&, ImVec2&inout)",
430  asFUNCTIONPR([](const string &id, ImVec2 &val)
431  { return ImGui::InputFloat2(id.c_str(), &val.x); },
432  (const string &, ImVec2 &), bool),
433  asCALL_CDECL);
434  // engine->RegisterGlobalFunction("bool InputFloat3(const string&, vector3&inout)",
435  // asFUNCTIONPR([](const string &id, Vector3 &val)
436  // { return ImGui::InputFloat3(id.c_str(), &val.x); },
437  // (const string &, Vector3 &), bool),
438  // asCALL_CDECL);
439  /* --- TODO: Register Vector4
440  engine->RegisterGlobalFunction("bool InputFloat4(const string&, Vector4&inout)", asFUNCTIONPR([](const string& id, Vector4& val) {
441  return ImGui::InputFloat4(id.c_str(), &val.x_); }, (const string&, Vector4&),bool), asCALL_CDECL);
442  engine->RegisterGlobalFunction("bool InputInt(const string&, int&inout)", asFUNCTIONPR([](const string& id, int& val) {
443  return ImGui::InputInt(id.c_str(), &val); }, (const string&, int&), bool), asCALL_CDECL);
444  engine->RegisterGlobalFunction("bool InputInt2(const string&, IntImVec2&inout)", asFUNCTIONPR([](const string& id, IntImVec2& val) {
445  return ImGui::InputInt2(id.c_str(), &val.x_); }, (const string&, IntImVec2&),bool), asCALL_CDECL);
446  engine->RegisterGlobalFunction("bool InputInt3(const string&, IntVector3&inout)", asFUNCTIONPR([](const string& id, IntVector3& val) {
447  return ImGui::InputInt3(id.c_str(), &val.x_); }, (const string&, IntVector3&), bool), asCALL_CDECL);
448  */
449 
450  // Widgets: Sliders (tip: ctrl+click on a slider to input with keyboard. manually input values aren't clamped, can go off-bounds)
451  engine->RegisterGlobalFunction("bool SliderFloat(const string&in, float&inout, float = 0.0f, float = 0.0f)",
452  asFUNCTIONPR([](const string &n, float &v, float mn, float mx)
453  { return ImGui::SliderFloat(n.c_str(), &v, mn, mx); },
454  (const string &, float &, float, float), bool),
455  asCALL_CDECL);
456  engine->RegisterGlobalFunction("bool SliderFloat2(const string&in, ImVec2&inout, float, float)",
457  asFUNCTIONPR([](const string &n, ImVec2 &v, float mn, float mx)
458  { return ImGui::SliderFloat2(n.c_str(), &v.x, mn, mx); },
459  (const string &, ImVec2 &, float, float), bool),
460  asCALL_CDECL);
461  // engine->RegisterGlobalFunction("bool SliderFloat3(const string&in, vector3&inout, float, float)",
462  // asFUNCTIONPR([](const string &n, Vector3 &v, float mn, float mx)
463  // { return ImGui::SliderFloat3(n.c_str(), &v.x, mn, mx); },
464  // (const string &, Vector3 &, float, float), bool),
465  // asCALL_CDECL);
466  /* --- TODO: Register Vector4
467  engine->RegisterGlobalFunction("bool SliderFloat4(const string&in, Vector4&inout, float, float)", asFUNCTIONPR([](const string& n, Vector4& v, float mn, float mx) {
468  return ImGui::SliderFloat4(n.c_str(), &v.x, mn, mx); }, (const string&, Vector4&,float,float),bool), asCALL_CDECL);
469  engine->RegisterGlobalFunction("bool SliderInt(const string&in, int&inout, int = 0, int = 0)", asFUNCTIONPR([](const string& n, int& v, int mn, int mx) {
470  return ImGui::SliderInt(n.c_str(), &v, mn, mx); }, (const string&, int&,int,int), bool), asCALL_CDECL);
471  engine->RegisterGlobalFunction("bool SliderInt2(const string&in, IntImVec2&inout, int = 0, int = 0)", asFUNCTIONPR([](const string& n, IntImVec2& v, int mn, int mx) {
472  return ImGui::SliderInt2(n.c_str(), &v.x, mn, mx); }, (const string&, IntImVec2&, int,int),bool), asCALL_CDECL);
473  engine->RegisterGlobalFunction("bool SliderInt3(const string&in, IntVector3&inout, int = 0, int = 0)", asFUNCTIONPR([](const string& n, IntVector3& v, int mn, int mx) {
474  return ImGui::SliderInt3(n.c_str(), &v.x, mn, mx); }, (const string&, IntVector3&, int,int),bool), asCALL_CDECL);
475  */
476 
477  // Widgets: Color Editor/Picker
478  // engine->RegisterGlobalFunction("bool ColorEdit3(const string&in, color&inout)",
479  // asFUNCTIONPR(
480  // [](const string &id, ColourValue &val)
481  // {
482  // Vector3 v(val.r, val.g, val.b);
483  // if (ImGui::ColorEdit3(id.c_str(), &v.x))
484  // {
485  // val = ColourValue(v.x, v.y, v.z);
486  // return true;
487  // }
488  // return false;
489  // },
490  // (const string &, ColourValue &), bool),
491  // asCALL_CDECL);
492  // engine->RegisterGlobalFunction("bool ColorEdit4(const string&in, color&inout)",
493  // asFUNCTIONPR(
494  // [](const string &id, ColourValue &val)
495  // {
496  // Vector4 v(val.r, val.g, val.b, val.a);
497  // if (ImGui::ColorEdit4(id.c_str(), &v.x))
498  // {
499  // val = ColourValue(v.x, v.y, v.z, v.w);
500  // return true;
501  // }
502  // return false;
503  // },
504  // (const string &, ColourValue &), bool),
505  // asCALL_CDECL);
506  /* engine->RegisterGlobalFunction("bool ColorPicker3(const string&in, color&inout)", asFUNCTIONPR([](const string& id, ColourValue& val) {
507  Vector3 v(val.r, val.g, val.b);
508  if (ImGui::ColorPicker3(id.c_str(), &v.x))
509  {
510  val = ColourValue(v.x, v.y, v.z);
511  return true;
512  }
513  return false;
514  }, (const string&, ColourValue&),bool), asCALL_CDECL);
515  engine->RegisterGlobalFunction("bool ColorPicker4(const string&in, color&inout)", asFUNCTIONPR([](const string& id, ColourValue& val) {
516  Vector4 v(val.r, val.g, val.b, val.a);
517  if (ImGui::ColorPicker4(id.c_str(), &v.x))
518  {
519  val = ColourValue(v.x, v.y, v.z, v.w);
520  return true;
521  }
522  return false;
523  }, (const string&, ColourValue&),bool), asCALL_CDECL);*/
524  // engine->RegisterGlobalFunction("bool ColorButton(const string&in, color)",
525  // asFUNCTIONPR(
526  // [](const string &id, ColourValue val)
527  // {
528  // Vector4 v(val.r, val.g, val.b, val.a);
529  // ImVec4 vv(v.x, v.y, v.z, v.w);
530  // return ImGui::ColorButton(id.c_str(), vv);
531  // },
532  // (const string &, ColourValue), bool),
533  // asCALL_CDECL);
534 
535  // Widgets: Trees
536  engine->RegisterGlobalFunction(
537  "bool TreeNode(const string&in)",
538  asFUNCTIONPR([](const string &id) { return ImGui::TreeNode(id.c_str()); }, (const string &), bool), asCALL_CDECL);
539  engine->RegisterGlobalFunction("void TreePush(const string&in)",
540  asFUNCTIONPR([](const string &id) { ImGui::TreePush(id.c_str()); }, (const string &), void),
541  asCALL_CDECL);
542  engine->RegisterGlobalFunction("void TreePop()", asFUNCTIONPR(ImGui::TreePop, (), void), asCALL_CDECL);
543  // engine->RegisterGlobalFunction("void TreeAdvanceToLabelPos()", asFUNCTIONPR(ImGui::TreeAdvanceToLabelPos, (), void),
544  // asCALL_CDECL);
545  engine->RegisterGlobalFunction("float GetTreeNodeToLabelSpacing()", asFUNCTIONPR(ImGui::GetTreeNodeToLabelSpacing, (), float),
546  asCALL_CDECL);
547  // engine->RegisterGlobalFunction("void SetNextTreeNodeOpen(bool)",
548  // asFUNCTIONPR([](bool val) { ImGui::SetNextTreeNodeOpen(val); }, (bool), void), asCALL_CDECL);
549  engine->RegisterGlobalFunction(
550  "bool CollapsingHeader(const string&in)",
551  asFUNCTIONPR([](const string &n) { return ImGui::CollapsingHeader(n.c_str()); }, (const string &), bool), asCALL_CDECL);
552  engine->RegisterGlobalFunction("bool CollapsingHeader(const string&in, bool&inout)",
553  asFUNCTIONPR([](const string &n, bool &v) { return ImGui::CollapsingHeader(n.c_str(), &v); },
554  (const string &, bool &), bool),
555  asCALL_CDECL);
556 
557  // Widgets: Selectable / Lists
558  engine->RegisterGlobalFunction(
559  "bool Selectable(const string&in, bool = false)",
560  asFUNCTIONPR([](const string &n, bool v) { return ImGui::Selectable(n.c_str(), v); }, (const string &, bool), bool),
561  asCALL_CDECL);
562  engine->RegisterGlobalFunction(
563  "bool ListBoxHeader(const string&in)",
564  asFUNCTIONPR([](const string &n) { return ImGui::ListBoxHeader(n.c_str()); }, (const string &), bool), asCALL_CDECL);
565 
566  // Values
567  engine->RegisterGlobalFunction(
568  "void Value(const string&in, bool)",
569  asFUNCTIONPR([](const string &n, bool v) { ImGui::Value(n.c_str(), v); }, (const string &, bool), void), asCALL_CDECL);
570  engine->RegisterGlobalFunction(
571  "void Value(const string&in, int)",
572  asFUNCTIONPR([](const string &n, int v) { ImGui::Value(n.c_str(), v); }, (const string &, int), void), asCALL_CDECL);
573  engine->RegisterGlobalFunction(
574  "void Value(const string&in, uint)",
575  asFUNCTIONPR([](const string &n, unsigned v) { ImGui::Value(n.c_str(), v); }, (const string &, unsigned), void),
576  asCALL_CDECL);
577  engine->RegisterGlobalFunction(
578  "void Value(const string&in, float)",
579  asFUNCTIONPR([](const string &n, float v) { ImGui::Value(n.c_str(), v); }, (const string &, float), void), asCALL_CDECL);
580 
581  // Tooltips
582  engine->RegisterGlobalFunction("void BeginTooltip()", asFUNCTIONPR(ImGui::BeginTooltip, (), void), asCALL_CDECL);
583  engine->RegisterGlobalFunction("void EndTooltip()", asFUNCTIONPR(ImGui::EndTooltip, (), void), asCALL_CDECL);
584  engine->RegisterGlobalFunction("void SetTooltip(const string&in)",
585  asFUNCTIONPR([](const string &t) { ImGui::SetTooltip(t.c_str()); }, (const string &), void),
586  asCALL_CDECL);
587 
588  // Menus
589  engine->RegisterGlobalFunction("bool BeginMainMenuBar()", asFUNCTIONPR([]() { return ImGui::BeginMainMenuBar(); }, (), bool),
590  asCALL_CDECL);
591  engine->RegisterGlobalFunction("void EndMainMenuBar()", asFUNCTIONPR([]() { ImGui::EndMainMenuBar(); }, (), void),
592  asCALL_CDECL);
593  engine->RegisterGlobalFunction("bool BeginMenuBar()", asFUNCTIONPR([]() { return ImGui::BeginMenuBar(); }, (), bool),
594  asCALL_CDECL);
595  engine->RegisterGlobalFunction("void EndMenuBar()", asFUNCTIONPR([]() { ImGui::EndMenuBar(); }, (), void), asCALL_CDECL);
596  engine->RegisterGlobalFunction("bool BeginMenu(const string&in, bool = true)",
597  asFUNCTIONPR([](const string &a, bool b)
598  { return ImGui::BeginMenu(a.empty() ? a.c_str() : 0x0, b); },
599  (const string &, bool), bool),
600  asCALL_CDECL);
601  engine->RegisterGlobalFunction("void EndMenu()", asFUNCTIONPR([]() { ImGui::EndMenu(); }, (), void), asCALL_CDECL);
602  engine->RegisterGlobalFunction(
603  "bool MenuItem(const string&in, const string&in = string(), bool = false, bool = true)",
604  asFUNCTIONPR([](const string &a, const string &b, bool c, bool d)
605  { return ImGui::MenuItem(a.empty() ? a.c_str() : 0x0, b.empty() ? b.c_str() : 0x0, c, d); },
606  (const string &, const string &, bool, bool), bool),
607  asCALL_CDECL);
608  engine->RegisterGlobalFunction(
609  "bool MenuItem(const string&in, const string&in, bool &inout, bool = true)",
610  asFUNCTIONPR([](const string &a, const string &b, bool &c, bool d)
611  { return ImGui::MenuItem(a.empty() ? a.c_str() : 0x0, b.empty() ? b.c_str() : 0x0, &c, d); },
612  (const string &, const string &, bool &, bool), bool),
613  asCALL_CDECL);
614 
615  // Popups
616  engine->RegisterGlobalFunction(
617  "void OpenPopup(const string&in)",
618  asFUNCTIONPR([](const string &a) { ImGui::OpenPopup(a.empty() ? a.c_str() : 0x0); }, (const string &), void), asCALL_CDECL);
619  /* engine->RegisterGlobalFunction("bool BeginPopup(const string&in, int = 0)", asFUNCTIONPR([](const string& a, int b) {
620  return ImGui::BeginPopup(a.empty() ? a.c_str() : 0x0, (ImGuiWindowFlags)b); }, (const string&, int), bool), asCALL_CDECL);*/ // FIXME: update imgui!
621  engine->RegisterGlobalFunction("bool BeginPopup(const string&in, int = 0)",
622  asFUNCTIONPR([](const string &a, int b)
623  { return ImGui::BeginPopup(a.empty() ? a.c_str() : 0x0); },
624  (const string &, int), bool),
625  asCALL_CDECL);
626  engine->RegisterGlobalFunction("bool BeginPopupContextItem(const string&in = string(), int = 1)",
627  asFUNCTIONPR([](const string &a, int b)
628  { return ImGui::BeginPopupContextItem(a.empty() ? a.c_str() : 0x0, b); },
629  (const string &, int), bool),
630  asCALL_CDECL);
631  engine->RegisterGlobalFunction("bool BeginPopupContextWindow(const string&in = string(), int = 1, bool = true)",
632  asFUNCTIONPR([](const string &a, int b, bool c)
633  { return ImGui::BeginPopupContextWindow(a.empty() ? a.c_str() : 0x0, b, c); },
634  (const string &, int, bool), bool),
635  asCALL_CDECL); // FIXME: update imgui! -- swapped args
636  engine->RegisterGlobalFunction("bool BeginPopupContextVoid(const string&in = string(), int = 1)",
637  asFUNCTIONPR([](const string &a, int b)
638  { return ImGui::BeginPopupContextVoid(a.empty() ? a.c_str() : 0x0, b); },
639  (const string &, int), bool),
640  asCALL_CDECL);
641  engine->RegisterGlobalFunction(
642  "bool BeginPopupModal(const string&in, bool &inout = null, int = 0)",
643  asFUNCTIONPR([](const string &a, bool &b, int c)
644  { return ImGui::BeginPopupModal(a.empty() ? a.c_str() : 0x0, &b, (ImGuiWindowFlags)c); },
645  (const string &, bool &, int), bool),
646  asCALL_CDECL);
647  engine->RegisterGlobalFunction("void EndPopup()", asFUNCTIONPR([]() { ImGui::EndPopup(); }, (), void), asCALL_CDECL);
648  /* engine->RegisterGlobalFunction("bool OpenPopupOnItemClick(const string&in = string(), int = 1)", asFUNCTIONPR([](const string& a, int b) {
649  return ImGui::OpenPopupOnItemClick(a.empty() ? a.c_str() : 0x0, b); }, (const string&, int), bool), asCALL_CDECL);*/ // FIXME: update imgui!
650  /* engine->RegisterGlobalFunction("bool IsPopupOpen(const string&in)", asFUNCTIONPR([](const string& a) {
651  return ImGui::IsPopupOpen(a.empty() ? a.c_str() : 0x0); }, (const string&), bool), asCALL_CDECL); */ // FIXME: update imgui!
652  engine->RegisterGlobalFunction("void CloseCurrentPopup()", asFUNCTIONPR([]() { ImGui::CloseCurrentPopup(); }, (), void),
653  asCALL_CDECL);
654 
655  // Clip-rects
656  engine->RegisterGlobalFunction("void PushClipRect(const ImVec2&, const ImVec2&, bool)",
657  asFUNCTIONPR([](const ImVec2 &a, const ImVec2 &b, bool c)
658  { ImGui::PushClipRect(ImVec2(a.x, a.y), ImVec2(b.x, b.y), c); },
659  (const ImVec2 &, const ImVec2 &, bool), void),
660  asCALL_CDECL);
661  engine->RegisterGlobalFunction("void PopClipRect()", asFUNCTIONPR([]() { ImGui::PopClipRect(); }, (), void), asCALL_CDECL);
662 
663  // Focus
664  /* engine->RegisterGlobalFunction("void SetItemDefaultFocus()", asFUNCTIONPR([]() { ImGui::SetItemDefaultFocus(); }, (), void), asCALL_CDECL); */ // TODO update imgui
665  engine->RegisterGlobalFunction("void SetKeyboardFocusHere(int = 0)",
666  asFUNCTIONPR([](int a) { ImGui::SetKeyboardFocusHere(a); }, (int), void), asCALL_CDECL);
667 
668  // Utilities
669  engine->RegisterGlobalFunction("bool IsItemHovered(int = 0)",
670  asFUNCTIONPR([](int a) { return ImGui::IsItemHovered(); }, (int), bool),
671  asCALL_CDECL); // TODO: update imgui -- flags omitted
672  engine->RegisterGlobalFunction("bool IsItemActive()", asFUNCTIONPR([]() { return ImGui::IsItemActive(); }, (), bool),
673  asCALL_CDECL);
674  engine->RegisterGlobalFunction("bool IsItemClicked(int = 0)",
675  asFUNCTIONPR([](int a) { return ImGui::IsItemClicked(a); }, (int), bool), asCALL_CDECL);
676  engine->RegisterGlobalFunction("bool IsItemVisible()", asFUNCTIONPR([]() { return ImGui::IsItemVisible(); }, (), bool),
677  asCALL_CDECL);
678  engine->RegisterGlobalFunction("bool IsAnyItemHovered()", asFUNCTIONPR([]() { return ImGui::IsAnyItemHovered(); }, (), bool),
679  asCALL_CDECL);
680  engine->RegisterGlobalFunction("bool IsAnyItemActive()", asFUNCTIONPR([]() { return ImGui::IsAnyItemActive(); }, (), bool),
681  asCALL_CDECL);
682  engine->RegisterGlobalFunction("ImVec2 GetItemRectMin()",
683  asFUNCTIONPR(
684  []()
685  {
686  auto v = ImGui::GetItemRectMin();
687  return ImVec2(v.x, v.y);
688  },
689  (), ImVec2),
690  asCALL_CDECL);
691  engine->RegisterGlobalFunction("ImVec2 GetItemRectMax()",
692  asFUNCTIONPR(
693  []()
694  {
695  auto v = ImGui::GetItemRectMax();
696  return ImVec2(v.x, v.y);
697  },
698  (), ImVec2),
699  asCALL_CDECL);
700  engine->RegisterGlobalFunction("ImVec2 GetItemRectSize()",
701  asFUNCTIONPR(
702  []()
703  {
704  auto v = ImGui::GetItemRectSize();
705  return ImVec2(v.x, v.y);
706  },
707  (), ImVec2),
708  asCALL_CDECL);
709  engine->RegisterGlobalFunction("void SetItemAllowOverlap()", asFUNCTIONPR([]() { ImGui::SetItemAllowOverlap(); }, (), void),
710  asCALL_CDECL);
711  engine->RegisterGlobalFunction("bool IsWindowFocused(int = 0)",
712  asFUNCTIONPR([](int a) { return ImGui::IsWindowFocused(); }, (int), bool),
713  asCALL_CDECL); // TODO: update imgui -- flags omitted
714  engine->RegisterGlobalFunction("bool IsWindowHovered(int = 0)",
715  asFUNCTIONPR([](int a) { return ImGui::IsWindowHovered(); }, (int), bool),
716  asCALL_CDECL); // TODO: update imgui -- flags omitted
717  engine->RegisterGlobalFunction(
718  "bool IsRectVisible(const ImVec2&)",
719  asFUNCTIONPR([](const ImVec2 &a) { return ImGui::IsRectVisible(ImVec2(a.x, a.y)); }, (const ImVec2 &), bool), asCALL_CDECL);
720  engine->RegisterGlobalFunction("bool IsRectVisible(const ImVec2&, const ImVec2&)",
721  asFUNCTIONPR([](const ImVec2 &a, const ImVec2 &b)
722  { return ImGui::IsRectVisible(ImVec2(a.x, a.y), ImVec2(b.x, b.y)); },
723  (const ImVec2 &, const ImVec2 &), bool),
724  asCALL_CDECL);
725  engine->RegisterGlobalFunction("float GetTime()", asFUNCTIONPR([]() { return (float)ImGui::GetTime(); }, (), float),
726  asCALL_CDECL);
727  engine->RegisterGlobalFunction("int GetFrameCount()", asFUNCTIONPR([]() { return ImGui::GetFrameCount(); }, (), int),
728  asCALL_CDECL);
729 
730  engine->RegisterGlobalFunction("ImVec2 CalcTextSize(const string&in, const string&in = string(), bool = false, float = -1.0f)",
731  asFUNCTIONPR(
732  [](const string &a, const string &b, bool c, float d)
733  {
734  auto v =
735  ImGui::CalcTextSize(a.empty() ? a.c_str() : 0x0, b.empty() ? b.c_str() : 0x0, c, d);
736  return ImVec2(v.x, v.y);
737  },
738  (const string &, const string &, bool, float), ImVec2),
739  asCALL_CDECL);
740  engine->RegisterGlobalFunction("void CalcListClipping(int, float, int&inout, int&inout)",
741  asFUNCTIONPR([](int a, float b, int &c, int &d) { ImGui::CalcListClipping(a, b, &c, &d); },
742  (int, float, int &, int &), void),
743  asCALL_CDECL);
744  engine->RegisterGlobalFunction("bool BeginChildFrame(uint, const ImVec2&, int = 0)",
745  asFUNCTIONPR([](unsigned a, const ImVec2 &b, int c)
746  { return ImGui::BeginChildFrame(a, ImVec2(b.x, b.y), (ImGuiWindowFlags)c); },
747  (unsigned, const ImVec2 &, int), bool),
748  asCALL_CDECL);
749  engine->RegisterGlobalFunction("void EndChildFrame()", asFUNCTIONPR([]() { ImGui::EndChildFrame(); }, (), void), asCALL_CDECL);
750 
751  engine->RegisterGlobalFunction("int GetKeyIndex(int)",
752  asFUNCTIONPR([](int a) { return ImGui::GetKeyIndex((ImGuiKey)a); }, (int), int), asCALL_CDECL);
753  engine->RegisterGlobalFunction("bool IsKeyDown(int)", asFUNCTIONPR([](int a) { return ImGui::IsKeyDown(a); }, (int), bool),
754  asCALL_CDECL);
755  engine->RegisterGlobalFunction("bool IsKeyPressed(int, bool = true)",
756  asFUNCTIONPR([](int a, bool b) { return ImGui::IsKeyPressed(a, b); }, (int, bool), bool),
757  asCALL_CDECL);
758  engine->RegisterGlobalFunction("bool IsKeyReleased(int)",
759  asFUNCTIONPR([](int a) { return ImGui::IsKeyReleased(a); }, (int), bool), asCALL_CDECL);
760  /*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
761  engine->RegisterGlobalFunction("bool IsMouseDown(int)", asFUNCTIONPR([](int a) { return ImGui::IsMouseDown(a); }, (int), bool),
762  asCALL_CDECL);
763  engine->RegisterGlobalFunction("bool IsMouseClicked(int, bool = false)",
764  asFUNCTIONPR([](int a, bool b) { return ImGui::IsMouseClicked(a, b); }, (int, bool), bool),
765  asCALL_CDECL);
766  engine->RegisterGlobalFunction("bool IsMouseDoubleClicked(int)",
767  asFUNCTIONPR([](int a) { return ImGui::IsMouseDoubleClicked(a); }, (int), bool), asCALL_CDECL);
768  engine->RegisterGlobalFunction("bool IsMouseReleased(int)",
769  asFUNCTIONPR([](int a) { return ImGui::IsMouseReleased(a); }, (int), bool), asCALL_CDECL);
770  engine->RegisterGlobalFunction("bool IsMouseDragging(int = 0, float = -1.0f)",
771  asFUNCTIONPR([](int a, float b) { return ImGui::IsMouseDragging(a, b); }, (int, float), bool),
772  asCALL_CDECL);
773  engine->RegisterGlobalFunction("bool IsMouseHoveringRect(const ImVec2&in, const ImVec2&in, bool = true)",
774  asFUNCTIONPR([](const ImVec2 &a, const ImVec2 &b, bool c)
775  { return ImGui::IsMouseHoveringRect(ImVec2(a.x, a.y), ImVec2(b.x, b.y), c); },
776  (const ImVec2 &, const ImVec2 &, bool), bool),
777  asCALL_CDECL);
778  /* engine->RegisterGlobalFunction("bool IsMousePosValid(const ImVec2&in)", asFUNCTIONPR([](const ImVec2& a) { auto v = ImVec2(a.x, a.y); return ImGui::IsMousePosValid(&v); }, (const ImVec2&), bool), asCALL_CDECL); */ // FIXME update imgui
779  engine->RegisterGlobalFunction("ImVec2 GetMousePos()",
780  asFUNCTIONPR(
781  []()
782  {
783  auto v = ImGui::GetMousePos();
784  return ImVec2(v.x, v.y);
785  },
786  (), ImVec2),
787  asCALL_CDECL);
788  engine->RegisterGlobalFunction("ImVec2 GetMousePosOnOpeningCurrentPopup()",
789  asFUNCTIONPR(
790  []()
791  {
792  auto v = ImGui::GetMousePosOnOpeningCurrentPopup();
793  return ImVec2(v.x, v.y);
794  },
795  (), ImVec2),
796  asCALL_CDECL);
797  engine->RegisterGlobalFunction("ImVec2 GetMouseDragDelta(int = 0, float = -1.0f)",
798  asFUNCTIONPR(
799  [](int a, float b)
800  {
801  auto v = ImGui::GetMouseDragDelta(a, b);
802  return ImVec2(v.x, v.y);
803  },
804  (int, float), ImVec2),
805  asCALL_CDECL);
806  engine->RegisterGlobalFunction("void ResetMouseDragDelta(int = 0)",
807  asFUNCTIONPR([](int a) { ImGui::ResetMouseDragDelta(a); }, (int), void), asCALL_CDECL);
808  engine->RegisterGlobalFunction("int GetMouseCursor()", asFUNCTIONPR([]() { return ImGui::GetMouseCursor(); }, (), int),
809  asCALL_CDECL);
810  engine->RegisterGlobalFunction("void SetMouseCursor(int)",
811  asFUNCTIONPR([](ImGuiMouseCursor a) { ImGui::SetMouseCursor(a); }, (int), void), asCALL_CDECL);
812  engine->RegisterGlobalFunction("void CaptureKeyboardFromApp(bool = true)",
813  asFUNCTIONPR([](bool a) { ImGui::CaptureKeyboardFromApp(a); }, (bool), void), asCALL_CDECL);
814  engine->RegisterGlobalFunction("void CaptureMouseFromApp(bool = true)",
815  asFUNCTIONPR([](bool a) { ImGui::CaptureMouseFromApp(a); }, (bool), void), asCALL_CDECL);
816 
817  engine->RegisterGlobalFunction("string GetClipboardText()",
818  asFUNCTIONPR([]() { return string(ImGui::GetClipboardText()); }, (), string), asCALL_CDECL);
819  engine->RegisterGlobalFunction(
820  "void SetClipboardText(const string&in)",
821  asFUNCTIONPR([](const string &a) { ImGui::SetClipboardText(a.empty() ? a.c_str() : 0x0); }, (const string &), void),
822  asCALL_CDECL);
823 
824  engine->SetDefaultNamespace("");
825 }

◆ registerImVec2()

void registerImVec2 ( asIScriptEngine *  engine)

Definition at line 24 of file ImGuiAngelscript.cxx.

25 {
26  int r;
27 
28  r = engine->RegisterObjectType("ImVec2", sizeof(ImVec2),
29  asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_CA | asOBJ_APP_CLASS_ALLFLOATS);
30  assert(r >= 0);
31 
32  // Register the object properties
33  r = engine->RegisterObjectProperty("ImVec2", "float x", offsetof(ImVec2, x));
34  assert(r >= 0);
35  r = engine->RegisterObjectProperty("ImVec2", "float y", offsetof(ImVec2, y));
36  assert(r >= 0);
37 
38  // Register the object constructors
39  r = engine->RegisterObjectBehaviour("ImVec2", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ImVec2DefaultConstructor),
40  asCALL_CDECL_OBJLAST);
41  assert(r >= 0);
42  r = engine->RegisterObjectBehaviour("ImVec2", asBEHAVE_CONSTRUCT, "void f(float, float)", asFUNCTION(ImVec2InitConstructor),
43  asCALL_CDECL_OBJLAST);
44  assert(r >= 0);
45  r = engine->RegisterObjectBehaviour("ImVec2", asBEHAVE_CONSTRUCT, "void f(const ImVec2 &in)", asFUNCTION(ImVec2CopyConstructor),
46  asCALL_CDECL_OBJLAST);
47  assert(r >= 0);
48  r = engine->RegisterObjectBehaviour("ImVec2", asBEHAVE_CONSTRUCT, "void f(float)", asFUNCTION(ImVec2InitConstructorScaler),
49  asCALL_CDECL_OBJLAST);
50  assert(r >= 0);
51 
52  // Register the object operators
53  r = engine->RegisterObjectMethod("ImVec2", "float opIndex(int) const", asMETHODPR(ImVec2, operator[], (size_t) const, float),
54  asCALL_THISCALL);
55  assert(r >= 0);
56  r = engine->RegisterObjectMethod("ImVec2", "ImVec2 &f(const ImVec2 &in)",
57  asMETHODPR(ImVec2, operator=, (const ImVec2 &), ImVec2 &), asCALL_THISCALL);
58  assert(r >= 0);
59 }
+ Here is the call graph for this function:
ImVec2InitConstructorScaler
static void ImVec2InitConstructorScaler(float s, ImVec2 *self)
Definition: ImGuiAngelscript.cxx:21
int
int
Definition: tileData.hxx:57
ImVec2CopyConstructor
static void ImVec2CopyConstructor(const ImVec2 &other, ImVec2 *self)
Definition: ImGuiAngelscript.cxx:17
ImVec2DefaultConstructor
static void ImVec2DefaultConstructor(ImVec2 *self)
Definition: ImGuiAngelscript.cxx:15
string
std::string string
Definition: AudioConfig.hxx:14
ImVec2InitConstructor
static void ImVec2InitConstructor(float x, float y, ImVec2 *self)
Definition: ImGuiAngelscript.cxx:19