Rigs of Rods 2026.01
Soft-body Physics Simulation
Loading...
Searching...
No Matches
ImGuiAngelscriptWrappers.h
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
27
28#pragma once
29
30#include "OgreImGui.h"
31#include "scriptarray/scriptarray.h"
32
33#include <angelscript.h>
34#include <Ogre.h>
35#include <string>
36
38
39using namespace AngelScript;
40using namespace Ogre;
41using std::string;
42
43static float ImGuiPlotLinesScriptValueGetterFunc(void* data, int index)
44{
45 CScriptArray* array_obj = static_cast<CScriptArray*>(data);
46 void* value_raw = array_obj->At(index);
47 if (value_raw == nullptr)
48 {
49 return 0.f; // out of bounds
50 }
51 else
52 {
53 return *static_cast<float*>(value_raw);
54 }
55}
56
57// ---------------------------------------------------------------------------
58// ImDrawList
59// ---------------------------------------------------------------------------
60
61static void ImDrawList_AddLine(ImDrawList* drawlist, Ogre::Vector2 const& p1, Ogre::Vector2 const& p2, Ogre::ColourValue const& col, float thickness)
62{
63 drawlist->AddLine(ImVec2(p1.x, p1.y), ImVec2(p2.x, p2.y), ImColor(col.r, col.g, col.b, col.a), thickness);
64}
65
66static void ImDrawList_AddTriangle(ImDrawList* drawlist, Ogre::Vector2 const& p1, Ogre::Vector2 const& p2, Ogre::Vector2 const& p3, Ogre::ColourValue const& col, float thickness)
67{
68 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);
69}
70
71static void ImDrawList_AddTriangleFilled(ImDrawList* drawlist, Ogre::Vector2 const& p1, Ogre::Vector2 const& p2, Ogre::Vector2 const& p3, Ogre::ColourValue const& col)
72{
73 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));
74}
75
76static void ImDrawList_AddRect(ImDrawList* drawlist, Ogre::Vector2 const& p1, Ogre::Vector2 const& p2, Ogre::ColourValue const& col, float rounding, int rounding_corners, float thickness)
77{
78 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);
79}
80
81static void ImDrawList_AddRectFilled(ImDrawList* drawlist, Ogre::Vector2 const& p1, Ogre::Vector2 const& p2, Ogre::ColourValue const& col, float rounding, int rounding_corners)
82{
83 drawlist->AddRectFilled(ImVec2(p1.x, p1.y), ImVec2(p2.x, p2.y), ImColor(col.r, col.g, col.b, col.a), rounding, rounding_corners);
84}
85
86static void ImDrawList_AddCircle(ImDrawList* drawlist, Ogre::Vector2 const& center, float radius, Ogre::ColourValue const& col, int num_segments, float thickness)
87{
88 drawlist->AddCircle(ImVec2(center.x, center.y), radius, ImColor(col.r, col.g, col.b, col.a), num_segments, thickness);
89}
90
91static void ImDrawList_AddCircleFilled(ImDrawList* drawlist, Ogre::Vector2 const& center, float radius, Ogre::ColourValue const& col, int num_segments)
92{
93 drawlist->AddCircleFilled(ImVec2(center.x, center.y), radius, ImColor(col.r, col.g, col.b, col.a), num_segments);
94}
95
96static void ImDrawList_AddText(ImDrawList* drawlist, Ogre::Vector2 const& pos, Ogre::ColourValue const& col, std::string const& text)
97{
98 drawlist->AddText(ImVec2(pos.x, pos.y), ImColor(col.r, col.g, col.b, col.a), text.c_str());
99}
100
101static void ImDrawList_AddImage(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)
102{
103 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));
104}
105
106// ---------------------------------------------------------------------------
107// Windows
108// ---------------------------------------------------------------------------
109
110static bool ImGui_Begin(const string& name, bool& opened, int flags)
111{
112 return ImGui::Begin(name.c_str(), &opened, flags);
113}
114
115static bool ImGui_BeginChild(const string& name, const Ogre::Vector2& size, bool border, int flags)
116{
117 return ImGui::BeginChild(name.c_str(), ImVec2(size.x, size.y), border, flags);
118}
119
120static bool ImGui_BeginChildById(ImGuiID id, const Ogre::Vector2& size, bool border, int flags)
121{
122 return ImGui::BeginChild(id, ImVec2(size.x, size.y), border, flags);
123}
124
125static void ImGui_PushStyleVarFloat(int index, float val)
126{
127 ImGui::PushStyleVar(index, val);
128}
129
130static void ImGui_PushStyleVarVector2(int index, const Ogre::Vector2& val)
131{
132 ImGui::PushStyleVar(index, ImVec2(val.x, val.y));
133}
134
135static void ImGui_PushStyleColor(int index, Ogre::ColourValue const& col)
136{
137 ImGui::PushStyleColor(index, (ImU32)ImColor(col.r, col.g, col.b, col.a));
138}
139
141{
142 auto v = ImGui::GetContentRegionMax(); return Vector2(v.x, v.y);
143}
144
146{
147 auto v = ImGui::GetContentRegionAvail(); return Vector2(v.x, v.y);
148}
149
151{
152 auto v = ImGui::GetWindowContentRegionMin(); return Vector2(v.x, v.y);
153}
154
156{
157 auto v = ImGui::GetWindowContentRegionMax(); return Vector2(v.x, v.y);
158}
159
160static Vector2 ImGui_GetWindowPos()
161{
162 auto v = ImGui::GetWindowPos(); return Vector2(v.x, v.y);
163}
164
165static Vector2 ImGui_GetWindowSize()
166{
167 auto v = ImGui::GetWindowSize(); return Vector2(v.x, v.y);
168}
169
170static void ImGui_SetNextWindowPos(Vector2 v, int flags, Vector2 pivot)
171{
172 ImGui::SetNextWindowPos(ImVec2(v.x, v.y), flags, ImVec2(pivot.x, pivot.y));
173}
174
175static void ImGui_SetNextWindowSize(Vector2 v)
176{
177 ImGui::SetNextWindowSize(ImVec2(v.x, v.y));
178}
179
180static void ImGui_SetNextWindowContentSize(Vector2 v)
181{
182 ImGui::SetNextWindowContentSize(ImVec2(v.x, v.y));
183}
184
186{
187 ImGui::SetNextWindowCollapsed(v);
188}
189
191{
192 ImGui::SetNextWindowFocus();
193}
194
195static void ImGui_SetWindowPos(Vector2 v)
196{
197 ImGui::SetWindowPos(ImVec2(v.x, v.y));
198}
199
200static void ImGui_SetWindowSize(Vector2 v)
201{
202 ImGui::SetWindowSize(ImVec2(v.x, v.y));
203}
204
205static void ImGui_SetWindowCollapsed(bool v)
206{
207 ImGui::SetWindowCollapsed(v);
208}
209
211{
212 ImGui::SetWindowFocus();
213}
214
215static void ImGui_SetWindowPosByName(const string& name, Vector2 v)
216{
217 ImGui::SetWindowPos(name.c_str(), ImVec2(v.x, v.y));
218}
219
220static void ImGui_SetWindowSizeByName(const string& name, Vector2 v)
221{
222 ImGui::SetWindowSize(name.c_str(), ImVec2(v.x, v.y));
223}
224
225static void ImGui_SetWindowCollapsedByName(const string& name, bool v)
226{
227 ImGui::SetWindowCollapsed(name.c_str(), v);
228}
229
230static void ImGui_SetWindowFocusByName(const string& v)
231{
232 ImGui::SetWindowFocus(v.c_str());
233}
234
235// ---------------------------------------------------------------------------
236// Cursor / Layout
237// ---------------------------------------------------------------------------
238
239static void ImGui_Dummy(Vector2 v)
240{
241 ImGui::Dummy(ImVec2(v.x, v.y));
242}
243
244static Vector2 ImGui_GetCursorPos()
245{
246 auto v = ImGui::GetCursorPos(); return Vector2(v.x, v.y);
247}
248
249static void ImGui_SetCursorPos(Vector2 v)
250{
251 ImGui::SetCursorPos(ImVec2(v.x, v.y));
252}
253
255{
256 auto v = ImGui::GetCursorStartPos(); return Vector2(v.x, v.y);
257}
258
260{
261 auto v = ImGui::GetCursorScreenPos(); return Vector2(v.x, v.y);
262}
263
264static void ImGui_SetCursorScreenPos(Vector2 v)
265{
266 ImGui::SetCursorScreenPos(ImVec2(v.x, v.y));
267}
268
269// ---------------------------------------------------------------------------
270// Columns (considered legacy in latest versions - superseded by Tables!)
271// ---------------------------------------------------------------------------
272
273static void ImGui_Columns(int a, const string& b, bool c)
274{
275 ImGui::Columns(a, b.c_str(), c);
276}
277
278static void ImGui_NextColumn()
279{
280 ImGui::NextColumn();
281}
282
284{
285 return ImGui::GetColumnIndex();
286}
287
288static float ImGui_GetColumnWidth(int a)
289{
290 return ImGui::GetColumnWidth(a);
291}
292
293static float ImGui_GetColumnOffset(int a)
294{
295 return ImGui::GetColumnOffset(a);
296}
297
298static void ImGui_SetColumnOffset(int a, float b)
299{
300 ImGui::SetColumnOffset(a, b);
301}
302
304{
305 return ImGui::GetColumnsCount();
306}
307
308// ---------------------------------------------------------------------------
309// Tab bars, tabs
310// ---------------------------------------------------------------------------
311
312static bool ImGui_BeginTabBar(const string& str_id, ImGuiTabBarFlags flags)
313{
314 return ImGui::BeginTabBar(str_id.c_str(), flags);
315}
316
317// BeginTabItem() without X close button.
318static bool ImGui_BeginTabItem(const string& label, ImGuiTabItemFlags flags)
319{
320 return ImGui::BeginTabItem(label.c_str(), nullptr, flags);
321}
322
323// BeginTabItem() with X close button.
324static bool ImGui_BeginTabItemClosable(const string& label, bool& p_open, ImGuiTabItemFlags flags)
325{
326 return ImGui::BeginTabItem(label.c_str(), &p_open, flags);
327}
328
329static void ImGui_SetTabItemClosed(const string& tab_or_docked_window_label)
330{
331 ImGui::SetTabItemClosed(tab_or_docked_window_label.c_str());
332}
333
334// ---------------------------------------------------------------------------
335// ID scopes
336// ---------------------------------------------------------------------------
337
338static void ImGui_PushIDStr(const string& n)
339{
340 ImGui::PushID(n.c_str());
341}
342
343static void ImGui_PushIDInt(int id)
344{
345 ImGui::PushID(id);
346}
347
348static unsigned ImGui_GetID(const string& n)
349{
350 return ImGui::GetID(n.c_str());
351}
352
353// ---------------------------------------------------------------------------
354// Widgets: Text
355// ---------------------------------------------------------------------------
356
357static void ImGui_Text(const string& n)
358{
359 ImGui::Text(n.c_str());
360}
361
362static void ImGui_TextDisabled(const string& n)
363{
364 ImGui::TextDisabled(n.c_str());
365}
366
367static void ImGui_TextColored(ColourValue c, const string& n)
368{
369 ImGui::TextColored(ImVec4(c.r, c.g, c.b, c.a), n.c_str());
370}
371
372static void ImGui_TextWrapped(const string& n)
373{
374 ImGui::TextWrapped(n.c_str());
375}
376
377static void ImGui_LabelText(const string& l, const string& n)
378{
379 ImGui::LabelText(l.c_str(), n.c_str());
380}
381
382static void ImGui_BulletText(const string& n)
383{
384 ImGui::BulletText(n.c_str());
385}
386
387// ---------------------------------------------------------------------------
388// Widgets: Main
389// ---------------------------------------------------------------------------
390
391static bool ImGui_Button(const string& n, Vector2 v)
392{
393 return ImGui::Button(n.c_str(), ImVec2(v.x, v.y));
394}
395
396static bool ImGui_SmallButton(const string& n)
397{
398 return ImGui::SmallButton(n.c_str());
399}
400
401static bool ImGui_InvisibleButton(const string& id, Vector2 v)
402{
403 return ImGui::InvisibleButton(id.c_str(), ImVec2(v.x, v.y));
404}
405
406static void ImGui_Image(Ogre::TexturePtr const& tex, Vector2 v)
407{
408 ImGui::Image((ImTextureID)tex->getHandle(), ImVec2(v.x, v.y));
409}
410
411static bool ImGui_Checkbox(const string& n, bool& v)
412{
413 return ImGui::Checkbox(n.c_str(), &v);
414}
415
416static bool ImGui_CheckboxFlags(const string& n, unsigned& f, unsigned v)
417{
418 return ImGui::CheckboxFlags(n.c_str(), &f, v);
419}
420
421static bool ImGui_RadioButton(const string& n, bool v)
422{
423 return ImGui::RadioButton(n.c_str(), v);
424}
425
426static bool ImGui_RadioButtonInt(const string& n, int& v, int vv)
427{
428 return ImGui::RadioButton(n.c_str(), &v, vv);
429}
430
431static void ImGui_ProgressBar(float v, Ogre::Vector2 size, const string& overlay)
432{
433 ImGui::ProgressBar(v, ImVec2(size.x, size.y), (overlay != "")?overlay.c_str():nullptr);
434}
435
436// ---------------------------------------------------------------------------
437// Widgets: Drags
438// ---------------------------------------------------------------------------
439
440static bool ImGui_DragFloat(const string& n, float& v, float speed, float mn, float mx)
441{
442 return ImGui::DragFloat(n.c_str(), &v, speed, mn, mx);
443}
444
445static bool ImGui_DragFloat2(const string& n, Vector2& v)
446{
447 return ImGui::DragFloat2(n.c_str(), &v.x);
448}
449
450static bool ImGui_DragFloat3(const string& n, Vector3& v)
451{
452 return ImGui::DragFloat3(n.c_str(), &v.x);
453}
454
455static bool ImGui_DragFloatRange2(const string& n, float& v0, float& v1, float mn, float mx)
456{
457 return ImGui::DragFloatRange2(n.c_str(), &v0, &v1, 1.0f, mn, mx);
458}
459
460static bool ImGui_DragIntRange2(const string& n, int& v0, int& v1, int mn, int mx)
461{
462 return ImGui::DragIntRange2(n.c_str(), &v0, &v1, 1.0f, mn, mx);
463}
464
465// ---------------------------------------------------------------------------
466// Widgets: Input with Keyboard
467// ---------------------------------------------------------------------------
468
469static char imgui_text_buffer[4096]; // shared with multiple widgets
470
471static bool ImGui_InputText(const string& id, string& val)
472{
473 memset(imgui_text_buffer, 0, sizeof(char) * 4096);
474 strcpy(imgui_text_buffer, val.c_str());
475 if (ImGui::InputText(id.c_str(), imgui_text_buffer, 4096))
476 {
477 val = imgui_text_buffer;
478 return true;
479 }
480 return false;
481}
482
483static bool ImGui_InputTextMultiline(const string& id, string& val, const Ogre::Vector2& size)
484{
485 return ImGui::InputTextMultiline(id.c_str(), (char*)val.data(), val.size(), ImVec2(size.x, size.y));
486}
487
488static bool ImGui_InputFloat(const string& id, float& val)
489{
490 return ImGui::InputFloat(id.c_str(), &val);
491}
492
493static bool ImGui_InputFloat2(const string& id, Vector2& val)
494{
495 return ImGui::InputFloat2(id.c_str(), &val.x);
496}
497
498static bool ImGui_InputFloat3(const string& id, Vector3& val)
499{
500 return ImGui::InputFloat3(id.c_str(), &val.x);
501}
502
503static bool ImGui_InputInt(const string& id, int& val)
504{
505 return ImGui::InputInt(id.c_str(), &val);
506}
507
508// ---------------------------------------------------------------------------
509// Widgets: Sliders
510// ---------------------------------------------------------------------------
511
512static bool ImGui_SliderFloat(const string& n, float& v, float mn, float mx)
513{
514 return ImGui::SliderFloat(n.c_str(), &v, mn, mx);
515}
516
517static bool ImGui_SliderFloat2(const string& n, Vector2& v, float mn, float mx)
518{
519 return ImGui::SliderFloat2(n.c_str(), &v.x, mn, mx);
520}
521
522static bool ImGui_SliderFloat3(const string& n, Vector3& v, float mn, float mx)
523{
524 return ImGui::SliderFloat3(n.c_str(), &v.x, mn, mx);
525}
526
527static bool ImGui_SliderInt(const string& n, int& v, int mn, int mx)
528{
529 return ImGui::SliderInt(n.c_str(), &v, mn, mx);
530}
531
532// ---------------------------------------------------------------------------
533// Widgets: Color Editor/Picker
534// ---------------------------------------------------------------------------
535
536static bool ImGui_ColorEdit3(const string& id, ColourValue& val)
537{
538 Vector3 v(val.r, val.g, val.b);
539 if (ImGui::ColorEdit3(id.c_str(), &v.x))
540 {
541 val = ColourValue(v.x, v.y, v.z);
542 return true;
543 }
544 return false;
545}
546
547static bool ImGui_ColorEdit4(const string& id, ColourValue& val)
548{
549 Vector4 v(val.r, val.g, val.b, val.a);
550 if (ImGui::ColorEdit4(id.c_str(), &v.x))
551 {
552 val = ColourValue(v.x, v.y, v.z, v.w);
553 return true;
554 }
555 return false;
556}
557
558static bool ImGui_ColorButton(const string& id, ColourValue val)
559{
560 Vector4 v(val.r, val.g, val.b, val.a);
561 ImVec4 vv(v.x, v.y, v.z, v.w);
562 return ImGui::ColorButton(id.c_str(), vv);
563}
564
565// ---------------------------------------------------------------------------
566// Widgets: Trees
567// ---------------------------------------------------------------------------
568
569static bool ImGui_TreeNode(const string& id)
570{
571 return ImGui::TreeNode(id.c_str());
572}
573
574static void ImGui_TreePush(const string& id)
575{
576 ImGui::TreePush(id.c_str());
577}
578
579static void ImGui_SetNextTreeNodeOpen(bool val)
580{
581 ImGui::SetNextTreeNodeOpen(val);
582}
583
584static bool ImGui_CollapsingHeader(const string& n)
585{
586 return ImGui::CollapsingHeader(n.c_str());
587}
588
589static bool ImGui_CollapsingHeaderClosable(const string& n, bool& v)
590{
591 return ImGui::CollapsingHeader(n.c_str(), &v);
592}
593
594// ---------------------------------------------------------------------------
595// Widgets: Selectable / Lists
596// ---------------------------------------------------------------------------
597
598static bool ImGui_Selectable(const string& n, bool v)
599{
600 return ImGui::Selectable(n.c_str(), v);
601}
602
603static bool ImGui_ListBoxHeader(const string& n)
604{
605 return ImGui::ListBoxHeader(n.c_str());
606}
607
608// ---------------------------------------------------------------------------
609// Values
610// ---------------------------------------------------------------------------
611
612static void ImGui_ValueBool(const string& n, bool v)
613{
614 ImGui::Value(n.c_str(), v);
615}
616
617static void ImGui_ValueInt(const string& n, int v)
618{
619 ImGui::Value(n.c_str(), v);
620}
621
622static void ImGui_ValueUint(const string& n, unsigned v)
623{
624 ImGui::Value(n.c_str(), v);
625}
626
627static void ImGui_ValueFloat(const string& n, float v)
628{
629 ImGui::Value(n.c_str(), v);
630}
631
632// ---------------------------------------------------------------------------
633// Tooltips
634// ---------------------------------------------------------------------------
635
636static void ImGui_SetTooltip(const string& t)
637{
638 ImGui::SetTooltip(t.c_str());
639}
640
641// ---------------------------------------------------------------------------
642// Menus
643// ---------------------------------------------------------------------------
644
646{
647 return ImGui::BeginMainMenuBar();
648}
649
651{
652 ImGui::EndMainMenuBar();
653}
654
656{
657 return ImGui::BeginMenuBar();
658}
659
660static void ImGui_EndMenuBar()
661{
662 ImGui::EndMenuBar();
663}
664
665static bool ImGui_BeginMenu(const string& a, bool b)
666{
667 return ImGui::BeginMenu(a.c_str(), b);
668}
669
670static void ImGui_EndMenu()
671{
672 ImGui::EndMenu();
673}
674
675static bool ImGui_MenuItem(const string& a, const string& b, bool c, bool d)
676{
677 return ImGui::MenuItem(a.c_str(), b.c_str(), c, d);
678}
679
680static bool ImGui_MenuItemToggle(const string& a, const string& b, bool& c, bool d)
681{
682 return ImGui::MenuItem(a.c_str(), b.c_str(), &c, d);
683}
684
685// ---------------------------------------------------------------------------
686// Popups
687// ---------------------------------------------------------------------------
688
689static void ImGui_OpenPopup(const string& a)
690{
691 ImGui::OpenPopup(a.c_str());
692}
693
694static bool ImGui_BeginPopup(const string& a, int b)
695{
696 return ImGui::BeginPopup(a.c_str()); // FIXME: update imgui! -- flags omitted
697}
698
699static bool ImGui_BeginPopupContextItem(const string& a, int b)
700{
701 return ImGui::BeginPopupContextItem(a.c_str(), b);
702}
703
704static bool ImGui_BeginPopupContextWindow(const string& a, int b, bool c)
705{
706 return ImGui::BeginPopupContextWindow(a.c_str(), b, c); // FIXME: update imgui! -- swapped args
707}
708
709static bool ImGui_BeginPopupContextVoid(const string& a, int b)
710{
711 return ImGui::BeginPopupContextVoid(a.c_str(), b);
712}
713
714static bool ImGui_BeginPopupModal(const string& a, bool& b, int c)
715{
716 return ImGui::BeginPopupModal(a.c_str(), &b, (ImGuiWindowFlags)c);
717}
718
719static void ImGui_EndPopup()
720{
721 ImGui::EndPopup();
722}
723
725{
726 ImGui::CloseCurrentPopup();
727}
728
729// ---------------------------------------------------------------------------
730// Clip-rects
731// ---------------------------------------------------------------------------
732
733static void ImGui_PushClipRect(const Vector2& a, const Vector2& b, bool c)
734{
735 ImGui::PushClipRect(ImVec2(a.x, a.y), ImVec2(b.x, b.y), c);
736}
737
738static void ImGui_PopClipRect()
739{
740 ImGui::PopClipRect();
741}
742
743// ---------------------------------------------------------------------------
744// Focus
745// ---------------------------------------------------------------------------
746
748{
749 ImGui::SetKeyboardFocusHere(a);
750}
751
752// ---------------------------------------------------------------------------
753// Utilities
754// ---------------------------------------------------------------------------
755
756static bool ImGui_IsItemHovered(int a)
757{
758 return ImGui::IsItemHovered(); // TODO: update imgui -- flags omitted
759}
760
762{
763 return ImGui::IsItemActive();
764}
765
766static bool ImGui_IsItemClicked(int a)
767{
768 return ImGui::IsItemClicked(a);
769}
770
772{
773 return ImGui::IsItemVisible();
774}
775
777{
778 return ImGui::IsAnyItemHovered();
779}
780
782{
783 return ImGui::IsAnyItemActive();
784}
785
786static Vector2 ImGui_GetItemRectMin()
787{
788 auto v = ImGui::GetItemRectMin(); return Vector2(v.x, v.y);
789}
790
791static Vector2 ImGui_GetItemRectMax()
792{
793 auto v = ImGui::GetItemRectMax(); return Vector2(v.x, v.y);
794}
795
796static Vector2 ImGui_GetItemRectSize()
797{
798 auto v = ImGui::GetItemRectSize(); return Vector2(v.x, v.y);
799}
800
802{
803 ImGui::SetItemAllowOverlap();
804}
805
806static bool ImGui_IsWindowFocused(int a)
807{
808 return ImGui::IsWindowFocused(); // TODO: update imgui -- flags omitted
809}
810
811static bool ImGui_IsWindowHovered(int a)
812{
813 return ImGui::IsWindowHovered(); // TODO: update imgui -- flags omitted
814}
815
816static bool ImGui_IsRectVisibleSize(const Vector2& a)
817{
818 return ImGui::IsRectVisible(ImVec2(a.x, a.y));
819}
820
821static bool ImGui_IsRectVisible(const Vector2& a, const Vector2& b)
822{
823 return ImGui::IsRectVisible(ImVec2(a.x, a.y), ImVec2(b.x, b.y));
824}
825
826static float ImGui_GetTime()
827{
828 return (float)ImGui::GetTime();
829}
830
832{
833 return ImGui::GetFrameCount();
834}
835
836static Vector2 ImGui_CalcTextSize(const string& a, bool c, float d)
837{
838 auto v = ImGui::CalcTextSize(a.c_str(), nullptr, c, d); return Vector2(v.x, v.y);
839}
840
841static void ImGui_CalcListClipping(int a, float b, int& c, int& d)
842{
843 ImGui::CalcListClipping(a, b, &c, &d);
844}
845
846static bool ImGui_BeginChildFrame(unsigned a, const Vector2& b, int c)
847{
848 return ImGui::BeginChildFrame(a, ImVec2(b.x,b.y), (ImGuiWindowFlags)c);
849}
850
852{
853 ImGui::EndChildFrame();
854}
855
856// ---------------------------------------------------------------------------
857// Inputs
858// ---------------------------------------------------------------------------
859
860static int ImGui_GetKeyIndex(int a)
861{
862 return ImGui::GetKeyIndex((ImGuiKey)a);
863}
864
865static bool ImGui_IsKeyDown(int a)
866{
867 return ImGui::IsKeyDown(a);
868}
869
870static bool ImGui_IsKeyPressed(int a, bool b)
871{
872 return ImGui::IsKeyPressed(a, b);
873}
874
875static bool ImGui_IsKeyReleased(int a)
876{
877 return ImGui::IsKeyReleased(a);
878}
879
880static bool ImGui_IsMouseDown(int a)
881{
882 return ImGui::IsMouseDown(a);
883}
884
885static bool ImGui_IsMouseClicked(int a, bool b)
886{
887 return ImGui::IsMouseClicked(a, b);
888}
889
891{
892 return ImGui::IsMouseDoubleClicked(a);
893}
894
895static bool ImGui_IsMouseReleased(int a)
896{
897 return ImGui::IsMouseReleased(a);
898}
899
900static bool ImGui_IsMouseDragging(int a, float b)
901{
902 return ImGui::IsMouseDragging(a, b);
903}
904
905static bool ImGui_IsMouseHoveringRect(const Vector2& a, const Vector2& b, bool c)
906{
907 return ImGui::IsMouseHoveringRect(ImVec2(a.x, a.y), ImVec2(b.x, b.y), c);
908}
909
910static Vector2 ImGui_GetMousePos()
911{
912 auto v = ImGui::GetMousePos(); return Vector2(v.x, v.y);
913}
914
916{
917 auto v = ImGui::GetMousePosOnOpeningCurrentPopup(); return Vector2(v.x, v.y);
918}
919
920static Vector2 ImGui_GetMouseDragDelta(int a, float b)
921{
922 auto v = ImGui::GetMouseDragDelta(a, b); return Vector2(v.x, v.y);
923}
924
926{
927 ImGui::ResetMouseDragDelta(a);
928}
929
931{
932 return ImGui::GetMouseCursor();
933}
934
935static void ImGui_SetMouseCursor(ImGuiMouseCursor a)
936{
937 ImGui::SetMouseCursor(a);
938}
939
941{
942 ImGui::CaptureKeyboardFromApp(a);
943}
944
945static void ImGui_CaptureMouseFromApp(bool a)
946{
947 ImGui::CaptureMouseFromApp(a);
948}
949
950// ---------------------------------------------------------------------------
951// Clipboard
952// ---------------------------------------------------------------------------
953
955{
956 return string(ImGui::GetClipboardText());
957}
958
959static void ImGui_SetClipboardText(const string& a)
960{
961 ImGui::SetClipboardText(a.c_str());
962}
963
964// ---------------------------------------------------------------------------
965// Data plotting - we wrap the 'getter func' variant to resemble the 'float*' variant.
966// 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));
967// ---------------------------------------------------------------------------
968
969static void ImGui_PlotLines(const string& label, CScriptArray* values, int values_count, int values_offset, const string& overlay_text, float scale_min, float scale_max, Vector2 graph_size)
970{
971 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));
972}
973
974} // namespace ImGuiAngelscriptWrappers
static void ImDrawList_AddRectFilled(ImDrawList *drawlist, Ogre::Vector2 const &p1, Ogre::Vector2 const &p2, Ogre::ColourValue const &col, float rounding, int rounding_corners)
static void ImGui_CalcListClipping(int a, float b, int &c, int &d)
static bool ImGui_ColorEdit4(const string &id, ColourValue &val)
static bool ImGui_BeginPopupContextVoid(const string &a, int b)
static void ImGui_SetCursorScreenPos(Vector2 v)
static void ImDrawList_AddTriangleFilled(ImDrawList *drawlist, Ogre::Vector2 const &p1, Ogre::Vector2 const &p2, Ogre::Vector2 const &p3, Ogre::ColourValue const &col)
static void ImGui_CaptureKeyboardFromApp(bool a)
static void ImGui_SetNextWindowSize(Vector2 v)
static bool ImGui_InputFloat(const string &id, float &val)
static void ImDrawList_AddRect(ImDrawList *drawlist, Ogre::Vector2 const &p1, Ogre::Vector2 const &p2, Ogre::ColourValue const &col, float rounding, int rounding_corners, float thickness)
static void ImDrawList_AddImage(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)
static Vector2 ImGui_GetWindowContentRegionMax()
static bool ImGui_SliderFloat(const string &n, float &v, float mn, float mx)
static bool ImGui_InputFloat3(const string &id, Vector3 &val)
static void ImGui_CaptureMouseFromApp(bool a)
static float ImGui_GetColumnWidth(int a)
static bool ImGui_BeginPopup(const string &a, int b)
static Vector2 ImGui_GetMouseDragDelta(int a, float b)
static void ImGui_SetCursorPos(Vector2 v)
static float ImGuiPlotLinesScriptValueGetterFunc(void *data, int index)
static void ImGui_ValueInt(const string &n, int v)
static bool ImGui_ListBoxHeader(const string &n)
static bool ImGui_MenuItemToggle(const string &a, const string &b, bool &c, bool d)
static bool ImGui_InputTextMultiline(const string &id, string &val, const Ogre::Vector2 &size)
static void ImGui_TextColored(ColourValue c, const string &n)
static void ImGui_PushStyleColor(int index, Ogre::ColourValue const &col)
static bool ImGui_BeginChildFrame(unsigned a, const Vector2 &b, int c)
static bool ImGui_TreeNode(const string &id)
static void ImGui_LabelText(const string &l, const string &n)
static bool ImGui_SliderInt(const string &n, int &v, int mn, int mx)
static void ImGui_ValueUint(const string &n, unsigned v)
static void ImDrawList_AddCircleFilled(ImDrawList *drawlist, Ogre::Vector2 const &center, float radius, Ogre::ColourValue const &col, int num_segments)
static bool ImGui_DragIntRange2(const string &n, int &v0, int &v1, int mn, int mx)
static bool ImGui_BeginTabBar(const string &str_id, ImGuiTabBarFlags flags)
static void ImDrawList_AddText(ImDrawList *drawlist, Ogre::Vector2 const &pos, Ogre::ColourValue const &col, std::string const &text)
static bool ImGui_Begin(const string &name, bool &opened, int flags)
static bool ImGui_IsMouseHoveringRect(const Vector2 &a, const Vector2 &b, bool c)
static bool ImGui_BeginTabItem(const string &label, ImGuiTabItemFlags flags)
static void ImGui_TreePush(const string &id)
static void ImGui_SetWindowCollapsed(bool v)
static void ImGui_SetNextTreeNodeOpen(bool val)
static void ImGui_PushStyleVarFloat(int index, float val)
static bool ImGui_SliderFloat2(const string &n, Vector2 &v, float mn, float mx)
static Vector2 ImGui_CalcTextSize(const string &a, bool c, float d)
static void ImGui_Columns(int a, const string &b, bool c)
static bool ImGui_CollapsingHeaderClosable(const string &n, bool &v)
static void ImGui_SetNextWindowPos(Vector2 v, int flags, Vector2 pivot)
static bool ImGui_DragFloat3(const string &n, Vector3 &v)
static void ImGui_SetColumnOffset(int a, float b)
static bool ImGui_IsMouseClicked(int a, bool b)
static void ImGui_TextWrapped(const string &n)
static void ImDrawList_AddTriangle(ImDrawList *drawlist, Ogre::Vector2 const &p1, Ogre::Vector2 const &p2, Ogre::Vector2 const &p3, Ogre::ColourValue const &col, float thickness)
static void ImGui_TextDisabled(const string &n)
static void ImGui_SetWindowSizeByName(const string &name, Vector2 v)
static bool ImGui_IsMouseDragging(int a, float b)
static unsigned ImGui_GetID(const string &n)
static bool ImGui_SliderFloat3(const string &n, Vector3 &v, float mn, float mx)
static void ImGui_PushClipRect(const Vector2 &a, const Vector2 &b, bool c)
static void ImGui_SetWindowCollapsedByName(const string &name, bool v)
static bool ImGui_InputText(const string &id, string &val)
static void ImGui_SetNextWindowContentSize(Vector2 v)
static bool ImGui_InputFloat2(const string &id, Vector2 &val)
static void ImGui_PushStyleVarVector2(int index, const Ogre::Vector2 &val)
static void ImDrawList_AddLine(ImDrawList *drawlist, Ogre::Vector2 const &p1, Ogre::Vector2 const &p2, Ogre::ColourValue const &col, float thickness)
static void ImGui_SetMouseCursor(ImGuiMouseCursor a)
static bool ImGui_DragFloat(const string &n, float &v, float speed, float mn, float mx)
static void ImGui_SetKeyboardFocusHere(int a)
static bool ImGui_ColorEdit3(const string &id, ColourValue &val)
static void ImGui_ProgressBar(float v, Ogre::Vector2 size, const string &overlay)
static void ImGui_OpenPopup(const string &a)
static bool ImGui_BeginPopupContextWindow(const string &a, int b, bool c)
static bool ImGui_RadioButton(const string &n, bool v)
static bool ImGui_MenuItem(const string &a, const string &b, bool c, bool d)
static void ImGui_SetTooltip(const string &t)
static Vector2 ImGui_GetWindowContentRegionMin()
static bool ImGui_BeginPopupContextItem(const string &a, int b)
static void ImGui_SetWindowPosByName(const string &name, Vector2 v)
static bool ImGui_BeginPopupModal(const string &a, bool &b, int c)
static void ImGui_PlotLines(const string &label, CScriptArray *values, int values_count, int values_offset, const string &overlay_text, float scale_min, float scale_max, Vector2 graph_size)
static bool ImGui_Selectable(const string &n, bool v)
static void ImGui_SetWindowFocusByName(const string &v)
static bool ImGui_BeginChild(const string &name, const Ogre::Vector2 &size, bool border, int flags)
static bool ImGui_SmallButton(const string &n)
static bool ImGui_ColorButton(const string &id, ColourValue val)
static void ImGui_PushIDStr(const string &n)
static bool ImGui_CheckboxFlags(const string &n, unsigned &f, unsigned v)
static void ImGui_SetClipboardText(const string &a)
static void ImGui_BulletText(const string &n)
static void ImGui_SetWindowSize(Vector2 v)
static void ImDrawList_AddCircle(ImDrawList *drawlist, Ogre::Vector2 const &center, float radius, Ogre::ColourValue const &col, int num_segments, float thickness)
static bool ImGui_Button(const string &n, Vector2 v)
static float ImGui_GetColumnOffset(int a)
static bool ImGui_CollapsingHeader(const string &n)
static bool ImGui_IsRectVisibleSize(const Vector2 &a)
static void ImGui_SetWindowPos(Vector2 v)
static bool ImGui_InvisibleButton(const string &id, Vector2 v)
static bool ImGui_Checkbox(const string &n, bool &v)
static bool ImGui_IsKeyPressed(int a, bool b)
static bool ImGui_DragFloatRange2(const string &n, float &v0, float &v1, float mn, float mx)
static bool ImGui_IsMouseDoubleClicked(int a)
static bool ImGui_IsRectVisible(const Vector2 &a, const Vector2 &b)
static bool ImGui_RadioButtonInt(const string &n, int &v, int vv)
static void ImGui_Image(Ogre::TexturePtr const &tex, Vector2 v)
static void ImGui_ResetMouseDragDelta(int a)
static bool ImGui_InputInt(const string &id, int &val)
static void ImGui_ValueBool(const string &n, bool v)
static void ImGui_Text(const string &n)
static Vector2 ImGui_GetMousePosOnOpeningCurrentPopup()
static void ImGui_SetNextWindowCollapsed(bool v)
static void ImGui_Dummy(Vector2 v)
static void ImGui_ValueFloat(const string &n, float v)
static bool ImGui_BeginTabItemClosable(const string &label, bool &p_open, ImGuiTabItemFlags flags)
static void ImGui_SetTabItemClosed(const string &tab_or_docked_window_label)
static bool ImGui_BeginChildById(ImGuiID id, const Ogre::Vector2 &size, bool border, int flags)
static bool ImGui_DragFloat2(const string &n, Vector2 &v)
static bool ImGui_BeginMenu(const string &a, bool b)