diff --git a/imgui-binding/src/main/java/imgui/ImDrawData.java b/imgui-binding/src/main/java/imgui/ImDrawData.java index 21c48da..9529789 100644 --- a/imgui-binding/src/main/java/imgui/ImDrawData.java +++ b/imgui-binding/src/main/java/imgui/ImDrawData.java @@ -11,7 +11,7 @@ import java.nio.ByteOrder; * BINDING NOTICE: Since it's impossible to do a 1:1 mapping with JNI, current class provides "getCmdList*()" methods. * Those are used to get the data needed to do a rendering. */ -public final class ImDrawData implements ImGuiDestroyableStruct { +public final class ImDrawData { public static final int SIZEOF_IM_DRAW_IDX = 2; public static final int SIZEOF_IM_DRAW_VERT = (4 + 1) * 4; @@ -26,11 +26,6 @@ public final class ImDrawData implements ImGuiDestroyableStruct { this.ptr = ptr; } - @Override - public void destroy() { - nDestroy(ptr); - } - /*JNI #include #include @@ -46,10 +41,6 @@ public final class ImDrawData implements ImGuiDestroyableStruct { imDrawDataPtrID = env->GetFieldID(jImDrawDataClass, "ptr", "J"); */ - private native void nDestroy(long ptr); /* - delete (ImDrawData*)ptr; - */ - ///////// Start of Render Methods | Binding /** diff --git a/imgui-binding/src/main/java/imgui/ImGui.java b/imgui-binding/src/main/java/imgui/ImGui.java index 3540461..69f9876 100644 --- a/imgui-binding/src/main/java/imgui/ImGui.java +++ b/imgui-binding/src/main/java/imgui/ImGui.java @@ -65,6 +65,7 @@ public final class ImGui { ImGuiStyle.nInit(); ImGuiWindowClass.nInit(); ImGuiStorage.nInit(); + ImGuiViewport.nInit(); nInitInputTextData(); } @@ -4373,7 +4374,25 @@ public final class ImGui { ImGui::DockSpace(imGuiID, ImVec2(sizeX, sizeY), imGuiDockNodeFlags, windowClassPtr != 0 ? (ImGuiWindowClass*)windowClassPtr : NULL); */ - // TODO: DockSpaceOverViewport + public static int dockSpaceOverViewport() { + return nDockSpaceOverViewport(0, 0, 0); + } + + public static int dockSpaceOverViewport(ImGuiViewport viewport) { + return nDockSpaceOverViewport(viewport.ptr, 0, 0); + } + + public static int dockSpaceOverViewport(ImGuiViewport viewport, int imGuiDockNodeFlags) { + return nDockSpaceOverViewport(viewport.ptr, imGuiDockNodeFlags, 0); + } + + public static int dockSpaceOverViewport(ImGuiViewport viewport, int imGuiDockNodeFlags, ImGuiWindowClass windowClass) { + return nDockSpaceOverViewport(viewport.ptr, imGuiDockNodeFlags, windowClass.ptr); + } + + private static native int nDockSpaceOverViewport(long viewportPtr, int imGuiDockNodeFlags, long windowClassPtr); /* + return ImGui::DockSpaceOverViewport(viewportPtr != 0 ? (ImGuiViewport*)viewportPtr : NULL, imGuiDockNodeFlags, windowClassPtr != 0 ? (ImGuiWindowClass*)windowClassPtr : NULL); + */ /** * Set next window dock id diff --git a/imgui-binding/src/main/java/imgui/ImGuiViewport.java b/imgui-binding/src/main/java/imgui/ImGuiViewport.java new file mode 100644 index 0000000..8fcd99c --- /dev/null +++ b/imgui-binding/src/main/java/imgui/ImGuiViewport.java @@ -0,0 +1,290 @@ +package imgui; + +/** + * The viewports created and managed by Dear ImGui. The role of the platform back-end is to create the platform/OS windows corresponding to each viewport. + * - Main Area = entire viewport. + * - Work Area = entire viewport minus sections optionally used by menu bars, status bars. Some positioning code will prefer to use this. Window are also trying to stay within this area. + */ +public final class ImGuiViewport { + final long ptr; + + ImGuiViewport(final long ptr) { + this.ptr = ptr; + } + + /*JNI + #include + #include + #include "jni_common.h" + + jfieldID imGuiViewportPtrID; + + #define IMGUI_VIEWPORT ((ImGuiViewport*)env->GetLongField(object, imGuiViewportPtrID)) + */ + + static native void nInit(); /* + jclass jImGuiViewportClass = env->FindClass("imgui/ImGuiViewport"); + imGuiViewportPtrID = env->GetFieldID(jImGuiViewportClass, "ptr", "J"); + */ + + /** + * Unique identifier for the viewport. + */ + public native int getImGuiId(); /* + return IMGUI_VIEWPORT->ID; + */ + + /** + * Unique identifier for the viewport. + */ + public native void setImGuiId(int imGuiID); /* + IMGUI_VIEWPORT->ID = imGuiID; + */ + + /** + * See ImGuiViewportFlags_. + */ + public native int getFlags(); /* + return IMGUI_VIEWPORT->Flags; + */ + + /** + * See ImGuiViewportFlags_. + */ + public native void setFlags(int flags); /* + IMGUI_VIEWPORT->Flags = flags; + */ + + /** + * Main Area: Position of the viewport (the imgui coordinates are the same as OS desktop/native coordinates). + */ + public native void getPos(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, &IMGUI_VIEWPORT->Pos, dstImVec2); + */ + + /** + * Main Area: Position of the viewport (the imgui coordinates are the same as OS desktop/native coordinates). + */ + public native float getPosX(); /* + return IMGUI_VIEWPORT->Pos.x; + */ + + /** + * Main Area: Position of the viewport (the imgui coordinates are the same as OS desktop/native coordinates). + */ + public native float getPosY(); /* + return IMGUI_VIEWPORT->Pos.y; + */ + + /** + * Main Area: Position of the viewport (the imgui coordinates are the same as OS desktop/native coordinates). + */ + public native void setPos(float x, float y); /* + IMGUI_VIEWPORT->Pos = ImVec2(x, y); + */ + + /** + * Main Area: Size of the viewport. + */ + public native void getSize(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, &IMGUI_VIEWPORT->Size, dstImVec2); + */ + + /** + * Main Area: Size of the viewport. + */ + public native float getSizeX(); /* + return IMGUI_VIEWPORT->Size.x; + */ + + /** + * Main Area: Size of the viewport. + */ + public native float getSizeY(); /* + return IMGUI_VIEWPORT->Size.y; + */ + + /** + * Main Area: Size of the viewport. + */ + public native void seSize(float x, float y); /* + IMGUI_VIEWPORT->Size = ImVec2(x, y); + */ + + /** + * Work Area: Offset from Pos to top-left corner of Work Area. Generally (0,0) or (0,+main_menu_bar_height). + * Work Area is Full Area but without menu-bars/status-bars (so WorkArea always fit inside Pos/Size!) + */ + public native void getWorkOffsetMin(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, &IMGUI_VIEWPORT->WorkOffsetMin, dstImVec2); + */ + + /** + * Work Area: Offset from Pos to top-left corner of Work Area. Generally (0,0) or (0,+main_menu_bar_height). + * Work Area is Full Area but without menu-bars/status-bars (so WorkArea always fit inside Pos/Size!) + */ + public native float getWorkOffsetMinX(); /* + return IMGUI_VIEWPORT->WorkOffsetMin.x; + */ + + /** + * Work Area: Offset from Pos to top-left corner of Work Area. Generally (0,0) or (0,+main_menu_bar_height). + * Work Area is Full Area but without menu-bars/status-bars (so WorkArea always fit inside Pos/Size!) + */ + public native float getWorkOffsetMinY(); /* + return IMGUI_VIEWPORT->WorkOffsetMin.y; + */ + + /** + * Work Area: Offset from Pos to top-left corner of Work Area. Generally (0,0) or (0,+main_menu_bar_height). + * Work Area is Full Area but without menu-bars/status-bars (so WorkArea always fit inside Pos/Size!) + */ + public native void seWorkOffsetMin(float x, float y); /* + IMGUI_VIEWPORT->WorkOffsetMin = ImVec2(x, y); + */ + + /** + * Work Area: Offset from Pos+Size to bottom-right corner of Work Area. Generally (0,0) or (0,-status_bar_height). + */ + public native void getWorkOffsetMax(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, &IMGUI_VIEWPORT->WorkOffsetMax, dstImVec2); + */ + + /** + * Work Area: Offset from Pos+Size to bottom-right corner of Work Area. Generally (0,0) or (0,-status_bar_height). + */ + public native float getWorkOffsetMaxX(); /* + return IMGUI_VIEWPORT->WorkOffsetMax.x; + */ + + /** + * Work Area: Offset from Pos+Size to bottom-right corner of Work Area. Generally (0,0) or (0,-status_bar_height). + */ + public native float getWorkOffsetMaxY(); /* + return IMGUI_VIEWPORT->WorkOffsetMax.y; + */ + + /** + * Work Area: Offset from Pos+Size to bottom-right corner of Work Area. Generally (0,0) or (0,-status_bar_height). + */ + public native void seWorkOffsetMax(float x, float y); /* + IMGUI_VIEWPORT->WorkOffsetMax = ImVec2(x, y); + */ + + /** + * 1.0f = 96 DPI = No extra scale. + */ + public native float getDpiScale(); /* + return IMGUI_VIEWPORT->DpiScale; + */ + + /** + * 1.0f = 96 DPI = No extra scale. + */ + public native void setDpiScale(float dpiScale); /* + IMGUI_VIEWPORT->DpiScale = dpiScale; + */ + + // TODO: DrawData + + /** + * (Advanced) 0: no parent. Instruct the platform back-end to setup a parent/child relationship between platform windows. + */ + public native int getParentViewportId(); /* + return IMGUI_VIEWPORT->ParentViewportId; + */ + + /** + * (Advanced) 0: no parent. Instruct the platform back-end to setup a parent/child relationship between platform windows. + */ + public native void setParentViewportId(int parentViewportId); /* + IMGUI_VIEWPORT->ParentViewportId = parentViewportId; + */ + + // Our design separate the Renderer and Platform back-ends to facilitate combining default back-ends with each others. + // When our create your own back-end for a custom engine, it is possible that both Renderer and Platform will be handled + // by the same system and you may not need to use all the UserData/Handle fields. + // The library never uses those fields, they are merely storage to facilitate back-end implementation. + + // TODO: PlatformUserData, PlatformHandle, PlatformHandleRaw + + /** + * Platform window requested move (e.g. window was moved by the OS / host window manager, authoritative position will be OS window position). + */ + public native boolean getPlatformRequestMove(); /* + return IMGUI_VIEWPORT->PlatformRequestMove; + */ + + /** + * Platform window requested move (e.g. window was moved by the OS / host window manager, authoritative position will be OS window position). + */ + public native void setPlatformRequestMove(boolean platformRequestMove); /* + IMGUI_VIEWPORT->PlatformRequestMove = platformRequestMove; + */ + + /** + * Platform window requested resize (e.g. window was resized by the OS / host window manager, authoritative size will be OS window size). + */ + public native boolean getPlatformRequestResize(); /* + return IMGUI_VIEWPORT->PlatformRequestResize; + */ + + /** + * Platform window requested resize (e.g. window was resized by the OS / host window manager, authoritative size will be OS window size). + */ + public native void setPlatformRequestResize(boolean platformRequestResize); /* + IMGUI_VIEWPORT->PlatformRequestResize = platformRequestResize; + */ + + /** + * Platform window requested closure (e.g. window was moved by the OS / host window manager, e.g. pressing ALT-F4). + */ + public native boolean getPlatformRequestClose(); /* + return IMGUI_VIEWPORT->PlatformRequestClose; + */ + + /** + * Platform window requested closure (e.g. window was moved by the OS / host window manager, e.g. pressing ALT-F4). + */ + public native void setPlatformRequestClose(boolean platformRequestClose); /* + IMGUI_VIEWPORT->PlatformRequestClose = platformRequestClose; + */ + + // Access work-area rectangle with GetWorkXXX functions (see comments above) + + public native void getCenter(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, IMGUI_VIEWPORT->GetCenter(), dstImVec2); + */ + + public native float getCenterX(); /* + return IMGUI_VIEWPORT->GetCenter().x; + */ + + public native float getCenterY(); /* + return IMGUI_VIEWPORT->GetCenter().y; + */ + + public native void getWorkPos(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, IMGUI_VIEWPORT->GetWorkPos(), dstImVec2); + */ + + public native float getWorkPosX(); /* + return IMGUI_VIEWPORT->GetWorkPos().x; + */ + + public native float getWorkPosY(); /* + return IMGUI_VIEWPORT->GetWorkPos().y; + */ + + public native void getWorkSize(ImVec2 dstImVec2); /* + Jni::ImVec2Cpy(env, IMGUI_VIEWPORT->GetWorkSize(), dstImVec2); + */ + + public native float getWorkSizeX(); /* + return IMGUI_VIEWPORT->GetWorkSize().x; + */ + + public native float getWorkSizeY(); /* + return IMGUI_VIEWPORT->GetWorkSize().y; + */ +} diff --git a/imgui-binding/src/main/java/imgui/ImGuiWindowClass.java b/imgui-binding/src/main/java/imgui/ImGuiWindowClass.java index 2458569..8e77846 100644 --- a/imgui-binding/src/main/java/imgui/ImGuiWindowClass.java +++ b/imgui-binding/src/main/java/imgui/ImGuiWindowClass.java @@ -83,7 +83,37 @@ public final class ImGuiWindowClass implements ImGuiDestroyableStruct { IMGUI_WINDOW_CLASS->ParentViewportId = parentViewportId; */ - // TODO: ViewportFlagsOverrideSet, ViewportFlagsOverrideClear + /** + * Viewport flags to set when a window of this class owns a viewport. + * This allows you to enforce OS decoration or task bar icon, override the defaults on a per-window basis. + */ + public native int getViewportFlagsOverrideSet(); /* + return IMGUI_WINDOW_CLASS->ViewportFlagsOverrideSet; + */ + + /** + * Viewport flags to set when a window of this class owns a viewport. + * This allows you to enforce OS decoration or task bar icon, override the defaults on a per-window basis. + */ + public native void setViewportFlagsOverrideSet(int viewportFlagsOverrideSet); /* + IMGUI_WINDOW_CLASS->ViewportFlagsOverrideSet = viewportFlagsOverrideSet; + */ + + /** + * Viewport flags to clear when a window of this class owns a viewport. + * This allows you to enforce OS decoration or task bar icon, override the defaults on a per-window basis. + */ + public native int getViewportFlagsOverrideClear(); /* + return IMGUI_WINDOW_CLASS->ViewportFlagsOverrideClear; + */ + + /** + * Viewport flags to clear when a window of this class owns a viewport. + * This allows you to enforce OS decoration or task bar icon, override the defaults on a per-window basis. + */ + public native void setViewportFlagsOverrideClear(int viewportFlagsOverrideClear); /* + IMGUI_WINDOW_CLASS->ViewportFlagsOverrideClear = viewportFlagsOverrideClear; + */ /** * [EXPERIMENTAL] Dock node flags to set when a window of this class is hosted by a dock node (it doesn't have to be selected!) diff --git a/imgui-binding/src/main/java/imgui/flag/ImGuiViewportFlags.java b/imgui-binding/src/main/java/imgui/flag/ImGuiViewportFlags.java new file mode 100644 index 0000000..a63c95a --- /dev/null +++ b/imgui-binding/src/main/java/imgui/flag/ImGuiViewportFlags.java @@ -0,0 +1,54 @@ +package imgui.flag; + +/** + * Flags stored in ImGuiViewport::Flags, giving indications to the platform back-ends. + */ +public final class ImGuiViewportFlags { + private ImGuiViewportFlags() { + } + + public static final int None = 0; + /** + * Platform Window: Disable platform decorations: title bar, borders, etc. + * (generally set all windows, but if ImGuiConfigFlags_ViewportsDecoration is set we only set this on popups/tooltips) + */ + public static final int NoDecoration = 1; + /** + * Platform Window: Disable platform task bar icon + * (generally set on popups/tooltips, or all windows if ImGuiConfigFlags_ViewportsNoTaskBarIcon is set) + */ + public static final int NoTaskBarIcon = 1 << 1; + /** + * Platform Window: Don't take focus when created. + */ + public static final int NoFocusOnAppearing = 1 << 2; + /** + * Platform Window: Don't take focus when clicked on. + */ + public static final int NoFocusOnClick = 1 << 3; + /** + * Platform Window: Make mouse pass through so we can drag this window while peaking behind it. + */ + public static final int NoInputs = 1 << 4; + /** + * Platform Window: Renderer doesn't need to clear the framebuffer ahead (because we will fill it entirely). + */ + public static final int NoRendererClear = 1 << 5; + /** + * Platform Window: Display on top (for tooltips only). + */ + public static final int TopMost = 1 << 6; + /** + * Platform Window: Window is minimized, can skip render. When minimized we tend to avoid using the viewport pos/size for clipping window or testing if they are contained in the viewport. + */ + public static final int Minimized = 1 << 7; + /** + * Platform Window: Avoid merging this window into another host window. This can only be set via ImGuiWindowClass viewport flags override + * (because we need to now ahead if we are going to create a viewport in the first place!). + */ + public static final int NoAutoMerge = 1 << 8; + /** + * Main viewport: can host multiple imgui windows (secondary viewports are associated to a single window). + */ + public static final int CanHostOtherWindows = 1 << 9; +}