-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimgui.js
4027 lines (4027 loc) · 447 KB
/
imgui.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
System.register(["./bind-imgui", "./imconfig"], function (exports_1, context_1) {
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var Bind, bind, config, IMGUI_VERSION, IMGUI_VERSION_NUM, ImStringBuffer, ImGuiWindowFlags, ImGuiInputTextFlags, ImGuiTreeNodeFlags, ImGuiSelectableFlags, ImGuiComboFlags, ImGuiFocusedFlags, ImGuiHoveredFlags, ImGuiDragDropFlags, IMGUI_PAYLOAD_TYPE_COLOR_3F, IMGUI_PAYLOAD_TYPE_COLOR_4F, ImGuiDataType, ImGuiDir, ImGuiKey, ImGuiNavInput, ImGuiConfigFlags, ImGuiCol, ImGuiStyleVar, ImGuiBackendFlags, ImGuiColorEditFlags, ImGuiMouseCursor, ImGuiCond, ImDrawCornerFlags, ImDrawListFlags, ImVec2, ImVec4, ImVector, ImGuiTextFilter, ImGuiTextBuffer, ImGuiStorage, ImGuiPayload, IM_COL32_R_SHIFT, IM_COL32_G_SHIFT, IM_COL32_B_SHIFT, IM_COL32_A_SHIFT, IM_COL32_A_MASK, IM_COL32_WHITE, IM_COL32_BLACK, IM_COL32_BLACK_TRANS, ImColor, ImGuiInputTextDefaultSize, ImGuiInputTextCallbackData, ImGuiSizeCallbackData, ImGuiListClipper, ImDrawCmd, ImDrawIdxSize, ImDrawVertSize, ImDrawVertPosOffset, ImDrawVertUVOffset, ImDrawVertColOffset, ImDrawVert, ImDrawChannel, ImDrawListSharedData, ImDrawList, ImDrawData, script_ImFontConfig, ImFontConfig, script_ImFontGlyph, ImFontGlyph, ImFontAtlasFlags, ImFontAtlas, ImFont, script_ImGuiStyle, ImGuiStyle, ImGuiIO, ImGuiContext;
var __moduleName = context_1 && context_1.id;
function default_1(value) {
return __awaiter(this, void 0, void 0, function* () {
return new Promise((resolve) => {
Bind.default(value).then((value) => {
exports_1("bind", bind = value);
resolve();
});
});
});
}
exports_1("default", default_1);
function import_Scalar(sca) {
if (Array.isArray(sca)) {
return [sca[0]];
}
if (typeof sca === "function") {
return [sca()];
}
return [sca.x];
}
function export_Scalar(tuple, sca) {
if (Array.isArray(sca)) {
sca[0] = tuple[0];
return;
}
if (typeof sca === "function") {
sca(tuple[0]);
return;
}
sca.x = tuple[0];
}
function import_Vector2(vec) {
if (Array.isArray(vec)) {
return [vec[0], vec[1]];
}
return [vec.x, vec.y];
}
function export_Vector2(tuple, vec) {
if (Array.isArray(vec)) {
vec[0] = tuple[0];
vec[1] = tuple[1];
return;
}
vec.x = tuple[0];
vec.y = tuple[1];
}
function import_Vector3(vec) {
if (Array.isArray(vec)) {
return [vec[0], vec[1], vec[2]];
}
return [vec.x, vec.y, vec.z];
}
function export_Vector3(tuple, vec) {
if (Array.isArray(vec)) {
vec[0] = tuple[0];
vec[1] = tuple[1];
vec[2] = tuple[2];
return;
}
vec.x = tuple[0];
vec.y = tuple[1];
vec.z = tuple[2];
}
function import_Vector4(vec) {
if (Array.isArray(vec)) {
return [vec[0], vec[1], vec[2], vec[3]];
}
return [vec.x, vec.y, vec.z, vec.w];
}
function export_Vector4(tuple, vec) {
if (Array.isArray(vec)) {
vec[0] = tuple[0];
vec[1] = tuple[1];
vec[2] = tuple[2];
vec[3] = tuple[3];
return;
}
vec.x = tuple[0];
vec.y = tuple[1];
vec.z = tuple[2];
vec.w = tuple[3];
}
function import_Color3(col) {
if (Array.isArray(col)) {
return [col[0], col[1], col[2]];
}
if ("r" in col) {
return [col.r, col.g, col.b];
}
return [col.x, col.y, col.z];
}
function export_Color3(tuple, col) {
if (Array.isArray(col)) {
col[0] = tuple[0];
col[1] = tuple[1];
col[2] = tuple[2];
return;
}
if ("r" in col) {
col.r = tuple[0];
col.g = tuple[1];
col.b = tuple[2];
return;
}
col.x = tuple[0];
col.y = tuple[1];
col.z = tuple[2];
}
function import_Color4(col) {
if (Array.isArray(col)) {
return [col[0], col[1], col[2], col[3]];
}
if ("r" in col) {
return [col.r, col.g, col.b, col.a];
}
return [col.x, col.y, col.z, col.w];
}
function export_Color4(tuple, col) {
if (Array.isArray(col)) {
col[0] = tuple[0];
col[1] = tuple[1];
col[2] = tuple[2];
return;
}
if ("r" in col) {
col.r = tuple[0];
col.g = tuple[1];
col.b = tuple[2];
return;
}
col.x = tuple[0];
col.y = tuple[1];
col.z = tuple[2];
}
// #define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert))
function IMGUI_CHECKVERSION() { return DebugCheckVersionAndDataLayout(IMGUI_VERSION, bind.ImGuiIOSize, bind.ImGuiStyleSize, bind.ImVec2Size, bind.ImVec4Size, bind.ImDrawVertSize); }
exports_1("IMGUI_CHECKVERSION", IMGUI_CHECKVERSION);
function IM_ASSERT(_EXPR) { if (!_EXPR) {
throw new Error();
} }
exports_1("IM_ASSERT", IM_ASSERT);
function IM_ARRAYSIZE(_ARR) {
if (_ARR instanceof ImStringBuffer) {
return _ARR.size;
}
else {
return _ARR.length;
}
}
exports_1("IM_ARRAYSIZE", IM_ARRAYSIZE);
function IM_COL32(R, G, B, A = 255) {
return ((A << IM_COL32_A_SHIFT) | (B << IM_COL32_B_SHIFT) | (G << IM_COL32_G_SHIFT) | (R << IM_COL32_R_SHIFT)) >>> 0;
}
exports_1("IM_COL32", IM_COL32);
// IMGUI_API ImGuiContext* CreateContext(ImFontAtlas* shared_font_atlas = NULL);
function CreateContext(shared_font_atlas = null) {
const ctx = new ImGuiContext(bind.CreateContext());
if (ImGuiContext.current_ctx === null) {
ImGuiContext.current_ctx = ctx;
}
return ctx;
}
exports_1("CreateContext", CreateContext);
// IMGUI_API void DestroyContext(ImGuiContext* ctx = NULL); // NULL = Destroy current context
function DestroyContext(ctx = null) {
if (ctx === null) {
ctx = ImGuiContext.current_ctx;
ImGuiContext.current_ctx = null;
}
bind.DestroyContext((ctx === null) ? null : ctx.native);
}
exports_1("DestroyContext", DestroyContext);
// IMGUI_API ImGuiContext* GetCurrentContext();
function GetCurrentContext() {
// const ctx_native: BindImGui.ImGuiContext | null = bind.GetCurrentContext();
return ImGuiContext.current_ctx;
}
exports_1("GetCurrentContext", GetCurrentContext);
// IMGUI_API void SetCurrentContext(ImGuiContext* ctx);
function SetCurrentContext(ctx) {
bind.SetCurrentContext((ctx === null) ? null : ctx.native);
ImGuiContext.current_ctx = ctx;
}
exports_1("SetCurrentContext", SetCurrentContext);
// IMGUI_API bool DebugCheckVersionAndDataLayout(const char* version_str, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_drawvert);
function DebugCheckVersionAndDataLayout(version_str, sz_io, sz_style, sz_vec2, sz_vec4, sz_draw_vert) {
return bind.DebugCheckVersionAndDataLayout(version_str, sz_io, sz_style, sz_vec2, sz_vec4, sz_draw_vert);
}
exports_1("DebugCheckVersionAndDataLayout", DebugCheckVersionAndDataLayout);
// Main
// IMGUI_API ImGuiIO& GetIO();
function GetIO() { return new ImGuiIO(bind.GetIO()); }
exports_1("GetIO", GetIO);
// IMGUI_API ImGuiStyle& GetStyle();
function GetStyle() { return new ImGuiStyle(bind.GetStyle()); }
exports_1("GetStyle", GetStyle);
// IMGUI_API void NewFrame(); // start a new ImGui frame, you can submit any command from this point until Render()/EndFrame().
function NewFrame() { bind.NewFrame(); }
exports_1("NewFrame", NewFrame);
// IMGUI_API void EndFrame(); // ends the ImGui frame. automatically called by Render(), so most likely don't need to ever call that yourself directly. If you don't need to render you may call EndFrame() but you'll have wasted CPU already. If you don't need to render, better to not create any imgui windows instead!
function EndFrame() { bind.EndFrame(); }
exports_1("EndFrame", EndFrame);
// IMGUI_API void Render(); // ends the ImGui frame, finalize the draw data, then call your io.RenderDrawListsFn() function if set.
function Render() { bind.Render(); }
exports_1("Render", Render);
// IMGUI_API ImDrawData* GetDrawData(); // same value as passed to your io.RenderDrawListsFn() function. valid after Render() and until the next call to NewFrame()
function GetDrawData() {
const draw_data = bind.GetDrawData();
return (draw_data === null) ? null : new ImDrawData(draw_data);
}
exports_1("GetDrawData", GetDrawData);
// Demo, Debug, Informations
// IMGUI_API void ShowDemoWindow(bool* p_open = NULL); // create demo/test window (previously called ShowTestWindow). demonstrate most ImGui features. call this to learn about the library! try to make it always available in your application!
function ShowDemoWindow(p_open = null) { bind.ShowDemoWindow(p_open); }
exports_1("ShowDemoWindow", ShowDemoWindow);
// IMGUI_API void ShowMetricsWindow(bool* p_open = NULL); // create metrics window. display ImGui internals: draw commands (with individual draw calls and vertices), window list, basic internal state, etc.
function ShowMetricsWindow(p_open = null) {
if (p_open === null) {
bind.ShowMetricsWindow(null);
}
else if (Array.isArray(p_open)) {
bind.ShowMetricsWindow(p_open);
}
else {
const ref_open = [p_open()];
const ret = bind.ShowMetricsWindow(ref_open);
p_open(ref_open[0]);
return ret;
}
}
exports_1("ShowMetricsWindow", ShowMetricsWindow);
// IMGUI_API void ShowStyleEditor(ImGuiStyle* ref = NULL); // add style editor block (not a window). you can pass in a reference ImGuiStyle structure to compare to, revert to and save to (else it uses the default style)
function ShowStyleEditor(ref = null) {
if (ref === null) {
bind.ShowStyleEditor(null);
}
else if (ref.internal instanceof bind.ImGuiStyle) {
bind.ShowStyleEditor(ref.internal);
}
else {
const native = new bind.ImGuiStyle();
const wrap = new ImGuiStyle(native);
wrap.Copy(ref);
bind.ShowStyleEditor(native);
ref.Copy(wrap);
native.delete();
}
}
exports_1("ShowStyleEditor", ShowStyleEditor);
// IMGUI_API bool ShowStyleSelector(const char* label);
function ShowStyleSelector(label) { return bind.ShowStyleSelector(label); }
exports_1("ShowStyleSelector", ShowStyleSelector);
// IMGUI_API void ShowFontSelector(const char* label);
function ShowFontSelector(label) { bind.ShowFontSelector(label); }
exports_1("ShowFontSelector", ShowFontSelector);
// IMGUI_API void ShowUserGuide(); // add basic help/info block (not a window): how to manipulate ImGui as a end-user (mouse/keyboard controls).
function ShowUserGuide() { bind.ShowUserGuide(); }
exports_1("ShowUserGuide", ShowUserGuide);
// IMGUI_API const char* GetVersion();
function GetVersion() { return bind.GetVersion(); }
exports_1("GetVersion", GetVersion);
// Styles
// IMGUI_API void StyleColorsClassic(ImGuiStyle* dst = NULL);
function StyleColorsClassic(dst = null) {
if (dst === null) {
bind.StyleColorsClassic(null);
}
else if (dst.internal instanceof bind.ImGuiStyle) {
bind.StyleColorsClassic(dst.internal);
}
else {
const native = new bind.ImGuiStyle();
const wrap = new ImGuiStyle(native);
wrap.Copy(dst);
bind.StyleColorsClassic(native);
dst.Copy(wrap);
native.delete();
}
}
exports_1("StyleColorsClassic", StyleColorsClassic);
// IMGUI_API void StyleColorsDark(ImGuiStyle* dst = NULL);
function StyleColorsDark(dst = null) {
if (dst === null) {
bind.StyleColorsDark(null);
}
else if (dst.internal instanceof bind.ImGuiStyle) {
bind.StyleColorsDark(dst.internal);
}
else {
const native = new bind.ImGuiStyle();
const wrap = new ImGuiStyle(native);
wrap.Copy(dst);
bind.StyleColorsDark(native);
dst.Copy(wrap);
native.delete();
}
}
exports_1("StyleColorsDark", StyleColorsDark);
// IMGUI_API void StyleColorsLight(ImGuiStyle* dst = NULL);
function StyleColorsLight(dst = null) {
if (dst === null) {
bind.StyleColorsLight(null);
}
else if (dst.internal instanceof bind.ImGuiStyle) {
bind.StyleColorsLight(dst.internal);
}
else {
const native = new bind.ImGuiStyle();
const wrap = new ImGuiStyle(native);
wrap.Copy(dst);
bind.StyleColorsLight(native);
dst.Copy(wrap);
native.delete();
}
}
exports_1("StyleColorsLight", StyleColorsLight);
// Window
// IMGUI_API bool Begin(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0); // push window to the stack and start appending to it. see .cpp for details. return false when window is collapsed, so you can early out in your code. 'bool* p_open' creates a widget on the upper-right to close the window (which sets your bool to false).
function Begin(name, open = null, flags = 0) {
if (open === null) {
return bind.Begin(name, null, flags);
}
else if (Array.isArray(open)) {
return bind.Begin(name, open, flags);
}
else {
const ref_open = [open()];
const opened = bind.Begin(name, ref_open, flags);
open(ref_open[0]);
return opened;
}
}
exports_1("Begin", Begin);
// IMGUI_API void End(); // finish appending to current window, pop it off the window stack.
function End() { bind.End(); }
exports_1("End", End);
// IMGUI_API bool BeginChild(const char* str_id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); // begin a scrolling region. size==0.0f: use remaining window size, size<0.0f: use remaining window size minus abs(size). size>0.0f: fixed size. each axis can use a different mode, e.g. ImVec2(0,400).
// IMGUI_API bool BeginChild(ImGuiID id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); // "
function BeginChild(id, size = ImVec2.ZERO, border = false, extra_flags = 0) {
return bind.BeginChild(id, size, border, extra_flags);
}
exports_1("BeginChild", BeginChild);
// IMGUI_API void EndChild();
function EndChild() { bind.EndChild(); }
exports_1("EndChild", EndChild);
// IMGUI_API ImVec2 GetContentRegionMax(); // current content boundaries (typically window boundaries including scrolling, or current column boundaries), in windows coordinates
function GetContentRegionMax(out = new ImVec2()) {
return bind.GetContentRegionMax(out);
}
exports_1("GetContentRegionMax", GetContentRegionMax);
// IMGUI_API ImVec2 GetContentRegionAvail(); // == GetContentRegionMax() - GetCursorPos()
function GetContentRegionAvail(out = new ImVec2()) {
return bind.GetContentRegionAvail(out);
}
exports_1("GetContentRegionAvail", GetContentRegionAvail);
// IMGUI_API float GetContentRegionAvailWidth(); //
function GetContentRegionAvailWidth() { return bind.GetContentRegionAvailWidth(); }
exports_1("GetContentRegionAvailWidth", GetContentRegionAvailWidth);
// IMGUI_API ImVec2 GetWindowContentRegionMin(); // content boundaries min (roughly (0,0)-Scroll), in window coordinates
function GetWindowContentRegionMin(out = new ImVec2()) {
return bind.GetWindowContentRegionMin(out);
}
exports_1("GetWindowContentRegionMin", GetWindowContentRegionMin);
// IMGUI_API ImVec2 GetWindowContentRegionMax(); // content boundaries max (roughly (0,0)+Size-Scroll) where Size can be override with SetNextWindowContentSize(), in window coordinates
function GetWindowContentRegionMax(out = new ImVec2()) {
return bind.GetWindowContentRegionMax(out);
}
exports_1("GetWindowContentRegionMax", GetWindowContentRegionMax);
// IMGUI_API float GetWindowContentRegionWidth(); //
function GetWindowContentRegionWidth() { return bind.GetWindowContentRegionWidth(); }
exports_1("GetWindowContentRegionWidth", GetWindowContentRegionWidth);
// IMGUI_API ImDrawList* GetWindowDrawList(); // get rendering command-list if you want to append your own draw primitives
function GetWindowDrawList() {
return new ImDrawList(bind.GetWindowDrawList());
}
exports_1("GetWindowDrawList", GetWindowDrawList);
// IMGUI_API ImVec2 GetWindowPos(); // get current window position in screen space (useful if you want to do your own drawing via the DrawList api)
function GetWindowPos(out = new ImVec2()) {
return bind.GetWindowPos(out);
}
exports_1("GetWindowPos", GetWindowPos);
// IMGUI_API ImVec2 GetWindowSize(); // get current window size
function GetWindowSize(out = new ImVec2()) {
return bind.GetWindowSize(out);
}
exports_1("GetWindowSize", GetWindowSize);
// IMGUI_API float GetWindowWidth();
function GetWindowWidth() { return bind.GetWindowWidth(); }
exports_1("GetWindowWidth", GetWindowWidth);
// IMGUI_API float GetWindowHeight();
function GetWindowHeight() { return bind.GetWindowHeight(); }
exports_1("GetWindowHeight", GetWindowHeight);
// IMGUI_API bool IsWindowCollapsed();
function IsWindowCollapsed() { return bind.IsWindowCollapsed(); }
exports_1("IsWindowCollapsed", IsWindowCollapsed);
// IMGUI_API bool IsWindowAppearing();
function IsWindowAppearing() { return bind.IsWindowAppearing(); }
exports_1("IsWindowAppearing", IsWindowAppearing);
// IMGUI_API void SetWindowFontScale(float scale); // per-window font scale. Adjust IO.FontGlobalScale if you want to scale all windows
function SetWindowFontScale(scale) { bind.SetWindowFontScale(scale); }
exports_1("SetWindowFontScale", SetWindowFontScale);
// IMGUI_API void SetNextWindowPos(const ImVec2& pos, ImGuiCond cond = 0, const ImVec2& pivot = ImVec2(0,0)); // set next window position. call before Begin(). use pivot=(0.5f,0.5f) to center on given point, etc.
function SetNextWindowPos(pos, cond = 0, pivot = ImVec2.ZERO) {
bind.SetNextWindowPos(pos, cond, pivot);
}
exports_1("SetNextWindowPos", SetNextWindowPos);
// IMGUI_API void SetNextWindowSize(const ImVec2& size, ImGuiCond cond = 0); // set next window size. set axis to 0.0f to force an auto-fit on this axis. call before Begin()
function SetNextWindowSize(pos, cond = 0) {
bind.SetNextWindowSize(pos, cond);
}
exports_1("SetNextWindowSize", SetNextWindowSize);
// IMGUI_API void SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeConstraintCallback custom_callback = NULL, void* custom_callback_data = NULL); // set next window size limits. use -1,-1 on either X/Y axis to preserve the current size. Use callback to apply non-trivial programmatic constraints.
function SetNextWindowSizeConstraints(size_min, size_max, custom_callback = null, custom_callback_data = null) {
if (custom_callback) {
bind.SetNextWindowSizeConstraints(size_min, size_max, (data) => {
custom_callback(new ImGuiSizeCallbackData(data, custom_callback_data));
}, null);
}
else {
bind.SetNextWindowSizeConstraints(size_min, size_max, null, null);
}
}
exports_1("SetNextWindowSizeConstraints", SetNextWindowSizeConstraints);
// IMGUI_API void SetNextWindowContentSize(const ImVec2& size); // set next window content size (~ enforce the range of scrollbars). not including window decorations (title bar, menu bar, etc.). set an axis to 0.0f to leave it automatic. call before Begin()
function SetNextWindowContentSize(size) {
bind.SetNextWindowContentSize(size);
}
exports_1("SetNextWindowContentSize", SetNextWindowContentSize);
// IMGUI_API void SetNextWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // set next window collapsed state. call before Begin()
function SetNextWindowCollapsed(collapsed, cond = 0) {
bind.SetNextWindowCollapsed(collapsed, cond);
}
exports_1("SetNextWindowCollapsed", SetNextWindowCollapsed);
// IMGUI_API void SetNextWindowFocus(); // set next window to be focused / front-most. call before Begin()
function SetNextWindowFocus() { bind.SetNextWindowFocus(); }
exports_1("SetNextWindowFocus", SetNextWindowFocus);
// IMGUI_API void SetNextWindowBgAlpha(float alpha); // set next window background color alpha. helper to easily modify ImGuiCol_WindowBg/ChildBg/PopupBg.
function SetNextWindowBgAlpha(alpha) { bind.SetNextWindowBgAlpha(alpha); }
exports_1("SetNextWindowBgAlpha", SetNextWindowBgAlpha);
// IMGUI_API void SetWindowPos(const ImVec2& pos, ImGuiCond cond = 0); // (not recommended) set current window position - call within Begin()/End(). prefer using SetNextWindowPos(), as this may incur tearing and side-effects.
// IMGUI_API void SetWindowSize(const ImVec2& size, ImGuiCond cond = 0); // (not recommended) set current window size - call within Begin()/End(). set to ImVec2(0,0) to force an auto-fit. prefer using SetNextWindowSize(), as this may incur tearing and minor side-effects.
// IMGUI_API void SetWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // (not recommended) set current window collapsed state. prefer using SetNextWindowCollapsed().
// IMGUI_API void SetWindowFocus(); // (not recommended) set current window to be focused / front-most. prefer using SetNextWindowFocus().
// IMGUI_API void SetWindowPos(const char* name, const ImVec2& pos, ImGuiCond cond = 0); // set named window position.
// IMGUI_API void SetWindowSize(const char* name, const ImVec2& size, ImGuiCond cond = 0); // set named window size. set axis to 0.0f to force an auto-fit on this axis.
// IMGUI_API void SetWindowCollapsed(const char* name, bool collapsed, ImGuiCond cond = 0); // set named window collapsed state
// IMGUI_API void SetWindowFocus(const char* name); // set named window to be focused / front-most. use NULL to remove focus.
function SetWindowPos(name_or_pos, pos_or_cond = 0, cond = 0) {
if (typeof (name_or_pos) === "string") {
bind.SetWindowNamePos(name_or_pos, pos_or_cond, cond);
return;
}
else {
bind.SetWindowPos(name_or_pos, pos_or_cond);
}
}
exports_1("SetWindowPos", SetWindowPos);
function SetWindowSize(name_or_size, size_or_cond = 0, cond = 0) {
if (typeof (name_or_size) === "string") {
bind.SetWindowNamePos(name_or_size, size_or_cond, cond);
}
else {
bind.SetWindowSize(name_or_size, size_or_cond);
}
}
exports_1("SetWindowSize", SetWindowSize);
function SetWindowCollapsed(name_or_collapsed, collapsed_or_cond = 0, cond = 0) {
if (typeof (name_or_collapsed) === "string") {
bind.SetWindowNameCollapsed(name_or_collapsed, collapsed_or_cond, cond);
}
else {
bind.SetWindowCollapsed(name_or_collapsed, collapsed_or_cond);
}
}
exports_1("SetWindowCollapsed", SetWindowCollapsed);
function SetWindowFocus(name) {
if (typeof (name) === "string") {
bind.SetWindowNameFocus(name);
}
else {
bind.SetWindowFocus();
}
}
exports_1("SetWindowFocus", SetWindowFocus);
// IMGUI_API float GetScrollX(); // get scrolling amount [0..GetScrollMaxX()]
function GetScrollX() { return bind.GetScrollX(); }
exports_1("GetScrollX", GetScrollX);
// IMGUI_API float GetScrollY(); // get scrolling amount [0..GetScrollMaxY()]
function GetScrollY() { return bind.GetScrollY(); }
exports_1("GetScrollY", GetScrollY);
// IMGUI_API float GetScrollMaxX(); // get maximum scrolling amount ~~ ContentSize.X - WindowSize.X
function GetScrollMaxX() { return bind.GetScrollMaxX(); }
exports_1("GetScrollMaxX", GetScrollMaxX);
// IMGUI_API float GetScrollMaxY(); // get maximum scrolling amount ~~ ContentSize.Y - WindowSize.Y
function GetScrollMaxY() { return bind.GetScrollMaxY(); }
exports_1("GetScrollMaxY", GetScrollMaxY);
// IMGUI_API void SetScrollX(float scroll_x); // set scrolling amount [0..GetScrollMaxX()]
function SetScrollX(scroll_x) { bind.SetScrollX(scroll_x); }
exports_1("SetScrollX", SetScrollX);
// IMGUI_API void SetScrollY(float scroll_y); // set scrolling amount [0..GetScrollMaxY()]
function SetScrollY(scroll_y) { bind.SetScrollY(scroll_y); }
exports_1("SetScrollY", SetScrollY);
// IMGUI_API void SetScrollHere(float center_y_ratio = 0.5f); // adjust scrolling amount to make current cursor position visible. center_y_ratio=0.0: top, 0.5: center, 1.0: bottom. When using to make a "default/current item" visible, consider using SetItemDefaultFocus() instead.
function SetScrollHere(center_y_ratio = 0.5) {
bind.SetScrollHere(center_y_ratio);
}
exports_1("SetScrollHere", SetScrollHere);
// IMGUI_API void SetScrollFromPosY(float pos_y, float center_y_ratio = 0.5f); // adjust scrolling amount to make given position valid. use GetCursorPos() or GetCursorStartPos()+offset to get valid positions.
function SetScrollFromPosY(pos_y, center_y_ratio = 0.5) {
bind.SetScrollFromPosY(pos_y, center_y_ratio);
}
exports_1("SetScrollFromPosY", SetScrollFromPosY);
// IMGUI_API void SetStateStorage(ImGuiStorage* tree); // replace tree state storage with our own (if you want to manipulate it yourself, typically clear subsection of it)
// IMGUI_API ImGuiStorage* GetStateStorage();
// Parameters stacks (shared)
// IMGUI_API void PushFont(ImFont* font); // use NULL as a shortcut to push default font
function PushFont(font) { bind.PushFont(font ? font.native : null); }
exports_1("PushFont", PushFont);
// IMGUI_API void PopFont();
function PopFont() { bind.PopFont(); }
exports_1("PopFont", PopFont);
// IMGUI_API void PushStyleColor(ImGuiCol idx, ImU32 col);
// IMGUI_API void PushStyleColor(ImGuiCol idx, const ImVec4& col);
function PushStyleColor(idx, col) {
if (col instanceof ImColor) {
bind.PushStyleColor(idx, col.Value);
}
else {
bind.PushStyleColor(idx, col);
}
}
exports_1("PushStyleColor", PushStyleColor);
// IMGUI_API void PopStyleColor(int count = 1);
function PopStyleColor(count = 1) {
bind.PopStyleColor(count);
}
exports_1("PopStyleColor", PopStyleColor);
// IMGUI_API void PushStyleVar(ImGuiStyleVar idx, float val);
// IMGUI_API void PushStyleVar(ImGuiStyleVar idx, const ImVec2& val);
function PushStyleVar(idx, val) {
bind.PushStyleVar(idx, val);
}
exports_1("PushStyleVar", PushStyleVar);
// IMGUI_API void PopStyleVar(int count = 1);
function PopStyleVar(count = 1) {
bind.PopStyleVar(count);
}
exports_1("PopStyleVar", PopStyleVar);
// IMGUI_API const ImVec4& GetStyleColorVec4(ImGuiCol idx); // retrieve style color as stored in ImGuiStyle structure. use to feed back into PushStyleColor(), otherwhise use GetColorU32() to get style color + style alpha.
function GetStyleColorVec4(idx) {
return bind.GetStyleColorVec4(idx);
}
exports_1("GetStyleColorVec4", GetStyleColorVec4);
// IMGUI_API ImFont* GetFont(); // get current font
function GetFont() {
return new ImFont(bind.GetFont());
}
exports_1("GetFont", GetFont);
// IMGUI_API float GetFontSize(); // get current font size (= height in pixels) of current font with current scale applied
function GetFontSize() { return bind.GetFontSize(); }
exports_1("GetFontSize", GetFontSize);
// IMGUI_API ImVec2 GetFontTexUvWhitePixel(); // get UV coordinate for a while pixel, useful to draw custom shapes via the ImDrawList API
function GetFontTexUvWhitePixel(out = new ImVec2()) {
return bind.GetFontTexUvWhitePixel(out);
}
exports_1("GetFontTexUvWhitePixel", GetFontTexUvWhitePixel);
function GetColorU32(...args) {
if (args.length === 1) {
if (typeof (args[0]) === "number") {
// TODO: ImGuiCol or ImU32
const idx = args[0];
return bind.GetColorU32_A(idx, 1.0);
}
else {
const col = args[0];
return bind.GetColorU32_B(col);
}
}
else {
const idx = args[0];
const alpha_mul = args[1];
return bind.GetColorU32_A(idx, alpha_mul);
}
}
exports_1("GetColorU32", GetColorU32);
// Parameters stacks (current window)
// IMGUI_API void PushItemWidth(float item_width); // width of items for the common item+label case, pixels. 0.0f = default to ~2/3 of windows width, >0.0f: width in pixels, <0.0f align xx pixels to the right of window (so -1.0f always align width to the right side)
function PushItemWidth(item_width) { bind.PushItemWidth(item_width); }
exports_1("PushItemWidth", PushItemWidth);
// IMGUI_API void PopItemWidth();
function PopItemWidth() { bind.PopItemWidth(); }
exports_1("PopItemWidth", PopItemWidth);
// IMGUI_API float CalcItemWidth(); // width of item given pushed settings and current cursor position
function CalcItemWidth() { return bind.CalcItemWidth(); }
exports_1("CalcItemWidth", CalcItemWidth);
// IMGUI_API void PushTextWrapPos(float wrap_pos_x = 0.0f); // word-wrapping for Text*() commands. < 0.0f: no wrapping; 0.0f: wrap to end of window (or column); > 0.0f: wrap at 'wrap_pos_x' position in window local space
function PushTextWrapPos(wrap_pos_x = 0.0) {
bind.PushTextWrapPos(wrap_pos_x);
}
exports_1("PushTextWrapPos", PushTextWrapPos);
// IMGUI_API void PopTextWrapPos();
function PopTextWrapPos() { bind.PopTextWrapPos(); }
exports_1("PopTextWrapPos", PopTextWrapPos);
// IMGUI_API void PushAllowKeyboardFocus(bool allow_keyboard_focus); // allow focusing using TAB/Shift-TAB, enabled by default but you can disable it for certain widgets
function PushAllowKeyboardFocus(allow_keyboard_focus) { bind.PushAllowKeyboardFocus(allow_keyboard_focus); }
exports_1("PushAllowKeyboardFocus", PushAllowKeyboardFocus);
// IMGUI_API void PopAllowKeyboardFocus();
function PopAllowKeyboardFocus() { bind.PopAllowKeyboardFocus(); }
exports_1("PopAllowKeyboardFocus", PopAllowKeyboardFocus);
// IMGUI_API void PushButtonRepeat(bool repeat); // in 'repeat' mode, Button*() functions return repeated true in a typematic manner (using io.KeyRepeatDelay/io.KeyRepeatRate setting). Note that you can call IsItemActive() after any Button() to tell if the button is held in the current frame.
function PushButtonRepeat(repeat) { bind.PushButtonRepeat(repeat); }
exports_1("PushButtonRepeat", PushButtonRepeat);
// IMGUI_API void PopButtonRepeat();
function PopButtonRepeat() { bind.PopButtonRepeat(); }
exports_1("PopButtonRepeat", PopButtonRepeat);
// Cursor / Layout
// IMGUI_API void Separator(); // separator, generally horizontal. inside a menu bar or in horizontal layout mode, this becomes a vertical separator.
function Separator() { bind.Separator(); }
exports_1("Separator", Separator);
// IMGUI_API void SameLine(float pos_x = 0.0f, float spacing_w = -1.0f); // call between widgets or groups to layout them horizontally
function SameLine(pos_x = 0.0, spacing_w = -1.0) {
bind.SameLine(pos_x, spacing_w);
}
exports_1("SameLine", SameLine);
// IMGUI_API void NewLine(); // undo a SameLine()
function NewLine() { bind.NewLine(); }
exports_1("NewLine", NewLine);
// IMGUI_API void Spacing(); // add vertical spacing
function Spacing() { bind.Spacing(); }
exports_1("Spacing", Spacing);
// IMGUI_API void Dummy(const ImVec2& size); // add a dummy item of given size
function Dummy(size) { bind.Dummy(size); }
exports_1("Dummy", Dummy);
// IMGUI_API void Indent(float indent_w = 0.0f); // move content position toward the right, by style.IndentSpacing or indent_w if != 0
function Indent(indent_w = 0.0) { bind.Indent(indent_w); }
exports_1("Indent", Indent);
// IMGUI_API void Unindent(float indent_w = 0.0f); // move content position back to the left, by style.IndentSpacing or indent_w if != 0
function Unindent(indent_w = 0.0) { bind.Unindent(indent_w); }
exports_1("Unindent", Unindent);
// IMGUI_API void BeginGroup(); // lock horizontal starting position + capture group bounding box into one "item" (so you can use IsItemHovered() or layout primitives such as SameLine() on whole group, etc.)
function BeginGroup() { bind.BeginGroup(); }
exports_1("BeginGroup", BeginGroup);
// IMGUI_API void EndGroup();
function EndGroup() { bind.EndGroup(); }
exports_1("EndGroup", EndGroup);
// IMGUI_API ImVec2 GetCursorPos(); // cursor position is relative to window position
function GetCursorPos(out = new ImVec2()) { return bind.GetCursorPos(out); }
exports_1("GetCursorPos", GetCursorPos);
// IMGUI_API float GetCursorPosX(); // "
function GetCursorPosX() { return bind.GetCursorPosX(); }
exports_1("GetCursorPosX", GetCursorPosX);
// IMGUI_API float GetCursorPosY(); // "
function GetCursorPosY() { return bind.GetCursorPosY(); }
exports_1("GetCursorPosY", GetCursorPosY);
// IMGUI_API void SetCursorPos(const ImVec2& local_pos); // "
function SetCursorPos(local_pos) { bind.SetCursorPos(local_pos); }
exports_1("SetCursorPos", SetCursorPos);
// IMGUI_API void SetCursorPosX(float x); // "
function SetCursorPosX(x) { bind.SetCursorPosX(x); }
exports_1("SetCursorPosX", SetCursorPosX);
// IMGUI_API void SetCursorPosY(float y); // "
function SetCursorPosY(y) { bind.SetCursorPosY(y); }
exports_1("SetCursorPosY", SetCursorPosY);
// IMGUI_API ImVec2 GetCursorStartPos(); // initial cursor position
function GetCursorStartPos(out = new ImVec2()) { return bind.GetCursorStartPos(out); }
exports_1("GetCursorStartPos", GetCursorStartPos);
// IMGUI_API ImVec2 GetCursorScreenPos(); // cursor position in absolute screen coordinates [0..io.DisplaySize] (useful to work with ImDrawList API)
function GetCursorScreenPos(out = new ImVec2()) { return bind.GetCursorScreenPos(out); }
exports_1("GetCursorScreenPos", GetCursorScreenPos);
// IMGUI_API void SetCursorScreenPos(const ImVec2& pos); // cursor position in absolute screen coordinates [0..io.DisplaySize]
function SetCursorScreenPos(pos) { bind.SetCursorScreenPos(pos); }
exports_1("SetCursorScreenPos", SetCursorScreenPos);
// IMGUI_API void AlignTextToFramePadding(); // vertically align/lower upcoming text to FramePadding.y so that it will aligns to upcoming widgets (call if you have text on a line before regular widgets)
function AlignTextToFramePadding() { bind.AlignTextToFramePadding(); }
exports_1("AlignTextToFramePadding", AlignTextToFramePadding);
// IMGUI_API float GetTextLineHeight(); // ~ FontSize
function GetTextLineHeight() { return bind.GetTextLineHeight(); }
exports_1("GetTextLineHeight", GetTextLineHeight);
// IMGUI_API float GetTextLineHeightWithSpacing(); // ~ FontSize + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of text)
function GetTextLineHeightWithSpacing() { return bind.GetTextLineHeightWithSpacing(); }
exports_1("GetTextLineHeightWithSpacing", GetTextLineHeightWithSpacing);
// IMGUI_API float GetFrameHeight(); // ~ FontSize + style.FramePadding.y * 2
function GetFrameHeight() { return bind.GetFrameHeight(); }
exports_1("GetFrameHeight", GetFrameHeight);
// IMGUI_API float GetFrameHeightWithSpacing(); // ~ FontSize + style.FramePadding.y * 2 + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of framed widgets)
function GetFrameHeightWithSpacing() { return bind.GetFrameHeightWithSpacing(); }
exports_1("GetFrameHeightWithSpacing", GetFrameHeightWithSpacing);
// Columns
// You can also use SameLine(pos_x) for simplified columns. The columns API is still work-in-progress and rather lacking.
// IMGUI_API void Columns(int count = 1, const char* id = NULL, bool border = true);
function Columns(count = 1, id = null, border = true) {
id = id || "";
bind.Columns(count, id, border);
}
exports_1("Columns", Columns);
// IMGUI_API void NextColumn(); // next column, defaults to current row or next row if the current row is finished
function NextColumn() { bind.NextColumn(); }
exports_1("NextColumn", NextColumn);
// IMGUI_API int GetColumnIndex(); // get current column index
function GetColumnIndex() { return bind.GetColumnIndex(); }
exports_1("GetColumnIndex", GetColumnIndex);
// IMGUI_API float GetColumnWidth(int column_index = -1); // get column width (in pixels). pass -1 to use current column
function GetColumnWidth(column_index = -1) {
return bind.GetColumnWidth(column_index);
}
exports_1("GetColumnWidth", GetColumnWidth);
// IMGUI_API void SetColumnWidth(int column_index, float width); // set column width (in pixels). pass -1 to use current column
function SetColumnWidth(column_index, width) { bind.SetColumnWidth(column_index, width); }
exports_1("SetColumnWidth", SetColumnWidth);
// IMGUI_API float GetColumnOffset(int column_index = -1); // get position of column line (in pixels, from the left side of the contents region). pass -1 to use current column, otherwise 0..GetColumnsCount() inclusive. column 0 is typically 0.0f
function GetColumnOffset(column_index = -1) {
return bind.GetColumnOffset(column_index);
}
exports_1("GetColumnOffset", GetColumnOffset);
// IMGUI_API void SetColumnOffset(int column_index, float offset_x); // set position of column line (in pixels, from the left side of the contents region). pass -1 to use current column
function SetColumnOffset(column_index, offset_x) { bind.SetColumnOffset(column_index, offset_x); }
exports_1("SetColumnOffset", SetColumnOffset);
// IMGUI_API int GetColumnsCount();
function GetColumnsCount() { return bind.GetColumnsCount(); }
exports_1("GetColumnsCount", GetColumnsCount);
// ID scopes
// If you are creating widgets in a loop you most likely want to push a unique identifier (e.g. object pointer, loop index) so ImGui can differentiate them.
// You can also use the "##foobar" syntax within widget label to distinguish them from each others. Read "A primer on the use of labels/IDs" in the FAQ for more details.
// IMGUI_API void PushID(const char* str_id); // push identifier into the ID stack. IDs are hash of the entire stack!
// IMGUI_API void PushID(const char* str_id_begin, const char* str_id_end);
// IMGUI_API void PushID(const void* ptr_id);
// IMGUI_API void PushID(int int_id);
function PushID(id) { bind.PushID(id); }
exports_1("PushID", PushID);
// IMGUI_API void PopID();
function PopID() { bind.PopID(); }
exports_1("PopID", PopID);
// IMGUI_API ImGuiID GetID(const char* str_id); // calculate unique ID (hash of whole ID stack + given parameter). e.g. if you want to query into ImGuiStorage yourself
// IMGUI_API ImGuiID GetID(const char* str_id_begin, const char* str_id_end);
// IMGUI_API ImGuiID GetID(const void* ptr_id);
function GetID(id) { return bind.GetID(id); }
exports_1("GetID", GetID);
// Widgets: Text
// IMGUI_API void TextUnformatted(const char* text, const char* text_end = NULL); // raw text without formatting. Roughly equivalent to Text("%s", text) but: A) doesn't require null terminated string if 'text_end' is specified, B) it's faster, no memory copy is done, no buffer size limits, recommended for long chunks of text.
function TextUnformatted(text, text_end = null) { bind.TextUnformatted(text_end !== null ? text.substring(0, text_end) : text); }
exports_1("TextUnformatted", TextUnformatted);
// IMGUI_API void Text(const char* fmt, ...) IM_FMTARGS(1); // simple formatted text
// IMGUI_API void TextV(const char* fmt, va_list args) IM_FMTLIST(1);
function Text(fmt /*, ...args: any[]*/) { bind.Text(fmt /*, ...args*/); }
exports_1("Text", Text);
// IMGUI_API void TextColored(const ImVec4& col, const char* fmt, ...) IM_FMTARGS(2); // shortcut for PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor();
// IMGUI_API void TextColoredV(const ImVec4& col, const char* fmt, va_list args) IM_FMTLIST(2);
function TextColored(col, fmt /*, ...args: any[]*/) {
bind.TextColored((col instanceof ImColor) ? col.Value : col, fmt /*, ...args*/);
}
exports_1("TextColored", TextColored);
// IMGUI_API void TextDisabled(const char* fmt, ...) IM_FMTARGS(1); // shortcut for PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]); Text(fmt, ...); PopStyleColor();
// IMGUI_API void TextDisabledV(const char* fmt, va_list args) IM_FMTLIST(1);
function TextDisabled(fmt /*, ...args: any[]*/) { bind.TextDisabled(fmt /*, ...args*/); }
exports_1("TextDisabled", TextDisabled);
// IMGUI_API void TextWrapped(const char* fmt, ...) IM_FMTARGS(1); // shortcut for PushTextWrapPos(0.0f); Text(fmt, ...); PopTextWrapPos();. Note that this won't work on an auto-resizing window if there's no other widgets to extend the window width, yoy may need to set a size using SetNextWindowSize().
// IMGUI_API void TextWrappedV(const char* fmt, va_list args) IM_FMTLIST(1);
function TextWrapped(fmt /*, ...args: any[]*/) { bind.TextWrapped(fmt /*, ...args*/); }
exports_1("TextWrapped", TextWrapped);
// IMGUI_API void LabelText(const char* label, const char* fmt, ...) IM_FMTARGS(2); // display text+label aligned the same way as value+label widgets
// IMGUI_API void LabelTextV(const char* label, const char* fmt, va_list args) IM_FMTLIST(2);
function LabelText(label, fmt /*, ...args: any[]*/) { bind.LabelText(label, fmt /*, ...args*/); }
exports_1("LabelText", LabelText);
// IMGUI_API void BulletText(const char* fmt, ...) IM_FMTARGS(1); // shortcut for Bullet()+Text()
// IMGUI_API void BulletTextV(const char* fmt, va_list args) IM_FMTLIST(1);
function BulletText(fmt /*, ...args: any[]*/) { bind.BulletText(fmt /*, ...args*/); }
exports_1("BulletText", BulletText);
// IMGUI_API void Bullet(); // draw a small circle and keep the cursor on the same line. advance cursor x position by GetTreeNodeToLabelSpacing(), same distance that TreeNode() uses
function Bullet() { bind.Bullet(); }
exports_1("Bullet", Bullet);
// Widgets: Main
// IMGUI_API bool Button(const char* label, const ImVec2& size = ImVec2(0,0)); // button
function Button(label, size = ImVec2.ZERO) {
return bind.Button(label, size);
}
exports_1("Button", Button);
// IMGUI_API bool SmallButton(const char* label); // button with FramePadding=(0,0) to easily embed within text
function SmallButton(label) { return bind.SmallButton(label); }
exports_1("SmallButton", SmallButton);
// IMGUI_API bool ArrowButton(const char* str_id, ImGuiDir dir); // square button with an arrow shape
function ArrowButton(str_id, dir) { return bind.ArrowButton(str_id, dir); }
exports_1("ArrowButton", ArrowButton);
// IMGUI_API bool InvisibleButton(const char* str_id, const ImVec2& size); // button behavior without the visuals, useful to build custom behaviors using the public api (along with IsItemActive, IsItemHovered, etc.)
function InvisibleButton(str_id, size) {
return bind.InvisibleButton(str_id, size);
}
exports_1("InvisibleButton", InvisibleButton);
// IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), const ImVec4& tint_col = ImVec4(1,1,1,1), const ImVec4& border_col = ImVec4(0,0,0,0));
function Image(user_texture_id, size, uv0 = ImVec2.ZERO, uv1 = ImVec2.UNIT, tint_col = ImVec4.WHITE, border_col = ImVec4.ZERO) {
bind.Image(ImGuiContext.setTexture(user_texture_id), size, uv0, uv1, tint_col, border_col);
}
exports_1("Image", Image);
// IMGUI_API bool ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0,0,0,0), const ImVec4& tint_col = ImVec4(1,1,1,1)); // <0 frame_padding uses default frame padding settings. 0 for no padding
function ImageButton(user_texture_id, size, uv0 = ImVec2.ZERO, uv1 = ImVec2.UNIT, frame_padding = -1, bg_col = ImVec4.ZERO, tint_col = ImVec4.WHITE) {
return bind.ImageButton(ImGuiContext.setTexture(user_texture_id), size, uv0, uv1, frame_padding, bg_col, tint_col);
}
exports_1("ImageButton", ImageButton);
// IMGUI_API bool Checkbox(const char* label, bool* v);
function Checkbox(label, v) {
if (Array.isArray(v)) {
return bind.Checkbox(label, v);
}
else {
const ref_v = [v()];
const ret = bind.Checkbox(label, ref_v);
v(ref_v[0]);
return ret;
}
}
exports_1("Checkbox", Checkbox);
// IMGUI_API bool CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value);
function CheckboxFlags(label, flags, flags_value) {
if (Array.isArray(flags)) {
return bind.CheckboxFlags(label, flags, flags_value);
}
else {
const ref_flags = [flags()];
const ret = bind.CheckboxFlags(label, ref_flags, flags_value);
flags(ref_flags[0]);
return ret;
}
}
exports_1("CheckboxFlags", CheckboxFlags);
function RadioButton(label, ...args) {
if (typeof (args[0]) === "boolean") {
const active = args[0];
return bind.RadioButton_A(label, active);
}
else {
const v = args[0];
const v_button = args[1];
const _v = Array.isArray(v) ? v : [v()];
const ret = bind.RadioButton_B(label, _v, v_button);
if (!Array.isArray(v)) {
v(_v[0]);
}
return ret;
}
}
exports_1("RadioButton", RadioButton);
function PlotLines(label, ...args) {
if (Array.isArray(args[0])) {
const values = args[0];
const values_getter = (data, idx) => values[idx * stride];
const values_count = typeof (args[1]) === "number" ? args[1] : values.length;
const values_offset = typeof (args[2]) === "number" ? args[2] : 0;
const overlay_text = typeof (args[3]) === "string" ? args[3] : null;
const scale_min = typeof (args[4]) === "number" ? args[4] : Number.MAX_VALUE;
const scale_max = typeof (args[5]) === "number" ? args[5] : Number.MAX_VALUE;
const graph_size = args[6] || ImVec2.ZERO;
const stride = typeof (args[7]) === "number" ? args[7] : 1;
bind.PlotLines(label, values_getter, null, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size);
}
else {
const values_getter = args[0];
const data = args[1];
const values_count = args[2];
const values_offset = typeof (args[3]) === "number" ? args[3] : 0;
const overlay_text = typeof (args[4]) === "string" ? args[4] : null;
const scale_min = typeof (args[5]) === "number" ? args[5] : Number.MAX_VALUE;
const scale_max = typeof (args[6]) === "number" ? args[6] : Number.MAX_VALUE;
const graph_size = args[7] || ImVec2.ZERO;
bind.PlotLines(label, values_getter, data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size);
}
}
exports_1("PlotLines", PlotLines);
function PlotHistogram(label, ...args) {
if (Array.isArray(args[0])) {
const values = args[0];
const values_getter = (data, idx) => values[idx * stride];
const values_count = typeof (args[1]) === "number" ? args[1] : values.length;
const values_offset = typeof (args[2]) === "number" ? args[2] : 0;
const overlay_text = typeof (args[3]) === "string" ? args[3] : null;
const scale_min = typeof (args[4]) === "number" ? args[4] : Number.MAX_VALUE;
const scale_max = typeof (args[5]) === "number" ? args[5] : Number.MAX_VALUE;
const graph_size = args[6] || ImVec2.ZERO;
const stride = typeof (args[7]) === "number" ? args[7] : 1;
bind.PlotHistogram(label, values_getter, null, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size);
}
else {
const values_getter = args[0];
const data = args[1];
const values_count = args[2];
const values_offset = typeof (args[3]) === "number" ? args[3] : 0;
const overlay_text = typeof (args[4]) === "string" ? args[4] : null;
const scale_min = typeof (args[5]) === "number" ? args[5] : Number.MAX_VALUE;
const scale_max = typeof (args[6]) === "number" ? args[6] : Number.MAX_VALUE;
const graph_size = args[7] || ImVec2.ZERO;
bind.PlotHistogram(label, values_getter, data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size);
}
}
exports_1("PlotHistogram", PlotHistogram);
// IMGUI_API void ProgressBar(float fraction, const ImVec2& size_arg = ImVec2(-1,0), const char* overlay = NULL);
function ProgressBar(fraction, size_arg = new ImVec2(-1, 0), overlay = null) {
bind.ProgressBar(fraction, size_arg, overlay);
}
exports_1("ProgressBar", ProgressBar);
// Widgets: Combo Box
// The new BeginCombo()/EndCombo() api allows you to manage your contents and selection state however you want it.
// The old Combo() api are helpers over BeginCombo()/EndCombo() which are kept available for convenience purpose.
// IMGUI_API bool BeginCombo(const char* label, const char* preview_value, ImGuiComboFlags flags = 0);
function BeginCombo(label, preview_value = null, flags = 0) {
return bind.BeginCombo(label, preview_value, flags);
}
exports_1("BeginCombo", BeginCombo);
// IMGUI_API void EndCombo();
function EndCombo() { bind.EndCombo(); }
exports_1("EndCombo", EndCombo);
function Combo(label, current_item, ...args) {
let ret = false;
const _current_item = Array.isArray(current_item) ? current_item : [current_item()];
if (Array.isArray(args[0])) {
const items = args[0];
const items_count = typeof (args[1]) === "number" ? args[1] : items.length;
const popup_max_height_in_items = typeof (args[2]) === "number" ? args[2] : -1;
const items_getter = (data, idx, out_text) => { out_text[0] = items[idx]; return true; };
ret = bind.Combo(label, _current_item, items_getter, null, items_count, popup_max_height_in_items);
}
else if (typeof (args[0]) === "string") {
const items_separated_by_zeros = args[0];
const popup_max_height_in_items = typeof (args[1]) === "number" ? args[1] : -1;
const items = items_separated_by_zeros.replace(/^\0+|\0+$/g, "").split("\0");
const items_count = items.length;
const items_getter = (data, idx, out_text) => { out_text[0] = items[idx]; return true; };
ret = bind.Combo(label, _current_item, items_getter, null, items_count, popup_max_height_in_items);
}
else {
const items_getter = args[0];
const data = args[1];
const items_count = args[2];
const popup_max_height_in_items = typeof (args[3]) === "number" ? args[3] : -1;
ret = bind.Combo(label, _current_item, items_getter, data, items_count, popup_max_height_in_items);
}
if (!Array.isArray(current_item)) {
current_item(_current_item[0]);
}
return ret;
}
exports_1("Combo", Combo);
// Widgets: Drags (tip: ctrl+click on a drag box to input with keyboard. manually input values aren't clamped, can go off-bounds)
// For all the Float2/Float3/Float4/Int2/Int3/Int4 versions of every functions, note that a 'float v[X]' function argument is the same as 'float* v', the array syntax is just a way to document the number of elements that are expected to be accessible. You can pass address of your first element out of a contiguous set, e.g. &myvector.x
// IMGUI_API bool DragFloat(const char* label, float* v, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", float power = 1.0f); // If v_min >= v_max we have no bound
function DragFloat(label, v, v_speed = 1.0, v_min = 0.0, v_max = 0.0, display_format = "%.3f", power = 1.0) {
const _v = import_Scalar(v);
const ret = bind.DragFloat(label, _v, v_speed, v_min, v_max, display_format, power);
export_Scalar(_v, v);
return ret;
}
exports_1("DragFloat", DragFloat);
// IMGUI_API bool DragFloat2(const char* label, float v[2], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", float power = 1.0f);
function DragFloat2(label, v, v_speed = 1.0, v_min = 0.0, v_max = 0.0, display_format = "%.3f", power = 1.0) {
const _v = import_Vector2(v);
const ret = bind.DragFloat2(label, _v, v_speed, v_min, v_max, display_format, power);
export_Vector2(_v, v);
return ret;
}
exports_1("DragFloat2", DragFloat2);
// IMGUI_API bool DragFloat3(const char* label, float v[3], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", float power = 1.0f);
function DragFloat3(label, v, v_speed = 1.0, v_min = 0.0, v_max = 0.0, display_format = "%.3f", power = 1.0) {
const _v = import_Vector3(v);
const ret = bind.DragFloat3(label, _v, v_speed, v_min, v_max, display_format, power);
export_Vector3(_v, v);
return ret;
}
exports_1("DragFloat3", DragFloat3);
// IMGUI_API bool DragFloat4(const char* label, float v[4], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", float power = 1.0f);
function DragFloat4(label, v, v_speed = 1.0, v_min = 0.0, v_max = 0.0, display_format = "%.3f", power = 1.0) {
const _v = import_Vector4(v);
const ret = bind.DragFloat4(label, _v, v_speed, v_min, v_max, display_format, power);
export_Vector4(_v, v);
return ret;
}
exports_1("DragFloat4", DragFloat4);
// IMGUI_API bool DragFloatRange2(const char* label, float* v_current_min, float* v_current_max, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", const char* display_format_max = NULL, float power = 1.0f);
function DragFloatRange2(label, v_current_min, v_current_max, v_speed = 1.0, v_min = 0.0, v_max = 0.0, display_format = "%.3f", display_format_max = null, power = 1.0) {
const _v_current_min = import_Scalar(v_current_min);
const _v_current_max = import_Scalar(v_current_max);
const ret = bind.DragFloatRange2(label, _v_current_min, _v_current_max, v_speed, v_min, v_max, display_format, display_format_max, power);
export_Scalar(_v_current_min, v_current_min);
export_Scalar(_v_current_max, v_current_max);
return ret;
}
exports_1("DragFloatRange2", DragFloatRange2);
// IMGUI_API bool DragInt(const char* label, int* v, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* display_format = "%d"); // If v_min >= v_max we have no bound
function DragInt(label, v, v_speed = 1.0, v_min = 0, v_max = 0, format = "%d") {
const _v = import_Scalar(v);
const ret = bind.DragInt(label, _v, v_speed, v_min, v_max, format);
export_Scalar(_v, v);