forked from dpethes/imgui-pas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfpimgui.pas
2331 lines (2127 loc) · 145 KB
/
fpimgui.pas
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
{
Bindings for dear imgui (AKA ImGui) - a bloat-free graphical user interface library for C++
Based on ImGui 1.53 + cimgui wrapper
Not all functions were tested.
}
unit fpimgui;
{$IFDEF FPC}
{$mode objfpc}{$H+}
{$modeswitch advancedrecords}
{$ENDIF}
interface
uses
{$IFDEF FPC}
{$PACKRECORDS C}
dynlibs, //for SharedSuffix
sysutils; //for Format()
{$ENDIF}
System.Types,
System.SysUtils;
const
{$IFDEF FPC}
ImguiLibName = 'cimgui.' + SharedSuffix;
{$ELSE}
ImguiLibName = 'cimgui.dll';
{$ENDIF}
type
bool = boolean;
Pbool = ^bool;
Pbyte = ^byte;
Pdword = ^dword;
TFloat2 = array[0..1] of single;
TFloat3 = array[0..2] of single;
TFloat4 = array[0..3] of single;
TLongInt2 = array[0..1] of longint;
TLongInt3 = array[0..2] of longint;
TLongInt4 = array[0..3] of longint;
PImGuiContext = Pointer;
ImVec2 = record
x, y: single;
end;
PImVec2 = ^ImVec2;
ImVec4 = record
x, y, z, w: single;
end;
PImVec4 = ^ImVec4;
const
FLT_MAX: single = 3.402823466e+38; //must match c/c++ def
ImVec2Zero: ImVec2 = (x: 0; y: 0);
type
ImU32 = dword;
ImWchar = word;
PImWchar = PWord;
ImTextureID = pointer;
ImGuiID = ImU32;
ImGuiCol = longint;
ImGuiStyleVar = longint;
ImGuiColorEditFlags = longint;
ImGuiKey = longint;
{$IFNDEF FPC}
size_t = LongWord;
PPByte = ^PByte;
{$ENDIF}
{ Enums }
ImGuiWindowFlags = longint;
ImGuiWindowFlagsEnum = (
ImGuiWindowFlags_Default = 0, // Default: 0
ImGuiWindowFlags_NoTitleBar = 1 shl 0, // Disable title-bar
ImGuiWindowFlags_NoResize = 1 shl 1, // Disable user resizing with the lower-right grip
ImGuiWindowFlags_NoMove = 1 shl 2, // Disable user moving the window
ImGuiWindowFlags_NoScrollbar = 1 shl 3, // Disable scrollbars (window can still scroll with mouse or programatically)
ImGuiWindowFlags_NoScrollWithMouse = 1 shl 4, // Disable user vertically scrolling with mouse wheel
ImGuiWindowFlags_NoCollapse = 1 shl 5, // Disable user collapsing window by double-clicking on it
ImGuiWindowFlags_AlwaysAutoResize = 1 shl 6, // Resize every window to its content every frame
//ImGuiWindowFlags_ShowBorders = 1 shl 7, // OBSOLETE
ImGuiWindowFlags_NoSavedSettings = 1 shl 8, // Never load/save settings in .ini file
ImGuiWindowFlags_NoInputs = 1 shl 9, // Disable catching mouse or keyboard inputs
ImGuiWindowFlags_MenuBar = 1 shl 10, // Has a menu-bar
ImGuiWindowFlags_HorizontalScrollbar = 1 shl 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.
ImGuiWindowFlags_NoFocusOnAppearing = 1 shl 12, // Disable taking focus when transitioning from hidden to visible state
ImGuiWindowFlags_NoBringToFrontOnFocus = 1 shl 13, // Disable bringing window to front when taking focus (e.g. clicking on it or programatically giving it focus)
ImGuiWindowFlags_AlwaysVerticalScrollbar= 1 shl 14, // Always show vertical scrollbar (even if ContentSize.y < Size.y)
ImGuiWindowFlags_AlwaysHorizontalScrollbar=1shl 15, // Always show horizontal scrollbar (even if ContentSize.x < Size.x)
ImGuiWindowFlags_AlwaysUseWindowPadding = 1 shl 16, // Ensure child windows without border uses style.WindowPadding (ignored by default for non-bordered child windows, because more convenient)
ImGuiWindowFlags_ResizeFromAnySide = 1 shl 17 // (WIP) Enable resize from any corners and borders. Your back-end needs to honor the different values of io.MouseCursor set by imgui.
);
// Flags for ImGui::InputText()
ImGuiInputTextFlags = longint;
ImGuiInputTextFlagsEnum = (
ImGuiInputTextFlags_CharsDecimal = 1 shl 0,
ImGuiInputTextFlags_CharsHexadecimal = 1 shl 1,
ImGuiInputTextFlags_CharsUppercase = 1 shl 2,
ImGuiInputTextFlags_CharsNoBlank = 1 shl 3,
ImGuiInputTextFlags_AutoSelectAll = 1 shl 4,
ImGuiInputTextFlags_EnterReturnsTrue = 1 shl 5,
ImGuiInputTextFlags_CallbackCompletion = 1 shl 6,
ImGuiInputTextFlags_CallbackHistory = 1 shl 7,
ImGuiInputTextFlags_CallbackAlways = 1 shl 8,
ImGuiInputTextFlags_CallbackCharFilter = 1 shl 9,
ImGuiInputTextFlags_AllowTabInput = 1 shl 10,
ImGuiInputTextFlags_CtrlEnterForNewLine = 1 shl 11,
ImGuiInputTextFlags_NoHorizontalScroll = 1 shl 12,
ImGuiInputTextFlags_AlwaysInsertMode = 1 shl 13,
ImGuiInputTextFlags_ReadOnly = 1 shl 14,
ImGuiInputTextFlags_Password = 1 shl 15,
ImGuiInputTextFlags_NoUndoRedo = 1 shl 16
);
// Flags for ImGui::TreeNodeEx(), ImGui::CollapsingHeader*()
ImGuiTreeNodeFlags = longint;
ImGuiTreeNodeFlagsEnum = (
ImGuiTreeNodeFlags_Selected = 1 shl 0,
ImGuiTreeNodeFlags_Framed = 1 shl 1,
ImGuiTreeNodeFlags_AllowItemOverlap = 1 shl 2,
ImGuiTreeNodeFlags_NoTreePushOnOpen = 1 shl 3,
ImGuiTreeNodeFlags_NoAutoOpenOnLog = 1 shl 4,
ImGuiTreeNodeFlags_CollapsingHeader = (1 shl 1) or (1 shl 4), //Framed or NoAutoOpenOnLog
ImGuiTreeNodeFlags_DefaultOpen = 1 shl 5,
ImGuiTreeNodeFlags_OpenOnDoubleClick = 1 shl 6,
ImGuiTreeNodeFlags_OpenOnArrow = 1 shl 7,
ImGuiTreeNodeFlags_Leaf = 1 shl 8,
ImGuiTreeNodeFlags_Bullet = 1 shl 9,
ImGuiTreeNodeFlags_FramePadding = 1 shl 10
);
ImGuiSelectableFlags = longint;
ImGuiSelectableFlagsEnum = (
ImGuiSelectableFlags_DontClosePopups = 1 shl 0,
ImGuiSelectableFlags_SpanAllColumns = 1 shl 1,
ImGuiSelectableFlags_AllowDoubleClick = 1 shl 2
);
ImGuiComboFlags = longint;
ImGuiComboFlagsEnum = (
ImGuiComboFlags_PopupAlignLeft = 1 shl 0,
ImGuiComboFlags_HeightSmall = 1 shl 1,
ImGuiComboFlags_HeightRegular = 1 shl 2,
ImGuiComboFlags_HeightLarge = 1 shl 3,
ImGuiComboFlags_HeightLargest = 1 shl 4,
ImGuiComboFlags_HeightMask_ = //ImGuiComboFlags_HeightSmall | ImGuiComboFlags_HeightRegular | ImGuiComboFlags_HeightLarge | ImGuiComboFlags_HeightLargest
(%11110)
);
ImGuiFocusedFlags = longint;
ImGuiFocusedFlagsEnum = (
ImGuiFocusedFlags_ChildWindows = 1 shl 0,
ImGuiFocusedFlags_RootWindow = 1 shl 1,
ImGuiFocusedFlags_RootAndChildWindows = //ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows
(%11)
);
ImGuiHoveredFlags = longint;
ImGuiHoveredFlagsEnum = (
ImGuiHoveredFlags_Default = 0,
ImGuiHoveredFlags_ChildWindows = 1 shl 0,
ImGuiHoveredFlags_RootWindow = 1 shl 1,
ImGuiHoveredFlags_AllowWhenBlockedByPopup = 1 shl 2,
ImGuiHoveredFlags_AllowWhenBlockedByActiveItem = 1 shl 4,
ImGuiHoveredFlags_AllowWhenOverlapped = 1 shl 5,
ImGuiHoveredFlags_RectOnly = //ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem | ImGuiHoveredFlags_AllowWhenOverlapped,
(1 shl 2) or (1 shl 4) or (1 shl 5),
ImGuiHoveredFlags_RootAndChildWindows = //ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows
(%11)
);
ImGuiDragDropFlags = longint;
ImGuiDragDropFlagsEnum = (
ImGuiDragDropFlags_SourceNoPreviewTooltip = 1 shl 0,
ImGuiDragDropFlags_SourceNoDisableHover = 1 shl 1,
ImGuiDragDropFlags_SourceNoHoldToOpenOthers = 1 shl 2,
ImGuiDragDropFlags_SourceAllowNullID = 1 shl 3,
ImGuiDragDropFlags_SourceExtern = 1 shl 4,
ImGuiDragDropFlags_AcceptBeforeDelivery = 1 shl 10,
ImGuiDragDropFlags_AcceptNoDrawDefaultRect = 1 shl 11,
ImGuiDragDropFlags_AcceptPeekOnly = //ImGuiDragDropFlags_AcceptBeforeDelivery | ImGuiDragDropFlags_AcceptNoDrawDefaultRect
(1 shl 10) or (1 shl 11)
);
ImGuiKey_ = (
ImGuiKey_Tab, // for tabbing through fields
ImGuiKey_LeftArrow, // for text edit
ImGuiKey_RightArrow,// for text edit
ImGuiKey_UpArrow, // for text edit
ImGuiKey_DownArrow, // for text edit
ImGuiKey_PageUp,
ImGuiKey_PageDown,
ImGuiKey_Home, // for text edit
ImGuiKey_End, // for text edit
ImGuiKey_Delete, // for text edit
ImGuiKey_Backspace, // for text edit
ImGuiKey_Enter, // for text edit
ImGuiKey_Escape, // for text edit
ImGuiKey_A, // for text edit CTRL+A: select all
ImGuiKey_C, // for text edit CTRL+C: copy
ImGuiKey_V, // for text edit CTRL+V: paste
ImGuiKey_X, // for text edit CTRL+X: cut
ImGuiKey_Y, // for text edit CTRL+Y: redo
ImGuiKey_Z // for text edit CTRL+Z: undo
//ImGuiKey_COUNT // this is unnecessary, if we declare KeyMap as array[ImGuiKey_]
);
ImGuiCol_ = (
ImGuiCol_Text,
ImGuiCol_TextDisabled,
ImGuiCol_WindowBg,
ImGuiCol_ChildBg,
ImGuiCol_PopupBg,
ImGuiCol_Border,
ImGuiCol_BorderShadow,
ImGuiCol_FrameBg,
ImGuiCol_FrameBgHovered,
ImGuiCol_FrameBgActive,
ImGuiCol_TitleBg,
ImGuiCol_TitleBgActive,
ImGuiCol_TitleBgCollapsed,
ImGuiCol_MenuBarBg,
ImGuiCol_ScrollbarBg,
ImGuiCol_ScrollbarGrab,
ImGuiCol_ScrollbarGrabHovered,
ImGuiCol_ScrollbarGrabActive,
ImGuiCol_CheckMark,
ImGuiCol_SliderGrab,
ImGuiCol_SliderGrabActive,
ImGuiCol_Button,
ImGuiCol_ButtonHovered,
ImGuiCol_ButtonActive,
ImGuiCol_Header,
ImGuiCol_HeaderHovered,
ImGuiCol_HeaderActive,
ImGuiCol_Separator,
ImGuiCol_SeparatorHovered,
ImGuiCol_SeparatorActive,
ImGuiCol_ResizeGrip,
ImGuiCol_ResizeGripHovered,
ImGuiCol_ResizeGripActive,
ImGuiCol_CloseButton,
ImGuiCol_CloseButtonHovered,
ImGuiCol_CloseButtonActive,
ImGuiCol_PlotLines,
ImGuiCol_PlotLinesHovered,
ImGuiCol_PlotHistogram,
ImGuiCol_PlotHistogramHovered,
ImGuiCol_TextSelectedBg,
ImGuiCol_ModalWindowDarkening
//ImGuiCol_COUNT - unnecessary
);
// Enumeration for PushStyleVar() / PopStyleVar()
// NB: the enum only refers to fields of ImGuiStyle() which makes sense to be pushed/poped in UI code. Feel free to add others.
ImGuiStyleVar_ = (
ImGuiStyleVar_Alpha, // float Alpha
ImGuiStyleVar_WindowPadding, // ImVec2 WindowPadding
ImGuiStyleVar_WindowRounding, // float WindowRounding
ImGuiStyleVar_WindowBorderSize, // float WindowBorderSize
ImGuiStyleVar_WindowMinSize, // ImVec2 WindowMinSize
ImGuiStyleVar_ChildRounding, // float ChildRounding
ImGuiStyleVar_ChildBorderSize, // float ChildBorderSize
ImGuiStyleVar_PopupRounding, // float PopupRounding
ImGuiStyleVar_PopupBorderSize, // float PopupBorderSize
ImGuiStyleVar_FramePadding, // ImVec2 FramePadding
ImGuiStyleVar_FrameRounding, // float FrameRounding
ImGuiStyleVar_FrameBorderSize, // float FrameBorderSize
ImGuiStyleVar_ItemSpacing, // ImVec2 ItemSpacing
ImGuiStyleVar_ItemInnerSpacing, // ImVec2 ItemInnerSpacing
ImGuiStyleVar_IndentSpacing, // float IndentSpacing
ImGuiStyleVar_GrabMinSize, // float GrabMinSize
ImGuiStyleVar_ButtonTextAlign // ImVec2 ButtonTextAlign
//ImGuiStyleVar_Count_ - unnecessary
);
ImGuiColorEditFlags_ = (
ImGuiColorEditFlags_NoAlpha = 1 shl 1,
ImGuiColorEditFlags_NoPicker = 1 shl 2,
ImGuiColorEditFlags_NoOptions = 1 shl 3,
ImGuiColorEditFlags_NoSmallPreview = 1 shl 4,
ImGuiColorEditFlags_NoInputs = 1 shl 5,
ImGuiColorEditFlags_NoTooltip = 1 shl 6,
ImGuiColorEditFlags_NoLabel = 1 shl 7,
ImGuiColorEditFlags_NoSidePreview = 1 shl 8,
// 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.
ImGuiColorEditFlags_AlphaBar = 1 shl 9,
ImGuiColorEditFlags_AlphaPreview = 1 shl 10,
ImGuiColorEditFlags_AlphaPreviewHalf= 1 shl 11,
ImGuiColorEditFlags_HDR = 1 shl 12,
ImGuiColorEditFlags_RGB = 1 shl 13,
ImGuiColorEditFlags_HSV = 1 shl 14,
ImGuiColorEditFlags_HEX = 1 shl 15,
ImGuiColorEditFlags_Uint8 = 1 shl 16,
ImGuiColorEditFlags_Float = 1 shl 17,
ImGuiColorEditFlags_PickerHueBar = 1 shl 18,
ImGuiColorEditFlags_PickerHueWheel = 1 shl 19
// Internals/Masks
{
ImGuiColorEditFlags__InputsMask = ImGuiColorEditFlags_RGB|ImGuiColorEditFlags_HSV|ImGuiColorEditFlags_HEX,
ImGuiColorEditFlags__DataTypeMask = ImGuiColorEditFlags_Uint8|ImGuiColorEditFlags_Float,
ImGuiColorEditFlags__PickerMask = ImGuiColorEditFlags_PickerHueWheel|ImGuiColorEditFlags_PickerHueBar,
ImGuiColorEditFlags__OptionsDefault = ImGuiColorEditFlags_Uint8|ImGuiColorEditFlags_RGB|ImGuiColorEditFlags_PickerHueBar // Change application default using SetColorEditOptions()
}
);
// Enumeration for GetMouseCursor()
ImGuiMouseCursor = longint;
ImGuiMouseCursorEnum = (
ImGuiMouseCursor_None = -1,
ImGuiMouseCursor_Arrow = 0,
ImGuiMouseCursor_TextInput,
ImGuiMouseCursor_Move,
ImGuiMouseCursor_ResizeNS,
ImGuiMouseCursor_ResizeEW,
ImGuiMouseCursor_ResizeNESW,
ImGuiMouseCursor_ResizeNWSE
//ImGuiMouseCursor_Count_ - unnecessary
);
// Condition flags for ImGui::SetWindow***(), SetNextWindow***(), SetNextTreeNode***() functions
// All those functions treat 0 as a shortcut to ImGuiCond_Always
ImGuiCond = longint;
ImGuiCondEnum = (
ImGuiCond_Always = 1 shl 0, // Set the variable
ImGuiCond_Once = 1 shl 1, // Set the variable once per runtime session (only the first call with succeed)
ImGuiCond_FirstUseEver = 1 shl 2, // Set the variable if the window has no saved data (if doesn't exist in the .ini file)
ImGuiCond_Appearing = 1 shl 3 // Set the variable if the window is appearing after being hidden/inactive (or the first time)
);
ImDrawCornerFlags = longint;
ImDrawCornerFlagsEnum = (
ImDrawCornerFlags_TopLeft = 1 shl 0,
ImDrawCornerFlags_TopRight = 1 shl 1,
ImDrawCornerFlags_BotLeft = 1 shl 2,
ImDrawCornerFlags_BotRight = 1 shl 3,
{ImDrawCornerFlags_Top = ImDrawCornerFlags_TopLeft | ImDrawCornerFlags_TopRight,
ImDrawCornerFlags_Bot = ImDrawCornerFlags_BotLeft | ImDrawCornerFlags_BotRight,
ImDrawCornerFlags_Left = ImDrawCornerFlags_TopLeft | ImDrawCornerFlags_BotLeft,
ImDrawCornerFlags_Right = ImDrawCornerFlags_TopRight | ImDrawCornerFlags_BotRight,}
ImDrawCornerFlags_All = $F
);
ImDrawListFlags = longint;
ImDrawListFlagsEnum = (
ImDrawListFlags_AntiAliasedLines = 1 shl 0,
ImDrawListFlags_AntiAliasedFill = 1 shl 1
);
{ Structs }
ImGuiStyle = record
Alpha : single;
WindowPadding : ImVec2;
WindowRounding : single;
WindowBorderSize : single;
WindowMinSize : ImVec2;
WindowTitleAlign : ImVec2;
ChildRounding : single;
ChildBorderSize : single;
PopupRounding : single;
PopupBorderSize : single;
FramePadding : ImVec2;
FrameRounding : single;
FrameBorderSize : single;
ItemSpacing : ImVec2;
ItemInnerSpacing : ImVec2;
TouchExtraPadding : ImVec2;
IndentSpacing : single;
ColumnsMinSpacing : single;
ScrollbarSize : single;
ScrollbarRounding : single;
GrabMinSize : single;
GrabRounding : single;
ButtonTextAlign : ImVec2;
DisplayWindowPadding : ImVec2;
DisplaySafeAreaPadding : ImVec2;
AntiAliasedLines : bool;
AntiAliasedFill : bool;
CurveTessellationTol : single;
Colors: array[ImGuiCol_] of ImVec4;
end;
PImGuiStyle = ^ImGuiStyle;
//forward decls for ImGuiIO
PImDrawData = ^ImDrawData;
PImFont = ^ImFont;
PImFontAtlas = ^ImFontAtlas;
PImFontConfig = ^ImFontConfig;
PImGuiSizeConstraintCallbackData = ^ImGuiSizeConstraintCallbackData;
PImGuiStorage = ^ImGuiStorage;
PImGuiTextEditCallbackData = ^ImGuiTextEditCallbackData;
ImGuiIO = record
DisplaySize : ImVec2;
DeltaTime : single;
IniSavingRate : single;
IniFilename : Pchar;
LogFilename : Pchar;
MouseDoubleClickTime : single;
MouseDoubleClickMaxDist : single;
MouseDragThreshold : single;
KeyMap : array[ImGuiKey_] of longint;
KeyRepeatDelay : single;
KeyRepeatRate : single;
UserData : pointer;
Fonts : PImFontAtlas;
FontGlobalScale : single;
FontAllowUserScaling : bool;
FontDefault : PImFont;
DisplayFramebufferScale : ImVec2;
DisplayVisibleMin : ImVec2;
DisplayVisibleMax : ImVec2;
// Advanced/subtle behaviors
OptMacOSXBehaviors : bool;
OptCursorBlink : bool;
// User Functions
RenderDrawListsFn : procedure (data:PImDrawData);cdecl;
GetClipboardTextFn : function (user_data:pointer):Pchar;cdecl;
SetClipboardTextFn : procedure (user_data:pointer; text:Pchar);cdecl;
ClipboardUserData : pointer;
MemAllocFn : function (sz:size_t):pointer;cdecl;
MemFreeFn : procedure (ptr:pointer);cdecl;
ImeSetInputScreenPosFn : procedure (x:longint; y:longint);cdecl;
ImeWindowHandle : pointer;
// Input - Fill before calling NewFrame()
MousePos : ImVec2;
MouseDown : array[0..4] of bool;
MouseWheel : single;
MouseDrawCursor : bool;
KeyCtrl : bool;
KeyShift : bool;
KeyAlt : bool;
KeySuper : bool;
KeysDown : array[0..511] of bool;
InputCharacters : array[0..16] of ImWchar;
// Output - Retrieve after calling NewFrame()
WantCaptureMouse : bool;
WantCaptureKeyboard : bool;
WantTextInput : bool;
Framerate : single;
MetricsAllocs : longint;
MetricsRenderVertices : longint;
MetricsRenderIndices : longint;
MetricsActiveWindows : longint;
MouseDelta : ImVec2;
// [Private] ImGui will maintain those fields. Forward compatibility not guaranteed!
// this part is not included, so be careful when doing sizeof(ImGuiIO) for example
end;
PImGuiIO = ^ImGuiIO;
ImDrawVert = record
pos, uv: ImVec2;
col: ImU32;
end;
PImDrawVert = ^ImDrawVert;
PImDrawIdx = ^ImDrawIdx;
ImDrawIdx = word;
PImDrawList = ^ImDrawList;
PImDrawCmd = ^ImDrawCmd;
ImDrawCallback = procedure(parent_list: PImDrawList; cmd: PImDrawCmd); cdecl;
ImDrawCmd = record
ElemCount: longword;
ClipRect: ImVec4;
TextureId: ImTextureID;
UserCallback: ImDrawCallback;
UserCallbackData: Pointer;
end;
PPImDrawList = ^PImDrawList;
//imgui uses generic T* pointer as Data, so we need to specialize with pointer types
{$IFDEF FPC}generic {$ENDIF}ImVector<_T> = record
Size: integer;
Capacity: integer;
Data: _T;
end;
ImVectorDrawCmd = {$IFDEF FPC}specialize {$ENDIF}ImVector<PImDrawCmd>;
ImVectorDrawIdx = {$IFDEF FPC}specialize {$ENDIF}ImVector<PImDrawIdx>;
ImVectorDrawVert = {$IFDEF FPC}specialize {$ENDIF}ImVector<PImDrawVert>;
//definitions for private members aren't translated, so always pass around pointers to this struct and don't copy it
ImDrawList = record
CmdBuffer: ImVectorDrawCmd;
IdxBuffer: ImVectorDrawIdx;
VtxBuffer: ImVectorDrawVert;
end;
_PImDrawList = array of PImDrawList;
ImDrawData = record
Valid: boolean;
CmdLists: _PImDrawList;
CmdListsCount,
TotalVtxCount,
TotalIdxCount: integer;
end;
ImFontAtlas = record
TexID: ImTextureID;
TexDesiredWidth: Integer;
TexGlyphPadding: Integer;
end;
ImGuiTextEditCallbackData = record
//not translated
end;
ImGuiSizeConstraintCallbackData = record
//not translated
end;
ImGuiStorage = record
//not translated
end;
ImFont = record
//not translated
end;
ImFontConfig = record
//not translated
end;
ImGuiPayload = record
//not translated
end;
ImGuiTextEditCallback = function(Data: PImGuiTextEditCallbackData): longint; cdecl;
ImGuiSizeConstraintCallback = procedure(Data: PImGuiSizeConstraintCallbackData); cdecl;
//binding helpers
type
TCol3 = array[0..2] of single; //todo : does this work?
TCol4 = array[0..3] of single;
function ImVec2Init(const x, y: single): Imvec2; inline;
function ImVec4Init(const x, y, z, w: single): ImVec4; inline;
function ImIDPtr(const i: integer): pointer; inline;
function ImColor(const color: ImVec4): ImU32; inline;
{ Static ImGui class, wraps external cimgui dll calls
Used for:
- having original's C++ styled API
- adding default parameters
- using native strings
Notes:
- formatting in functions with variable parameter list is done by pascal's Format() function from sysutils
- trivial methods should be inlined to prevent calling overhead. Functions with variable parameter list cannot be inlined as of FPC 3.0
}
type
ImGui = class
public
class function GetIO(): PImGuiIO; inline;
class function GetStyle(): PImGuiStyle; inline;
class function GetDrawData(): PImDrawData; inline;
class procedure NewFrame; inline;
class procedure Render; inline;
class procedure Shutdown; inline;
class procedure ShowUserGuide; inline;
class procedure ShowStyleEditor(ref: PImGuiStyle); inline;
class procedure ShowDemoWindow(p_open: Pbool = nil); inline;
class procedure ShowMetricsWindow(p_open: Pbool = nil); inline;
{ Window }
class function Begin_(name: string; p_open: Pbool = nil; flags: ImGuiWindowFlags = 0): Boolean; inline;
class procedure End_; inline;
class function BeginChild(str_id: string; size: ImVec2; border: bool; extra_flags: ImGuiWindowFlags): bool; inline;
class function BeginChildEx(id: ImGuiID; size: ImVec2; border: bool; extra_flags: ImGuiWindowFlags): bool; inline;
class procedure EndChild; inline;
class procedure GetContentRegionMax(out_: PImVec2); inline;
class procedure GetContentRegionAvail(out_: PImVec2); inline;
class function GetContentRegionAvailWidth: single; inline;
class procedure GetWindowContentRegionMin(out_: PImVec2); inline;
class procedure GetWindowContentRegionMax(out_: PImVec2); inline;
class function GetWindowContentRegionWidth: single; inline;
class function GetWindowDrawList(): PImDrawList; inline;
class procedure GetWindowPos(out_: PImVec2); inline;
class procedure GetWindowSize(out_: PImVec2); inline;
class function GetWindowWidth: single; inline;
class function GetWindowHeight: single; inline;
class function IsWindowCollapsed: bool; inline;
class procedure SetWindowFontScale(scale: single); inline;
class procedure SetNextWindowPos(pos: ImVec2; cond: ImGuiCond; const pivot: ImVec2); overload; inline;
class procedure SetNextWindowPos(pos: ImVec2; cond: ImGuiCond = 0); overload; inline;
//NOTFOUND class procedure SetNextWindowPosCenter(cond: ImGuiCond = 0); inline;
class procedure SetNextWindowSize(size: ImVec2; cond: ImGuiCond = 0); inline;
class procedure SetNextWindowSizeConstraints(size_min: ImVec2; size_max: ImVec2; custom_callback: ImGuiSizeConstraintCallback; custom_callback_data: pointer); inline;
class procedure SetNextWindowContentSize(size: ImVec2); inline;
class procedure SetNextWindowCollapsed(collapsed: bool; cond: ImGuiCond = 0); inline;
class procedure SetNextWindowFocus; inline;
class procedure SetWindowPos(pos: ImVec2; cond: ImGuiCond = 0); inline;
class procedure SetWindowSize(size: ImVec2; cond: ImGuiCond = 0); inline;
class procedure SetWindowCollapsed(collapsed: bool; cond: ImGuiCond = 0); inline;
class procedure SetWindowFocus; inline;
class procedure SetWindowPosByName(Name: PChar; pos: ImVec2; cond: ImGuiCond = 0); inline;
class procedure SetWindowSize2(Name: PChar; size: ImVec2; cond: ImGuiCond = 0); inline;
class procedure SetWindowCollapsed2(Name: PChar; collapsed: bool; cond: ImGuiCond = 0); inline;
class procedure SetWindowFocus2(Name: PChar); inline;
class function GetScrollX: single; inline;
class function GetScrollY: single; inline;
class function GetScrollMaxX: single; inline;
class function GetScrollMaxY: single; inline;
class procedure SetScrollX(scroll_x: single); inline;
class procedure SetScrollY(scroll_y: single); inline;
class procedure SetScrollHere(center_y_ratio: single); inline;
class procedure SetScrollFromPosY(pos_y: single; center_y_ratio: single); inline;
class procedure SetStateStorage(tree: PImGuiStorage); inline;
class function GetStateStorage(): PImGuiStorage; inline;
{ Parameters stacks (shared) }
class procedure PushFont(font: PImFont); inline;
class procedure PopFont; inline;
class procedure PushStyleColor(idx: ImGuiCol; col: ImVec4); inline;
class procedure PopStyleColor(count: longint); inline;
class procedure PushStyleVar(idx: ImGuiStyleVar; val: single); inline;
class procedure PushStyleVarVec(idx: ImGuiStyleVar; val: ImVec2); inline;
class procedure PopStyleVar(count: longint = 1); inline;
class function GetFont(): PImFont; inline;
class function GetFontSize: single; inline;
class function GetFontTexUvWhitePixel(): ImVec2;
class function GetColorU32(idx: ImGuiCol; alpha_mul: single): ImU32; inline;
class function GetColorU32Vec(col: PImVec4): ImU32; inline;
{ Parameters stacks (current window) }
class procedure PushItemWidth(item_width: single); inline;
class procedure PopItemWidth; inline;
class function CalcItemWidth: single; inline;
class procedure PushTextWrapPos(wrap_pos_x: single); inline;
class procedure PopTextWrapPos; inline;
class procedure PushAllowKeyboardFocus(v: bool); inline;
class procedure PopAllowKeyboardFocus; inline;
class procedure PushButtonRepeat(_repeat: bool); inline;
class procedure PopButtonRepeat; inline;
{ Layout }
class procedure Separator; inline;
class procedure SameLine(pos_x: single = 0; spacing_w: single = -1); inline;
class procedure NewLine; inline;
class procedure Spacing; inline;
class procedure Dummy(size: PImVec2); inline;
class procedure Indent(indent_w: single); inline;
class procedure Unindent(indent_w: single); inline;
class procedure BeginGroup; inline;
class procedure EndGroup; inline;
class function GetCursorPos(): ImVec2; inline;
class function GetCursorPosX: single; inline;
class function GetCursorPosY: single; inline;
class procedure SetCursorPos(local_pos: ImVec2); inline;
class procedure SetCursorPosX(x: single); inline;
class procedure SetCursorPosY(y: single); inline;
class function GetCursorStartPos(): ImVec2; inline;
class function GetCursorScreenPos(): ImVec2; inline;
class procedure SetCursorScreenPos(pos: ImVec2); inline;
class procedure igAlignTextToFramePadding; inline;
class function GetTextLineHeight: single; inline;
class function GetTextLineHeightWithSpacing: single; inline;
class function GetFrameHeight: single; inline;
class function GetFrameHeightWithSpacing: single; inline;
{ Columns }
class procedure Columns(Count: longint; id: PChar; border: bool); inline;
class procedure NextColumn; inline;
class function GetColumnIndex: longint; inline;
class function GetColumnOffset(column_index: longint): single; inline;
class procedure SetColumnOffset(column_index: longint; offset_x: single); inline;
class function GetColumnWidth(column_index: longint): single; inline;
class procedure SetColumnWidth(column_index: longint; width: single); inline;
class function GetColumnsCount: longint; inline;
{ ID scopes }
{ If you are creating widgets in a loop you most likely want to push a unique identifier so ImGui can differentiate them }
{ You can also use "##extra" within your widget name to distinguish them from each others (see 'Programmer Guide') }
class procedure PushIdStr(str_id: PChar); inline;
class procedure PushIdStrRange(str_begin: PChar; str_end: PChar); inline;
class procedure PushIdPtr(ptr_id: pointer); inline;
class procedure PushIdInt(int_id: longint); inline;
class procedure PopId; inline;
class function GetIdStr(str_id: PChar): ImGuiID; inline;
class function GetIdStrRange(str_begin: PChar; str_end: PChar): ImGuiID; inline;
class function GetIdPtr(ptr_id: pointer): ImGuiID; inline;
{ Widgets: Text }
class procedure Text(const text_: string); overload;
class procedure Text(const Fmt: string; const Args: array of Const); overload;
//procedure igTextV(fmt:Pchar; args:va_list);cdecl;external ImguiLibName;
class procedure TextColored(col: ImVec4; fmt: PChar; args: array of const);overload; { inline; }
class procedure TextColored(col: ImVec4; const fmt: string);overload; inline;
//procedure igTextColoredV(col:ImVec4; fmt:Pchar; args:va_list);cdecl;external ImguiLibName;
class procedure TextDisabled(const fmt: string; args: array of const);overload; {inline;}
class procedure TextDisabled(const fmt: string);overload; inline;
//procedure igTextDisabledV(fmt:Pchar; args:va_list);cdecl;external ImguiLibName;
class procedure TextWrapped(const fmt: string; args: array of const);overload; {inline;}
class procedure TextWrapped(const fmt: string);overload; inline;
//procedure igTextWrappedV(fmt:Pchar; args:va_list);cdecl;external ImguiLibName;
class procedure TextUnformatted(const _text: string);overload;
class procedure TextUnformatted(const _text: PChar; const text_end: PChar = nil);overload;
class procedure LabelText(_label: string; fmt: string);overload;
class procedure LabelText(_label: string; fmt: PChar; args: array of const);overload;
//procedure igLabelTextV(_label:Pchar; fmt:Pchar; args:va_list);cdecl;external ImguiLibName;
class procedure Bullet; inline;
class procedure BulletText(const fmt: string; args: array of const); overload;{inline;}
class procedure BulletText(const fmt: string);overload; inline;
//procedure igBulletTextV(fmt:Pchar; args:va_list);cdecl;external ImguiLibName;
{ Widgets: Main }
class function Button(_label: string; size: ImVec2): bool;overload;
class function Button(_label: string): bool;overload; //overload for default size (0,0)
class function SmallButton(_label: PChar): bool; inline;
class function InvisibleButton(str_id: PChar; size: ImVec2): bool; inline;
class procedure Image(user_texture_id: ImTextureID; size: ImVec2; uv0: ImVec2; uv1: ImVec2; tint_col: ImVec4; border_col: ImVec4); inline;
class function ImageButton(user_texture_id: ImTextureID; size: ImVec2; uv0: ImVec2; uv1: ImVec2; frame_padding: longint; bg_col: ImVec4; tint_col: ImVec4): bool; inline;
class function Checkbox(_label: PChar; v: Pbool): bool; inline;
class function CheckboxFlags(_label: PChar; flags: Pdword; flags_value: dword): bool; inline;
class function RadioButtonBool(_label: PChar; active: bool): bool; inline;
class function RadioButton(_label: PChar; v: Plongint; v_button: longint): bool; inline;
class function BeginCombo(const _label, preview_value: string; flags: ImGuiComboFlags = 0): bool; inline;
class procedure EndCombo;
class function Combo(_label: string; current_item: Plongint; items: PPchar; items_count: longint; height_in_items: longint): bool; inline;
class function Combo2(_label: string; current_item: Plongint; items_separated_by_zeros: PChar; height_in_items: longint): bool; inline;
class function ColorButton(desc_id: PChar; col: ImVec4; flags: ImGuiColorEditFlags; size: ImVec2): bool; inline;
class function ColorEdit3(_label: PChar; col: TCol3; flags: ImGuiColorEditFlags = 0): bool; inline;
class function ColorEdit4(_label: PChar; col: TCol4; flags: ImGuiColorEditFlags = 0): bool; inline;
class function ColorPicker3(_label: PChar; col: TCol3; flags: ImGuiColorEditFlags = 0): bool; inline;
class function ColorPicker4(_label: PChar; col: TCol4; flags: ImGuiColorEditFlags = 0): bool; inline;
class procedure SetColorEditOptions(flags: ImGuiColorEditFlags); inline;
class procedure PlotLines(_label: PChar; values: Psingle; values_count: longint; values_offset: longint; overlay_text: PChar; scale_min: single; scale_max: single; graph_size: ImVec2; stride: longint); inline;
//TODO : func type
//procedure igPlotLines2(_label:Pchar; values_getter:function (data:pointer; idx:longint):single; data:pointer; values_count:longint; values_offset:longint;
// overlay_text:Pchar; scale_min:single; scale_max:single; graph_size:ImVec2);cdecl;external ImguiLibName;
class procedure PlotHistogram(_label: PChar; values: Psingle; values_count: longint; values_offset: longint; overlay_text: PChar; scale_min: single; scale_max: single; graph_size: ImVec2; stride: longint); inline;
//TODO : func type
//procedure igPlotHistogram2(_label:Pchar; values_getter:function (data:pointer; idx:longint):single; data:pointer; values_count:longint; values_offset:longint;
// overlay_text:Pchar; scale_min:single; scale_max:single; graph_size:ImVec2);cdecl;external ImguiLibName;
class procedure ProgressBar(fraction: single; size_arg: PImVec2; overlay: PChar); inline;
{ Widgets: Sliders (tip: ctrl+click on a slider to input text) }
class function SliderFloat (_label: PChar; v: Psingle; v_min: single; v_max: single; display_format: PChar{$IFDEF FPC} = '%.3f'{$ENDIF}; power: single = 1): bool; inline;
class function SliderFloat2(_label: PChar; v: TFloat2; v_min: single; v_max: single; display_format: PChar{$IFDEF FPC} = '%.3f'{$ENDIF}; power: single = 1): bool; inline;
class function SliderFloat3(_label: PChar; v: TFloat3; v_min: single; v_max: single; display_format: PChar{$IFDEF FPC} = '%.3f'{$ENDIF}; power: single = 1): bool; inline;
class function SliderFloat4(_label: PChar; v: TFloat4; v_min: single; v_max: single; display_format: PChar{$IFDEF FPC} = '%.3f'{$ENDIF}; power: single = 1): bool; inline;
class function SliderAngle(_label: PChar; v_rad: Psingle; v_degrees_min: single = -360; v_degrees_max: single = 360): bool; inline;
class function SliderInt (_label: PChar; v: Plongint; v_min: longint; v_max: longint; display_format: PChar{$IFDEF FPC} = '%.0f'{$ENDIF}): bool; inline;
class function SliderInt2(_label: PChar; v: TLongInt2; v_min: longint; v_max: longint; display_format: PChar{$IFDEF FPC} = '%.0f'{$ENDIF}): bool; inline;
class function SliderInt3(_label: PChar; v: TLongInt3; v_min: longint; v_max: longint; display_format: PChar{$IFDEF FPC} = '%.0f'{$ENDIF}): bool; inline;
class function SliderInt4(_label: PChar; v: TLongInt4; v_min: longint; v_max: longint; display_format: PChar{$IFDEF FPC} = '%.0f'{$ENDIF}): bool; inline;
class function VSliderFloat(_label: PChar; size: ImVec2; v: Psingle; v_min: single; v_max: single; display_format: PChar{$IFDEF FPC} = '%.3f'{$ENDIF}; power: single = 1): bool; inline;
class function VSliderInt(_label: PChar; size: ImVec2; v: Plongint; v_min: longint; v_max: longint; display_format: PChar{$IFDEF FPC} = '%.0f'{$ENDIF}): bool; inline;
{ Widgets: Drags (tip: ctrl+click on a drag box to input text) }
// For all the Float2/Float3/Float4/Int2/Int3/Int4 versions of every functions, remember than a 'float v[3]' function argument is the same as 'float* v'. You can pass address of your first element out of a contiguous set, e.g. &myvector.x
{ If v_min >= v_max we have no bound }
class function DragFloat (_label: PChar; v: Psingle; v_speed: single; v_min: single; v_max: single; display_format: PChar{$IFDEF FPC} = '%.3f'{$ENDIF}; power: single = 1): bool; inline;
class function DragFloat2(_label: PChar; v: TFloat2; v_speed: single; v_min: single; v_max: single; display_format: PChar{$IFDEF FPC} = '%.3f'{$ENDIF}; power: single = 1): bool; inline;
class function DragFloat3(_label: PChar; v: TFloat3; v_speed: single; v_min: single; v_max: single; display_format: PChar{$IFDEF FPC} = '%.3f'{$ENDIF}; power: single = 1): bool; inline;
class function DragFloat4(_label: PChar; v: TFloat4; v_speed: single; v_min: single; v_max: single; display_format: PChar{$IFDEF FPC} = '%.3f'{$ENDIF}; power: single = 1): bool; inline;
class function DragFloatRange2(_label: PChar; v_current_min: Psingle; v_current_max: Psingle; v_speed: single = 1;
v_min: single = 0; v_max: single = 0; display_format: PChar{$IFDEF FPC} = '%.3f'{$ELSE}=nil{$ENDIF}; display_format_max: PChar = nil; power: single = 1): bool; inline;
{ If v_min >= v_max we have no bound }
class function DragInt (_label: PChar; v: Plongint; v_speed: single = 1; v_min: longint = 0; v_max: longint = 0; display_format: PChar{$IFDEF FPC} = '%.0f'{$ELSE}=nil{$ENDIF}): bool; inline;
class function DragInt2(_label: PChar; v: TLongInt2; v_speed: single = 1; v_min: longint = 0; v_max: longint = 0; display_format: PChar{$IFDEF FPC} = '%.0f'{$ELSE}=nil{$ENDIF}): bool; inline;
class function DragInt3(_label: PChar; v: TLongInt3; v_speed: single = 1; v_min: longint = 0; v_max: longint = 0; display_format: PChar{$IFDEF FPC} = '%.0f'{$ELSE}=nil{$ENDIF}): bool; inline;
class function DragInt4(_label: PChar; v: TLongInt4; v_speed: single = 1; v_min: longint = 0; v_max: longint = 0; display_format: PChar{$IFDEF FPC} = '%.0f'{$ELSE}=nil{$ENDIF}): bool; inline;
class function DragIntRange2(_label: PChar; v_current_min: Plongint; v_current_max: Plongint; v_speed: single = 1;
v_min: longint = 0; v_max: longint = 0; display_format: PChar{$IFDEF FPC} = '%.0f'{$ELSE}=nil{$ENDIF}; display_format_max: PChar = nil): bool; inline;
{ Widgets: Input with Keyboard }
class function InputText(_label: PChar; buf: PChar; buf_size: size_t; flags: ImGuiInputTextFlags = 0; callback: ImGuiTextEditCallback = nil; user_data: pointer = nil): bool; inline;
class function InputTextMultiline(_label: PChar; buf: PChar; buf_size: size_t; size: ImVec2; flags: ImGuiInputTextFlags = 0; callback: ImGuiTextEditCallback = nil; user_data: pointer = nil): bool; inline;
class function InputFloat(_label: PChar; v: Psingle; step: single; step_fast: single; decimal_precision: longint; extra_flags: ImGuiInputTextFlags): bool; inline;
class function InputFloat2(_label: PChar; v: TFloat2; decimal_precision: longint; extra_flags: ImGuiInputTextFlags): bool; inline;
class function InputFloat3(_label: PChar; v: TFloat3; decimal_precision: longint; extra_flags: ImGuiInputTextFlags): bool; inline;
class function InputFloat4(_label: PChar; v: TFloat4; decimal_precision: longint; extra_flags: ImGuiInputTextFlags): bool; inline;
class function InputInt(_label: PChar; v: Plongint; step: longint; step_fast: longint; extra_flags: ImGuiInputTextFlags): bool; inline;
class function InputInt2(_label: PChar; v: TLongInt2; extra_flags: ImGuiInputTextFlags): bool; inline;
class function InputInt3(_label: PChar; v: TLongInt3; extra_flags: ImGuiInputTextFlags): bool; inline;
class function InputInt4(_label: PChar; v: TLongInt4; extra_flags: ImGuiInputTextFlags): bool; inline;
{ Widgets: Trees }
class function TreeNode(_label: string): bool;{$IFNDEF FPC}overload;{$ENDIF} inline;
class function TreeNode(str_id: string; fmt: string; args: array of const): bool;{$IFNDEF FPC}overload;{$ENDIF} {inline;}
class function TreeNode(str_id: string; fmt: string): bool;{$IFNDEF FPC}overload;{$ENDIF} inline;
class function TreeNode(ptr_id: pointer; fmt: string; args: array of const): bool;{$IFNDEF FPC}overload;{$ENDIF} {inline;}
class function TreeNode(ptr_id: pointer; fmt: string): bool;{$IFNDEF FPC}overload;{$ENDIF} inline;
class function TreeNodeEx(_label: PChar; flags: ImGuiTreeNodeFlags): bool;{$IFNDEF FPC}overload;{$ENDIF} inline;
class function TreeNodeEx(str_id: PChar; flags: ImGuiTreeNodeFlags; fmt: string; args: array of const): bool;{$IFNDEF FPC}overload;{$ENDIF} {inline;}
class function TreeNodeEx(str_id: PChar; flags: ImGuiTreeNodeFlags; fmt: string): bool;{$IFNDEF FPC}overload;{$ENDIF} inline;
class function TreeNodeEx(ptr_id: pointer; flags: ImGuiTreeNodeFlags; fmt: string; args: array of const): bool; {$IFNDEF FPC}overload;{$ENDIF}{inline;}
class function TreeNodeEx(ptr_id: pointer; flags: ImGuiTreeNodeFlags; fmt: string): bool;{$IFNDEF FPC}overload;{$ENDIF} inline;
//todo : vargs
// function igTreeNodeExV(str_id:Pchar; flags:ImGuiTreeNodeFlags; fmt:Pchar; args:va_list):bool;cdecl;external ImguiLibName;
//todo : vargs
// function igTreeNodeExVPtr(ptr_id:pointer; flags:ImGuiTreeNodeFlags; fmt:Pchar; args:va_list):bool;cdecl;external ImguiLibName;
class procedure TreePushStr(str_id: PChar); inline;
class procedure TreePushPtr(ptr_id: pointer); inline;
class procedure TreePop; inline;
class procedure TreeAdvanceToLabelPos; inline;
class function GetTreeNodeToLabelSpacing: single; inline;
class procedure SetNextTreeNodeOpen(opened: bool; cond: ImGuiCond = 0); inline;
class function CollapsingHeader(_label: PChar; flags: ImGuiTreeNodeFlags = 0): bool;{$IFNDEF FPC}overload;{$ENDIF} inline;
class function CollapsingHeader(_label: PChar; p_open: Pbool; flags: ImGuiTreeNodeFlags = 0): bool;{$IFNDEF FPC}overload;{$ENDIF} inline;
{ Widgets: Selectable / Lists }
class function Selectable(_label: string; selected: bool; flags: ImGuiSelectableFlags; size: ImVec2): bool;{$IFNDEF FPC}overload;{$ENDIF}
class function Selectable(_label: string; selected: bool; flags: ImGuiSelectableFlags = 0): bool;{$IFNDEF FPC}overload;{$ENDIF} //overload for default size (0,0)
class function SelectableEx(_label: PChar; p_selected: Pbool; flags: ImGuiSelectableFlags; size: ImVec2): bool; inline;
class function ListBox(_label: PChar; current_item: Plongint; items: PPchar; items_count: longint; height_in_items: longint): bool; inline;
//todo : func type
// function igListBox2(_label:Pchar; current_item:Plongint; items_getter:function (data:pointer; idx:longint; out_text:PPchar):bool; data:pointer; items_count:longint;
// height_in_items:longint):bool;cdecl;external ImguiLibName;
class function ListBoxHeader(_label: PChar; size: ImVec2): bool; inline;
class function ListBoxHeader2(_label: PChar; items_count: longint; height_in_items: longint): bool; inline;
class procedure ListBoxFooter; inline;
{ Widgets: Value() Helpers. Output single value in "name: value" format (tip: freely declare your own within the ImGui namespace!) }
class procedure ValueBool(prefix: PChar; b: bool); inline;
class procedure ValueInt(prefix: PChar; v: longint); inline;
class procedure ValueUInt(prefix: PChar; v: dword); inline;
class procedure ValueFloat(prefix: PChar; v: single; float_format: PChar); inline;
{ Tooltip }
class procedure SetTooltip(fmt: string; args: array of const);{$IFNDEF FPC}overload;{$ENDIF} {inline}
class procedure SetTooltip(fmt: string);{$IFNDEF FPC}overload;{$ENDIF} inline;
//todo : vargs
// procedure igSetTooltipV(fmt:Pchar; args:va_list);cdecl;external ImguiLibName;
class procedure BeginTooltip; inline;
class procedure EndTooltip; inline;
{ Widgets: Menus }
class function BeginMainMenuBar: bool; inline;
class procedure EndMainMenuBar; inline;
class function BeginMenuBar: bool; inline;
class procedure EndMenuBar; inline;
class function BeginMenu(_label: PChar; Enabled: bool = true): bool; inline;
class procedure EndMenu; inline;
class function MenuItem(_label: PChar; shortcut: PChar; selected: bool; Enabled: bool = true): bool;{$IFNDEF FPC}overload;{$ENDIF} inline;
class function MenuItem(_label: PChar; shortcut: PChar; p_selected: Pbool; Enabled: bool = true): bool;{$IFNDEF FPC}overload;{$ENDIF} inline;
{ Popup }
class procedure OpenPopup(str_id: PChar); inline;
class function BeginPopup(str_id: PChar): bool; inline;
class function BeginPopupModal(Name: PChar; p_open: Pbool; extra_flags: ImGuiWindowFlags): bool; inline;
class function BeginPopupContextItem(str_id: PChar; mouse_button: longint): bool; inline;
class function BeginPopupContextWindow(str_id: PChar = nil; mouse_button: longint = 1; also_over_items: bool = true): bool; inline;
class function BeginPopupContextVoid(str_id: PChar; mouse_button: longint): bool; inline;
class procedure EndPopup; inline;
class function IsPopupOpen(str_id: PChar): bool; inline;
class procedure CloseCurrentPopup; inline;
{ Logging: all text output from interface is redirected to tty/file/clipboard. Tree nodes are automatically opened. }
class procedure LogToTTY(max_depth: longint); inline;
class procedure LogToFile(max_depth: longint; filename: PChar); inline;
class procedure LogToClipboard(max_depth: longint); inline;
class procedure LogFinish; inline;
class procedure LogButtons; inline;
class procedure LogText(const fmt: string; args: array of const);{$IFNDEF FPC}overload;{$ENDIF}
class procedure LogText(const fmt: string);{$IFNDEF FPC}overload;{$ENDIF}
{ Drag and Drop }
{ Clipping }
class procedure PushClipRect(clip_rect_min: ImVec2; clip_rect_max: ImVec2; intersect_with_current_clip_rect: bool); inline;
class procedure PopClipRect; inline;
{ Styles }
class procedure StyleColorsClassic(dst: PImGuiStyle); inline;
class procedure StyleColorsDark(dst: PImGuiStyle); inline;
class procedure StyleColorsLight(dst: PImGuiStyle); inline;
{ Focus }
class procedure SetItemDefaultFocus(); inline;
class procedure SetKeyboardFocusHere(offset: integer = 0); inline;
{ Utilities }
class function IsItemHovered(flags: ImGuiHoveredFlags = 0): bool; inline;
class function IsItemActive: bool; inline;
class function IsItemClicked(mouse_button: longint = 0): bool; inline;
class function IsItemVisible: bool; inline;
class function IsAnyItemHovered: bool; inline;
class function IsAnyItemActive: bool; inline;
class procedure GetItemRectMin(pOut: PImVec2); inline;
class procedure GetItemRectMax(pOut: PImVec2); inline;
class procedure GetItemRectSize(pOut: PImVec2); inline;
class procedure SetItemAllowOverlap; inline;
class function IsWindowFocused(flags: ImGuiHoveredFlags = 0): bool; inline;
class function IsWindowHovered(flags: ImGuiHoveredFlags = 0): bool; inline;
class function IsAnyWindowFocused: bool; inline;
class function IsAnyWindowHovered: bool; inline;
class function IsRectVisible(const item_size: ImVec2): bool;{$IFNDEF FPC}overload;{$ENDIF} inline;
class function IsRectVisible(const rect_min, rect_max: PImVec2): bool;{$IFNDEF FPC}overload;{$ENDIF} inline;
class function GetTime: single; inline;
class function GetFrameCount: longint; inline;
class function GetStyleColorName(idx: ImGuiCol): PChar; inline;
class function CalcItemRectClosestPoint(pos: ImVec2; on_edge: bool; outward: single): ImVec2; inline;
class function CalcTextSize(_text: PChar; text_end: PChar = nil; hide_text_after_double_hash: bool = false; wrap_width: single = -1): ImVec2; inline;
class procedure CalcListClipping(items_count: longint; items_height: single; out_items_display_start: Plongint; out_items_display_end: Plongint); inline;
class function BeginChildFrame(id: ImGuiID; size: ImVec2; extra_flags: ImGuiWindowFlags): bool; inline;
class procedure EndChildFrame; inline;
class procedure ColorConvertU32ToFloat4(pOut: PImVec4; in_: ImU32); inline;
class function ColorConvertFloat4ToU32(in_: ImVec4): ImU32; inline;
class procedure ColorConvertRGBtoHSV(r: single; g: single; b: single; out_h: Psingle; out_s: Psingle; out_v: Psingle); inline;
class procedure ColorConvertHSVtoRGB(h: single; s: single; v: single; out_r: Psingle; out_g: Psingle; out_b: Psingle); inline;
class function GetKeyIndex(key: ImGuiKey): longint; inline;
class function IsKeyDown(user_key_index: longint): bool; inline;
class function IsKeyPressed(user_key_index: longint; _repeat: bool = true): bool; inline;
class function IsKeyReleased(user_key_index: longint): bool; inline;
class function IsMouseDown(_button: longint): bool; inline;
class function IsMouseClicked(_button: longint; _repeat: bool = false): bool; inline;
class function IsMouseDoubleClicked(_button: longint): bool; inline;
class function IsMouseReleased(_button: longint): bool; inline;
class function IsMouseHoveringRect(r_min: ImVec2; r_max: ImVec2; clip: bool = true): bool; inline;
class function IsMouseDragging(_button: longint = 0; lock_threshold: single = -1): bool; inline;
class function GetMousePos: ImVec2; inline;
class function GetMousePosOnOpeningCurrentPopup: ImVec2; inline;
class function GetMouseDragDelta(_button: longint = 0; lock_threshold: single = -1): ImVec2; inline;
class procedure ResetMouseDragDelta(_button: longint = 0); inline;
class function GetMouseCursor: ImGuiMouseCursor; inline;
class procedure SetMouseCursor(_type: ImGuiMouseCursor); inline;
class procedure CaptureKeyboardFromApp(capture: bool = true); inline;
class procedure CaptureMouseFromApp(capture: bool = true); inline;
{ Helpers functions to access functions pointers in ImGui::GetIO() }
class function MemAlloc(sz: size_t): pointer; inline;
class procedure MemFree(ptr: pointer); inline;
class function GetClipboardText: PChar; inline;
class procedure SetClipboardText(_text: PChar); inline;
{ Internal state access - if you want to share ImGui state between modules (e.g. DLL) or allocate it yourself }
class function GetVersion(): PChar; inline;
end;
{ Record helper for ImDrawList, wraps external cimgui dll calls
Used for:
- having original's C++ styled API - struct with functions
- adding default parameters
Notes:
- it could be a type helper for PImDrawList instead of record helper, but Lazarus' code completion seems to work better this way (at the moment)
}
TImDrawListHelper = record helper for ImDrawList
procedure PushClipRect(clip_rect_min: ImVec2; clip_rect_max: ImVec2; intersect_with_current_clip_rect: bool); inline;
procedure PushClipRectFullScreen(); inline;
procedure PopClipRect(); inline;
procedure PushTextureID(texture_id: ImTextureID); inline;
procedure PopTextureID(); inline;
{ Primitives }
procedure AddLine(a: ImVec2; b: ImVec2; col: ImU32; thickness: single); inline;
procedure AddRect(a: ImVec2; b: ImVec2; col: ImU32; rounding: single = 0; rounding_corners_flags: longint = not 0; thickness: single = 1); inline;
procedure AddRectFilled(a: ImVec2; b: ImVec2; col: ImU32; rounding: single = 0; rounding_corners_flags: longint = not 0); inline;
procedure AddRectFilledMultiColor(a: ImVec2; b: ImVec2; col_upr_left: ImU32; col_upr_right: ImU32; col_bot_right: ImU32; col_bot_left: ImU32); inline;
procedure AddQuad(a: ImVec2; b: ImVec2; c: ImVec2; d: ImVec2; col: ImU32; thickness: single); inline;
procedure AddQuadFilled(a: ImVec2; b: ImVec2; c: ImVec2; d: ImVec2; col: ImU32); inline;
procedure AddTriangle(a: ImVec2; b: ImVec2; c: ImVec2; col: ImU32; thickness: single); inline;
procedure AddTriangleFilled(a: ImVec2; b: ImVec2; c: ImVec2; col: ImU32); inline;
procedure AddCircle(centre: ImVec2; radius: single; col: ImU32; num_segments: longint; thickness: single); inline;
procedure AddCircleFilled(centre: ImVec2; radius: single; col: ImU32; num_segments: longint); inline;
procedure AddText(pos: ImVec2; col: ImU32; text_begin: PChar; text_end: PChar); inline;
procedure AddTextExt(font: PImFont; font_size: single; pos: ImVec2; col: ImU32; text_begin: PChar; text_end: PChar; wrap_width: single; cpu_fine_clip_rect: PImVec4); inline;
procedure AddImage(user_texture_id: ImTextureID; a: ImVec2; b: ImVec2; uva: ImVec2; uvb: ImVec2; col: ImU32); inline;
procedure AddImageQuad(user_texture_id: ImTextureID; const a, b, c, d: ImVec2; const uva, uvb, uvc, uvd: ImVec2; col: ImU32); inline;
procedure AddPolyline(points: PImVec2; num_points: longint; col: ImU32; closed: bool; thickness: single; anti_aliased: bool); inline;
procedure AddConvexPolyFilled(points: PImVec2; num_points: longint; col: ImU32; anti_aliased: bool); inline;
procedure AddBezierCurve(pos0: ImVec2; cp0: ImVec2; cp1: ImVec2; pos1: ImVec2; col: ImU32; thickness: single; num_segments: longint); inline;
{ Stateful path API, add points then finish with PathFill() or PathStroke() }
procedure PathClear(); inline;
procedure PathLineTo(pos: ImVec2); inline;