-
-
Notifications
You must be signed in to change notification settings - Fork 89
/
ImGui.java
6162 lines (5031 loc) · 259 KB
/
ImGui.java
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
package imgui;
import imgui.assertion.ImAssertCallback;
import imgui.callback.ImGuiInputTextCallback;
import imgui.flag.ImGuiCond;
import imgui.flag.ImGuiDragDropFlags;
import imgui.flag.ImGuiInputTextFlags;
import imgui.internal.ImGuiContext;
import imgui.type.ImBoolean;
import imgui.type.ImDouble;
import imgui.type.ImFloat;
import imgui.type.ImInt;
import imgui.type.ImLong;
import imgui.type.ImShort;
import imgui.type.ImString;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.lang.ref.WeakReference;
import java.nio.file.AccessDeniedException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.Optional;
import java.util.Properties;
public class ImGui {
private static final String LIB_PATH_PROP = "imgui.library.path";
private static final String LIB_NAME_PROP = "imgui.library.name";
private static final String LIB_NAME_DEFAULT = System.getProperty("os.arch").contains("64") ? "imgui-java64" : "imgui-java";
private static final String LIB_TMP_DIR_PREFIX = "imgui-java-natives";
private static final ImGuiContext IMGUI_CONTEXT;
private static final ImGuiIO IMGUI_IO;
private static final ImDrawList WINDOW_DRAW_LIST;
private static final ImDrawList BACKGROUND_DRAW_LIST;
private static final ImDrawList FOREGROUND_DRAW_LIST;
private static final ImGuiStorage IMGUI_STORAGE;
private static final ImGuiViewport WINDOW_VIEWPORT;
private static final ImGuiViewport FIND_VIEWPORT;
private static final ImDrawData DRAW_DATA;
private static final ImFont FONT;
private static final ImGuiStyle STYLE;
private static final ImGuiViewport MAIN_VIEWPORT;
private static final ImGuiPlatformIO PLATFORM_IO;
static {
final String libPath = System.getProperty(LIB_PATH_PROP);
final String libName = System.getProperty(LIB_NAME_PROP, LIB_NAME_DEFAULT);
final String fullLibName = resolveFullLibName();
if (libPath != null) {
System.load(Paths.get(libPath).resolve(fullLibName).toAbsolutePath().toString());
} else {
try {
System.loadLibrary(libName);
} catch (Exception | Error e) {
final String extractedLibAbsPath = tryLoadFromClasspath(fullLibName);
if (extractedLibAbsPath != null) {
System.load(extractedLibAbsPath);
} else {
throw e;
}
}
}
IMGUI_CONTEXT = new ImGuiContext(0);
IMGUI_IO = new ImGuiIO(0);
WINDOW_DRAW_LIST = new ImDrawList(0);
BACKGROUND_DRAW_LIST = new ImDrawList(0);
FOREGROUND_DRAW_LIST = new ImDrawList(0);
IMGUI_STORAGE = new ImGuiStorage(0);
WINDOW_VIEWPORT = new ImGuiViewport(0);
FIND_VIEWPORT = new ImGuiViewport(0);
DRAW_DATA = new ImDrawData(0);
FONT = new ImFont(0);
STYLE = new ImGuiStyle(0);
MAIN_VIEWPORT = new ImGuiViewport(0);
PLATFORM_IO = new ImGuiPlatformIO(0);
nInitJni();
ImFontAtlas.nInit();
ImGuiPlatformIO.init();
nInitInputTextData();
setAssertCallback(new ImAssertCallback() {
@Override
public void imAssertCallback(String assertion, int line, String file) {
System.err.println("Dear ImGui Assertion Failed: " + assertion);
System.err.println("Assertion Located At: " + file + ":" + line);
Thread.dumpStack();
}
});
}
private static String resolveFullLibName() {
final boolean isWin = System.getProperty("os.name").toLowerCase().contains("win");
final boolean isMac = System.getProperty("os.name").toLowerCase().contains("mac");
final String libPrefix;
final String libSuffix;
if (isWin) {
libPrefix = "";
libSuffix = ".dll";
} else if (isMac) {
libPrefix = "lib";
libSuffix = ".dylib";
} else {
libPrefix = "lib";
libSuffix = ".so";
}
return System.getProperty(LIB_NAME_PROP, libPrefix + LIB_NAME_DEFAULT + libSuffix);
}
// This method tries to unpack the library binary from classpath into the temp dir.
private static String tryLoadFromClasspath(final String fullLibName) {
try (InputStream is = ImGui.class.getClassLoader().getResourceAsStream("io/imgui/java/native-bin/" + fullLibName)) {
if (is == null) {
return null;
}
final String version = getVersionString().orElse("undefined");
final Path tmpDir = Paths.get(System.getProperty("java.io.tmpdir")).resolve(LIB_TMP_DIR_PREFIX).resolve(version);
if (!Files.exists(tmpDir)) {
Files.createDirectories(tmpDir);
}
final Path libBin = tmpDir.resolve(fullLibName);
try {
Files.copy(is, libBin, StandardCopyOption.REPLACE_EXISTING);
} catch (AccessDeniedException e) {
if (!Files.exists(libBin)) {
throw e;
}
}
return libBin.toAbsolutePath().toString();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
private static Optional<String> getVersionString() {
final Properties properties = new Properties();
try (InputStream is = ImGui.class.getResourceAsStream("/imgui/imgui-java.properties")) {
if (is != null) {
properties.load(is);
return Optional.of(properties.get("imgui.java.version").toString());
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
return Optional.empty();
}
/**
* For internal usage.
* Method is used to initiate static instantiation (loading of the native libraries etc.).
* Otherwise native libraries will be loaded on demand and natively mapped objects won't work.
*/
public static void init() {
}
/*JNI
#include "_common.h"
*/
private static native void nInitJni(); /*
Jni::InitJvm(env);
Jni::InitCommon(env);
Jni::InitAssertion(env);
Jni::InitCallbacks(env);
Jni::InitBindingStruct(env);
*/
// Context creation and access
// Each context create its own ImFontAtlas by default.
// You may instance one yourself and pass it to CreateContext() to share a font atlas between imgui contexts.
// None of those functions is reliant on the current context.
//
// BINDING NOTICE: Getting of the current context is not implemented since it's a part of internal API which is not exposed here.
public static ImGuiContext createContext() {
IMGUI_CONTEXT.ptr = nCreateContext();
return IMGUI_CONTEXT;
}
private static native long nCreateContext(); /*
return (intptr_t)ImGui::CreateContext();
*/
public static ImGuiContext createContext(ImFontAtlas sharedFontAtlas) {
IMGUI_CONTEXT.ptr = nCreateContext(sharedFontAtlas.ptr);
return IMGUI_CONTEXT;
}
private static native long nCreateContext(long sharedFontAtlasPtr); /*
return (intptr_t)ImGui::CreateContext((ImFontAtlas*)sharedFontAtlasPtr);
*/
public static native void destroyContext(); /*
ImGui::DestroyContext();
*/
public static void destroyContext(ImGuiContext ctx) {
nDestroyContext(ctx.ptr);
}
private static native void nDestroyContext(long ptr); /*
ImGui::DestroyContext((ImGuiContext*) ptr);
*/
public static ImGuiContext getCurrentContext() {
IMGUI_CONTEXT.ptr = nGetCurrentContext();
return IMGUI_CONTEXT;
}
private static native long nGetCurrentContext(); /*
return (intptr_t)ImGui::GetCurrentContext();
*/
public static void setCurrentContext(ImGuiContext ctx) {
nSetCurrentContext(ctx.ptr);
}
private static native void nSetCurrentContext(long ptr); /*
ImGui::SetCurrentContext((ImGuiContext*) ptr);
*/
/**
* Set a custom assertion callback for ImGui assertions.
* Take note: Any custom assertion callback SHOULD NOT throw any exception.
* After any callback the application will be terminated, any attempt to bypass this behavior
* will result in a EXCEPTION_ACCESS_VIOLATION from within the native layer.
* @param callback The custom ImGui assertion callback
*/
public static native void setAssertCallback(ImAssertCallback callback); /*
Jni::SetAssertionCallback(callback);
*/
// Main
/**
* Access the IO structure (mouse/keyboard/gamepad inputs, time, various configuration options/flags).
*/
public static ImGuiIO getIO() {
IMGUI_IO.ptr = nGetIO();
return IMGUI_IO;
}
private static native long nGetIO(); /*
return (intptr_t)&ImGui::GetIO();
*/
/**
* Access the Style structure (colors, sizes). Always use PushStyleCol(), PushStyleVar() to modify style mid-frame!
*/
public static ImGuiStyle getStyle() {
STYLE.ptr = nGetStyle();
return STYLE;
}
private static native long nGetStyle(); /*
return (intptr_t)&ImGui::GetStyle();
*/
/**
* Start a new Dear ImGui frame, you can submit any command from this point until Render()/EndFrame().
*/
public static native void newFrame(); /*
ImGui::NewFrame();
*/
/**
* Ends the Dear ImGui frame. automatically called by Render(). If you don't need to render data (skipping rendering) you may call EndFrame() without
* Render()... but you'll have wasted CPU already! If you don't need to render, better to not create any windows and not call NewFrame() at all!
*/
public static native void endFrame(); /*
ImGui::EndFrame();
*/
/**
* Ends the Dear ImGui frame, finalize the draw data. You can then get call GetDrawData().
*/
public static native void render(); /*
ImGui::Render();
*/
/**
* Valid after Render() and until the next call to NewFrame(). this is what you have to render.
*/
public static ImDrawData getDrawData() {
DRAW_DATA.ptr = nGetDrawData();
return DRAW_DATA;
}
private static native long nGetDrawData(); /*
return (intptr_t)ImGui::GetDrawData();
*/
// Demo, Debug, Information
/**
* Create Demo window. Demonstrate most ImGui features. Call this to learn about the library!
*/
public static native void showDemoWindow(); /*
ImGui::ShowDemoWindow();
*/
public static void showDemoWindow(ImBoolean pOpen) {
nShowDemoWindow(pOpen.getData());
}
private static native void nShowDemoWindow(boolean[] pOpen); /*
ImGui::ShowDemoWindow(&pOpen[0]);
*/
/**
* Create Metrics/Debugger window. display Dear ImGui internals: windows, draw commands, various internal state, etc.
*/
public static void showMetricsWindow(ImBoolean pOpen) {
nShowMetricsWindow(pOpen.getData());
}
/**
* Create Metrics/Debugger window. display Dear ImGui internals: windows, draw commands, various internal state, etc.
*/
public static native void showMetricsWindow(); /*
ImGui::ShowMetricsWindow();
*/
private static native void nShowMetricsWindow(boolean[] pOpen); /*
ImGui::ShowMetricsWindow(&pOpen[0]);
*/
/**
* Create Stack Tool window. hover items with mouse to query information about the source of their unique ID.
*/
public static void showStackToolWindow(ImBoolean pOpen) {
nShowMetricsWindow(pOpen.getData());
}
/**
* Create Stack Tool window. hover items with mouse to query information about the source of their unique ID.
*/
public static native void showStackToolWindow(); /*
ImGui::ShowStackToolWindow();
*/
private static native void nShowStackToolWindow(boolean[] pOpen); /*
ImGui::ShowStackToolWindow(&pOpen[0]);
*/
/**
* Create About window. display Dear ImGui version, credits and build/system information.
*/
public static native void showAboutWindow(); /*
ImGui::ShowAboutWindow();
*/
public static void showAboutWindow(ImBoolean pOpen) {
nShowAboutWindow(pOpen.getData());
}
private static native void nShowAboutWindow(boolean[] pOpen); /*
ImGui::ShowAboutWindow(&pOpen[0]);
*/
/**
* Add style editor block (not a window).
* You can pass in a reference ImGuiStyle structure to compare to, revert to and save to (else it uses the default style)
*/
public static native void showStyleEditor(); /*
ImGui::ShowStyleEditor();
*/
public static void showStyleEditor(ImGuiStyle ref) {
nShowStyleEditor(ref.ptr);
}
private static native void nShowStyleEditor(long ref); /*
ImGui::ShowStyleEditor((ImGuiStyle*)ref);
*/
/**
* Add style selector block (not a window), essentially a combo listing the default styles.
*/
public static native boolean showStyleSelector(String label); /*
return ImGui::ShowStyleSelector(label);
*/
/**
* Add font selector block (not a window), essentially a combo listing the loaded fonts.
*/
public static native void showFontSelector(String label); /*
ImGui::ShowFontSelector(label);
*/
/**
* Add basic help/info block (not a window): how to manipulate ImGui as a end-user (mouse/keyboard controls).
*/
public static native void showUserGuide(); /*
ImGui::ShowUserGuide();
*/
/**
* Get the compiled version string e.g. "1.80 WIP" (essentially the value for IMGUI_VERSION from the compiled version of imgui.cpp)
*/
public static native String getVersion(); /*
return env->NewStringUTF(ImGui::GetVersion());
*/
// Styles
/**
* New, recommended style (default)
*/
public static native void styleColorsDark(); /*
ImGui::StyleColorsDark();
*/
public static void styleColorsDark(ImGuiStyle style) {
nStyleColorsDark(style.ptr);
}
private static native void nStyleColorsDark(long ptr); /*
ImGui::StyleColorsDark((ImGuiStyle*)ptr);
*/
/**
* Best used with borders and a custom, thicker font
*/
public static native void styleColorsLight(); /*
ImGui::StyleColorsLight();
*/
public static void styleColorsLight(ImGuiStyle style) {
nStyleColorsLight(style.ptr);
}
private static native void nStyleColorsLight(long ptr); /*
ImGui::StyleColorsLight((ImGuiStyle*)ptr);
*/
/**
* Classic imgui style
*/
public static native void styleColorsClassic(); /*
ImGui::StyleColorsClassic();
*/
public static void styleColorsClassic(ImGuiStyle style) {
nStyleColorsClassic(style.ptr);
}
private static native void nStyleColorsClassic(long ptr); /*
ImGui::StyleColorsClassic((ImGuiStyle*)ptr);
*/
// Windows
// - Begin() = push window to the stack and start appending to it. End() = pop window from the stack.
// - You may append multiple times to the same window during the same frame.
// - Passing 'bool* pOpen != NULL' shows a window-closing widget in the upper-right corner of the window,
// which clicking will set the boolean to false when clicked.
// - You may append multiple times to the same window during the same frame by calling Begin()/End() pairs multiple times.
// Some information such as 'flags' or 'p_open' will only be considered by the first call to Begin().
// - Begin() return false to indicate the window is collapsed or fully clipped, so you may early out and omit submitting
// anything to the window. Always call a matching End() for each Begin() call, regardless of its return value!
// [Important: due to legacy reason, this is inconsistent with most other functions such as BeginMenu/EndMenu,
// BeginPopup/EndPopup, etc. where the EndXXX call should only be called if the corresponding BeginXXX function
// returned true. Begin and BeginChild are the only odd ones out. Will be fixed in a future update.]
// - Note that the bottom of window stack always contains a window called "Debug".
public static native boolean begin(String title); /*
return ImGui::Begin(title);
*/
public static boolean begin(String title, ImBoolean pOpen) {
return nBegin(title, pOpen.getData(), 0);
}
public static boolean begin(String title, int imGuiWindowFlags) {
return nBegin(title, imGuiWindowFlags);
}
public static boolean begin(String title, ImBoolean pOpen, int imGuiWindowFlags) {
return nBegin(title, pOpen.getData(), imGuiWindowFlags);
}
private static native boolean nBegin(String title, int imGuiWindowFlags); /*
return ImGui::Begin(title, NULL, imGuiWindowFlags);
*/
private static native boolean nBegin(String title, boolean[] pOpen, int imGuiWindowFlags); /*
return ImGui::Begin(title, &pOpen[0], imGuiWindowFlags);
*/
public static native void end(); /*
ImGui::End();
*/
// Child Windows
// - Use child windows to begin into a self-contained independent scrolling/clipping regions within a host window. Child windows can embed their own child.
// - For each independent axis of 'size': ==0.0f: use remaining host window size / >0.0f: fixed size / <0.0f: use remaining window size minus abs(size) / Each axis can use a different mode, e.g. ImVec2(0,400).
// - BeginChild() returns false to indicate the window is collapsed or fully clipped, so you may early out and omit submitting anything to the window.
// Always call a matching EndChild() for each BeginChild() call, regardless of its return value.
// [Important: due to legacy reason, this is inconsistent with most other functions such as BeginMenu/EndMenu,
// BeginPopup/EndPopup, etc. where the EndXXX call should only be called if the corresponding BeginXXX function
// returned true. Begin and BeginChild are the only odd ones out. Will be fixed in a future update.]
public static native boolean beginChild(String strId); /*
return ImGui::BeginChild(strId);
*/
public static native boolean beginChild(String strId, float width, float height); /*
return ImGui::BeginChild(strId, ImVec2(width, height));
*/
public static native boolean beginChild(String strId, float width, float height, boolean border); /*
return ImGui::BeginChild(strId, ImVec2(width, height), border);
*/
public static native boolean beginChild(String strId, float width, float height, boolean border, int imGuiWindowFlags); /*
return ImGui::BeginChild(strId, ImVec2(width, height), border, imGuiWindowFlags);
*/
public static native boolean beginChild(int imGuiID); /*
return ImGui::BeginChild(imGuiID);
*/
public static native boolean beginChild(int imGuiID, float width, float height, boolean border); /*
return ImGui::BeginChild(imGuiID, ImVec2(width, height), border);
*/
public static native boolean beginChild(int imGuiID, float width, float height, boolean border, int imGuiWindowFlags); /*
return ImGui::BeginChild(imGuiID, ImVec2(width, height), border, imGuiWindowFlags);
*/
public static native void endChild(); /*
ImGui::EndChild();
*/
// Windows Utilities
// - "current window" = the window we are appending into while inside a Begin()/End() block. "next window" = next window we will Begin() into.
public static native boolean isWindowAppearing(); /*
return ImGui::IsWindowAppearing();
*/
public static native boolean isWindowCollapsed(); /*
return ImGui::IsWindowCollapsed();
*/
/**
* Is current window focused? or its root/child, depending on flags. see flags for options.
*/
public static native boolean isWindowFocused(); /*
return ImGui::IsWindowFocused();
*/
/**
* Is current window focused? or its root/child, depending on flags. see flags for options.
*/
public static native boolean isWindowFocused(int imGuiFocusedFlags); /*
return ImGui::IsWindowFocused(imGuiFocusedFlags);
*/
/**
* Is current window hovered (and typically: not blocked by a popup/modal)? see flags for options.
* NB: If you are trying to check whether your mouse should be dispatched to imgui or to your app,
* you should use the 'io.WantCaptureMouse' boolean for that! Please read the FAQ!
*/
public static native boolean isWindowHovered(); /*
return ImGui::IsWindowHovered();
*/
/**
* Is current window hovered (and typically: not blocked by a popup/modal)? see flags for options.
* NB: If you are trying to check whether your mouse should be dispatched to imgui or to your app,
* you should use the 'io.WantCaptureMouse' boolean for that! Please read the FAQ!
*/
public static native boolean isWindowHovered(int imGuiHoveredFlags); /*
return ImGui::IsWindowHovered(imGuiHoveredFlags);
*/
/**
* Get draw list associated to the current window, to append your own drawing primitives
*/
public static ImDrawList getWindowDrawList() {
WINDOW_DRAW_LIST.ptr = nGetWindowDrawList();
return WINDOW_DRAW_LIST;
}
private static native long nGetWindowDrawList(); /*
return (intptr_t)ImGui::GetWindowDrawList();
*/
/**
* Get DPI scale currently associated to the current window's viewport.
*/
public static native float getWindowDpiScale(); /*
return ImGui::GetWindowDpiScale();
*/
/**
* Get current window position in screen space (useful if you want to do your own drawing via the DrawList API)
*/
public static ImVec2 getWindowPos() {
final ImVec2 value = new ImVec2();
getWindowPos(value);
return value;
}
/**
* Get current window position in screen space (useful if you want to do your own drawing via the DrawList API)
*/
public static native void getWindowPos(ImVec2 dstImVec2); /*
Jni::ImVec2Cpy(env, ImGui::GetWindowPos(), dstImVec2);
*/
/**
* Get current window position in screen space (useful if you want to do your own drawing via the DrawList API)
*/
public static native float getWindowPosX(); /*
return ImGui::GetWindowPos().x;
*/
/**
* Get current window position in screen space (useful if you want to do your own drawing via the DrawList API)
*/
public static native float getWindowPosY(); /*
return ImGui::GetWindowPos().y;
*/
/**
* Get current window size
*/
public static ImVec2 getWindowSize() {
final ImVec2 value = new ImVec2();
getWindowSize(value);
return value;
}
/**
* Get current window size
*/
public static native void getWindowSize(ImVec2 dstImVec2); /*
Jni::ImVec2Cpy(env, ImGui::GetWindowSize(), dstImVec2);
*/
/**
* Get current window size
*/
public static native float getWindowSizeX(); /*
return ImGui::GetWindowSize().x;
*/
/**
* Get current window size
*/
public static native float getWindowSizeY(); /*
return ImGui::GetWindowSize().y;
*/
/**
* Get current window width (shortcut for GetWindowSize().x)
*/
public static native float getWindowWidth(); /*
return ImGui::GetWindowWidth();
*/
/**
* Get current window height (shortcut for GetWindowSize().y)
*/
public static native float getWindowHeight(); /*
return ImGui::GetWindowHeight();
*/
/**
* Get viewport currently associated to the current window.
*/
public static ImGuiViewport getWindowViewport() {
WINDOW_VIEWPORT.ptr = nGetWindowViewport();
return WINDOW_VIEWPORT;
}
private static native long nGetWindowViewport(); /*
return (intptr_t)ImGui::GetWindowViewport();
*/
// Prefer using SetNextXXX functions (before Begin) rather that SetXXX functions (after Begin).
/**
* Set next window position. call before Begin(). use pivot=(0.5f,0.5f) to center on given point, etc.
*/
public static native void setNextWindowPos(float x, float y); /*
ImGui::SetNextWindowPos(ImVec2(x, y));
*/
/**
* Set next window position. call before Begin(). use pivot=(0.5f,0.5f) to center on given point, etc.
*/
public static native void setNextWindowPos(float x, float y, int imGuiCond); /*
ImGui::SetNextWindowPos(ImVec2(x, y), imGuiCond);
*/
/**
* Set next window position. call before Begin(). use pivot=(0.5f,0.5f) to center on given point, etc.
*/
public static native void setNextWindowPos(float x, float y, int imGuiCond, float pivotX, float pivotY); /*
ImGui::SetNextWindowPos(ImVec2(x, y), imGuiCond, ImVec2(pivotX, pivotY));
*/
/**
* Set next window size. set axis to 0.0f to force an auto-fit on this axis. call before Begin()
*/
public static native void setNextWindowSize(float width, float height); /*
ImGui::SetNextWindowSize(ImVec2(width, height));
*/
/**
* Set next window size. set axis to 0.0f to force an auto-fit on this axis. call before Begin()
*/
public static native void setNextWindowSize(float width, float height, int imGuiCond); /*
ImGui::SetNextWindowSize(ImVec2(width, height), imGuiCond);
*/
/**
* Set next window size limits. use -1,-1 on either X/Y axis to preserve the current size. Sizes will be rounded down.
*/
public static native void setNextWindowSizeConstraints(float minWidth, float minHeight, float maxWidth, float maxHeight); /*
ImGui::SetNextWindowSizeConstraints(ImVec2(minWidth, minHeight), ImVec2(maxWidth, maxHeight));
*/
/**
* Set next window content size (~ scrollable client area, which enforce the range of scrollbars).
* Not including window decorations (title bar, menu bar, etc.) nor WindowPadding. set an axis to 0.0f to leave it automatic. call before Begin()
*/
public static native void setNextWindowContentSize(float width, float height); /*
ImGui::SetNextWindowContentSize(ImVec2(width, height));
*/
/**
* Set next window collapsed state. call before Begin()
*/
public static native void setNextWindowCollapsed(boolean collapsed); /*
ImGui::SetNextWindowCollapsed(collapsed);
*/
/**
* Set next window collapsed state. call before Begin()
*/
public static native void setNextWindowCollapsed(boolean collapsed, int imGuiCond); /*
ImGui::SetNextWindowCollapsed(collapsed, imGuiCond);
*/
/**
* Set next window to be focused / top-most. call before Begin()
*/
public static native void setNextWindowFocus(); /*
ImGui::SetNextWindowFocus();
*/
/**
* Set next window background color alpha. helper to easily override the Alpha component of ImGuiCol_WindowBg/ChildBg/PopupBg.
* You may also use ImGuiWindowFlags_NoBackground.
*/
public static native void setNextWindowBgAlpha(float alpha); /*
ImGui::SetNextWindowBgAlpha(alpha);
*/
/**
* Set next window viewport.
*/
public static native void setNextWindowViewport(int viewportId); /*
ImGui::SetNextWindowViewport(viewportId);
*/
/**
* (not recommended) set current window position - call within Begin()/End().
* Prefer using SetNextWindowPos(), as this may incur tearing and side-effects.
*/
public static native void setWindowPos(float x, float y); /*
ImGui::SetWindowPos(ImVec2(x, y));
*/
/**
* (not recommended) set current window position - call within Begin()/End().
* Prefer using SetNextWindowPos(), as this may incur tearing and side-effects.
*/
public static native void setWindowPos(float x, float y, int imGuiCond); /*
ImGui::SetWindowPos(ImVec2(x, y), imGuiCond);
*/
/**
* (not recommended) set current window size - call within Begin()/End(). set to ImVec2(0,0) to force an auto-fit.
* Prefer using SetNextWindowSize(), as this may incur tearing and minor side-effects.
*/
public static native void setWindowSize(float width, float height); /*
ImGui::SetWindowSize(ImVec2(width, height));
*/
/**
* (not recommended) set current window size - call within Begin()/End(). set to ImVec2(0,0) to force an auto-fit.
* Prefer using SetNextWindowSize(), as this may incur tearing and minor side-effects.
*/
public static native void setWindowSize(float width, float height, int imGuiCond); /*
ImGui::SetWindowSize(ImVec2(width, height), imGuiCond);
*/
/**
* (not recommended) set current window collapsed state. prefer using SetNextWindowCollapsed().
*/
public static native void setWindowCollapsed(boolean collapsed); /*
ImGui::SetWindowCollapsed(collapsed);
*/
/**
* (not recommended) set current window collapsed state. prefer using SetNextWindowCollapsed().
*/
public static native void setWindowCollapsed(boolean collapsed, int imGuiCond); /*
ImGui::SetWindowCollapsed(collapsed, imGuiCond);
*/
/**
* (not recommended) set current window to be focused / top-most. prefer using SetNextWindowFocus().
*/
public static native void setWindowFocus(); /*
ImGui::SetWindowFocus();
*/
/**
* Set font scale. Adjust IO.FontGlobalScale if you want to scale all windows.
* This is an old API! For correct scaling, prefer to reload font + rebuild ImFontAtlas + call style.ScaleAllSizes().
*/
public native void setWindowFontScale(float scale); /*
ImGui::SetWindowFontScale(scale);
*/
/**
* Set named window position.
*/
public static native void setWindowPos(String name, float x, float y); /*
ImGui::SetWindowPos(name, ImVec2(x, y));
*/
/**
* Set named window position.
*/
public static native void setWindowPos(String name, float x, float y, int imGuiCond); /*
ImGui::SetWindowPos(name, ImVec2(x, y), imGuiCond);
*/
/**
* Set named window size. set axis to 0.0f to force an auto-fit on this axis.
*/
public static native void setWindowSize(String name, float x, float y); /*
ImGui::SetWindowSize(name, ImVec2(x, y));
*/
/**
* Set named window size. set axis to 0.0f to force an auto-fit on this axis.
*/
public static native void setWindowSize(String name, float x, float y, int imGuiCond); /*
ImGui::SetWindowSize(name, ImVec2(x, y), imGuiCond);
*/
/**
* Set named window collapsed state
*/
public static native void setWindowCollapsed(String name, boolean collapsed); /*
ImGui::SetWindowCollapsed(name, collapsed, 0);
*/
/**
* Set named window collapsed state
*/
public static native void setWindowCollapsed(String name, boolean collapsed, int imGuiCond); /*
ImGui::SetWindowCollapsed(name, collapsed, imGuiCond);
*/
/**
* Set named window to be focused / top-most. Use NULL to remove focus.
*/
public static native void setWindowFocus(String name); /*MANUAL
if (obj_name == NULL)
ImGui::SetWindowFocus(NULL);
else {
char* name = (char*)env->GetStringUTFChars(obj_name, JNI_FALSE);
ImGui::SetWindowFocus(name);
env->ReleaseStringUTFChars(obj_name, name);
}
*/
// Content region
// - Retrieve available space from a given point. GetContentRegionAvail() is frequently useful.
// - Those functions are bound to be redesigned (they are confusing, incomplete and the Min/Max return values are in local window coordinates which increases confusion)
/**
* == GetContentRegionMax() - GetCursorPos()
*/
public static ImVec2 getContentRegionAvail() {
final ImVec2 value = new ImVec2();
getContentRegionAvail(value);
return value;
}
/**
* == GetContentRegionMax() - GetCursorPos()
*/
public static native void getContentRegionAvail(ImVec2 dstImVec2); /*
Jni::ImVec2Cpy(env, ImGui::GetContentRegionAvail(), dstImVec2);
*/
/**
* == GetContentRegionMax() - GetCursorPos()
*/
public static native float getContentRegionAvailX(); /*
return ImGui::GetContentRegionAvail().x;
*/
/**
* == GetContentRegionMax() - GetCursorPos()
*/
public static native float getContentRegionAvailY(); /*
return ImGui::GetContentRegionAvail().y;
*/
/**
* Current content boundaries (typically window boundaries including scrolling, or current column boundaries), in windows coordinates
*/
public static ImVec2 getContentRegionMax() {
final ImVec2 value = new ImVec2();
getContentRegionMax(value);
return value;
}
/**
* Current content boundaries (typically window boundaries including scrolling, or current column boundaries), in windows coordinates
*/
public static native void getContentRegionMax(ImVec2 dstImVec2); /*
Jni::ImVec2Cpy(env, ImGui::GetContentRegionMax(), dstImVec2);
*/
/**
* Current content boundaries (typically window boundaries including scrolling, or current column boundaries), in windows coordinates
*/
public static native float getContentRegionMaxX(); /*
return ImGui::GetContentRegionMax().x;
*/
/**
* Current content boundaries (typically window boundaries including scrolling, or current column boundaries), in windows coordinates
*/
public static native float getContentRegionMaxY(); /*
return ImGui::GetContentRegionMax().y;
*/
/**
* Content boundaries max (roughly (0,0)+Size-Scroll) where Size can be override with SetNextWindowContentSize(), in window coordinates
*/
public static ImVec2 getWindowContentRegionMin() {
final ImVec2 value = new ImVec2();
getWindowContentRegionMin(value);
return value;
}
/**
* Content boundaries max (roughly (0,0)+Size-Scroll) where Size can be override with SetNextWindowContentSize(), in window coordinates
*/
public static native void getWindowContentRegionMin(ImVec2 dstImVec2); /*
Jni::ImVec2Cpy(env, ImGui::GetWindowContentRegionMin(), dstImVec2);
*/
/**
* Content boundaries max (roughly (0,0)+Size-Scroll) where Size can be override with SetNextWindowContentSize(), in window coordinates
*/
public static native float getWindowContentRegionMinX(); /*
return ImGui::GetWindowContentRegionMin().x;
*/
/**
* Content boundaries max (roughly (0,0)+Size-Scroll) where Size can be override with SetNextWindowContentSize(), in window coordinates
*/
public static native float getWindowContentRegionMinY(); /*
return ImGui::GetWindowContentRegionMin().y;
*/
public static ImVec2 getWindowContentRegionMax() {
final ImVec2 value = new ImVec2();
getWindowContentRegionMax(value);
return value;
}
public static native void getWindowContentRegionMax(ImVec2 dstImVec2); /*
Jni::ImVec2Cpy(env, ImGui::GetWindowContentRegionMax(), dstImVec2);