Skip to content

Commit ed7bf36

Browse files
committed
Update binding API to Dear ImGui v1.76
1 parent 182a612 commit ed7bf36

File tree

12 files changed

+143
-68
lines changed

12 files changed

+143
-68
lines changed

imgui-binding/src/main/java/imgui/ImFontGlyph.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package imgui;
22

3+
/**
4+
* Hold rendering data for one glyph.
5+
* (Note: some language parsers may fail to convert the 31+1 bitfield members, in this case maybe drop store a single u32 or we can rework this)
6+
*/
37
public final class ImFontGlyph implements ImDestroyable {
48
final long ptr;
59

@@ -48,15 +52,29 @@ public void destroy() {
4852
/**
4953
* 0x0000..0xFFFF
5054
*/
51-
public native short getCodepoint(); /*
52-
return (short)IM_FONT_GLYPH->Codepoint;
55+
public native int getCodepoint(); /*
56+
return (unsigned int)IM_FONT_GLYPH->Codepoint;
5357
*/
5458

5559
/**
5660
* 0x0000..0xFFFF
5761
*/
58-
public native void setCodepoint(short codepoint); /*
59-
IM_FONT_GLYPH->Codepoint = (ImWchar)codepoint;
62+
public native void setCodepoint(int codepoint); /*
63+
IM_FONT_GLYPH->Codepoint = (unsigned int)codepoint;
64+
*/
65+
66+
/**
67+
* Flag to allow early out when rendering
68+
*/
69+
public native int getVisible(); /*
70+
return (unsigned int)IM_FONT_GLYPH->Visible;
71+
*/
72+
73+
/**
74+
* Flag to allow early out when rendering
75+
*/
76+
public native void setVisible(int visible); /*
77+
IM_FONT_GLYPH->Visible = (unsigned int)visible;
6078
*/
6179

6280
/**

imgui-binding/src/main/java/imgui/ImGui.java

Lines changed: 46 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public static ImGuiIO getIO() {
147147
}
148148

149149
/**
150-
* Access the Style structure (colors, sizes). Always use PushStyleCol(), PushStyleVar() to modify style mid-frame.
150+
* Access the Style structure (colors, sizes). Always use PushStyleCol(), PushStyleVar() to modify style mid-frame!
151151
*/
152152
public static ImGuiStyle getStyle() {
153153
if (style == null) {
@@ -168,17 +168,17 @@ public static ImGuiStyle getStyle() {
168168
*/
169169

170170
/**
171-
* Ends the Dear ImGui frame. automatically called by Render(), you likely don't need to call that yourself directly.
172-
* If you don't need to render data (skipping rendering) you may call EndFrame() but you'll have wasted CPU already!
173-
* If you don't need to render, better to not create any imgui windows and not call NewFrame() at all!
171+
* Ends the Dear ImGui frame. automatically called by Render(). If you don't need to render data (skipping rendering) you may call EndFrame() without
172+
* 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!
174173
*/
175174
public static native void endFrame(); /*
176175
ImGui::EndFrame();
177176
*/
178177

179178
/**
180179
* Ends the Dear ImGui frame, finalize the draw data.
181-
* You can get call GetDrawData() to obtain it and run your rendering function.
180+
* You can get call GetDrawData() to obtain it and run your rendering function (up to v1.60, this used to call io.RenderDrawListsFn().
181+
* Nowadays, we allow and prefer calling your render function yourself.)
182182
*/
183183
public static native void render(); /*
184184
ImGui::Render();
@@ -232,13 +232,17 @@ public static void showAboutWindow(ImBool pOpen) {
232232
*/
233233

234234
/**
235-
* Create Metrics/Debug window.
235+
* Create Debug/Metrics window.
236236
* Display Dear ImGui internals: draw commands (with individual draw calls and vertices), window list, basic internal state, etc.
237237
*/
238238
public static native void showMetricsWindow(); /*
239239
ImGui::ShowMetricsWindow();
240240
*/
241241

242+
/**
243+
* Create Debug/Metrics window.
244+
* Display Dear ImGui internals: draw commands (with individual draw calls and vertices), window list, basic internal state, etc.
245+
*/
242246
public static void showMetricsWindow(ImBool pOpen) {
243247
nShowMetricsWindow(pOpen.data);
244248
}
@@ -945,7 +949,7 @@ public static ImFont getFont() {
945949
// Parameters stacks (current window)
946950

947951
/**
948-
* Set width of items for common large "item+label" widgets. {@code > 0.0f}: width in pixels,
952+
* Push width of items for common large "item+label" widgets. {@code > 0.0f}: width in pixels,
949953
* {@code <0.0f} align xx pixels to the right of window (so -1.0f always align width to the right side). 0.0f = default to ~2/3 of windows width,
950954
*/
951955
public static native void pushItemWidth(float itemWidth); /*
@@ -972,16 +976,16 @@ public static ImFont getFont() {
972976
*/
973977

974978
/**
975-
* Word-wrapping for Text*() commands. {@code < 0.0f}: no wrapping; 0.0f: wrap to end of window (or column); {@code > 0.0f}: wrap at 'wrap_posX'
976-
* position in window local space
979+
* Push Word-wrapping positions for Text*() commands. {@code < 0.0f}: no wrapping; 0.0f: wrap to end of window (or column); {@code > 0.0f}: wrap at
980+
* 'wrap_posX' position in window local space
977981
*/
978982
public static native void pushTextWrapPos(); /*
979983
ImGui::PushTextWrapPos();
980984
*/
981985

982986
/**
983-
* Word-wrapping for Text*() commands. {@code < 0.0f}: no wrapping; 0.0f: wrap to end of window (or column); {@code > 0.0f}: wrap at 'wrap_posX'
984-
* position in window local space
987+
* Push Word-wrapping positions for Text*() commands. {@code < 0.0f}: no wrapping; 0.0f: wrap to end of window (or column); {@code > 0.0f}: wrap at
988+
* 'wrap_posX' position in window local space
985989
*/
986990
public static native void pushTextWrapPos(float wrapLocalPosX); /*
987991
ImGui::PushTextWrapPos(wrapLocalPosX);
@@ -1018,6 +1022,9 @@ public static ImFont getFont() {
10181022
// - By "cursor" we mean the current output position.
10191023
// - The typical widget behavior is to output themselves at the current cursor position, then move the cursor one line down.
10201024
// - You can call SameLine() between widgets to undo the last carriage return and output at the right of the preceeding widget.
1025+
// - Attention! We currently have inconsistencies between window-local and absolute positions we will aim to fix with future API:
1026+
// Window-local coordinates: SameLine(), GetCursorPos(), SetCursorPos(), GetCursorStartPos(), GetContentRegionMax(), GetWindowContentRegion*(), PushTextWrapPos()
1027+
// Absolute coordinate: GetCursorScreenPos(), SetCursorScreenPos(), all ImDrawList:: functions.
10211028

10221029
/**
10231030
* Separator, generally horizontal. inside a menu bar or in horizontal layout mode, this becomes a vertical separator.
@@ -3568,7 +3575,8 @@ public static void listBox(String label, ImInt currentItem, String[] items, int
35683575

35693576
// Widgets: Menus
35703577
// - Use BeginMenuBar() on a window ImGuiWindowFlags_MenuBar to append to its menu bar.
3571-
// - Use BeginMainMenuBar() to create a menu bar at the top of the screen.
3578+
// - Use BeginMainMenuBar() to create a menu bar at the top of the screen and append to it.
3579+
// - Use BeginMenu() to create a menu. You can call BeginMenu() multiple time with the same identifier to append more items to it.
35723580

35733581
/**
35743582
* Append to menu-bar of current window (requires ImGuiWindowFlags_MenuBar flag set on parent window).
@@ -3881,7 +3889,7 @@ public static boolean beginPopupModal(String name, ImBool pOpen, int imGuiWindow
38813889
// - You can also use SameLine(posX) to mimic simplified columns.
38823890
// - The columns API is work-in-progress and rather lacking (columns are arguably the worst part of dear imgui at the moment!)
38833891
// - There is a maximum of 64 columns.
3884-
// - Currently working on new 'Tables' api which will replace columns (see GitHub #2957)
3892+
// - Currently working on new 'Tables' api which will replace columns around Q2 2020 (see GitHub #2957).
38853893

38863894
public static native void columns(); /*
38873895
ImGui::Columns();
@@ -4108,7 +4116,7 @@ public static boolean beginTabItem(String label, ImBool pOpen, int imGuiTabBarFl
41084116
*/
41094117

41104118
// Drag and Drop
4111-
// [BETA API] API may evolve!
4119+
// - [BETA API] API may evolve!
41124120

41134121
/**
41144122
* Call when the current item is active. If this return true, you can call SetDragDropPayload() + EndDragDropSource()
@@ -4427,26 +4435,6 @@ public static ImDrawList getForegroundDrawList() {
44274435

44284436
// TODO SetStateStorage, GetStateStorage
44294437

4430-
public static native void calcTextSize(ImVec2 dstImVec2, String text); /*
4431-
ImVec2 src = ImGui::CalcTextSize(text);
4432-
Jni::ImVec2Cpy(env, src, dstImVec2);
4433-
*/
4434-
4435-
public static native void calcTextSize(ImVec2 dstImVec2, String text, String textEnd); /*
4436-
ImVec2 src = ImGui::CalcTextSize(text, textEnd);
4437-
Jni::ImVec2Cpy(env, src, dstImVec2);
4438-
*/
4439-
4440-
public static native void calcTextSize(ImVec2 dstImVec2, String text, String textEnd, boolean hideTextAfterDoubleHas); /*
4441-
ImVec2 src = ImGui::CalcTextSize(text, textEnd, hideTextAfterDoubleHas);
4442-
Jni::ImVec2Cpy(env, src, dstImVec2);
4443-
*/
4444-
4445-
public static native void calcTextSize(ImVec2 dstImVec2, String text, String textEnd, boolean hideTextAfterDoubleHas, float wrapWidth); /*
4446-
ImVec2 src = ImGui::CalcTextSize(text, textEnd, hideTextAfterDoubleHas, wrapWidth);
4447-
Jni::ImVec2Cpy(env, src, dstImVec2);
4448-
*/
4449-
44504438
/**
44514439
* Calculate coarse clipping for large list of evenly sized items. Prefer using the ImGuiListClipper higher-level helper if you can.
44524440
*/
@@ -4475,6 +4463,28 @@ public static ImDrawList getForegroundDrawList() {
44754463
ImGui::EndChildFrame();
44764464
*/
44774465

4466+
// Text Utilities
4467+
4468+
public static native void calcTextSize(ImVec2 dstImVec2, String text); /*
4469+
ImVec2 src = ImGui::CalcTextSize(text);
4470+
Jni::ImVec2Cpy(env, src, dstImVec2);
4471+
*/
4472+
4473+
public static native void calcTextSize(ImVec2 dstImVec2, String text, String textEnd); /*
4474+
ImVec2 src = ImGui::CalcTextSize(text, textEnd);
4475+
Jni::ImVec2Cpy(env, src, dstImVec2);
4476+
*/
4477+
4478+
public static native void calcTextSize(ImVec2 dstImVec2, String text, String textEnd, boolean hideTextAfterDoubleHas); /*
4479+
ImVec2 src = ImGui::CalcTextSize(text, textEnd, hideTextAfterDoubleHas);
4480+
Jni::ImVec2Cpy(env, src, dstImVec2);
4481+
*/
4482+
4483+
public static native void calcTextSize(ImVec2 dstImVec2, String text, String textEnd, boolean hideTextAfterDoubleHas, float wrapWidth); /*
4484+
ImVec2 src = ImGui::CalcTextSize(text, textEnd, hideTextAfterDoubleHas, wrapWidth);
4485+
Jni::ImVec2Cpy(env, src, dstImVec2);
4486+
*/
4487+
44784488
// Color Utilities
44794489

44804490
public static native void colorConvertU32ToFloat4(long in, ImVec4 dstImVec4); /*
@@ -4722,7 +4732,8 @@ public static ImDrawList getForegroundDrawList() {
47224732
ImGui::CaptureMouseFromApp(wantCaptureMouseValue);
47234733
*/
47244734

4725-
// Clipboard Utilities (also see the LogToClipboard() function to capture or output text data to the clipboard)
4735+
// Clipboard Utilities
4736+
// - Also see the LogToClipboard() function to capture GUI into clipboard, or easily output text data to the clipboard.
47264737

47274738
public static native String getClipboardText(); /*
47284739
return env->NewStringUTF(ImGui::GetClipboardText());

imgui-binding/src/main/java/imgui/ImGuiIO.java

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -649,66 +649,70 @@ void setClipboardTextStub(void* userData, const char* text) {
649649
*/
650650

651651
//------------------------------------------------------------------
652-
// Output - Retrieve after calling NewFrame()
652+
// Output - Updated by NewFrame() or EndFrame()/Render()
653+
// (when reading from the io.WantCaptureMouse, io.WantCaptureKeyboard flags to dispatch your inputs, it is
654+
// generally easier and more correct to use their state BEFORE calling NewFrame(). See FAQ for details!)
653655
//------------------------------------------------------------------
654656

655657
/**
656-
* When io.WantCaptureMouse is true, imgui will use the mouse inputs, do not dispatch them to your main game/application (in both cases, always pass on mouse inputs to imgui).
658+
* Set when Dear ImGui will use mouse inputs, in this case do not dispatch them to your main game/application
659+
* (either way, always pass on mouse inputs to imgui).
657660
* (e.g. unclicked mouse is hovering over an imgui window, widget is active, mouse was clicked over an imgui window, etc.).
658661
*/
659662
public native boolean getWantCaptureMouse(); /*
660663
return ImGui::GetIO().WantCaptureMouse;
661664
*/
662665

663666
/**
664-
* When io.WantCaptureMouse is true, imgui will use the mouse inputs, do not dispatch them to your main game/application (in both cases, always pass on mouse inputs to imgui).
667+
* Set when Dear ImGui will use mouse inputs, in this case do not dispatch them to your main game/application
668+
* (either way, always pass on mouse inputs to imgui).
665669
* (e.g. unclicked mouse is hovering over an imgui window, widget is active, mouse was clicked over an imgui window, etc.).
666670
*/
667671
public native void setWantCaptureMouse(boolean wantCaptureMouse); /*
668672
ImGui::GetIO().WantCaptureMouse = wantCaptureMouse;
669673
*/
670674

671675
/**
672-
* When io.WantCaptureKeyboard is true, imgui will use the keyboard inputs, do not dispatch them to your main game/application (in both cases, always pass keyboard inputs to imgui).
673-
* (e.g. InputText active, or an imgui window is focused and navigation is enabled, etc.).
676+
* Set when Dear ImGui will use keyboard inputs, in this case do not dispatch them to your main game/application
677+
* (either way, always pass keyboard inputs to imgui). (e.g. InputText active, or an imgui window is focused and navigation is enabled, etc.).
674678
*/
675679
public native boolean getWantCaptureKeyboard(); /*
676680
return ImGui::GetIO().WantCaptureKeyboard;
677681
*/
678682

679683
/**
680-
* When io.WantCaptureKeyboard is true, imgui will use the keyboard inputs, do not dispatch them to your main game/application (in both cases, always pass keyboard inputs to imgui).
681-
* (e.g. InputText active, or an imgui window is focused and navigation is enabled, etc.).
684+
* Set when Dear ImGui will use keyboard inputs, in this case do not dispatch them to your main game/application
685+
* (either way, always pass keyboard inputs to imgui). (e.g. InputText active, or an imgui window is focused and navigation is enabled, etc.).
682686
*/
683687
public native void setWantCaptureKeyboard(boolean wantCaptureKeyboard); /*
684688
ImGui::GetIO().WantCaptureKeyboard = wantCaptureKeyboard;
685689
*/
686690

687691
/**
688-
* Mobile/console: when io.WantTextInput is true, you may display an on-screen keyboard.
689-
* This is set by ImGui when it wants textual keyboard input to happen (e.g. when a InputText widget is active).
692+
* Mobile/console: when set, you may display an on-screen keyboard.
693+
* This is set by Dear ImGui when it wants textual keyboard input to happen (e.g. when a InputText widget is active).
690694
*/
691695
public native boolean getWantTextInput(); /*
692696
return ImGui::GetIO().WantTextInput;
693697
*/
694698

695699
/**
696-
* Mobile/console: when io.WantTextInput is true, you may display an on-screen keyboard.
697-
* This is set by ImGui when it wants textual keyboard input to happen (e.g. when a InputText widget is active).
700+
* Mobile/console: when set, you may display an on-screen keyboard.
701+
* This is set by Dear ImGui when it wants textual keyboard input to happen (e.g. when a InputText widget is active).
698702
*/
699703
public native void setWantTextInput(boolean wantTextInput); /*
700704
ImGui::GetIO().WantTextInput = wantTextInput;
701705
*/
702706

703707
/**
704-
* MousePos has been altered, back-end should reposition mouse on next frame. Set only when ImGuiConfigFlags_NavEnableSetMousePos flag is enabled.
708+
* MousePos has been altered, back-end should reposition mouse on next frame. Rarely used! Set only when ImGuiConfigFlags_NavEnableSetMousePos flag is enabled.
705709
*/
706710
public native boolean getWantSetMousePos(); /*
707711
return ImGui::GetIO().WantSetMousePos;
708712
*/
709713

710714
/**
711-
* MousePos has been altered, back-end should reposition mouse on next frame. Set only when ImGuiConfigFlags_NavEnableSetMousePos flag is enabled.
715+
* MousePos has been altered, back-end should reposition mouse on next frame. Rarely used! Set only when ImGuiConfigFlags_NavEnableSetMousePos flag is enabled.
712716
*/
713717
public native void setWantSetMousePos(boolean wantSetMousePos); /*
714718
ImGui::GetIO().WantSetMousePos = wantSetMousePos;
@@ -717,7 +721,7 @@ void setClipboardTextStub(void* userData, const char* text) {
717721
/**
718722
* When manual .ini load/save is active (io.IniFilename == NULL),
719723
* this will be set to notify your application that you can call SaveIniSettingsToMemory() and save yourself.
720-
* IMPORTANT: You need to clear io.WantSaveIniSettings yourself.
724+
* Important: clear io.WantSaveIniSettings yourself after saving!
721725
*/
722726
public native boolean getWantSaveIniSettings(); /*
723727
return ImGui::GetIO().WantSaveIniSettings;
@@ -726,49 +730,53 @@ void setClipboardTextStub(void* userData, const char* text) {
726730
/**
727731
* When manual .ini load/save is active (io.IniFilename == NULL),
728732
* this will be set to notify your application that you can call SaveIniSettingsToMemory() and save yourself.
729-
* IMPORTANT: You need to clear io.WantSaveIniSettings yourself.
733+
* Important: clear io.WantSaveIniSettings yourself after saving!
730734
*/
731735
public native void setWantSaveIniSettings(boolean wantSaveIniSettings); /*
732736
ImGui::GetIO().WantSaveIniSettings = wantSaveIniSettings;
733737
*/
734738

735739
/**
736-
* Directional navigation is currently allowed (will handle ImGuiKey_NavXXX events) = a window is focused and it doesn't use the ImGuiWindowFlags_NoNavInputs flag.
740+
* Keyboard/Gamepad navigation is currently allowed (will handle ImGuiKey_NavXXX events) = a window is focused
741+
* and it doesn't use the ImGuiWindowFlags_NoNavInputs flag.
737742
*/
738743
public native boolean getNavActive(); /*
739744
return ImGui::GetIO().NavActive;
740745
*/
741746

742747
/**
743-
* Directional navigation is currently allowed (will handle ImGuiKey_NavXXX events) = a window is focused and it doesn't use the ImGuiWindowFlags_NoNavInputs flag.
748+
* Keyboard/Gamepad navigation is currently allowed (will handle ImGuiKey_NavXXX events) = a window is focused
749+
* and it doesn't use the ImGuiWindowFlags_NoNavInputs flag.
744750
*/
745751
public native void setNavActive(boolean navActive); /*
746752
ImGui::GetIO().NavActive = navActive;
747753
*/
748754

749755
/**
750-
* Directional navigation is visible and allowed (will handle ImGuiKey_NavXXX events).
756+
* Keyboard/Gamepad navigation is visible and allowed (will handle ImGuiKey_NavXXX events).
751757
*/
752758
public native boolean getNavVisible(); /*
753759
return ImGui::GetIO().NavVisible;
754760
*/
755761

756762
/**
757-
* Directional navigation is visible and allowed (will handle ImGuiKey_NavXXX events).
763+
* Keyboard/Gamepad navigation is visible and allowed (will handle ImGuiKey_NavXXX events).
758764
*/
759765
public native void setNavVisible(boolean navVisible); /*
760766
ImGui::GetIO().NavVisible = navVisible;
761767
*/
762768

763769
/**
764-
* Application framerate estimation, in frame per second. Solely for convenience. Rolling average estimation based on IO.DeltaTime over 120 frames
770+
* Application framerate estimate, in frame per second. Solely for convenience. Rolling average estimation based on io.DeltaTime over 120 frames.
771+
* Solely for convenience. Rolling average estimation based on IO.DeltaTime over 120 frames
765772
*/
766773
public native float getFramerate(); /*
767774
return ImGui::GetIO().Framerate;
768775
*/
769776

770777
/**
771-
* Application framerate estimation, in frame per second. Solely for convenience. Rolling average estimation based on IO.DeltaTime over 120 frames
778+
* Application framerate estimate, in frame per second. Solely for convenience. Rolling average estimation based on io.DeltaTime over 120 frames.
779+
* Solely for convenience. Rolling average estimation based on IO.DeltaTime over 120 frames
772780
*/
773781
public native void setFramerate(float framerate); /*
774782
ImGui::GetIO().Framerate = framerate;
@@ -868,6 +876,13 @@ void setClipboardTextStub(void* userData, const char* text) {
868876
ImGui::GetIO().AddInputCharacter((unsigned int)c);
869877
*/
870878

879+
/**
880+
* Queue new character input from an UTF-16 character, it can be a surrogate
881+
*/
882+
public native void addInputCharacterUTF16(short c); /*
883+
ImGui::GetIO().AddInputCharacterUTF16((ImWchar16)c);
884+
*/
885+
871886
/**
872887
* Queue new characters input from an UTF-8 string.
873888
*/

0 commit comments

Comments
 (0)