|
| 1 | +package imgui.internal; |
| 2 | + |
| 3 | +import imgui.type.ImInt; |
| 4 | + |
| 5 | +public final class ImGui extends imgui.ImGui { |
| 6 | + private static final ImGuiDockNode DOCK_NODE = new ImGuiDockNode(0); |
| 7 | + |
| 8 | + /*JNI |
| 9 | + #include <stdint.h> |
| 10 | + #include <imgui.h> |
| 11 | + #include <imgui_internal.h> |
| 12 | + */ |
| 13 | + |
| 14 | + // Docking - Builder function needs to be generally called before the node is used/submitted. |
| 15 | + // - The DockBuilderXXX functions are designed to _eventually_ become a public API, but it is too early to expose it and guarantee stability. |
| 16 | + // - Do not hold on ImGuiDockNode* pointers! They may be invalidated by any split/merge/remove operation and every frame. |
| 17 | + // - To create a DockSpace() node, make sure to set the ImGuiDockNodeFlags_DockSpace flag when calling DockBuilderAddNode(). |
| 18 | + // You can create dockspace nodes (attached to a window) _or_ floating nodes (carry its own window) with this API. |
| 19 | + // - DockBuilderSplitNode() create 2 child nodes within 1 node. The initial node becomes a parent node. |
| 20 | + // - If you intend to split the node immediately after creation using DockBuilderSplitNode(), make sure |
| 21 | + // to call DockBuilderSetNodeSize() beforehand. If you don't, the resulting split sizes may not be reliable. |
| 22 | + // - Call DockBuilderFinish() after you are done. |
| 23 | + |
| 24 | + public static native void dockBuilderDockWindow(String windowName, int nodeId); /* |
| 25 | + ImGui::DockBuilderDockWindow(windowName, nodeId); |
| 26 | + */ |
| 27 | + |
| 28 | + public static ImGuiDockNode dockBuilderGetNode(final int nodeId) { |
| 29 | + final long ptr = nDockBuilderGetNode(nodeId); |
| 30 | + if (ptr == 0) { |
| 31 | + return null; |
| 32 | + } else { |
| 33 | + DOCK_NODE.ptr = ptr; |
| 34 | + return DOCK_NODE; |
| 35 | + } |
| 36 | + } |
| 37 | + |
| 38 | + private static native long nDockBuilderGetNode(int nodeId); /* |
| 39 | + return (intptr_t)ImGui::DockBuilderGetNode(nodeId); |
| 40 | + */ |
| 41 | + |
| 42 | + public static ImGuiDockNode dockBuilderGetCentralNode(final int nodeId) { |
| 43 | + final long ptr = nDockBuilderGetCentralNode(nodeId); |
| 44 | + if (ptr == 0) { |
| 45 | + return null; |
| 46 | + } else { |
| 47 | + DOCK_NODE.ptr = ptr; |
| 48 | + return DOCK_NODE; |
| 49 | + } |
| 50 | + } |
| 51 | + |
| 52 | + private static native long nDockBuilderGetCentralNode(int nodeId); /* |
| 53 | + return (intptr_t)ImGui::DockBuilderGetCentralNode(nodeId); |
| 54 | + */ |
| 55 | + |
| 56 | + public static native int dockBuilderAddNode(); /* |
| 57 | + return ImGui::DockBuilderAddNode(); |
| 58 | + */ |
| 59 | + |
| 60 | + public static native int dockBuilderAddNode(int nodeId); /* |
| 61 | + return ImGui::DockBuilderAddNode(nodeId); |
| 62 | + */ |
| 63 | + |
| 64 | + public static native int dockBuilderAddNode(int nodeId, int flags); /* |
| 65 | + return ImGui::DockBuilderAddNode(nodeId, flags); |
| 66 | + */ |
| 67 | + |
| 68 | + /** |
| 69 | + * Remove node and all its child, undock all windows. |
| 70 | + */ |
| 71 | + public static native void dockBuilderRemoveNode(int nodeId); /* |
| 72 | + ImGui::DockBuilderRemoveNode(nodeId); |
| 73 | + */ |
| 74 | + |
| 75 | + public static native void dockBuilderRemoveNodeDockedWindows(int nodeId); /* |
| 76 | + ImGui::DockBuilderRemoveNodeDockedWindows(nodeId); |
| 77 | + */ |
| 78 | + |
| 79 | + public static native void dockBuilderRemoveNodeDockedWindows(int nodeId, boolean clearSettingsRefs); /* |
| 80 | + ImGui::DockBuilderRemoveNodeDockedWindows(nodeId, clearSettingsRefs); |
| 81 | + */ |
| 82 | + |
| 83 | + /** |
| 84 | + * Remove all split/hierarchy. All remaining docked windows will be re-docked to the remaining root node (node_id). |
| 85 | + */ |
| 86 | + public static native void dockBuilderRemoveNodeChildNodes(int nodeId); /* |
| 87 | + ImGui::DockBuilderRemoveNodeChildNodes(nodeId); |
| 88 | + */ |
| 89 | + |
| 90 | + public static native void dockBuilderSetNodePos(int nodeId, float posX, float posY); /* |
| 91 | + ImGui::DockBuilderSetNodePos(nodeId, ImVec2(posX, posY)); |
| 92 | + */ |
| 93 | + |
| 94 | + public static native void dockBuilderSetNodeSize(int nodeId, float sizeX, float sizeY); /* |
| 95 | + ImGui::DockBuilderSetNodeSize(nodeId, ImVec2(sizeX, sizeY)); |
| 96 | + */ |
| 97 | + |
| 98 | + /** |
| 99 | + * Create 2 child nodes in this parent node. |
| 100 | + */ |
| 101 | + public static int dockBuilderSplitNode(int nodeId, int splitDir, float sizeRationForNodeAtDir, ImInt outIdAtDir, ImInt outIdAtOppositeDir) { |
| 102 | + if (outIdAtDir == null && outIdAtOppositeDir != null) { |
| 103 | + return nDockBuilderSplitNode(nodeId, splitDir, sizeRationForNodeAtDir, null, outIdAtOppositeDir.getData()); |
| 104 | + } else if (outIdAtDir != null && outIdAtOppositeDir == null) { |
| 105 | + return nDockBuilderSplitNode(nodeId, splitDir, sizeRationForNodeAtDir, outIdAtDir.getData()); |
| 106 | + } else if (outIdAtDir != null) { |
| 107 | + return nDockBuilderSplitNode(nodeId, splitDir, sizeRationForNodeAtDir, outIdAtDir.getData(), outIdAtOppositeDir.getData()); |
| 108 | + } else { |
| 109 | + return nDockBuilderSplitNode(nodeId, splitDir, sizeRationForNodeAtDir); |
| 110 | + } |
| 111 | + } |
| 112 | + |
| 113 | + private static native int nDockBuilderSplitNode(int nodeId, int splitDir, float sizeRationForNodeAtDir, int[] outIdAtDir, int[] outIdAtOppositeDir); /* |
| 114 | + return ImGui::DockBuilderSplitNode(nodeId, splitDir, sizeRationForNodeAtDir, (ImGuiID*)&outIdAtDir[0], (ImGuiID*)&outIdAtOppositeDir[0]); |
| 115 | + */ |
| 116 | + |
| 117 | + private static native int nDockBuilderSplitNode(int nodeId, int splitDir, float sizeRationForNodeAtDir); /* |
| 118 | + return ImGui::DockBuilderSplitNode(nodeId, splitDir, sizeRationForNodeAtDir, NULL, NULL); |
| 119 | + */ |
| 120 | + |
| 121 | + private static native int nDockBuilderSplitNode(int nodeId, int splitDir, float sizeRationForNodeAtDir, int[] outIdAtDir); /* |
| 122 | + return ImGui::DockBuilderSplitNode(nodeId, splitDir, sizeRationForNodeAtDir, (ImGuiID*)&outIdAtDir[0], NULL); |
| 123 | + */ |
| 124 | + |
| 125 | + private static native int nDockBuilderSplitNode(int nodeId, int splitDir, float sizeRationForNodeAtDir, Object o, int[] outIdAtOppositeDir); /* |
| 126 | + return ImGui::DockBuilderSplitNode(nodeId, splitDir, sizeRationForNodeAtDir, NULL, (ImGuiID*)&outIdAtOppositeDir[0]); |
| 127 | + */ |
| 128 | + |
| 129 | + // TODO DockBuilderCopyDockSpace, DockBuilderCopyNode |
| 130 | + |
| 131 | + public static native void dockBuilderCopyWindowSettings(String srcName, String dstName); /* |
| 132 | + ImGui::DockBuilderCopyWindowSettings(srcName, dstName); |
| 133 | + */ |
| 134 | + |
| 135 | + public static native void dockBuilderFinish(int nodeId); /* |
| 136 | + ImGui::DockBuilderFinish(nodeId); |
| 137 | + */ |
| 138 | +} |
0 commit comments