diff --git a/bin/imgui-java.dll b/bin/imgui-java.dll index e0e74ec..9d8edb0 100755 Binary files a/bin/imgui-java.dll and b/bin/imgui-java.dll differ diff --git a/bin/imgui-java64.dll b/bin/imgui-java64.dll index 9d4c599..7c0b8f9 100755 Binary files a/bin/imgui-java64.dll and b/bin/imgui-java64.dll differ diff --git a/bin/libimgui-java.so b/bin/libimgui-java.so index add29f4..135c6f1 100755 Binary files a/bin/libimgui-java.so and b/bin/libimgui-java.so differ diff --git a/bin/libimgui-java64.so b/bin/libimgui-java64.so index efdfecd..f26518f 100755 Binary files a/bin/libimgui-java64.so and b/bin/libimgui-java64.so differ diff --git a/imgui-binding/src/main/java/imgui/ImGuiIO.java b/imgui-binding/src/main/java/imgui/ImGuiIO.java index 08c8cb8..0df4c4e 100644 --- a/imgui-binding/src/main/java/imgui/ImGuiIO.java +++ b/imgui-binding/src/main/java/imgui/ImGuiIO.java @@ -590,6 +590,75 @@ public final class ImGuiIO { ImGui::GetIO().ConfigDockingTransparentPayload = value; */ + // Viewport options (when ImGuiConfigFlags_ViewportsEnable is set) + + /** + * Set to make all floating imgui windows always create their own viewport. + * Otherwise, they are merged into the main host viewports when overlapping it. May also set ImGuiViewportFlags_NoAutoMerge on individual viewport. + */ + public native boolean getConfigViewportsNoAutoMerge(); /* + return ImGui::GetIO().ConfigViewportsNoAutoMerge; + */ + + /** + * Set to make all floating imgui windows always create their own viewport. + * Otherwise, they are merged into the main host viewports when overlapping it. May also set ImGuiViewportFlags_NoAutoMerge on individual viewport. + */ + public native void setConfigViewportsNoAutoMerge(boolean value); /* + ImGui::GetIO().ConfigViewportsNoAutoMerge = value; + */ + + /** + * Disable default OS task bar icon flag for secondary viewports. When a viewport doesn't want a task bar icon, ImGuiViewportFlags_NoTaskBarIcon will be set on it. + */ + public native boolean getConfigViewportsNoTaskBarIcon(); /* + return ImGui::GetIO().ConfigViewportsNoTaskBarIcon; + */ + + /** + * Disable default OS task bar icon flag for secondary viewports. When a viewport doesn't want a task bar icon, ImGuiViewportFlags_NoTaskBarIcon will be set on it. + */ + public native void setConfigViewportsNoTaskBarIcon(boolean value); /* + ImGui::GetIO().ConfigViewportsNoTaskBarIcon = value; + */ + + /** + * [BETA] Disable default OS window decoration flag for secondary viewports. When a viewport doesn't want window decorations, + * ImGuiViewportFlags_NoDecoration will be set on it. Enabling decoration can create subsequent issues at OS levels (e.g. minimum window size). + */ + public native boolean getConfigViewportsNoDecoration(); /* + return ImGui::GetIO().ConfigViewportsNoDecoration; + */ + + /** + * [BETA] Disable default OS window decoration flag for secondary viewports. When a viewport doesn't want window decorations, + * ImGuiViewportFlags_NoDecoration will be set on it. Enabling decoration can create subsequent issues at OS levels (e.g. minimum window size). + */ + public native void setConfigViewportsNoDecoration(boolean value); /* + ImGui::GetIO().ConfigViewportsNoDecoration = value; + */ + + /** + * Disable default OS parenting to main viewport for secondary viewports. + * By default, viewports are marked with ParentViewportId = , + * expecting the platform back-end to setup a parent/child relationship between the OS windows (some back-end may ignore this). + * Set to true if you want the default to be 0, then all viewports will be top-level OS windows. + */ + public native boolean getConfigViewportsNoDefaultParent(); /* + return ImGui::GetIO().ConfigViewportsNoDefaultParent; + */ + + /** + * Disable default OS parenting to main viewport for secondary viewports. + * By default, viewports are marked with ParentViewportId = , + * expecting the platform back-end to setup a parent/child relationship between the OS windows (some back-end may ignore this). + * Set to true if you want the default to be 0, then all viewports will be top-level OS windows. + */ + public native void setConfigViewportsNoDefaultParent(boolean value); /* + ImGui::GetIO().ConfigViewportsNoDefaultParent = value; + */ + + /** * Time elapsed since last frame, in seconds. *

diff --git a/imgui-binding/src/main/java/imgui/ImGuiPlatformIO.java b/imgui-binding/src/main/java/imgui/ImGuiPlatformIO.java index 23a85db..f3edc9f 100644 --- a/imgui-binding/src/main/java/imgui/ImGuiPlatformIO.java +++ b/imgui-binding/src/main/java/imgui/ImGuiPlatformIO.java @@ -191,7 +191,7 @@ public final class ImGuiPlatformIO extends ImGuiStruct { JNIEnv* env = Jni::GetEnv();\ env->SetLongField(jTmpViewport, Jni::GetBindingStructPtrID(), (intptr_t)vp);\ Jni::CallImPlatformFuncViewportSuppImVec2(env, platformCallback##name, jTmpViewport, jTmpImVec2);\ - Jni::ImVec2Cpy(env, jTmpImVec2, dst);\ + Jni::ImVec2Cpy(env, jTmpImVec2, &dst);\ }\ return dst;\ } diff --git a/imgui-binding/src/main/java/imgui/ImGuiViewport.java b/imgui-binding/src/main/java/imgui/ImGuiViewport.java index 952adfd..4f44d0e 100644 --- a/imgui-binding/src/main/java/imgui/ImGuiViewport.java +++ b/imgui-binding/src/main/java/imgui/ImGuiViewport.java @@ -38,14 +38,14 @@ public final class ImGuiViewport extends ImGuiStruct { */ /** - * See ImGuiViewportFlags_. + * See {@link imgui.flag.ImGuiViewportFlags}. */ public native int getFlags(); /* return IMGUI_VIEWPORT->Flags; */ /** - * See ImGuiViewportFlags_. + * See {@link imgui.flag.ImGuiViewportFlags}. */ public native void setFlags(int flags); /* IMGUI_VIEWPORT->Flags = flags; diff --git a/imgui-binding/src/main/java/imgui/glfw/ImGuiImplGlfwNative.java b/imgui-binding/src/main/java/imgui/glfw/ImGuiImplGlfwNative.java new file mode 100644 index 0000000..e69ef28 --- /dev/null +++ b/imgui-binding/src/main/java/imgui/glfw/ImGuiImplGlfwNative.java @@ -0,0 +1,24 @@ +package imgui.glfw; + +final class ImGuiImplGlfwNative { + private ImGuiImplGlfwNative() { + } + + /*JNI + #if defined(_WIN32) + #include + #endif + */ + + // GLFW hack: Hide icon from task bar + // Applied only for windows + static native void win32hideFromTaskBar(long hwndPtr); /* + #if defined(_WIN32) + HWND hwnd = (HWND)hwndPtr; + LONG ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE); + ex_style &= ~WS_EX_APPWINDOW; + ex_style |= WS_EX_TOOLWINDOW; + ::SetWindowLong(hwnd, GWL_EXSTYLE, ex_style); + #endif + */ +} diff --git a/imgui-binding/src/main/native/jni_common.cpp b/imgui-binding/src/main/native/jni_common.cpp index aa2a5ef..52a817a 100644 --- a/imgui-binding/src/main/native/jni_common.cpp +++ b/imgui-binding/src/main/native/jni_common.cpp @@ -48,11 +48,6 @@ namespace Jni dst->y = env->GetFloatField(src, imVec2YID); } - void ImVec2Cpy(JNIEnv* env, jobject src, ImVec2 dst) { - dst.x = env->GetFloatField(src, imVec2XID); - dst.y = env->GetFloatField(src, imVec2YID); - } - void ImVec4Cpy(JNIEnv* env, ImVec4* src, jobject dst) { env->SetFloatField(dst, imVec4XID, src->x); env->SetFloatField(dst, imVec4YID, src->y); diff --git a/imgui-binding/src/main/native/jni_common.h b/imgui-binding/src/main/native/jni_common.h index 056cc92..f8138c3 100644 --- a/imgui-binding/src/main/native/jni_common.h +++ b/imgui-binding/src/main/native/jni_common.h @@ -14,7 +14,6 @@ namespace Jni void ImVec2Cpy(JNIEnv* env, ImVec2 src, jobject dst); void ImVec2Cpy(JNIEnv* env, jobject src, ImVec2* dst); - void ImVec2Cpy(JNIEnv* env, jobject src, ImVec2 dst); void ImVec4Cpy(JNIEnv* env, ImVec4* src, jobject dst); void ImVec4Cpy(JNIEnv* env, ImVec4 src, jobject dst); diff --git a/imgui-lwjgl3/src/main/java/imgui/glfw/ImGuiImplGlfw.java b/imgui-lwjgl3/src/main/java/imgui/glfw/ImGuiImplGlfw.java index 632420d..c2b7138 100644 --- a/imgui-lwjgl3/src/main/java/imgui/glfw/ImGuiImplGlfw.java +++ b/imgui-lwjgl3/src/main/java/imgui/glfw/ImGuiImplGlfw.java @@ -26,6 +26,7 @@ import org.lwjgl.glfw.GLFWErrorCallback; import org.lwjgl.glfw.GLFWKeyCallback; import org.lwjgl.glfw.GLFWMonitorCallback; import org.lwjgl.glfw.GLFWMouseButtonCallback; +import org.lwjgl.glfw.GLFWNativeWin32; import org.lwjgl.glfw.GLFWScrollCallback; import org.lwjgl.glfw.GLFWVidMode; @@ -43,6 +44,8 @@ import static org.lwjgl.system.MemoryUtil.NULL; * modify the rendering routine in the way you'd like. */ public class ImGuiImplGlfw { + protected static final boolean IS_WINDOWS = System.getProperty("os.name", "generic").toLowerCase().contains("win"); + // Pointer of the current GLFW window private long windowPtr; @@ -239,6 +242,10 @@ public class ImGuiImplGlfw { final ImGuiViewport mainViewport = ImGui.getMainViewport(); mainViewport.setPlatformHandle(windowPtr); + if (IS_WINDOWS) { + mainViewport.setPlatformHandleRaw(GLFWNativeWin32.glfwGetWin32Window(windowId)); + } + if ((io.getConfigFlags() & ImGuiConfigFlags.ViewportsEnable) != 0) { initPlatformInterface(); } @@ -528,6 +535,10 @@ public class ImGuiImplGlfw { vp.setPlatformHandle(data.window); + if (IS_WINDOWS) { + vp.setPlatformHandleRaw(GLFWNativeWin32.glfwGetWin32Window(data.window)); + } + glfwSetWindowPos(data.window, (int) vp.getPosX(), (int) vp.getPosY()); // Install GLFW callbacks for secondary viewports @@ -562,6 +573,11 @@ public class ImGuiImplGlfw { @Override public void accept(final ImGuiViewport vp) { final ImGuiViewportDataGlfw data = (ImGuiViewportDataGlfw) vp.getPlatformUserData(); + + if (IS_WINDOWS && (vp.getFlags() & ImGuiViewportFlags.NoTaskBarIcon) != 0) { + ImGuiImplGlfwNative.win32hideFromTaskBar(vp.getPlatformHandleRaw()); + } + glfwShowWindow(data.window); } } @@ -606,7 +622,7 @@ public class ImGuiImplGlfw { public void accept(final ImGuiViewport vp, final ImVec2 imVec2) { final ImGuiViewportDataGlfw data = (ImGuiViewportDataGlfw) vp.getPlatformUserData(); data.ignoreWindowSizeEventFrame = ImGui.getFrameCount(); - glfwSetWindowSize(data.window, (int) imVec2.y, (int) imVec2.y); + glfwSetWindowSize(data.window, (int) imVec2.x, (int) imVec2.y); } } diff --git a/imgui-lwjgl3/src/test/java/ExampleUi.java b/imgui-lwjgl3/src/test/java/ExampleUi.java index d1e5b1c..202d97a 100644 --- a/imgui-lwjgl3/src/test/java/ExampleUi.java +++ b/imgui-lwjgl3/src/test/java/ExampleUi.java @@ -1,3 +1,4 @@ +import imgui.ImGuiViewport; import imgui.type.ImBoolean; import imgui.ImColor; import imgui.ImGui; @@ -40,8 +41,10 @@ final class ExampleUi { } void render() { + final ImGuiViewport mainViewport = ImGui.getMainViewport(); + ImGui.setNextWindowSize(600, 300, ImGuiCond.Once); - ImGui.setNextWindowPos(10, 10, ImGuiCond.Once); + ImGui.setNextWindowPos(mainViewport.getWorkPosX() + 10, mainViewport.getWorkPosY() + 10, ImGuiCond.Once); ImGui.begin("Custom window"); // Start Custom window diff --git a/imgui-lwjgl3/src/test/java/ImGuiGlfwExample.java b/imgui-lwjgl3/src/test/java/ImGuiGlfwExample.java index 3682253..f0843cc 100644 --- a/imgui-lwjgl3/src/test/java/ImGuiGlfwExample.java +++ b/imgui-lwjgl3/src/test/java/ImGuiGlfwExample.java @@ -12,6 +12,8 @@ import imgui.ImFontConfig; import imgui.ImGui; import imgui.ImGuiFreeType; import imgui.ImGuiIO; +import imgui.ImGuiStyle; +import imgui.flag.ImGuiCol; import imgui.flag.ImGuiConfigFlags; import imgui.gl3.ImGuiImplGl3; import imgui.glfw.ImGuiImplGlfw; @@ -143,7 +145,6 @@ public final class ImGuiGlfwExample { // Initialize ImGuiIO config final ImGuiIO io = ImGui.getIO(); - io.setMouseDrawCursor(true); io.setIniFilename(null); // We don't want to save .ini file io.addConfigFlags(ImGuiConfigFlags.NavEnableKeyboard | ImGuiConfigFlags.DockingEnable | ImGuiConfigFlags.ViewportsEnable); @@ -185,6 +186,13 @@ public final class ImGuiGlfwExample { // ------------------------------------------------------------ // Use freetype instead of stb_truetype to build a fonts texture ImGuiFreeType.buildFontAtlas(fontAtlas, ImGuiFreeType.RasterizerFlags.LightHinting); + + // When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones. + if ((io.getConfigFlags() & ImGuiConfigFlags.ViewportsEnable) != 0) { + final ImGuiStyle style = ImGui.getStyle(); + style.setWindowRounding(0.0f); + style.setColor(ImGuiCol.WindowBg, ImGui.getColorU32(ImGuiCol.WindowBg, 1)); + } } // Main application loop