Skip to content

Commit eed23db

Browse files
committed
Update binding API to Dear ImGui v1.75
1 parent 14bb10f commit eed23db

File tree

7 files changed

+102
-51
lines changed

7 files changed

+102
-51
lines changed

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

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ public final class ImDrawList {
105105

106106
// Primitives
107107
// - For rectangular primitives, "pMin" and "pMax" represent the upper-left and lower-right corners.
108+
// - For circle primitives, use "num_segments == 0" to automatically calculate tessellation (preferred).
109+
// In future versions we will use textures to provide cheaper and higher-quality circles.
110+
// Use AddNgon() and AddNgonFilled() functions if you need to guaranteed a specific number of sides.
108111

109112
public native void addLine(float p1X, float p1Y, float p2X, float p2Y, int col); /*
110113
getDrawList(env->GetIntField(object, drawListTypeID))->AddLine(ImVec2(p1X, p1Y), ImVec2(p2X, p2Y), col);
@@ -190,6 +193,18 @@ public final class ImDrawList {
190193
getDrawList(env->GetIntField(object, drawListTypeID))->AddCircleFilled(ImVec2(centreX, centreY), radius, col, numSegments);
191194
*/
192195

196+
public native void AddNgon(float centreX, float centreY, float radius, int col, int numSegments); /*
197+
getDrawList(env->GetIntField(object, drawListTypeID))->AddNgon(ImVec2(centreX, centreY), radius, col, numSegments);
198+
*/
199+
200+
public native void AddNgon(float centreX, float centreY, float radius, int col, int numSegments, float thickness); /*
201+
getDrawList(env->GetIntField(object, drawListTypeID))->AddNgon(ImVec2(centreX, centreY), radius, col, numSegments, thickness);
202+
*/
203+
204+
public native void AddNgonFilled(float centreX, float centreY, float radius, int col, int numSegments); /*
205+
getDrawList(env->GetIntField(object, drawListTypeID))->AddNgonFilled(ImVec2(centreX, centreY), radius, col, numSegments);
206+
*/
207+
193208
public native void addText(float posX, float posY, int col, String textBegin); /*
194209
getDrawList(env->GetIntField(object, drawListTypeID))->AddText(ImVec2(posX, posY), col, textBegin);
195210
*/
@@ -225,12 +240,12 @@ public final class ImDrawList {
225240
getDrawList(env->GetIntField(object, drawListTypeID))->AddConvexPolyFilled(_points, numPoints, col);
226241
*/
227242

228-
public native void addBezierCurve(float pos0X, float pos0Y, float cp0X, float cp0Y, float cp1X, float cp1Y, float pos1X, float pos1Y, int col, float thickness); /*
229-
getDrawList(env->GetIntField(object, drawListTypeID))->AddBezierCurve(ImVec2(pos0X, pos0Y), ImVec2(cp0X, cp0Y), ImVec2(cp1X, cp1Y), ImVec2(pos1X, pos1Y), col, thickness);
243+
public native void addBezierCurve(float p1X, float p1Y, float p2X, float p2Y, float p3X, float p3Y, float p4X, float p4Y, int col, float thickness); /*
244+
getDrawList(env->GetIntField(object, drawListTypeID))->AddBezierCurve(ImVec2(p1X, p1Y), ImVec2(p2X, p2Y), ImVec2(p3X, p3Y), ImVec2(p4X, p4Y), col, thickness);
230245
*/
231246

232-
public native void addBezierCurve(float pos0X, float pos0Y, float cp0X, float cp0Y, float cp1X, float cp1Y, float pos1X, float pos1Y, int col, float thickness, int numSegments); /*
233-
getDrawList(env->GetIntField(object, drawListTypeID))->AddBezierCurve(ImVec2(pos0X, pos0Y), ImVec2(cp0X, cp0Y), ImVec2(cp1X, cp1Y), ImVec2(pos1X, pos1Y), col, thickness, numSegments);
247+
public native void addBezierCurve(float p1X, float p1Y, float p2X, float p2Y, float p3X, float p3Y, float p4X, float p4Y, int col, float thickness, int numSegments); /*
248+
getDrawList(env->GetIntField(object, drawListTypeID))->AddBezierCurve(ImVec2(p1X, p1Y), ImVec2(p2X, p2Y), ImVec2(p3X, p3Y), ImVec2(p4X, p4Y), col, thickness, numSegments);
234249
*/
235250

236251
// Image primitives
@@ -338,8 +353,8 @@ public final class ImDrawList {
338353
getDrawList(env->GetIntField(object, drawListTypeID))->PathArcToFast(ImVec2(centerX, centerY), radius, aMinOf12, aMaxOf12);
339354
*/
340355

341-
public native void pathBezierCurveTo(float p1X, float p1Y, float p2X, float p2Y, float p3X, float p3Y, int numSegments); /*
342-
getDrawList(env->GetIntField(object, drawListTypeID))->PathBezierCurveTo(ImVec2(p1X, p1Y), ImVec2(p2X, p2Y), ImVec2(p3X, p3Y), numSegments);
356+
public native void pathBezierCurveTo(float p2X, float p2Y, float p3X, float p3Y, float p4X, float p4Y, int numSegments); /*
357+
getDrawList(env->GetIntField(object, drawListTypeID))->PathBezierCurveTo(ImVec2(p2X, p2Y), ImVec2(p3X, p3Y), ImVec2(p4X, p4Y), numSegments);
343358
*/
344359

345360
public native void pathRect(float rectMinX, float rectMinY, float rectMaxX, float rectMaxY); /*
@@ -355,8 +370,10 @@ public final class ImDrawList {
355370
*/
356371

357372
// Advanced: Channels
358-
// - Use to split render into layers. By switching channels to can render out-of-order (e.g. submit foreground primitives before background primitives)
359-
// - Use to minimize draw calls (e.g. if going back-and-forth between multiple non-overlapping clipping rectangles, prefer to append into separate channels then merge at the end)
373+
// - Use to split render into layers. By switching channels to can render out-of-order (e.g. submit FG primitives before BG primitives)
374+
// - Use to minimize draw calls (e.g. if going back-and-forth between multiple clipping rectangles, prefer to append into separate channels then merge at the end)
375+
// Prefer using your own persistent copy of ImDrawListSplitter as you can stack them.
376+
// Using the ImDrawList::ChannelsXXXX you cannot stack a split over another.
360377

361378
public native void channelsSplit(int count); /*
362379
ImDrawList* drawList = getDrawList(env->GetIntField(object, drawListTypeID));

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,14 @@ public ImFontGlyph getFallbackGlyph() {
135135
IM_FONT->EllipsisChar = (ImWchar)ellipsisChar;
136136
*/
137137

138+
public native boolean getDirtyLookupTables(); /*
139+
return IM_FONT->DirtyLookupTables;
140+
*/
141+
142+
public native void setDirtyLookupTables(boolean dirtyLookupTables); /*
143+
IM_FONT->DirtyLookupTables = dirtyLookupTables;
144+
*/
145+
138146
/**
139147
* Base font scale, multiplied by the per-window font scale which you can adjust with SetWindowFontScale()
140148
*/
@@ -191,13 +199,5 @@ public ImFontGlyph getFallbackGlyph() {
191199
IM_FONT->MetricsTotalSurface = metricsTotalSurface;
192200
*/
193201

194-
public native boolean getDirtyLookupTables(); /*
195-
return IM_FONT->DirtyLookupTables;
196-
*/
197-
198-
public native void setDirtyLookupTables(boolean dirtyLookupTables); /*
199-
IM_FONT->DirtyLookupTables = dirtyLookupTables;
200-
*/
201-
202202
// TODO methods
203203
}

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

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ public static ImDrawList getWindowDrawList() {
529529
*/
530530

531531
/**
532-
* Set next window background color alpha. helper to easily modify ImGuiCol_WindowBg/ChildBg/PopupBg.
532+
* Set next window background color alpha. helper to easily override the Alpha component of ImGuiCol_WindowBg/ChildBg/PopupBg.
533533
* You may also use ImGuiWindowFlags_NoBackground.
534534
*/
535535
public static native void setNextWindowBgAlpha(float alpha); /*
@@ -1495,6 +1495,7 @@ public static boolean combo(String label, ImInt currentItem, String itemsSeparat
14951495
// - Adjust format string to decorate the value with a prefix, a suffix, or adapt the editing and display precision e.g. "%.3f" -> 1.234; "%5.2f secs" -> 01.23 secs; "Biscuit: %.0f" -> Biscuit: 1; etc.
14961496
// - Speed are per-pixel of mouse movement (vSpeed=0.2f: mouse needs to move by 5 pixels to increase value by 1). For gamepad/keyboard navigation, minimum speed is Max(vSpeed, minimum_step_at_given_precision).
14971497
// - Use vMin < vMax to clamp edits to given limits. Note that CTRL+Click manual input can override those limits.
1498+
// - Use v_max = FLT_MAX / INT_MAX etc to avoid clamping to a maximum, same with v_min = -FLT_MAX / INT_MIN to avoid clamping to a minimum.
14981499
// - Use vMin > vMax to lock edits.
14991500

15001501
public static native boolean dragFloat(String label, float[] v); /*
@@ -2520,7 +2521,7 @@ public static boolean vSliderScalar(String label, float sizeX, float sizeY, int
25202521
*/
25212522

25222523
// Widgets: Input with Keyboard
2523-
// - If you want to use InputText() with a dynamic string type such as std::string or your own, see misc/cpp/imgui_stdlib.h
2524+
// - If you want to use InputText() with std::string or any custom dynamic string type, see misc/cpp/imgui_stdlib.h and comments in imgui_demo.cpp.
25242525
// - Most of the ImGuiInputTextFlags flags are only useful for InputText() and not for InputFloatX, InputIntX, InputDouble etc.
25252526

25262527
/*JNI
@@ -3655,6 +3656,7 @@ public static boolean menuItem(String label, String shortcut, ImBool pSelected,
36553656
// - Unless modal, they can be closed by clicking anywhere outside them, or by pressing ESCAPE.
36563657
// - Their visibility state (~bool) is held internally by imgui instead of being held by the programmer as we are used to with regular Begin() calls.
36573658
// User can manipulate the visibility state by calling OpenPopup().
3659+
// - We default to use the right mouse (ImGuiMouseButton_Right=1) for the Popup Context functions.
36583660
// (*) You can use IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup) to bypass it and detect hovering even when normally blocked by a popup.
36593661
// Those three properties are connected. The library needs to hold their visibility state because it can close popups at any time.
36603662

@@ -3839,7 +3841,8 @@ public static boolean beginPopupModal(String name, ImBool pOpen, int imGuiWindow
38393841
// Columns
38403842
// - You can also use SameLine(posX) to mimic simplified columns.
38413843
// - The columns API is work-in-progress and rather lacking (columns are arguably the worst part of dear imgui at the moment!)
3842-
// - By end of the 2019 we will expose a new 'Table' api which will replace columns.
3844+
// - There is a maximum of 64 columns.
3845+
// - Currently working on new 'Tables' api which will replace columns (see GitHub #2957)
38433846

38443847
public static native void columns(); /*
38453848
ImGui::Columns();
@@ -4451,7 +4454,9 @@ public static ImDrawList getForegroundDrawList() {
44514454
ImGui::ColorConvertHSVtoRGB(hsv[0], hsv[1], hsv[2], rgb[0], rgb[1], rgb[2]);
44524455
*/
44534456

4454-
// Inputs Utilities
4457+
// Inputs Utilities: Keyboard
4458+
// - For 'int user_key_index' you can use your own indices/enums according to how your backend/engine stored them in io.KeysDown[].
4459+
// - We don't know the meaning of those value. You can use GetKeyIndex() to map a ImGuiKey_ value into the user index.
44554460

44564461
/**
44574462
* Map ImGuiKey_* values into user's key index. == io.KeyMap[key]
@@ -4461,22 +4466,21 @@ public static ImDrawList getForegroundDrawList() {
44614466
*/
44624467

44634468
/**
4464-
* Is key being held. == io.KeysDown[userKeyIndex]. note that imgui doesn't know the semantic of each entry of io.KeysDown[].
4465-
* Use your own indices/enums according to how your backend/engine stored them into io.KeysDown[]!
4469+
* Is key being held. == io.KeysDown[user_key_index].
44664470
*/
44674471
public static native boolean isKeyDown(int userKeyIndex); /*
44684472
return ImGui::IsKeyDown(userKeyIndex);
44694473
*/
44704474

44714475
/**
4472-
* Was key pressed (went from !Down to Down). if repeat=true, uses io.KeyRepeatDelay / KeyRepeatRate
4476+
* Was key pressed (went from !Down to Down)? if repeat=true, uses io.KeyRepeatDelay / KeyRepeatRate
44734477
*/
44744478
public static native boolean isKeyPressed(int userKeyIndex); /*
44754479
return ImGui::IsKeyPressed(userKeyIndex);
44764480
*/
44774481

44784482
/**
4479-
* Was key pressed (went from !Down to Down). if repeat=true, uses io.KeyRepeatDelay / KeyRepeatRate
4483+
* Was key pressed (went from !Down to Down)? if repeat=true, uses io.KeyRepeatDelay / KeyRepeatRate
44804484
*/
44814485
public static native boolean isKeyPressed(int userKeyIndex, boolean repeat); /*
44824486
return ImGui::IsKeyPressed(userKeyIndex, repeat);
@@ -4497,6 +4501,29 @@ public static ImDrawList getForegroundDrawList() {
44974501
return ImGui::GetKeyPressedAmount(keyIndex, repeatDelay, rate);
44984502
*/
44994503

4504+
/**
4505+
* Attention: misleading name! manually override io.WantCaptureKeyboard flag next frame (said flag is entirely left for your application to handle).
4506+
* e.g. force capture keyboard when your widget is being hovered.
4507+
* This is equivalent to setting "io.WantCaptureKeyboard = wantCaptureKeyboardValue"; after the next NewFrame() call.
4508+
*/
4509+
public static native void captureKeyboardFromApp(); /*
4510+
ImGui::CaptureKeyboardFromApp();
4511+
*/
4512+
4513+
/**
4514+
* Attention: misleading name! manually override io.WantCaptureKeyboard flag next frame (said flag is entirely left for your application to handle).
4515+
* e.g. force capture keyboard when your widget is being hovered.
4516+
* This is equivalent to setting "io.WantCaptureKeyboard = wantCaptureKeyboardValue"; after the next NewFrame() call.
4517+
*/
4518+
public static native void captureKeyboardFromApp(boolean wantCaptureKeyboardValue); /*
4519+
ImGui::CaptureKeyboardFromApp(wantCaptureKeyboardValue);
4520+
*/
4521+
4522+
// Inputs Utilities: Mouse
4523+
// - To refer to a mouse button, you may use named enums in your code e.g. ImGuiMouseButton_Left, ImGuiMouseButton_Right.
4524+
// - You can also use regular integer: it is forever guaranteed that 0=Left, 1=Right, 2=Middle.
4525+
// - Dragging operations are only reported after mouse has moved a certain distance away from the initial clicking position (see 'lock_threshold' and 'io.MouseDraggingThreshold')
4526+
45004527
/**
45014528
* Is mouse button held (0=left, 1=right, 2=middle)
45024529
*/
@@ -4536,13 +4563,6 @@ public static ImDrawList getForegroundDrawList() {
45364563
return ImGui::IsMouseReleased(button);
45374564
*/
45384565

4539-
/**
4540-
* Is mouse dragging. if lockThreshold {@code < -1.0f} uses io.MouseDraggingThreshold
4541-
*/
4542-
public static native boolean isMouseDragging(); /*
4543-
return ImGui::IsMouseDragging();
4544-
*/
4545-
45464566
/**
45474567
* Is mouse dragging. if lockThreshold {@code < -1.0f} uses io.MouseDraggingThreshold
45484568
*/
@@ -4647,24 +4667,6 @@ public static ImDrawList getForegroundDrawList() {
46474667
ImGui::SetMouseCursor(type);
46484668
*/
46494669

4650-
/**
4651-
* Attention: misleading name! manually override io.WantCaptureKeyboard flag next frame (said flag is entirely left for your application to handle).
4652-
* e.g. force capture keyboard when your widget is being hovered.
4653-
* This is equivalent to setting "io.WantCaptureKeyboard = wantCaptureKeyboardValue"; after the next NewFrame() call.
4654-
*/
4655-
public static native void captureKeyboardFromApp(); /*
4656-
ImGui::CaptureKeyboardFromApp();
4657-
*/
4658-
4659-
/**
4660-
* Attention: misleading name! manually override io.WantCaptureKeyboard flag next frame (said flag is entirely left for your application to handle).
4661-
* e.g. force capture keyboard when your widget is being hovered.
4662-
* This is equivalent to setting "io.WantCaptureKeyboard = wantCaptureKeyboardValue"; after the next NewFrame() call.
4663-
*/
4664-
public static native void captureKeyboardFromApp(boolean wantCaptureKeyboardValue); /*
4665-
ImGui::CaptureKeyboardFromApp(wantCaptureKeyboardValue);
4666-
*/
4667-
46684670
/**
46694671
* Attention: misleading name! manually override io.WantCaptureMouse flag next frame (said flag is entirely left for your application to handle).
46704672
* This is equivalent to setting "io.WantCaptureMouse = wantCaptureMouseValue;" after the next NewFrame() call.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ public void setFontDefault(final ImFont fontDefault) {
319319
*/
320320

321321
// Optional: Access OS clipboard
322-
// (default to use native Win32 clipboard on Windows, otherwise uses a private clipboard. Override to access OS clipboard on other architectures)
322+
// (default to use native Win32 clipIsMouseDraggingboard on Windows, otherwise uses a private clipboard. Override to access OS clipboard on other architectures)
323323

324324
/*JNI
325325
jobject _setClipboardTextCallback = NULL;

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,22 @@ public final class ImGuiStyle {
406406
ImGui::GetStyle().CurveTessellationTol = curveTessellationTol;
407407
*/
408408

409+
/**
410+
* Maximum error (in pixels) allowed when using AddCircle()/AddCircleFilled() or drawing rounded corner rectangles with no explicit segment count specified.
411+
* Decrease for higher quality but more geometry.
412+
*/
413+
public native float getCircleSegmentMaxError(); /*
414+
return ImGui::GetStyle().CircleSegmentMaxError;
415+
*/
416+
417+
/**
418+
* Maximum error (in pixels) allowed when using AddCircle()/AddCircleFilled() or drawing rounded corner rectangles with no explicit segment count specified.
419+
* Decrease for higher quality but more geometry.
420+
*/
421+
public native void setCircleSegmentMaxError(float circleSegmentMaxError); /*
422+
ImGui::GetStyle().CircleSegmentMaxError = circleSegmentMaxError;
423+
*/
424+
409425
// Colors
410426
// BINDING NOTICE: buff is a 2d array with sizes: [ImGuiCol_COUNT][4]
411427
//
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package imgui.enums;
2+
3+
/**
4+
* Identify a mouse button.
5+
* Those values are guaranteed to be stable and we frequently use 0/1 directly. Named enums provided for convenience.
6+
*/
7+
public final class ImGuiMouseButton {
8+
private ImGuiMouseButton() {
9+
}
10+
11+
public static final int Left = 0;
12+
public static final int Right = 1;
13+
public static final int Middle = 2;
14+
public static final int COUNT = 5;
15+
}

imgui-binding/src/main/java/imgui/enums/ImGuiMouseCursor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ private ImGuiMouseCursor() {
1717
public static final int ResizeNESW = 5; // When hovering over the bottom-left corner of a window
1818
public static final int ResizeNWSE = 6; // When hovering over the bottom-right corner of a window
1919
public static final int Hand = 7; // (Unused by Dear ImGui functions. Use for e.g. hyperlinks)
20-
public static final int COUNT = 8;
20+
public static final int NotAllowed = 8; // When hovering something with disallowed interaction. Usually a crossed circle.
21+
public static final int COUNT = 9;
2122
}

0 commit comments

Comments
 (0)