diff --git a/imgui-binding/src/main/java/imgui/ImFont.java b/imgui-binding/src/main/java/imgui/ImFont.java index 2ebf82a..f4c867b 100644 --- a/imgui-binding/src/main/java/imgui/ImFont.java +++ b/imgui-binding/src/main/java/imgui/ImFont.java @@ -73,35 +73,6 @@ public final class ImFont extends ImGuiStructDestroyable { return (intptr_t)IM_FONT->FallbackGlyph; */ - /** - * Offset font rendering by xx pixels - */ - public native void getDisplayOffset(ImVec2 dstImVec2); /* - Jni::ImVec2Cpy(env, &IM_FONT->DisplayOffset, dstImVec2); - */ - - /** - * Offset font rendering by xx pixels - */ - public native float getDisplayOffsetX(); /* - return IM_FONT->DisplayOffset.x; - */ - - /** - * Offset font rendering by xx pixels - */ - public native float getDisplayOffsetY(); /* - return IM_FONT->DisplayOffset.y; - */ - - /** - * Offset font rendering by xx pixels - */ - public native void setDisplayOffset(float x, float y); /* - IM_FONT->DisplayOffset.x = x; - IM_FONT->DisplayOffset.y = y; - */ - // TODO ContainerAtlas, ConfigData /** diff --git a/imgui-binding/src/main/java/imgui/ImGui.java b/imgui-binding/src/main/java/imgui/ImGui.java index 7237cfd..532b5c7 100644 --- a/imgui-binding/src/main/java/imgui/ImGui.java +++ b/imgui-binding/src/main/java/imgui/ImGui.java @@ -4018,29 +4018,29 @@ public class ImGui { /** * Helper to open popup when clicked on last item. return true when just opened. (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors) */ - public static native void openPopupContextItem(); /* - ImGui::OpenPopupContextItem(); + public static native void openPopupOnItemClick(); /* + ImGui::OpenPopupOnItemClick(); */ /** * Helper to open popup when clicked on last item. return true when just opened. (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors) */ - public static native void openPopupContextItem(String strId); /* - ImGui::OpenPopupContextItem(strId); + public static native void openPopupOnItemClick(String strId); /* + ImGui::OpenPopupOnItemClick(strId); */ /** * Helper to open popup when clicked on last item. return true when just opened. (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors) */ - public static native void openPopupContextItem(int imGuiPopupFlags); /* - ImGui::OpenPopupContextItem(NULL, imGuiPopupFlags); + public static native void openPopupOnItemClick(int imGuiPopupFlags); /* + ImGui::OpenPopupOnItemClick(NULL, imGuiPopupFlags); */ /** * Helper to open popup when clicked on last item. return true when just opened. (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors) */ - public static native void openPopupContextItem(String strId, int imGuiPopupFlags); /* - ImGui::OpenPopupContextItem(strId, imGuiPopupFlags); + public static native void openPopupOnItemClick(String strId, int imGuiPopupFlags); /* + ImGui::OpenPopupOnItemClick(strId, imGuiPopupFlags); */ /** @@ -4050,44 +4050,11 @@ public class ImGui { ImGui::CloseCurrentPopup(); */ - /** - * Helper to open popup when clicked on last item (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors). - * return true when just opened. - * - * @deprecated use {@link ImGui#openPopupContextItem()} - * @since 1.77 - */ - public static native boolean openPopupOnItemClick(); /* - return ImGui::OpenPopupOnItemClick(); - */ - - /** - * Helper to open popup when clicked on last item (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors). - * return true when just opened. - * - * @deprecated use {@link ImGui#openPopupContextItem(String)} - * @since 1.77 - */ - public static native boolean openPopupOnItemClick(String strId); /* - return ImGui::OpenPopupOnItemClick(strId); - */ - - /** - * Helper to open popup when clicked on last item (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors). - * return true when just opened. - * - * @deprecated use {@link ImGui#openPopupContextItem(String, int)} - * @since 1.77 - */ - public static native boolean openPopupOnItemClick(String strId, int mouseButton); /* - return ImGui::OpenPopupOnItemClick(strId, mouseButton); - */ - // Popups: open+begin combined functions helpers // - Helpers to do OpenPopup+BeginPopup where the Open action is triggered by e.g. hovering an item and right-clicking. // - They are convenient to easily create context menus, hence the name. // - IMPORTANT: Notice that BeginPopupContextXXX takes ImGuiPopupFlags just like OpenPopup() and unlike BeginPopup(). For full consistency, we may add ImGuiWindowFlags to the BeginPopupContextXXX functions in the future. - // - We exceptionally default their flags to 1 (== ImGuiPopupFlags_MouseButtonRight) for backward compatibility with older API taking 'int mouse_button = 1' parameter. Passing a mouse button to ImGuiPopupFlags is guaranteed to be legal. + // - IMPORTANT: we exceptionally default their flags to 1 (== ImGuiPopupFlags_MouseButtonRight) for backward compatibility with older API taking 'int mouse_button = 1' parameter, so if you add other flags remember to re-add the ImGuiPopupFlags_MouseButtonRight. /** * Open+begin popup when clicked on last item. if you can pass a NULL str_id only if the previous item had an id. @@ -4329,23 +4296,23 @@ public class ImGui { /** * Create a Tab. Returns true if the Tab is selected. */ - public static boolean beginTabItem(String label, int imGuiTabBarFlags) { - return nBeginTabItem(label, imGuiTabBarFlags); + public static boolean beginTabItem(String label, int imGuiTabItemFlags) { + return nBeginTabItem(label, imGuiTabItemFlags); } /** * Create a Tab. Returns true if the Tab is selected. */ - public static boolean beginTabItem(String label, ImBoolean pOpen, int imGuiTabBarFlags) { - return nBeginTabItem(label, pOpen.getData(), imGuiTabBarFlags); + public static boolean beginTabItem(String label, ImBoolean pOpen, int imGuiTabItemFlags) { + return nBeginTabItem(label, pOpen.getData(), imGuiTabItemFlags); } - private static native boolean nBeginTabItem(String label, int imGuiTabBarFlags); /* - return ImGui::BeginTabItem(label, NULL, imGuiTabBarFlags); + private static native boolean nBeginTabItem(String label, int imGuiTabItemFlags); /* + return ImGui::BeginTabItem(label, NULL, imGuiTabItemFlags); */ - private static native boolean nBeginTabItem(String label, boolean[] pOpen, int imGuiTabBarFlags); /* - return ImGui::BeginTabItem(label, &pOpen[0], imGuiTabBarFlags); + private static native boolean nBeginTabItem(String label, boolean[] pOpen, int imGuiTabItemFlags); /* + return ImGui::BeginTabItem(label, &pOpen[0], imGuiTabItemFlags); */ /** @@ -4355,6 +4322,20 @@ public class ImGui { ImGui::EndTabItem(); */ + /** + * Create a Tab behaving like a button. return true when clicked. cannot be selected in the tab bar. + */ + public static native boolean tabItemButton(String label); /* + return ImGui::TabItemButton(label); + */ + + /** + * Create a Tab behaving like a button. return true when clicked. cannot be selected in the tab bar. + */ + public static native boolean tabItemButton(String label, int imGuiTabItemFlags); /* + return ImGui::TabItemButton(label, imGuiTabItemFlags); + */ + /** * Notify TabBar or Docking system of a closed tab/window ahead (useful to reduce visual flicker on reorderable tab bars). * For tab-bar: call after BeginTabBar() and before Tab submissions. Otherwise call with a window name. diff --git a/imgui-binding/src/main/java/imgui/ImGuiListClipper.java b/imgui-binding/src/main/java/imgui/ImGuiListClipper.java index 215d878..c4b0b00 100644 --- a/imgui-binding/src/main/java/imgui/ImGuiListClipper.java +++ b/imgui-binding/src/main/java/imgui/ImGuiListClipper.java @@ -4,20 +4,23 @@ import imgui.callback.ImListClipperCallback; /** * Helper: Manually clip large list of items. - * If you are submitting lots of evenly spaced items and you have a random access to the list, you can perform coarse clipping based on visibility to save yourself from processing those items at all. + * If you are submitting lots of evenly spaced items and you have a random access to the list, you can perform coarse + * clipping based on visibility to save yourself from processing those items at all. * The clipper calculates the range of visible items and advance the cursor to compensate for the non-visible items we have skipped. - * ImGui already clip items based on their bounds but it needs to measure text size to do so. Coarse clipping before submission makes this cost and your own data fetching/submission cost null. - * Usage: + * (Dear ImGui already clip items based on their bounds but it needs to measure text size to do so, whereas manual coarse clipping before submission makes this cost and your own data fetching/submission cost almost null) *
- *     ImGuiListClipper clipper(1000);  // we have 1000 elements, evenly spaced.
- *     while (clipper.Step())
- *         for (int i = clipper.DisplayStart; i {@code <} clipper.DisplayEnd; i++)
- *             ImGui::Text("line number %d", i);
+ *   ImGuiListClipper clipper;
+ *   clipper.Begin(1000);         // We have 1000 elements, evenly spaced.
+ *   while (clipper.Step())
+ *       for (int i = clipper.DisplayStart; i {@code <} clipper.DisplayEnd; i++)
+ *           ImGui::Text("line number %d", i);
  * 
- * - Step 0: the clipper let you process the first element, regardless of it being visible or not, so we can measure the element height (step skipped if we passed a known height as second arg to constructor). - * - Step 1: the clipper infer height from first element, calculate the actual range of elements to display, and position the cursor before the first element. - * - (Step 2: empty step only required if an explicit items_height was passed to constructor or Begin() and user call Step(). Does nothing and switch to Step 3.) - * - Step 3: the clipper validate that we have reached the expected Y position (corresponding to element DisplayEnd), advance the cursor to the end of the list and then returns 'false' to end the loop. + * Generally what happens is: + * - Clipper lets you process the first element (DisplayStart = 0, DisplayEnd = 1) regardless of it being visible or not. + * - User code submit one element. + * - Clipper can measure the height of the first element + * - Clipper calculate the actual range of elements to display based on the current clipping rectangle, position the cursor before the first visible element. + * - User code submit visible elements. *

* BINDING NOTICE: * It's impossible to implement the same API like in the original. Method {@link #forEach(int, int, ImListClipperCallback)} could be used instead. @@ -55,7 +58,8 @@ public final class ImGuiListClipper { * @param callback action to do in iterations */ public static native void forEach(int itemsCount, int itemsHeight, ImListClipperCallback callback); /* - ImGuiListClipper clipper(itemsCount); + ImGuiListClipper clipper; + clipper.Begin(itemsCount, itemsHeight); while (clipper.Step()) { for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) { Jni::CallImListClipperCallback(env, callback, i); diff --git a/imgui-binding/src/main/java/imgui/ImGuiStyle.java b/imgui-binding/src/main/java/imgui/ImGuiStyle.java index 0088c4f..f16490b 100644 --- a/imgui-binding/src/main/java/imgui/ImGuiStyle.java +++ b/imgui-binding/src/main/java/imgui/ImGuiStyle.java @@ -512,16 +512,16 @@ public final class ImGuiStyle extends ImGuiStructDestroyable { * Minimum width for close button to appears on an unselected tab when hovered. * Set to 0.0f to always show when hovering, set to FLT_MAX to never show close button unless selected. */ - public native float getTabMinWidthForUnselectedCloseButton(); /* - return IMGUI_STYLE->TabMinWidthForUnselectedCloseButton; + public native float getTabMinWidthForCloseButton(); /* + return IMGUI_STYLE->TabMinWidthForCloseButton; */ /** * Minimum width for close button to appears on an unselected tab when hovered. * Set to 0.0f to always show when hovering, set to FLT_MAX to never show close button unless selected. */ - public native void setTabMinWidthForUnselectedCloseButton(float tabMinWidthForUnselectedCloseButton); /* - IMGUI_STYLE->TabMinWidthForUnselectedCloseButton = tabMinWidthForUnselectedCloseButton; + public native void setTabMinWidthForCloseButton(float tabMinWidthForCloseButton); /* + IMGUI_STYLE->TabMinWidthForCloseButton = tabMinWidthForCloseButton; */ /** diff --git a/imgui-binding/src/main/java/imgui/flag/ImGuiConfigFlags.java b/imgui-binding/src/main/java/imgui/flag/ImGuiConfigFlags.java index 05737e7..c1a458a 100644 --- a/imgui-binding/src/main/java/imgui/flag/ImGuiConfigFlags.java +++ b/imgui-binding/src/main/java/imgui/flag/ImGuiConfigFlags.java @@ -47,7 +47,7 @@ public final class ImGuiConfigFlags { // When using viewports it is recommended that your default value for ImGuiCol_WindowBg is opaque (Alpha=1.0) so transition to a viewport won't be noticeable. /** - * Viewport enable flags (require both ImGuiConfigFlags_PlatformHasViewports + ImGuiConfigFlags_RendererHasViewports set by the respective back-ends) + * Viewport enable flags (require both ImGuiBackendFlags_PlatformHasViewports + ImGuiBackendFlags_RendererHasViewports set by the respective back-ends) */ public static final int ViewportsEnable = 1 << 10; /** diff --git a/imgui-binding/src/main/java/imgui/flag/ImGuiPopupFlags.java b/imgui-binding/src/main/java/imgui/flag/ImGuiPopupFlags.java index 587a5da..0691205 100644 --- a/imgui-binding/src/main/java/imgui/flag/ImGuiPopupFlags.java +++ b/imgui-binding/src/main/java/imgui/flag/ImGuiPopupFlags.java @@ -14,15 +14,15 @@ public final class ImGuiPopupFlags { public static final int None = 0; /** - * For BeginPopupContext*(): open on Left Mouse release. Guaranted to always be == 0 (same as ImGuiMouseButton_Left) + * For BeginPopupContext*(): open on Left Mouse release. Guaranteed to always be == 0 (same as ImGuiMouseButton_Left) */ public static final int MouseButtonLeft = 0; /** - * For BeginPopupContext*(): open on Right Mouse release. Guaranted to always be == 1 (same as ImGuiMouseButton_Right) + * For BeginPopupContext*(): open on Right Mouse release. Guaranteed to always be == 1 (same as ImGuiMouseButton_Right) */ public static final int MouseButtonRight = 1; /** - * For BeginPopupContext*(): open on Middle Mouse release. Guaranted to always be == 2 (same as ImGuiMouseButton_Middle) + * For BeginPopupContext*(): open on Middle Mouse release. Guaranteed to always be == 2 (same as ImGuiMouseButton_Middle) */ public static final int MouseButtonMiddle = 2; public static final int MouseButtonMask = 0x1F; diff --git a/imgui-binding/src/main/java/imgui/flag/ImGuiSliderFlags.java b/imgui-binding/src/main/java/imgui/flag/ImGuiSliderFlags.java index eb6e0ce..9d965e7 100644 --- a/imgui-binding/src/main/java/imgui/flag/ImGuiSliderFlags.java +++ b/imgui-binding/src/main/java/imgui/flag/ImGuiSliderFlags.java @@ -8,7 +8,7 @@ public final class ImGuiSliderFlags { /** * Clamp value to min/max bounds when input manually with CTRL+Click. By default CTRL+Click allows going out of bounds. */ - public static final int ClampOnInput = 1 << 4; + public static final int AlwaysClamp = 1 << 4; /** * Make the widget logarithmic (linear otherwise). * Consider using ImGuiSliderFlags_NoRoundToFormat with this if using a format-string with small amount of digits. diff --git a/imgui-binding/src/main/java/imgui/flag/ImGuiTabItemFlags.java b/imgui-binding/src/main/java/imgui/flag/ImGuiTabItemFlags.java index 9784ad8..3e9863c 100644 --- a/imgui-binding/src/main/java/imgui/flag/ImGuiTabItemFlags.java +++ b/imgui-binding/src/main/java/imgui/flag/ImGuiTabItemFlags.java @@ -30,4 +30,16 @@ public final class ImGuiTabItemFlags { * Disable tooltip for the given tab */ public static final int NoTooltip = 1 << 4; + /** + * Disable reordering this tab or having another tab cross over this tab + */ + public static final int NoReorder = 1 << 5; + /** + * Enforce the tab position to the left of the tab bar (after the tab list popup button) + */ + public static final int Leading = 1 << 6; + /** + * Enforce the tab position to the right of the tab bar (before the scrolling buttons) + */ + public static final int Trailing = 1 << 7; } diff --git a/imgui-binding/src/main/java/imgui/internal/ImRect.java b/imgui-binding/src/main/java/imgui/internal/ImRect.java index f0c5569..3f1d580 100644 --- a/imgui-binding/src/main/java/imgui/internal/ImRect.java +++ b/imgui-binding/src/main/java/imgui/internal/ImRect.java @@ -8,7 +8,7 @@ import java.util.Objects; * Helper: ImRect (2D axis aligned bounding-box) * NB: we can't rely on ImVec2 math operators being available here! */ -public final class ImRect { +public final class ImRect implements Cloneable { /** * Upper-left */ @@ -35,6 +35,10 @@ public final class ImRect { max.y = y2; } + public ImRect(final ImRect imRect) { + this(imRect.min, imRect.max); + } + @Override public String toString() { return "ImRect{" @@ -61,4 +65,9 @@ public final class ImRect { public int hashCode() { return Objects.hash(min, max); } + + @Override + public ImRect clone() { + return new ImRect(this); + } } diff --git a/imgui-lwjgl3/src/main/java/imgui/glfw/ImGuiImplGlfw.java b/imgui-lwjgl3/src/main/java/imgui/glfw/ImGuiImplGlfw.java index c455c9f..72f212e 100644 --- a/imgui-lwjgl3/src/main/java/imgui/glfw/ImGuiImplGlfw.java +++ b/imgui-lwjgl3/src/main/java/imgui/glfw/ImGuiImplGlfw.java @@ -460,10 +460,19 @@ public class ImGuiImplGlfw { final float mainSizeY = vidMode.height(); glfwGetMonitorWorkarea(monitor, monitorWorkAreaX, monitorWorkAreaY, monitorWorkAreaWidth, monitorWorkAreaHeight); - final float workPosX = monitorWorkAreaX[0]; - final float workPosY = monitorWorkAreaY[0]; - final float workSizeX = monitorWorkAreaWidth[0]; - final float workSizeY = monitorWorkAreaHeight[0]; + + float workPosX = 0; + float workPosY = 0; + float workSizeX = 0; + float workSizeY = 0; + + // Workaround a small GLFW issue reporting zero on monitor changes: https://github.com/glfw/glfw/pull/1761 + if (monitorWorkAreaWidth[0] > 0 && monitorWorkAreaHeight[0] > 0) { + workPosX = monitorWorkAreaX[0]; + workPosY = monitorWorkAreaY[0]; + workSizeX = monitorWorkAreaWidth[0]; + workSizeY = monitorWorkAreaHeight[0]; + } // Warning: the validity of monitor DPI information on Windows depends on the application DPI awareness settings, // which generally needs to be set in the manifest or at runtime.