[API] Add support for DockBuilder
This commit is contained in:
1 parent
b3b26e9136
commit
4e564240ca
11 files changed
+1057
-14
No files matched your search
@@ -0,0 +1,138 @@
|
||||
package imgui.internal;
|
||||
|
||||
import imgui.type.ImInt;
|
||||
|
||||
public final class ImGui extends imgui.ImGui {
|
||||
private static final ImGuiDockNode DOCK_NODE = new ImGuiDockNode(0);
|
||||
|
||||
/*JNI
|
||||
#include <stdint.h>
|
||||
#include <imgui.h>
|
||||
#include <imgui_internal.h>
|
||||
*/
|
||||
|
||||
// Docking - Builder function needs to be generally called before the node is used/submitted.
|
||||
// - The DockBuilderXXX functions are designed to _eventually_ become a public API, but it is too early to expose it and guarantee stability.
|
||||
// - Do not hold on ImGuiDockNode* pointers! They may be invalidated by any split/merge/remove operation and every frame.
|
||||
// - To create a DockSpace() node, make sure to set the ImGuiDockNodeFlags_DockSpace flag when calling DockBuilderAddNode().
|
||||
// You can create dockspace nodes (attached to a window) _or_ floating nodes (carry its own window) with this API.
|
||||
// - DockBuilderSplitNode() create 2 child nodes within 1 node. The initial node becomes a parent node.
|
||||
// - If you intend to split the node immediately after creation using DockBuilderSplitNode(), make sure
|
||||
// to call DockBuilderSetNodeSize() beforehand. If you don't, the resulting split sizes may not be reliable.
|
||||
// - Call DockBuilderFinish() after you are done.
|
||||
|
||||
public static native void dockBuilderDockWindow(String windowName, int nodeId); /*
|
||||
ImGui::DockBuilderDockWindow(windowName, nodeId);
|
||||
*/
|
||||
|
||||
public static ImGuiDockNode dockBuilderGetNode(final int nodeId) {
|
||||
final long ptr = nDockBuilderGetNode(nodeId);
|
||||
if (ptr == 0) {
|
||||
return null;
|
||||
} else {
|
||||
DOCK_NODE.ptr = ptr;
|
||||
return DOCK_NODE;
|
||||
}
|
||||
}
|
||||
|
||||
private static native long nDockBuilderGetNode(int nodeId); /*
|
||||
return (intptr_t)ImGui::DockBuilderGetNode(nodeId);
|
||||
*/
|
||||
|
||||
public static ImGuiDockNode dockBuilderGetCentralNode(final int nodeId) {
|
||||
final long ptr = nDockBuilderGetCentralNode(nodeId);
|
||||
if (ptr == 0) {
|
||||
return null;
|
||||
} else {
|
||||
DOCK_NODE.ptr = ptr;
|
||||
return DOCK_NODE;
|
||||
}
|
||||
}
|
||||
|
||||
private static native long nDockBuilderGetCentralNode(int nodeId); /*
|
||||
return (intptr_t)ImGui::DockBuilderGetCentralNode(nodeId);
|
||||
*/
|
||||
|
||||
public static native int dockBuilderAddNode(); /*
|
||||
return ImGui::DockBuilderAddNode();
|
||||
*/
|
||||
|
||||
public static native int dockBuilderAddNode(int nodeId); /*
|
||||
return ImGui::DockBuilderAddNode(nodeId);
|
||||
*/
|
||||
|
||||
public static native int dockBuilderAddNode(int nodeId, int flags); /*
|
||||
return ImGui::DockBuilderAddNode(nodeId, flags);
|
||||
*/
|
||||
|
||||
/**
|
||||
* Remove node and all its child, undock all windows.
|
||||
*/
|
||||
public static native void dockBuilderRemoveNode(int nodeId); /*
|
||||
ImGui::DockBuilderRemoveNode(nodeId);
|
||||
*/
|
||||
|
||||
public static native void dockBuilderRemoveNodeDockedWindows(int nodeId); /*
|
||||
ImGui::DockBuilderRemoveNodeDockedWindows(nodeId);
|
||||
*/
|
||||
|
||||
public static native void dockBuilderRemoveNodeDockedWindows(int nodeId, boolean clearSettingsRefs); /*
|
||||
ImGui::DockBuilderRemoveNodeDockedWindows(nodeId, clearSettingsRefs);
|
||||
*/
|
||||
|
||||
/**
|
||||
* Remove all split/hierarchy. All remaining docked windows will be re-docked to the remaining root node (node_id).
|
||||
*/
|
||||
public static native void dockBuilderRemoveNodeChildNodes(int nodeId); /*
|
||||
ImGui::DockBuilderRemoveNodeChildNodes(nodeId);
|
||||
*/
|
||||
|
||||
public static native void dockBuilderSetNodePos(int nodeId, float posX, float posY); /*
|
||||
ImGui::DockBuilderSetNodePos(nodeId, ImVec2(posX, posY));
|
||||
*/
|
||||
|
||||
public static native void dockBuilderSetNodeSize(int nodeId, float sizeX, float sizeY); /*
|
||||
ImGui::DockBuilderSetNodeSize(nodeId, ImVec2(sizeX, sizeY));
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create 2 child nodes in this parent node.
|
||||
*/
|
||||
public static int dockBuilderSplitNode(int nodeId, int splitDir, float sizeRationForNodeAtDir, ImInt outIdAtDir, ImInt outIdAtOppositeDir) {
|
||||
if (outIdAtDir == null && outIdAtOppositeDir != null) {
|
||||
return nDockBuilderSplitNode(nodeId, splitDir, sizeRationForNodeAtDir, null, outIdAtOppositeDir.getData());
|
||||
} else if (outIdAtDir != null && outIdAtOppositeDir == null) {
|
||||
return nDockBuilderSplitNode(nodeId, splitDir, sizeRationForNodeAtDir, outIdAtDir.getData());
|
||||
} else if (outIdAtDir != null) {
|
||||
return nDockBuilderSplitNode(nodeId, splitDir, sizeRationForNodeAtDir, outIdAtDir.getData(), outIdAtOppositeDir.getData());
|
||||
} else {
|
||||
return nDockBuilderSplitNode(nodeId, splitDir, sizeRationForNodeAtDir);
|
||||
}
|
||||
}
|
||||
|
||||
private static native int nDockBuilderSplitNode(int nodeId, int splitDir, float sizeRationForNodeAtDir, int[] outIdAtDir, int[] outIdAtOppositeDir); /*
|
||||
return ImGui::DockBuilderSplitNode(nodeId, splitDir, sizeRationForNodeAtDir, (ImGuiID*)&outIdAtDir[0], (ImGuiID*)&outIdAtOppositeDir[0]);
|
||||
*/
|
||||
|
||||
private static native int nDockBuilderSplitNode(int nodeId, int splitDir, float sizeRationForNodeAtDir); /*
|
||||
return ImGui::DockBuilderSplitNode(nodeId, splitDir, sizeRationForNodeAtDir, NULL, NULL);
|
||||
*/
|
||||
|
||||
private static native int nDockBuilderSplitNode(int nodeId, int splitDir, float sizeRationForNodeAtDir, int[] outIdAtDir); /*
|
||||
return ImGui::DockBuilderSplitNode(nodeId, splitDir, sizeRationForNodeAtDir, (ImGuiID*)&outIdAtDir[0], NULL);
|
||||
*/
|
||||
|
||||
private static native int nDockBuilderSplitNode(int nodeId, int splitDir, float sizeRationForNodeAtDir, Object o, int[] outIdAtOppositeDir); /*
|
||||
return ImGui::DockBuilderSplitNode(nodeId, splitDir, sizeRationForNodeAtDir, NULL, (ImGuiID*)&outIdAtOppositeDir[0]);
|
||||
*/
|
||||
|
||||
// TODO DockBuilderCopyDockSpace, DockBuilderCopyNode
|
||||
|
||||
public static native void dockBuilderCopyWindowSettings(String srcName, String dstName); /*
|
||||
ImGui::DockBuilderCopyWindowSettings(srcName, dstName);
|
||||
*/
|
||||
|
||||
public static native void dockBuilderFinish(int nodeId); /*
|
||||
ImGui::DockBuilderFinish(nodeId);
|
||||
*/
|
||||
}
|
||||
Reference in new issue
Block a user