forked from flyover/imgui-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimgui.ts
More file actions
3836 lines (3612 loc) · 277 KB
/
Copy pathimgui.ts
File metadata and controls
3836 lines (3612 loc) · 277 KB
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
export interface XY { x: number, y: number; }
export interface XYZ extends XY { z: number; }
export interface XYZW extends XYZ { w: number; }
export interface RGB { r: number; g: number; b: number; }
export interface RGBA extends RGB { a: number; }
import * as Bind from "./bind-imgui";
export { Bind };
let bind: Bind.Module;
export default async function(value?: Partial<Bind.Module>): Promise<void> {
return new Promise<void>((resolve: () => void) => {
Bind.default(value).then((value: Bind.Module): void => {
bind = value;
resolve();
});
});
}
export { bind };
function import_Scalar(sca: XY | XYZ | XYZW | Bind.ImAccess<number> | Bind.ImScalar<number> | Bind.ImTuple2<number> | Bind.ImTuple3<number> | Bind.ImTuple4<number> | Bind.interface_ImVec4): Bind.ImScalar<number> {
if (Array.isArray(sca)) { return [ sca[0] ]; }
if (typeof sca === "function") { return [ sca() ]; }
return [ sca.x ];
}
function export_Scalar(tuple: Bind.ImScalar<number>, sca: XY | XYZ | XYZW | Bind.ImAccess<number> | Bind.ImScalar<number> | Bind.ImTuple2<number> | Bind.ImTuple3<number> | Bind.ImTuple4<number> | Bind.interface_ImVec4): void {
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: XY | XYZ | XYZW | Bind.ImTuple2<number> | Bind.ImTuple3<number> | Bind.ImTuple4<number> | Bind.interface_ImVec4): Bind.ImTuple2<number> {
if (Array.isArray(vec)) { return [ vec[0], vec[1] ]; }
return [ vec.x, vec.y ];
}
function export_Vector2(tuple: Bind.ImTuple2<number>, vec: XY | XYZ | XYZW | Bind.ImTuple2<number> | Bind.ImTuple3<number> | Bind.ImTuple4<number> | Bind.interface_ImVec4): void {
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: XYZ | XYZW | Bind.ImTuple3<number> | Bind.ImTuple4<number> | Bind.interface_ImVec4): Bind.ImTuple3<number> {
if (Array.isArray(vec)) { return [ vec[0], vec[1], vec[2] ]; }
return [ vec.x, vec.y, vec.z ];
}
function export_Vector3(tuple: Bind.ImTuple3<number>, vec: XYZ | XYZW | Bind.ImTuple3<number> | Bind.ImTuple4<number> | Bind.interface_ImVec4): void {
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: XYZW | Bind.ImTuple3<number> | Bind.ImTuple4<number> | Bind.interface_ImVec4 | XYZW): Bind.ImTuple4<number> {
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: Bind.ImTuple4<number>, vec: XYZW | Bind.ImTuple3<number> | Bind.ImTuple4<number> | Bind.interface_ImVec4 | XYZW): void {
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: RGB | RGBA | Bind.ImTuple3<number> | Bind.ImTuple4<number> | Bind.interface_ImVec4): Bind.ImTuple3<number> {
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: Bind.ImTuple3<number>, col: RGB | RGBA | Bind.ImTuple3<number> | Bind.ImTuple4<number> | Bind.interface_ImVec4): void {
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: RGBA | Bind.ImTuple4<number> | Bind.interface_ImVec4 | RGBA): Bind.ImTuple4<number> {
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: Bind.ImTuple4<number>, col: RGBA | Bind.ImTuple4<number> | Bind.interface_ImVec4 | RGBA): void {
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];
}
import * as config from "./imconfig";
export const IMGUI_VERSION: string = "1.66"; // bind.IMGUI_VERSION;
export const IMGUI_VERSION_NUM: number = 16601; // bind.IMGUI_VERSION_NUM;
// #define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert))
export function IMGUI_CHECKVERSION(): boolean { return DebugCheckVersionAndDataLayout(IMGUI_VERSION, bind.ImGuiIOSize, bind.ImGuiStyleSize, bind.ImVec2Size, bind.ImVec4Size, bind.ImDrawVertSize); }
export function IM_ASSERT(_EXPR: boolean | number): void { if (!_EXPR) { throw new Error(); } }
export function IM_ARRAYSIZE(_ARR: ArrayLike<any> | ImStringBuffer): number {
if (_ARR instanceof ImStringBuffer) {
return _ARR.size;
} else {
return _ARR.length;
}
}
export class ImStringBuffer {
constructor(public size: number, public buffer: string = "") {}
}
export { ImAccess } from "./bind-imgui";
export { ImScalar } from "./bind-imgui";
export { ImTuple2 } from "./bind-imgui";
export { ImTuple3 } from "./bind-imgui";
export { ImTuple4 } from "./bind-imgui";
export type ImTextureID = WebGLTexture;
// Flags for ImGui::Begin()
export { ImGuiWindowFlags as WindowFlags };
export enum ImGuiWindowFlags {
None = 0,
NoTitleBar = 1 << 0, // Disable title-bar
NoResize = 1 << 1, // Disable user resizing with the lower-right grip
NoMove = 1 << 2, // Disable user moving the window
NoScrollbar = 1 << 3, // Disable scrollbars (window can still scroll with mouse or programatically)
NoScrollWithMouse = 1 << 4, // Disable user vertically scrolling with mouse wheel. On child window, mouse wheel will be forwarded to the parent unless NoScrollbar is also set.
NoCollapse = 1 << 5, // Disable user collapsing window by double-clicking on it
AlwaysAutoResize = 1 << 6, // Resize every window to its content every frame
NoBackground = 1 << 7, // Disable drawing background color (WindowBg, etc.) and outside border. Similar as using SetNextWindowBgAlpha(0.0f).
NoSavedSettings = 1 << 8, // Never load/save settings in .ini file
NoMouseInputs = 1 << 9, // Disable catching mouse or keyboard inputs, hovering test with pass through.
MenuBar = 1 << 10, // Has a menu-bar
HorizontalScrollbar = 1 << 11, // Allow horizontal scrollbar to appear (off by default). You may use SetNextWindowContentSize(ImVec2(width,0.0f)); prior to calling Begin() to specify width. Read code in imgui_demo in the "Horizontal Scrolling" section.
NoFocusOnAppearing = 1 << 12, // Disable taking focus when transitioning from hidden to visible state
NoBringToFrontOnFocus = 1 << 13, // Disable bringing window to front when taking focus (e.g. clicking on it or programatically giving it focus)
AlwaysVerticalScrollbar= 1 << 14, // Always show vertical scrollbar (even if ContentSize.y < Size.y)
AlwaysHorizontalScrollbar= 1 << 15, // Always show horizontal scrollbar (even if ContentSize.x < Size.x)
AlwaysUseWindowPadding = 1 << 16, // Ensure child windows without border uses style.WindowPadding (ignored by default for non-bordered child windows, because more convenient)
NoNavInputs = 1 << 18, // No gamepad/keyboard navigation within the window
NoNavFocus = 1 << 19, // No focusing toward this window with gamepad/keyboard navigation (e.g. skipped by CTRL+TAB)
NoNav = NoNavInputs | NoNavFocus,
NoDecoration = NoTitleBar | NoResize | NoScrollbar | NoCollapse,
NoInputs = NoMouseInputs | NoNavInputs | NoNavFocus,
// [Internal]
NavFlattened = 1 << 23, // (WIP) Allow gamepad/keyboard navigation to cross over parent border to this child (only use on child that have no scrolling!)
ChildWindow = 1 << 24, // Don't use! For internal use by BeginChild()
Tooltip = 1 << 25, // Don't use! For internal use by BeginTooltip()
Popup = 1 << 26, // Don't use! For internal use by BeginPopup()
Modal = 1 << 27, // Don't use! For internal use by BeginPopupModal()
ChildMenu = 1 << 28, // Don't use! For internal use by BeginMenu()
}
// Flags for ImGui::InputText()
export { ImGuiInputTextFlags as InputTextFlags };
export enum ImGuiInputTextFlags {
None = 0,
CharsDecimal = 1 << 0, // Allow 0123456789.+-*/
CharsHexadecimal = 1 << 1, // Allow 0123456789ABCDEFabcdef
CharsUppercase = 1 << 2, // Turn a..z into A..Z
CharsNoBlank = 1 << 3, // Filter out spaces, tabs
AutoSelectAll = 1 << 4, // Select entire text when first taking mouse focus
EnterReturnsTrue = 1 << 5, // Return 'true' when Enter is pressed (as opposed to when the value was modified)
CallbackCompletion = 1 << 6, // Call user function on pressing TAB (for completion handling)
CallbackHistory = 1 << 7, // Call user function on pressing Up/Down arrows (for history handling)
CallbackAlways = 1 << 8, // Call user function every time. User code may query cursor position, modify text buffer.
CallbackCharFilter = 1 << 9, // Call user function to filter character. Modify data->EventChar to replace/filter input, or return 1 to discard character.
AllowTabInput = 1 << 10, // Pressing TAB input a '\t' character into the text field
CtrlEnterForNewLine = 1 << 11, // In multi-line mode, unfocus with Enter, add new line with Ctrl+Enter (default is opposite: unfocus with Ctrl+Enter, add line with Enter).
NoHorizontalScroll = 1 << 12, // Disable following the cursor horizontally
AlwaysInsertMode = 1 << 13, // Insert mode
ReadOnly = 1 << 14, // Read-only mode
Password = 1 << 15, // Password mode, display all characters as '*'
NoUndoRedo = 1 << 16, // Disable undo/redo. Note that input text owns the text data while active, if you want to provide your own undo/redo stack you need e.g. to call ClearActiveID().
CharsScientific = 1 << 17, // Allow 0123456789.+-*/eE (Scientific notation input)
CallbackResize = 1 << 18, // Allow buffer capacity resize + notify when the string wants to be resized (for string types which hold a cache of their Size) (see misc/stl/imgui_stl.h for an example of using this)
// [Internal]
Multiline = 1 << 20, // For internal use by InputTextMultiline()
}
// Flags for ImGui::TreeNodeEx(), ImGui::CollapsingHeader*()
export { ImGuiTreeNodeFlags as TreeNodeFlags };
export enum ImGuiTreeNodeFlags {
None = 0,
Selected = 1 << 0, // Draw as selected
Framed = 1 << 1, // Full colored frame (e.g. for CollapsingHeader)
AllowItemOverlap = 1 << 2, // Hit testing to allow subsequent widgets to overlap this one
NoTreePushOnOpen = 1 << 3, // Don't do a TreePush() when open (e.g. for CollapsingHeader) = no extra indent nor pushing on ID stack
NoAutoOpenOnLog = 1 << 4, // Don't automatically and temporarily open node when Logging is active (by default logging will automatically open tree nodes)
DefaultOpen = 1 << 5, // Default node to be open
OpenOnDoubleClick = 1 << 6, // Need double-click to open node
OpenOnArrow = 1 << 7, // Only open when clicking on the arrow part. If OpenOnDoubleClick is also set, single-click arrow or double-click all box to open.
Leaf = 1 << 8, // No collapsing, no arrow (use as a convenience for leaf nodes).
Bullet = 1 << 9, // Display a bullet instead of arrow
FramePadding = 1 << 10, // Use FramePadding (even for an unframed text node) to vertically align text baseline to regular widget height. Equivalent to calling AlignTextToFramePadding().
//SpanAllAvailWidth = 1 << 11, // FIXME: TODO: Extend hit box horizontally even if not framed
//NoScrollOnOpen = 1 << 12, // FIXME: TODO: Disable automatic scroll on TreePop() if node got just open and contents is not visible
NavLeftJumpsBackHere = 1 << 13, // (WIP) Nav: left direction may move to this TreeNode() from any of its child (items submitted between TreeNode and TreePop)
CollapsingHeader = Framed | NoTreePushOnOpen | NoAutoOpenOnLog,
}
// Flags for ImGui::Selectable()
export { ImGuiSelectableFlags as SelectableFlags };
export enum ImGuiSelectableFlags {
None = 0,
DontClosePopups = 1 << 0, // Clicking this don't close parent popup window
SpanAllColumns = 1 << 1, // Selectable frame can span all columns (text will still fit in current column)
AllowDoubleClick = 1 << 2, // Generate press events on double clicks too
Disabled = 1 << 3 // Cannot be selected, display greyed out text
}
// Flags for ImGui::BeginCombo()
export { ImGuiComboFlags as ComboFlags };
export enum ImGuiComboFlags {
None = 0,
PopupAlignLeft = 1 << 0, // Align the popup toward the left by default
HeightSmall = 1 << 1, // Max ~4 items visible. Tip: If you want your combo popup to be a specific size you can use SetNextWindowSizeConstraints() prior to calling BeginCombo()
HeightRegular = 1 << 2, // Max ~8 items visible (default)
HeightLarge = 1 << 3, // Max ~20 items visible
HeightLargest = 1 << 4, // As many fitting items as possible
NoArrowButton = 1 << 5, // Display on the preview box without the square arrow button
NoPreview = 1 << 6, // Display only a square arrow button
HeightMask_ = HeightSmall | HeightRegular | HeightLarge | HeightLargest,
}
// Flags for ImGui::IsWindowFocused()
export { ImGuiFocusedFlags as FocusedFlags };
export enum ImGuiFocusedFlags {
None = 0,
ChildWindows = 1 << 0, // IsWindowFocused(): Return true if any children of the window is focused
RootWindow = 1 << 1, // IsWindowFocused(): Test from root window (top most parent of the current hierarchy)
AnyWindow = 1 << 2, // IsWindowFocused(): Return true if any window is focused
RootAndChildWindows = RootWindow | ChildWindows,
}
// Flags for ImGui::IsItemHovered(), ImGui::IsWindowHovered()
export { ImGuiHoveredFlags as HoveredFlags };
export enum ImGuiHoveredFlags {
None = 0, // Return true if directly over the item/window, not obstructed by another window, not obstructed by an active popup or modal blocking inputs under them.
ChildWindows = 1 << 0, // IsWindowHovered() only: Return true if any children of the window is hovered
RootWindow = 1 << 1, // IsWindowHovered() only: Test from root window (top most parent of the current hierarchy)
AnyWindow = 1 << 2, // IsWindowHovered() only: Return true if any window is hovered
AllowWhenBlockedByPopup = 1 << 3, // Return true even if a popup window is normally blocking access to this item/window
//AllowWhenBlockedByModal = 1 << 4, // Return true even if a modal popup window is normally blocking access to this item/window. FIXME-TODO: Unavailable yet.
AllowWhenBlockedByActiveItem = 1 << 5, // Return true even if an active item is blocking access to this item/window. Useful for Drag and Drop patterns.
AllowWhenOverlapped = 1 << 6, // Return true even if the position is overlapped by another window
AllowWhenDisabled = 1 << 7, // Return true even if the item is disabled
RectOnly = AllowWhenBlockedByPopup | AllowWhenBlockedByActiveItem | AllowWhenOverlapped,
RootAndChildWindows = RootWindow | ChildWindows,
}
// Flags for ImGui::BeginDragDropSource(), ImGui::AcceptDragDropPayload()
export { ImGuiDragDropFlags as DragDropFlags };
export enum ImGuiDragDropFlags {
// BeginDragDropSource() flags
None = 0,
SourceNoPreviewTooltip = 1 << 0, // By default, a successful call to BeginDragDropSource opens a tooltip so you can display a preview or description of the source contents. This flag disable this behavior.
SourceNoDisableHover = 1 << 1, // By default, when dragging we clear data so that IsItemHovered() will return true, to avoid subsequent user code submitting tooltips. This flag disable this behavior so you can still call IsItemHovered() on the source item.
SourceNoHoldToOpenOthers = 1 << 2, // Disable the behavior that allows to open tree nodes and collapsing header by holding over them while dragging a source item.
SourceAllowNullID = 1 << 3, // Allow items such as Text(), Image() that have no unique identifier to be used as drag source, by manufacturing a temporary identifier based on their window-relative position. This is extremely unusual within the dear imgui ecosystem and so we made it explicit.
SourceExtern = 1 << 4, // External source (from outside of imgui), won't attempt to read current item/window info. Will always return true. Only one Extern source can be active simultaneously.
SourceAutoExpirePayload = 1 << 5, // Automatically expire the payload if the source cease to be submitted (otherwise payloads are persisting while being dragged)
// AcceptDragDropPayload() flags
AcceptBeforeDelivery = 1 << 10, // AcceptDragDropPayload() will returns true even before the mouse button is released. You can then call IsDelivery() to test if the payload needs to be delivered.
AcceptNoDrawDefaultRect = 1 << 11, // Do not draw the default highlight rectangle when hovering over target.
AcceptNoPreviewTooltip = 1 << 12, // Request hiding the BeginDragDropSource tooltip from the BeginDragDropTarget site.
AcceptPeekOnly = AcceptBeforeDelivery | AcceptNoDrawDefaultRect, // For peeking ahead and inspecting the payload before delivery.
}
// Standard Drag and Drop payload types. You can define you own payload types using 12-characters long strings. Types starting with '_' are defined by Dear ImGui.
export const IMGUI_PAYLOAD_TYPE_COLOR_3F: string = "_COL3F"; // float[3] // Standard type for colors, without alpha. User code may use this type.
export const IMGUI_PAYLOAD_TYPE_COLOR_4F: string = "_COL4F"; // float[4] // Standard type for colors. User code may use this type.
// A primary data type
export { ImGuiDataType as DataType };
export enum ImGuiDataType {
S32, // int
U32, // unsigned int
S64, // long long, __int64
U64, // unsigned long long, unsigned __int64
Float, // float
Double, // double
COUNT
}
// A cardinal direction
export { ImGuiDir as Dir };
export enum ImGuiDir {
None = -1,
Left = 0,
Right = 1,
Up = 2,
Down = 3,
COUNT
}
// User fill ImGuiIO.KeyMap[] array with indices into the ImGuiIO.KeysDown[512] array
export { ImGuiKey as Key };
export enum ImGuiKey {
Tab,
LeftArrow,
RightArrow,
UpArrow,
DownArrow,
PageUp,
PageDown,
Home,
End,
Insert,
Delete,
Backspace,
Space,
Enter,
Escape,
A, // for text edit CTRL+A: select all
C, // for text edit CTRL+C: copy
V, // for text edit CTRL+V: paste
X, // for text edit CTRL+X: cut
Y, // for text edit CTRL+Y: redo
Z, // for text edit CTRL+Z: undo
COUNT,
}
// [BETA] Gamepad/Keyboard directional navigation
// Keyboard: Set io.ConfigFlags |= EnableKeyboard to enable. NewFrame() will automatically fill io.NavInputs[] based on your io.KeyDown[] + io.KeyMap[] arrays.
// Gamepad: Set io.ConfigFlags |= EnableGamepad to enable. Fill the io.NavInputs[] fields before calling NewFrame(). Note that io.NavInputs[] is cleared by EndFrame().
// Read instructions in imgui.cpp for more details.
export { ImGuiNavInput as NavInput };
export enum ImGuiNavInput
{
// Gamepad Mapping
Activate, // activate / open / toggle / tweak value // e.g. Circle (PS4), A (Xbox), B (Switch), Space (Keyboard)
Cancel, // cancel / close / exit // e.g. Cross (PS4), B (Xbox), A (Switch), Escape (Keyboard)
Input, // text input / on-screen keyboard // e.g. Triang.(PS4), Y (Xbox), X (Switch), Return (Keyboard)
Menu, // tap: toggle menu / hold: focus, move, resize // e.g. Square (PS4), X (Xbox), Y (Switch), Alt (Keyboard)
DpadLeft, // move / tweak / resize window (w/ PadMenu) // e.g. D-pad Left/Right/Up/Down (Gamepads), Arrow keys (Keyboard)
DpadRight, //
DpadUp, //
DpadDown, //
LStickLeft, // scroll / move window (w/ PadMenu) // e.g. Left Analog Stick Left/Right/Up/Down
LStickRight, //
LStickUp, //
LStickDown, //
FocusPrev, // next window (w/ PadMenu) // e.g. L1 or L2 (PS4), LB or LT (Xbox), L or ZL (Switch)
FocusNext, // prev window (w/ PadMenu) // e.g. R1 or R2 (PS4), RB or RT (Xbox), R or ZL (Switch)
TweakSlow, // slower tweaks // e.g. L1 or L2 (PS4), LB or LT (Xbox), L or ZL (Switch)
TweakFast, // faster tweaks // e.g. R1 or R2 (PS4), RB or RT (Xbox), R or ZL (Switch)
// [Internal] Don't use directly! This is used internally to differentiate keyboard from gamepad inputs for behaviors that require to differentiate them.
// Keyboard behavior that have no corresponding gamepad mapping (e.g. CTRL+TAB) may be directly reading from io.KeyDown[] instead of io.NavInputs[].
KeyMenu_, // toggle menu // = io.KeyAlt
KeyLeft_, // move left // = Arrow keys
KeyRight_, // move right
KeyUp_, // move up
KeyDown_, // move down
COUNT,
InternalStart_ = KeyMenu_,
}
// [BETA] Gamepad/Keyboard directional navigation flags, stored in io.ConfigFlags
export { ImGuiConfigFlags as ConfigFlags };
export enum ImGuiConfigFlags
{
NavEnableKeyboard = 1 << 0, // Master keyboard navigation enable flag. NewFrame() will automatically fill io.NavInputs[] based on io.KeyDown[].
NavEnableGamepad = 1 << 1, // Master gamepad navigation enable flag. This is mostly to instruct your imgui back-end to fill io.NavInputs[].
NavEnableSetMousePos = 1 << 2, // Request navigation to allow moving the mouse cursor. May be useful on TV/console systems where moving a virtual mouse is awkward. Will update io.MousePos and set io.WantMoveMouse=true. If enabled you MUST honor io.WantMoveMouse requests in your binding, otherwise ImGui will react as if the mouse is jumping around back and forth.
NavNoCaptureKeyboard = 1 << 3, // Do not set the io.WantCaptureKeyboard flag with io.NavActive is set.
NoMouse = 1 << 4, // Instruct imgui to clear mouse position/buttons in NewFrame(). This allows ignoring the mouse information back-end
NoMouseCursorChange = 1 << 5, // Instruct back-end to not alter mouse cursor shape and visibility.
IsSRGB = 1 << 20, // Application is SRGB-aware.
IsTouchScreen = 1 << 21 // Application is using a touch screen instead of a mouse.
}
// Enumeration for PushStyleColor() / PopStyleColor()
export { ImGuiCol as Col };
export enum ImGuiCol {
Text,
TextDisabled,
WindowBg, // Background of normal windows
ChildBg, // Background of child windows
PopupBg, // Background of popups, menus, tooltips windows
Border,
BorderShadow,
FrameBg, // Background of checkbox, radio button, plot, slider, text input
FrameBgHovered,
FrameBgActive,
TitleBg,
TitleBgActive,
TitleBgCollapsed,
MenuBarBg,
ScrollbarBg,
ScrollbarGrab,
ScrollbarGrabHovered,
ScrollbarGrabActive,
CheckMark,
SliderGrab,
SliderGrabActive,
Button,
ButtonHovered,
ButtonActive,
Header,
HeaderHovered,
HeaderActive,
Separator,
SeparatorHovered,
SeparatorActive,
ResizeGrip,
ResizeGripHovered,
ResizeGripActive,
PlotLines,
PlotLinesHovered,
PlotHistogram,
PlotHistogramHovered,
TextSelectedBg,
DragDropTarget,
NavHighlight, // Gamepad/keyboard: current highlighted item
NavWindowingHighlight, // Highlight window when using CTRL+TAB
NavWindowingDimBg, // Darken/colorize entire screen behind the CTRL+TAB window list, when active
ModalWindowDimBg, // Darken/colorize entire screen behind a modal window, when one is active
COUNT,
}
// Enumeration for PushStyleVar() / PopStyleVar() to temporarily modify the ImGuiStyle structure.
// NB: the enum only refers to fields of ImGuiStyle which makes sense to be pushed/popped inside UI code. During initialization, feel free to just poke into ImGuiStyle directly.
// NB: if changing this enum, you need to update the associated internal table GStyleVarInfo[] accordingly. This is where we link enum values to members offset/type.
export { ImGuiStyleVar as StyleVar };
export enum ImGuiStyleVar {
// Enum name ......................// Member in ImGuiStyle structure (see ImGuiStyle for descriptions)
Alpha, // float Alpha
WindowPadding, // ImVec2 WindowPadding
WindowRounding, // float WindowRounding
WindowBorderSize, // float WindowBorderSize
WindowMinSize, // ImVec2 WindowMinSize
WindowTitleAlign, // ImVec2 WindowTitleAlign
ChildRounding, // float ChildRounding
ChildBorderSize, // float ChildBorderSize
PopupRounding, // float PopupRounding
PopupBorderSize, // float PopupBorderSize
FramePadding, // ImVec2 FramePadding
FrameRounding, // float FrameRounding
FrameBorderSize, // float FrameBorderSize
ItemSpacing, // ImVec2 ItemSpacing
ItemInnerSpacing, // ImVec2 ItemInnerSpacing
IndentSpacing, // float IndentSpacing
ScrollbarSize, // float ScrollbarSize
ScrollbarRounding, // float ScrollbarRounding
GrabMinSize, // float GrabMinSize
GrabRounding, // float GrabRounding
ButtonTextAlign, // ImVec2 ButtonTextAlign
Count_, COUNT = Count_,
}
// Back-end capabilities flags stored in io.BackendFlags. Set by imgui_impl_xxx or custom back-end.
export { ImGuiBackendFlags as BackendFlags };
export enum ImGuiBackendFlags {
HasGamepad = 1 << 0, // Back-end has a connected gamepad.
HasMouseCursors = 1 << 1, // Back-end can honor GetMouseCursor() values and change the OS cursor shape.
HasSetMousePos = 1 << 2 // Back-end can honor io.WantSetMousePos and reposition the mouse (only used if ImGuiConfigFlags_NavEnableSetMousePos is set).
}
// Enumeration for ColorEdit3() / ColorEdit4() / ColorPicker3() / ColorPicker4() / ColorButton()
export { ImGuiColorEditFlags as ColorEditFlags };
export enum ImGuiColorEditFlags {
None = 0,
NoAlpha = 1 << 1, // // ColorEdit, ColorPicker, ColorButton: ignore Alpha component (read 3 components from the input pointer).
NoPicker = 1 << 2, // // ColorEdit: disable picker when clicking on colored square.
NoOptions = 1 << 3, // // ColorEdit: disable toggling options menu when right-clicking on inputs/small preview.
NoSmallPreview = 1 << 4, // // ColorEdit, ColorPicker: disable colored square preview next to the inputs. (e.g. to show only the inputs)
NoInputs = 1 << 5, // // ColorEdit, ColorPicker: disable inputs sliders/text widgets (e.g. to show only the small preview colored square).
NoTooltip = 1 << 6, // // ColorEdit, ColorPicker, ColorButton: disable tooltip when hovering the preview.
NoLabel = 1 << 7, // // ColorEdit, ColorPicker: disable display of inline text label (the label is still forwarded to the tooltip and picker).
NoSidePreview = 1 << 8, // // ColorPicker: disable bigger color preview on right side of the picker, use small colored square preview instead.
NoDragDrop = 1 << 9, // // ColorEdit: disable drag and drop target. ColorButton: disable drag and drop source.
// User Options (right-click on widget to change some of them). You can set application defaults using SetColorEditOptions(). The idea is that you probably don't want to override them in most of your calls, let the user choose and/or call SetColorEditOptions() during startup.
AlphaBar = 1 << 16, // // ColorEdit, ColorPicker: show vertical alpha bar/gradient in picker.
AlphaPreview = 1 << 17, // // ColorEdit, ColorPicker, ColorButton: display preview as a transparent color over a checkerboard, instead of opaque.
AlphaPreviewHalf= 1 << 18, // // ColorEdit, ColorPicker, ColorButton: display half opaque / half checkerboard, instead of opaque.
HDR = 1 << 19, // // (WIP) ColorEdit: Currently only disable 0.0f..1.0f limits in RGBA edition (note: you probably want to use Float flag as well).
RGB = 1 << 20, // [Inputs] // ColorEdit: choose one among RGB/HSV/HEX. ColorPicker: choose any combination using RGB/HSV/HEX.
HSV = 1 << 21, // [Inputs] // "
HEX = 1 << 22, // [Inputs] // "
Uint8 = 1 << 23, // [DataType] // ColorEdit, ColorPicker, ColorButton: _display_ values formatted as 0..255.
Float = 1 << 24, // [DataType] // ColorEdit, ColorPicker, ColorButton: _display_ values formatted as 0.0f..1.0f floats instead of 0..255 integers. No round-trip of value via integers.
PickerHueBar = 1 << 25, // [PickerMode] // ColorPicker: bar for Hue, rectangle for Sat/Value.
PickerHueWheel = 1 << 26, // [PickerMode] // ColorPicker: wheel for Hue, triangle for Sat/Value.
// Internals/Masks
_InputsMask = RGB | HSV | HEX,
_DataTypeMask = Uint8 | Float,
_PickerMask = PickerHueWheel | PickerHueBar,
_OptionsDefault = Uint8 | RGB | PickerHueBar, // Change application default using SetColorEditOptions()
}
// Enumeration for GetMouseCursor()
export { ImGuiMouseCursor as MouseCursor };
export enum ImGuiMouseCursor {
None = -1,
Arrow = 0,
TextInput, // When hovering over InputText, etc.
ResizeAll, // (Unused by imgui functions)
ResizeNS, // When hovering over an horizontal border
ResizeEW, // When hovering over a vertical border or a column
ResizeNESW, // When hovering over the bottom-left corner of a window
ResizeNWSE, // When hovering over the bottom-right corner of a window
Hand, // (Unused by imgui functions. Use for e.g. hyperlinks)
Count_, COUNT = Count_,
}
// Condition for ImGui::SetWindow***(), SetNextWindow***(), SetNextTreeNode***() functions
// All those functions treat 0 as a shortcut to Always. From the point of view of the user use this as an enum (don't combine multiple values into flags).
export { ImGuiCond as Cond };
export enum ImGuiCond {
Always = 1 << 0, // Set the variable
Once = 1 << 1, // Set the variable once per runtime session (only the first call with succeed)
FirstUseEver = 1 << 2, // Set the variable if the window has no saved data (if doesn't exist in the .ini file)
Appearing = 1 << 3, // Set the variable if the window is appearing after being hidden/inactive (or the first time)
}
export { ImDrawCornerFlags as wCornerFlags };
export enum ImDrawCornerFlags
{
TopLeft = 1 << 0, // 0x1
TopRight = 1 << 1, // 0x2
BotLeft = 1 << 2, // 0x4
BotRight = 1 << 3, // 0x8
Top = TopLeft | TopRight, // 0x3
Bot = BotLeft | BotRight, // 0xC
Left = TopLeft | BotLeft, // 0x5
Right = TopRight | BotRight, // 0xA
All = 0xF, // In your function calls you may use ~0 (= all bits sets) instead of All, as a convenience
}
export { ImDrawListFlags as wListFlags };
export enum ImDrawListFlags
{
AntiAliasedLines = 1 << 0,
AntiAliasedFill = 1 << 1,
}
export { ImU32 } from "./bind-imgui";
export { interface_ImVec2 } from "./bind-imgui";
export { reference_ImVec2 } from "./bind-imgui";
export class ImVec2 implements Bind.interface_ImVec2 {
public static readonly ZERO: Readonly<ImVec2> = new ImVec2(0.0, 0.0);
public static readonly UNIT: Readonly<ImVec2> = new ImVec2(1.0, 1.0);
public static readonly UNIT_X: Readonly<ImVec2> = new ImVec2(1.0, 0.0);
public static readonly UNIT_Y: Readonly<ImVec2> = new ImVec2(0.0, 1.0);
constructor(public x: number = 0.0, public y: number = 0.0) {}
public Set(x: number, y: number): this {
this.x = x;
this.y = y;
return this;
}
public Copy(other: Readonly<Bind.interface_ImVec2>): this {
this.x = other.x;
this.y = other.y;
return this;
}
public Equals(other: Readonly<Bind.interface_ImVec2>): boolean {
if (this.x !== other.x) { return false; }
if (this.y !== other.y) { return false; }
return true;
}
}
export { interface_ImVec4 } from "./bind-imgui";
export { reference_ImVec4 } from "./bind-imgui";
export class ImVec4 implements Bind.interface_ImVec4 {
public static readonly ZERO: Readonly<ImVec4> = new ImVec4(0.0, 0.0, 0.0, 0.0);
public static readonly UNIT: Readonly<ImVec4> = new ImVec4(1.0, 1.0, 1.0, 1.0);
public static readonly UNIT_X: Readonly<ImVec4> = new ImVec4(1.0, 0.0, 0.0, 0.0);
public static readonly UNIT_Y: Readonly<ImVec4> = new ImVec4(0.0, 1.0, 0.0, 0.0);
public static readonly UNIT_Z: Readonly<ImVec4> = new ImVec4(0.0, 0.0, 1.0, 0.0);
public static readonly UNIT_W: Readonly<ImVec4> = new ImVec4(0.0, 0.0, 0.0, 1.0);
public static readonly BLACK: Readonly<ImVec4> = new ImVec4(0.0, 0.0, 0.0, 1.0);
public static readonly WHITE: Readonly<ImVec4> = new ImVec4(1.0, 1.0, 1.0, 1.0);
constructor(public x: number = 0.0, public y: number = 0.0, public z: number = 0.0, public w: number = 1.0) {}
public Set(x: number, y: number, z: number, w: number): this {
this.x = x;
this.y = y;
this.z = z;
this.w = w;
return this;
}
public Copy(other: Readonly<Bind.interface_ImVec4>): this {
this.x = other.x;
this.y = other.y;
this.z = other.z;
this.w = other.w;
return this;
}
public Equals(other: Readonly<Bind.interface_ImVec4>): boolean {
if (this.x !== other.x) { return false; }
if (this.y !== other.y) { return false; }
if (this.z !== other.z) { return false; }
if (this.w !== other.w) { return false; }
return true;
}
}
//-----------------------------------------------------------------------------
// Helpers
//-----------------------------------------------------------------------------
// Lightweight std::vector<> like class to avoid dragging dependencies (also: windows implementation of STL with debug enabled is absurdly slow, so let's bypass it so our code runs fast in debug).
// Our implementation does NOT call C++ constructors/destructors. This is intentional and we do not require it. Do not use this class as a straight std::vector replacement in your code!
export class ImVector<T> extends Array<T>
{
public get Size(): number { return this.length; }
public Data: T[] = this;
public empty(): boolean { return this.length === 0; }
public clear(): void { this.length = 0; }
public pop_back(): T | undefined { return this.pop(); }
public push_back(value: T): void { this.push(value); }
// public:
// int Size;
// int Capacity;
// T* Data;
// typedef T value_type;
// typedef value_type* iterator;
// typedef const value_type* const_iterator;
// inline ImVector() { Size = Capacity = 0; Data = NULL; }
// inline ~ImVector() { if (Data) ImGui::MemFree(Data); }
// inline bool empty() const { return Size == 0; }
// inline int size() const { return Size; }
// inline int capacity() const { return Capacity; }
// inline value_type& operator[](int i) { IM_ASSERT(i < Size); return Data[i]; }
// inline const value_type& operator[](int i) const { IM_ASSERT(i < Size); return Data[i]; }
// inline void clear() { if (Data) { Size = Capacity = 0; ImGui::MemFree(Data); Data = NULL; } }
// inline iterator begin() { return Data; }
// inline const_iterator begin() const { return Data; }
// inline iterator end() { return Data + Size; }
// inline const_iterator end() const { return Data + Size; }
// inline value_type& front() { IM_ASSERT(Size > 0); return Data[0]; }
// inline const value_type& front() const { IM_ASSERT(Size > 0); return Data[0]; }
// inline value_type& back() { IM_ASSERT(Size > 0); return Data[Size - 1]; }
// inline const value_type& back() const { IM_ASSERT(Size > 0); return Data[Size - 1]; }
// inline void swap(ImVector<T>& rhs) { int rhs_size = rhs.Size; rhs.Size = Size; Size = rhs_size; int rhs_cap = rhs.Capacity; rhs.Capacity = Capacity; Capacity = rhs_cap; value_type* rhs_data = rhs.Data; rhs.Data = Data; Data = rhs_data; }
// inline int _grow_capacity(int size) const { int new_capacity = Capacity ? (Capacity + Capacity/2) : 8; return new_capacity > size ? new_capacity : size; }
// inline void resize(int new_size) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); Size = new_size; }
// inline void resize(int new_size, const T& v){ if (new_size > Capacity) reserve(_grow_capacity(new_size)); if (new_size > Size) for (int n = Size; n < new_size; n++) Data[n] = v; Size = new_size; }
// inline void reserve(int new_capacity)
// {
// if (new_capacity <= Capacity)
// return;
// T* new_data = (value_type*)ImGui::MemAlloc((size_t)new_capacity * sizeof(T));
// if (Data)
// memcpy(new_data, Data, (size_t)Size * sizeof(T));
// ImGui::MemFree(Data);
// Data = new_data;
// Capacity = new_capacity;
// }
// inline void push_back(const value_type& v) { if (Size == Capacity) reserve(_grow_capacity(Size + 1)); Data[Size++] = v; }
// inline void pop_back() { IM_ASSERT(Size > 0); Size--; }
// inline void push_front(const value_type& v) { if (Size == 0) push_back(v); else insert(Data, v); }
// inline iterator erase(const_iterator it) { IM_ASSERT(it >= Data && it < Data+Size); const ptrdiff_t off = it - Data; memmove(Data + off, Data + off + 1, ((size_t)Size - (size_t)off - 1) * sizeof(value_type)); Size--; return Data + off; }
// inline iterator erase(const_iterator it, const_iterator it_last){ IM_ASSERT(it >= Data && it < Data+Size && it_last > it && it_last <= Data+Size); const ptrdiff_t count = it_last - it; const ptrdiff_t off = it - Data; memmove(Data + off, Data + off + count, ((size_t)Size - (size_t)off - count) * sizeof(value_type)); Size -= (int)count; return Data + off; }
// inline iterator erase_unsorted(const_iterator it) { IM_ASSERT(it >= Data && it < Data+Size); const ptrdiff_t off = it - Data; if (it < Data+Size-1) memcpy(Data + off, Data + Size - 1, sizeof(value_type)); Size--; return Data + off; }
// inline iterator insert(const_iterator it, const value_type& v) { IM_ASSERT(it >= Data && it <= Data+Size); const ptrdiff_t off = it - Data; if (Size == Capacity) reserve(_grow_capacity(Size + 1)); if (off < (int)Size) memmove(Data + off + 1, Data + off, ((size_t)Size - (size_t)off) * sizeof(value_type)); Data[off] = v; Size++; return Data + off; }
// inline bool contains(const value_type& v) const { const T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data++ == v) return true; return false; }
}
// Helper: Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]"
export class ImGuiTextFilter
{
// IMGUI_API ImGuiTextFilter(const char* default_filter = "");
constructor(default_filter: string = "") {
if (default_filter)
{
// ImStrncpy(InputBuf, default_filter, IM_ARRAYSIZE(InputBuf));
this.InputBuf.buffer = default_filter;
this.Build();
}
else
{
// InputBuf[0] = 0;
this.InputBuf.buffer = "";
this.CountGrep = 0;
}
}
// IMGUI_API bool Draw(const char* label = "Filter (inc,-exc)", float width = 0.0f); // Helper calling InputText+Build
public Draw(label: string = "Filter (inc,-exc)", width: number = 0.0): boolean {
if (width !== 0.0)
bind.PushItemWidth(width);
const value_changed: boolean = InputText(label, this.InputBuf, IM_ARRAYSIZE(this.InputBuf));
if (width !== 0.0)
bind.PopItemWidth();
if (value_changed)
this.Build();
return value_changed;
}
// IMGUI_API bool PassFilter(const char* text, const char* text_end = NULL) const;
public PassFilter(text: string, text_end: number | null = null): boolean {
// if (Filters.empty())
// return true;
// if (text == NULL)
// text = "";
// for (int i = 0; i != Filters.Size; i++)
// {
// const TextRange& f = Filters[i];
// if (f.empty())
// continue;
// if (f.front() == '-')
// {
// // Subtract
// if (ImStristr(text, text_end, f.begin()+1, f.end()) != NULL)
// return false;
// }
// else
// {
// // Grep
// if (ImStristr(text, text_end, f.begin(), f.end()) != NULL)
// return true;
// }
// }
// Implicit * grep
if (this.CountGrep === 0)
return true;
return false;
}
// IMGUI_API void Build();
public Build(): void {
// Filters.resize(0);
// TextRange input_range(InputBuf, InputBuf+strlen(InputBuf));
// input_range.split(',', Filters);
this.CountGrep = 0;
// for (int i = 0; i != Filters.Size; i++)
// {
// Filters[i].trim_blanks();
// if (Filters[i].empty())
// continue;
// if (Filters[i].front() != '-')
// CountGrep += 1;
// }
}
// void Clear() { InputBuf[0] = 0; Build(); }
public Clear(): void { this.InputBuf.buffer = ""; this.Build(); }
// bool IsActive() const { return !Filters.empty(); }
public IsActive(): boolean { return false; }
// [Internal]
// struct TextRange
// {
// const char* b;
// const char* e;
// TextRange() { b = e = NULL; }
// TextRange(const char* _b, const char* _e) { b = _b; e = _e; }
// const char* begin() const { return b; }
// const char* end() const { return e; }
// bool empty() const { return b == e; }
// char front() const { return *b; }
// static bool is_blank(char c) { return c == ' ' || c == '\t'; }
// void trim_blanks() { while (b < e && is_blank(*b)) b++; while (e > b && is_blank(*(e-1))) e--; }
// IMGUI_API void split(char separator, ImVector<TextRange>& out);
// };
// char InputBuf[256];
public InputBuf: ImStringBuffer = new ImStringBuffer(256);
// ImVector<TextRange> Filters;
// int CountGrep;
public CountGrep: number = 0;
}
// Helper: Text buffer for logging/accumulating text
export class ImGuiTextBuffer
{
// ImVector<char> Buf;
public Buf: string = "";
public begin(): string { return this.Buf; }
public size(): number { return this.Buf.length; }
public clear(): void { this.Buf = ""; }
public append(text: string): void { this.Buf += text; }
// ImGuiTextBuffer() { Buf.push_back(0); }
// inline char operator[](int i) { return Buf.Data[i]; }
// const char* begin() const { return &Buf.front(); }
// const char* end() const { return &Buf.back(); } // Buf is zero-terminated, so end() will point on the zero-terminator
// int size() const { return Buf.Size - 1; }
// bool empty() { return Buf.Size <= 1; }
// void clear() { Buf.clear(); Buf.push_back(0); }
// void reserve(int capacity) { Buf.reserve(capacity); }
// const char* c_str() const { return Buf.Data; }
// IMGUI_API void appendf(const char* fmt, ...) IM_FMTARGS(2);
// IMGUI_API void appendfv(const char* fmt, va_list args) IM_FMTLIST(2);
}
// Helper: Simple Key->value storage
// Typically you don't have to worry about this since a storage is held within each Window.
// We use it to e.g. store collapse state for a tree (Int 0/1), store color edit options.
// This is optimized for efficient reading (dichotomy into a contiguous buffer), rare writing (typically tied to user interactions)
// You can use it as custom user storage for temporary values. Declare your own storage if, for example:
// - You want to manipulate the open/close state of a particular sub-tree in your interface (tree node uses Int 0/1 to store their state).
// - You want to store custom debug data easily without adding or editing structures in your code (probably not efficient, but convenient)
// Types are NOT stored, so it is up to you to make sure your Key don't collide with different types.
export class ImGuiStorage
{
// struct Pair
// {
// ImGuiID key;
// union { int val_i; float val_f; void* val_p; };
// Pair(ImGuiID _key, int _val_i) { key = _key; val_i = _val_i; }
// Pair(ImGuiID _key, float _val_f) { key = _key; val_f = _val_f; }
// Pair(ImGuiID _key, void* _val_p) { key = _key; val_p = _val_p; }
// };
// ImVector<Pair> Data;
// - Get***() functions find pair, never add/allocate. Pairs are sorted so a query is O(log N)
// - Set***() functions find pair, insertion on demand if missing.
// - Sorted insertion is costly, paid once. A typical frame shouldn't need to insert any new pair.
// void Clear() { Data.clear(); }
// IMGUI_API int GetInt(ImGuiID key, int default_val = 0) const;
// IMGUI_API void SetInt(ImGuiID key, int val);
// IMGUI_API bool GetBool(ImGuiID key, bool default_val = false) const;
// IMGUI_API void SetBool(ImGuiID key, bool val);
// IMGUI_API float GetFloat(ImGuiID key, float default_val = 0.0f) const;
// IMGUI_API void SetFloat(ImGuiID key, float val);
// IMGUI_API void* GetVoidPtr(ImGuiID key) const; // default_val is NULL
// IMGUI_API void SetVoidPtr(ImGuiID key, void* val);
// - Get***Ref() functions finds pair, insert on demand if missing, return pointer. Useful if you intend to do Get+Set.
// - References are only valid until a new value is added to the storage. Calling a Set***() function or a Get***Ref() function invalidates the pointer.
// - A typical use case where this is convenient for quick hacking (e.g. add storage during a live Edit&Continue session if you can't modify existing struct)
// float* pvar = ImGui::GetFloatRef(key); ImGui::SliderFloat("var", pvar, 0, 100.0f); some_var += *pvar;
// IMGUI_API int* GetIntRef(ImGuiID key, int default_val = 0);
// IMGUI_API bool* GetBoolRef(ImGuiID key, bool default_val = false);
// IMGUI_API float* GetFloatRef(ImGuiID key, float default_val = 0.0f);
// IMGUI_API void** GetVoidPtrRef(ImGuiID key, void* default_val = NULL);
// Use on your own storage if you know only integer are being stored (open/close all tree nodes)
// IMGUI_API void SetAllInt(int val);
// For quicker full rebuild of a storage (instead of an incremental one), you may add all your contents and then sort once.
// IMGUI_API void BuildSortByKey();
}
// Data payload for Drag and Drop operations
export class ImGuiPayload<T>
{
// Members
// void* Data; // Data (copied and owned by dear imgui)
Data!: T;
// int DataSize; // Data size
// [Internal]
// ImGuiID SourceId; // Source item id
// ImGuiID SourceParentId; // Source parent id (if available)
// int DataFrameCount; // Data timestamp
// char DataType[12 + 1]; // Data type tag (short user-supplied string, 12 characters max)
// bool Preview; // Set when AcceptDragDropPayload() was called and mouse has been hovering the target item (nb: handle overlapping drag targets)
// bool Delivery; // Set when AcceptDragDropPayload() was called and mouse button is released over the target item.
// ImGuiPayload() { Clear(); }
// void Clear() { SourceId = SourceParentId = 0; Data = NULL; DataSize = 0; memset(DataType, 0, sizeof(DataType)); DataFrameCount = -1; Preview = Delivery = false; }
// bool IsDataType(const char* type) const { return DataFrameCount != -1 && strcmp(type, DataType) == 0; }
// bool IsPreview() const { return Preview; }
// bool IsDelivery() const { return Delivery; }
}
// Helpers macros to generate 32-bits encoded colors
export const IM_COL32_R_SHIFT: number = config.IMGUI_USE_BGRA_PACKED_COLOR ? 16 : 0;
export const IM_COL32_G_SHIFT: number = 8;
export const IM_COL32_B_SHIFT: number = config.IMGUI_USE_BGRA_PACKED_COLOR ? 0 : 16;
export const IM_COL32_A_SHIFT: number = 24;
export const IM_COL32_A_MASK: number = 0xFF000000;
export function IM_COL32(R: number, G: number, B: number, A: number = 255): number {
return ((A << IM_COL32_A_SHIFT) | (B << IM_COL32_B_SHIFT) | (G << IM_COL32_G_SHIFT) | (R << IM_COL32_R_SHIFT)) >>> 0;
}
export const IM_COL32_WHITE: number = IM_COL32(255, 255, 255, 255); // Opaque white = 0xFFFFFFFF
export const IM_COL32_BLACK: number = IM_COL32(0, 0, 0, 255); // Opaque black
export const IM_COL32_BLACK_TRANS: number = IM_COL32(0, 0, 0, 0); // Transparent black = 0x00000000
// ImColor() helper to implicity converts colors to either ImU32 (packed 4x1 byte) or ImVec4 (4x1 float)
// Prefer using IM_COL32() macros if you want a guaranteed compile-time ImU32 for usage with ImDrawList API.
// **Avoid storing ImColor! Store either u32 of ImVec4. This is not a full-featured color class. MAY OBSOLETE.
// **None of the ImGui API are using ImColor directly but you can use it as a convenience to pass colors in either ImU32 or ImVec4 formats. Explicitly cast to ImU32 or ImVec4 if needed.
export class ImColor
{
// ImVec4 Value;
public Value: ImVec4 = new ImVec4();
// ImColor() { Value.x = Value.y = Value.z = Value.w = 0.0f; }
// ImColor(int r, int g, int b, int a = 255) { float sc = 1.0f/255.0f; Value.x = (float)r * sc; Value.y = (float)g * sc; Value.z = (float)b * sc; Value.w = (float)a * sc; }
// ImColor(ImU32 rgba) { float sc = 1.0f/255.0f; Value.x = (float)((rgba>>IM_COL32_R_SHIFT)&0xFF) * sc; Value.y = (float)((rgba>>IM_COL32_G_SHIFT)&0xFF) * sc; Value.z = (float)((rgba>>IM_COL32_B_SHIFT)&0xFF) * sc; Value.w = (float)((rgba>>IM_COL32_A_SHIFT)&0xFF) * sc; }
// ImColor(float r, float g, float b, float a = 1.0f) { Value.x = r; Value.y = g; Value.z = b; Value.w = a; }
// ImColor(const ImVec4& col) { Value = col; }
constructor();
constructor(r: number, g: number, b: number);
constructor(r: number, g: number, b: number, a: number);
constructor(rgba: Bind.ImU32);
constructor(col: Readonly<Bind.interface_ImVec4>);
constructor(r: number | Bind.ImU32 | Readonly<Bind.interface_ImVec4> = 0.0, g: number = 0.0, b: number = 0.0, a: number = 1.0) {
if (typeof(r) === "number") {
if (r > 255 && g === 0.0 && b === 0.0 && a === 1.0) {
this.Value.x = Math.max(0.0, Math.min(1.0, ((r >> IM_COL32_R_SHIFT) & 0xFF) / 255));
this.Value.y = Math.max(0.0, Math.min(1.0, ((r >> IM_COL32_G_SHIFT) & 0xFF) / 255));
this.Value.z = Math.max(0.0, Math.min(1.0, ((r >> IM_COL32_B_SHIFT) & 0xFF) / 255));
this.Value.w = Math.max(0.0, Math.min(1.0, ((r >> IM_COL32_A_SHIFT) & 0xFF) / 255));
} else if (r <= 1.0 && g <= 1.0 && b <= 1.0 && a <= 1.0) {
this.Value.x = Math.max(0.0, r);
this.Value.y = Math.max(0.0, g);
this.Value.z = Math.max(0.0, b);
this.Value.w = Math.max(0.0, a);
} else {
this.Value.x = Math.max(0.0, Math.min(1.0, r / 255));
this.Value.y = Math.max(0.0, Math.min(1.0, g / 255));
this.Value.z = Math.max(0.0, Math.min(1.0, b / 255));
if (a <= 1.0) {
this.Value.w = Math.max(0.0, a);
} else {
this.Value.w = Math.max(0.0, Math.min(1.0, a / 255));
}
}
} else {
this.Value.Copy(r);
}
}
// inline operator ImU32() const { return ImGui::ColorConvertFloat4ToU32(Value); }
public toImU32(): Bind.ImU32 { return ColorConvertFloat4ToU32(this.Value); }
// inline operator ImVec4() const { return Value; }
public toImVec4(): ImVec4 { return this.Value; }
// FIXME-OBSOLETE: May need to obsolete/cleanup those helpers.
// inline void SetHSV(float h, float s, float v, float a = 1.0f){ ImGui::ColorConvertHSVtoRGB(h, s, v, Value.x, Value.y, Value.z); Value.w = a; }
public SetHSV(h: number, s: number, v: number, a: number = 1.0): void {
const ref_r: Bind.ImScalar<number> = [ this.Value.x ];
const ref_g: Bind.ImScalar<number> = [ this.Value.y ];
const ref_b: Bind.ImScalar<number> = [ this.Value.z ];
ColorConvertHSVtoRGB(h, s, v, ref_r, ref_g, ref_b);
this.Value.x = ref_r[0];
this.Value.y = ref_g[0];
this.Value.z = ref_b[0];
this.Value.w = a;
}
// static ImColor HSV(float h, float s, float v, float a = 1.0f) { float r,g,b; ImGui::ColorConvertHSVtoRGB(h, s, v, r, g, b); return ImColor(r,g,b,a); }
public static HSV(h: number, s: number, v: number, a: number = 1.0): ImColor {
const color = new ImColor();
color.SetHSV(h, s, v, a);
return color;
}
}
export const ImGuiInputTextDefaultSize: number = 128;
export type ImGuiInputTextCallback = (data: ImGuiInputTextCallbackData) => number;
// Shared state of InputText(), passed to callback when a ImGuiInputTextFlags_Callback* flag is used and the corresponding callback is triggered.
export class ImGuiInputTextCallbackData {
constructor(public readonly native: Bind.reference_ImGuiInputTextCallbackData, public readonly UserData: any) {}
// ImGuiInputTextFlags EventFlag; // One of ImGuiInputTextFlags_Callback* // Read-only
public get EventFlag(): ImGuiInputTextFlags { return this.native.EventFlag; }
// ImGuiInputTextFlags Flags; // What user passed to InputText() // Read-only
public get Flags(): ImGuiInputTextFlags { return this.native.Flags; }
// void* UserData; // What user passed to InputText() // Read-only
// public get UserData(): any { return this.native.UserData; }
// CharFilter event:
// ImWchar EventChar; // Character input // Read-write (replace character or set to zero)
public get EventChar(): Bind.ImWchar { return this.native.EventChar; }
public set EventChar(value: Bind.ImWchar) { this.native.EventChar = value; }
// Completion,History,Always events:
// If you modify the buffer contents make sure you update 'BufTextLen' and set 'BufDirty' to true.
// ImGuiKey EventKey; // Key pressed (Up/Down/TAB) // Read-only
public get EventKey(): ImGuiKey { return this.native.EventKey; }
// char* Buf; // Current text buffer // Read-write (pointed data only, can't replace the actual pointer)
public get Buf(): string { return this.native.Buf; }
public set Buf(value: string) { this.native.Buf = value; }
// int BufTextLen; // Current text length in bytes // Read-write
public get BufTextLen(): number { return this.native.BufTextLen; }
public set BufTextLen(value: number) { this.native.BufTextLen = value; }
// int BufSize; // Maximum text length in bytes // Read-only
public get BufSize(): number { return this.native.BufSize; }
// bool BufDirty; // Set if you modify Buf/BufTextLen!! // Write