[API] Add support for DockBuilder

This commit is contained in:
SpaiR committed 2020-09-05 15:27:03 +03:00
1 parent b3b26e9136
commit 4e564240ca
11 files changed
+1057 -14

No files matched your search

@@ -0,0 +1,81 @@
def inputTxt = new File(args[0]).text
def outputFile = new File(args[1])
def jStructName = args[2] as String
outputFile.text = ''
inputTxt = inputTxt
.replace('ImGuiID', 'int')
.replace('bool', 'boolean')
.replace('char*', 'String')
.replace('const char*', 'String')
def regex = ~'(\\w+)\\s+(\\w+)(?:.*?//(.+))?'
inputTxt.eachLine { line ->
def trimmedLine = line.trim()
if (!trimmedLine.contains(';') || trimmedLine.startsWith('#'))
return
def m = regex.matcher(trimmedLine)
def fieldType
def fieldName
def fieldComment
m.find()
fieldType = m.group(1)
fieldName = m.group(2)
fieldComment = m.group(3)?.trim()
def javadoc = null
if (fieldComment) {
javadoc = """ /**
| * $fieldComment
| */""".stripMargin()
}
def classTxt
if (fieldType == 'ImVec2') {
classTxt = """
|${javadoc ? javadoc : ''}
| public native void get${fieldName.capitalize()}(ImVec2 dstImVec2); /*
| Jni::ImVec2Cpy(env, &$jStructName->$fieldName, dstImVec2);
| */
|
|${javadoc ? javadoc : ''}
| public native float get${fieldName.capitalize()}X(); /*
| return $jStructName->${fieldName}.x;
| */
|
|${javadoc ? javadoc : ''}
| public native float get${fieldName.capitalize()}Y(); /*
| return $jStructName->${fieldName}.y;
| */
|
|${javadoc ? javadoc : ''}
| public native void set${fieldName.capitalize()}(float x, float y); /*
| $jStructName->${fieldName}.x = x;
| $jStructName->${fieldName}.y = y;
| */
""".stripMargin()
} else {
classTxt = """
|${javadoc ? javadoc : ''}
| public native $fieldType get${fieldName.capitalize()}(); /*
| return $jStructName->$fieldName;
| */
|
|${javadoc ? javadoc : ''}
| public native void set${fieldName.capitalize()}($fieldType ${fieldName.uncapitalize()}); /*
| $jStructName->$fieldName = ${fieldName.uncapitalize()};
| */
""".stripMargin()
}
outputFile << classTxt
}
+8 -4
View File
@@ -18,7 +18,7 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
public final class ImGui {
public class ImGui {
private static final String LIB_PATH_PROP = "imgui.library.path";
private static final String LIB_NAME_PROP = "imgui.library.name";
private static final String LIB_NAME_DEFAULT = System.getProperty("os.arch").contains("64") ? "imgui-java64" : "imgui-java";
@@ -114,9 +114,6 @@ public final class ImGui {
public static void init() {
}
private ImGui() {
}
/*JNI
#include <stdint.h>
#include <imgui.h>
@@ -650,6 +647,13 @@ public final class ImGui {
ImGui::SetNextWindowBgAlpha(alpha);
*/
/**
* Set next window viewport.
*/
public static native void setNextWindowViewport(int viewportId); /*
ImGui::SetNextWindowViewport(viewportId);
*/
/**
* (not recommended) set current window position - call within Begin()/End().
* Prefer using SetNextWindowPos(), as this may incur tearing and side-effects.
@@ -26,14 +26,14 @@ public final class ImGuiViewport extends ImGuiStruct {
/**
* Unique identifier for the viewport.
*/
public native int getImGuiId(); /*
public native int getID(); /*
return IMGUI_VIEWPORT->ID;
*/
/**
* Unique identifier for the viewport.
*/
public native void setImGuiId(int imGuiID); /*
public native void setID(int imGuiID); /*
IMGUI_VIEWPORT->ID = imGuiID;
*/
@@ -4,10 +4,8 @@ package imgui.flag;
* Flags for ImGui::DockSpace(), shared/inherited by child nodes.
* (Some flags can be applied to individual nodes directly)
*/
public final class ImGuiDockNodeFlags {
private ImGuiDockNodeFlags() {
}
@SuppressWarnings("HideUtilityClassConstructor")
public class ImGuiDockNodeFlags {
public static final int None = 0;
/**
* Don't display the dockspace node but keep it alive. Windows docked into this dockspace node won't be undocked.
@@ -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);
*/
}
@@ -0,0 +1,645 @@
package imgui.internal;
import imgui.ImGuiWindowClass;
import imgui.ImVec2;
import imgui.binding.ImGuiStruct;
public final class ImGuiDockNode extends ImGuiStruct {
private static final ImGuiDockNode PARENT_NODE = new ImGuiDockNode(0);
private static final ImGuiDockNode CHILD_NODE_FIRST = new ImGuiDockNode(0);
private static final ImGuiDockNode CHILD_NODE_SECOND = new ImGuiDockNode(0);
private static final ImGuiWindowClass WINDOW_CLASS = new ImGuiWindowClass(0);
private static final ImGuiDockNode CENTRAL_NODE = new ImGuiDockNode(0);
private static final ImGuiDockNode ONLY_NODE_WITH_WINDOWS = new ImGuiDockNode(0);
private static final ImRect RECT = new ImRect();
public ImGuiDockNode(final long ptr) {
super(ptr);
}
/*JNI
#include <stdint.h>
#include <imgui.h>
#include <imgui_internal.h>
#include "jni_common.h"
#include "jni_binding_struct.h"
#define IMGUI_DOCK_NODE ((ImGuiDockNode*)STRUCT_PTR)
*/
public native int getID(); /*
return IMGUI_DOCK_NODE->ID;
*/
public native void setID(int imGuiID); /*
IMGUI_DOCK_NODE->ID = imGuiID;
*/
/**
* Flags shared by all nodes of a same dockspace hierarchy (inherited from the root node)
*/
public native int getSharedFlags(); /*
return IMGUI_DOCK_NODE->SharedFlags;
*/
/**
* Flags shared by all nodes of a same dockspace hierarchy (inherited from the root node)
*/
public native void setSharedFlags(int sharedFlags); /*
IMGUI_DOCK_NODE->SharedFlags = sharedFlags;
*/
/**
* Flags shared by all nodes of a same dockspace hierarchy (inherited from the root node)
*/
public void addSharedFlags(final int flags) {
setSharedFlags(getSharedFlags() | flags);
}
/**
* Flags shared by all nodes of a same dockspace hierarchy (inherited from the root node)
*/
public void removeSharedFlags(final int flags) {
setSharedFlags(getSharedFlags() & ~(flags));
}
/**
* Flags specific to this node
*/
public native int getLocalFlags(); /*
return IMGUI_DOCK_NODE->LocalFlags;
*/
/**
* Flags specific to this node
*/
public native void setLocalFlags(int localFlags); /*
IMGUI_DOCK_NODE->LocalFlags = localFlags;
*/
/**
* Flags specific to this node
*/
public void addLocalFlags(final int flags) {
setLocalFlags(getLocalFlags() | flags);
}
/**
* Flags specific to this node
*/
public void removeLocalFlags(final int flags) {
setLocalFlags(getLocalFlags() & ~(flags));
}
public ImGuiDockNode getParentNode() {
PARENT_NODE.ptr = nGetParentNode();
return PARENT_NODE;
}
private native long nGetParentNode(); /*
return (intptr_t)IMGUI_DOCK_NODE->ParentNode;
*/
public void setParentNode(final ImGuiDockNode imGuiDockNode) {
nSetParentNode(imGuiDockNode.ptr);
}
private native void nSetParentNode(long imGuiDockNodePtr); /*
IMGUI_DOCK_NODE->ParentNode = (ImGuiDockNode*)imGuiDockNodePtr;
*/
/**
* [Split node only] Child nodes (left/right or top/bottom). Consider switching to an array.
*/
public ImGuiDockNode getChildNodeFirst() {
CHILD_NODE_FIRST.ptr = nGetChildNodeFirst();
return CHILD_NODE_FIRST;
}
private native long nGetChildNodeFirst(); /*
return (intptr_t)IMGUI_DOCK_NODE->ChildNodes[0];
*/
/**
* [Split node only] Child nodes (left/right or top/bottom). Consider switching to an array.
*/
public void setChildNodeFirst(final ImGuiDockNode imGuiDockNode) {
nSetChildNodeFirst(imGuiDockNode.ptr);
}
private native void nSetChildNodeFirst(long imGuiDockNodePtr); /*
IMGUI_DOCK_NODE->ChildNodes[0] = (ImGuiDockNode*)imGuiDockNodePtr;
*/
/**
* [Split node only] Child nodes (left/right or top/bottom). Consider switching to an array.
*/
public ImGuiDockNode getChildNodeSecond() {
CHILD_NODE_SECOND.ptr = nGetChildNodeSecond();
return CHILD_NODE_SECOND;
}
private native long nGetChildNodeSecond(); /*
return (intptr_t)IMGUI_DOCK_NODE->ChildNodes[1];
*/
/**
* [Split node only] Child nodes (left/right or top/bottom). Consider switching to an array.
*/
public void setChildNodeSecond(final ImGuiDockNode imGuiDockNode) {
nSetChildNodeSecond(imGuiDockNode.ptr);
}
private native void nSetChildNodeSecond(long imGuiDockNodePtr); /*
IMGUI_DOCK_NODE->ChildNodes[1] = (ImGuiDockNode*)imGuiDockNodePtr;
*/
// TODO Windows, TabBar
/**
* [Root node only]
*/
public ImGuiWindowClass getWindowClass() {
WINDOW_CLASS.ptr = nGetWindowClass();
return WINDOW_CLASS;
}
/**
* [Root node only]
*/
private native long nGetWindowClass(); /*
return (intptr_t)&IMGUI_DOCK_NODE->WindowClass;
*/
/**
* [Root node only]
*/
public void setWindowClass(final ImGuiWindowClass imGuiWindowClass) {
nSetWindowClass(imGuiWindowClass.ptr);
}
/**
* [Root node only]
*/
private native void nSetWindowClass(long imGuiWindowClassPtr); /*
IMGUI_DOCK_NODE->WindowClass = *((ImGuiWindowClass*)imGuiWindowClassPtr);
*/
/**
* Current position
*/
public native void getPos(ImVec2 dstImVec2); /*
Jni::ImVec2Cpy(env, &IMGUI_DOCK_NODE->Pos, dstImVec2);
*/
/**
* Current position
*/
public native float getPosX(); /*
return IMGUI_DOCK_NODE->Pos.x;
*/
/**
* Current position
*/
public native float getPosY(); /*
return IMGUI_DOCK_NODE->Pos.y;
*/
/**
* Current position
*/
public native void setPos(float x, float y); /*
IMGUI_DOCK_NODE->Pos.x = x;
IMGUI_DOCK_NODE->Pos.y = y;
*/
/**
* Current size
*/
public native void getSize(ImVec2 dstImVec2); /*
Jni::ImVec2Cpy(env, &IMGUI_DOCK_NODE->Size, dstImVec2);
*/
/**
* Current size
*/
public native float getSizeX(); /*
return IMGUI_DOCK_NODE->Size.x;
*/
/**
* Current size
*/
public native float getSizeY(); /*
return IMGUI_DOCK_NODE->Size.y;
*/
/**
* Current size
*/
public native void setSize(float x, float y); /*
IMGUI_DOCK_NODE->Size.x = x;
IMGUI_DOCK_NODE->Size.y = y;
*/
/**
* [Split node only] Last explicitly written-to size (overridden when using a splitter affecting the node), used to calculate Size.
*/
public native void getSizeRef(ImVec2 dstImVec2); /*
Jni::ImVec2Cpy(env, &IMGUI_DOCK_NODE->SizeRef, dstImVec2);
*/
/**
* [Split node only] Last explicitly written-to size (overridden when using a splitter affecting the node), used to calculate Size.
*/
public native float getSizeRefX(); /*
return IMGUI_DOCK_NODE->SizeRef.x;
*/
/**
* [Split node only] Last explicitly written-to size (overridden when using a splitter affecting the node), used to calculate Size.
*/
public native float getSizeRefY(); /*
return IMGUI_DOCK_NODE->SizeRef.y;
*/
/**
* [Split node only] Last explicitly written-to size (overridden when using a splitter affecting the node), used to calculate Size.
*/
public native void setSizeRef(float x, float y); /*
IMGUI_DOCK_NODE->SizeRef.x = x;
IMGUI_DOCK_NODE->SizeRef.y = y;
*/
/**
* [Split node only] Split axis (X or Y)
*/
public native int getSplitAxis(); /*
return IMGUI_DOCK_NODE->SplitAxis;
*/
/**
* [Split node only] Split axis (X or Y)
*/
public native void setSplitAxis(int splitAxis); /*
IMGUI_DOCK_NODE->SplitAxis = (ImGuiAxis)splitAxis;
*/
public native int getState(); /*
return IMGUI_DOCK_NODE->State;
*/
public native void setState(int state); /*
IMGUI_DOCK_NODE->State = (ImGuiDockNodeState)state;
*/
// TODO HostWindow, VisibleWindow
/**
* [Root node only] Pointer to central node.
*/
public ImGuiDockNode getCentralNode() {
CENTRAL_NODE.ptr = nGetCentralNode();
return PARENT_NODE;
}
private native long nGetCentralNode(); /*
return (intptr_t)IMGUI_DOCK_NODE->CentralNode;
*/
/**
* [Root node only] Pointer to central node.
*/
public void setCentralNode(final ImGuiDockNode imGuiDockNode) {
nSetCentralNode(imGuiDockNode.ptr);
}
private native void nSetCentralNode(long imGuiDockNodePtr); /*
IMGUI_DOCK_NODE->CentralNode = (ImGuiDockNode*)imGuiDockNodePtr;
*/
/**
* [Root node only] Set when there is a single visible node within the hierarchy.
*/
public ImGuiDockNode getOnlyNodeWithWindows() {
ONLY_NODE_WITH_WINDOWS.ptr = nGetOnlyNodeWithWindows();
return PARENT_NODE;
}
private native long nGetOnlyNodeWithWindows(); /*
return (intptr_t)IMGUI_DOCK_NODE->OnlyNodeWithWindows;
*/
/**
* [Root node only] Set when there is a single visible node within the hierarchy.
*/
public void setOnlyNodeWithWindows(final ImGuiDockNode imGuiDockNode) {
nSetOnlyNodeWithWindows(imGuiDockNode.ptr);
}
private native void nSetOnlyNodeWithWindows(long imGuiDockNodePtr); /*
IMGUI_DOCK_NODE->OnlyNodeWithWindows = (ImGuiDockNode*)imGuiDockNodePtr;
*/
/**
* Last frame number the node was updated or kept alive explicitly with DockSpace() + int_KeepAliveOnly
*/
public native int getLastFrameAlive(); /*
return IMGUI_DOCK_NODE->LastFrameAlive;
*/
/**
* Last frame number the node was updated or kept alive explicitly with DockSpace() + int_KeepAliveOnly
*/
public native void setLastFrameAlive(int lastFrameAlive); /*
IMGUI_DOCK_NODE->LastFrameAlive = lastFrameAlive;
*/
/**
* Last frame number the node was updated.
*/
public native int getLastFrameActive(); /*
return IMGUI_DOCK_NODE->LastFrameActive;
*/
/**
* Last frame number the node was updated.
*/
public native void setLastFrameActive(int lastFrameActive); /*
IMGUI_DOCK_NODE->LastFrameActive = lastFrameActive;
*/
/**
* Last frame number the node was focused.
*/
public native int getLastFrameFocused(); /*
return IMGUI_DOCK_NODE->LastFrameFocused;
*/
/**
* Last frame number the node was focused.
*/
public native void setLastFrameFocused(int lastFrameFocused); /*
IMGUI_DOCK_NODE->LastFrameFocused = lastFrameFocused;
*/
/**
* [Root node only] Which of our child docking node (any ancestor in the hierarchy) was last focused.
*/
public native int getLastFocusedNodeId(); /*
return IMGUI_DOCK_NODE->LastFocusedNodeId;
*/
/**
* [Root node only] Which of our child docking node (any ancestor in the hierarchy) was last focused.
*/
public native void setLastFocusedNodeId(int lastFocusedNodeId); /*
IMGUI_DOCK_NODE->LastFocusedNodeId = lastFocusedNodeId;
*/
/**
* [Leaf node only] Which of our tab/window is selected.
*/
public native int getSelectedTabId(); /*
return IMGUI_DOCK_NODE->SelectedTabId;
*/
/**
* [Leaf node only] Which of our tab/window is selected.
*/
public native void setSelectedTabId(int selectedTabId); /*
IMGUI_DOCK_NODE->SelectedTabId = selectedTabId;
*/
/**
* [Leaf node only] Set when closing a specific tab/window.
*/
public native int getWantCloseTabId(); /*
return IMGUI_DOCK_NODE->WantCloseTabId;
*/
/**
* [Leaf node only] Set when closing a specific tab/window.
*/
public native void setWantCloseTabId(int wantCloseTabId); /*
IMGUI_DOCK_NODE->WantCloseTabId = wantCloseTabId;
*/
public native int getAuthorityForPos(); /*
return IMGUI_DOCK_NODE->AuthorityForPos;
*/
public native void setAuthorityForPos(int authorityForPos); /*
IMGUI_DOCK_NODE->AuthorityForPos = authorityForPos;
*/
public native int getAuthorityForSize(); /*
return IMGUI_DOCK_NODE->AuthorityForSize;
*/
public native void setAuthorityForSize(int authorityForSize); /*
IMGUI_DOCK_NODE->AuthorityForSize = authorityForSize;
*/
public native int getAuthorityForViewport(); /*
return IMGUI_DOCK_NODE->AuthorityForViewport;
*/
public native void setAuthorityForViewport(int authorityForViewport); /*
IMGUI_DOCK_NODE->AuthorityForViewport = authorityForViewport;
*/
/**
* Set to false when the node is hidden (usually disabled as it has no active window)
*/
public native boolean getIsVisible(); /*
return IMGUI_DOCK_NODE->IsVisible;
*/
/**
* Set to false when the node is hidden (usually disabled as it has no active window)
*/
public native void setIsVisible(boolean isVisible); /*
IMGUI_DOCK_NODE->IsVisible = isVisible;
*/
public native boolean getIsFocused(); /*
return IMGUI_DOCK_NODE->IsFocused;
*/
public native void setIsFocused(boolean isFocused); /*
IMGUI_DOCK_NODE->IsFocused = isFocused;
*/
public native boolean getHasCloseButton(); /*
return IMGUI_DOCK_NODE->HasCloseButton;
*/
public native void setHasCloseButton(boolean hasCloseButton); /*
IMGUI_DOCK_NODE->HasCloseButton = hasCloseButton;
*/
public native boolean getHasWindowMenuButton(); /*
return IMGUI_DOCK_NODE->HasWindowMenuButton;
*/
public native void setHasWindowMenuButton(boolean hasWindowMenuButton); /*
IMGUI_DOCK_NODE->HasWindowMenuButton = hasWindowMenuButton;
*/
public native boolean getEnableCloseButton(); /*
return IMGUI_DOCK_NODE->EnableCloseButton;
*/
public native void setEnableCloseButton(boolean enableCloseButton); /*
IMGUI_DOCK_NODE->EnableCloseButton = enableCloseButton;
*/
/**
* Set when closing all tabs at once.
*/
public native boolean getWantCloseAll(); /*
return IMGUI_DOCK_NODE->WantCloseAll;
*/
/**
* Set when closing all tabs at once.
*/
public native void setWantCloseAll(boolean wantCloseAll); /*
IMGUI_DOCK_NODE->WantCloseAll = wantCloseAll;
*/
public native boolean getWantLockSizeOnce(); /*
return IMGUI_DOCK_NODE->WantLockSizeOnce;
*/
public native void setWantLockSizeOnce(boolean wantLockSizeOnce); /*
IMGUI_DOCK_NODE->WantLockSizeOnce = wantLockSizeOnce;
*/
/**
* After a node extraction we need to transition toward moving the newly created host window
*/
public native boolean getWantMouseMove(); /*
return IMGUI_DOCK_NODE->WantMouseMove;
*/
/**
* After a node extraction we need to transition toward moving the newly created host window
*/
public native void setWantMouseMove(boolean wantMouseMove); /*
IMGUI_DOCK_NODE->WantMouseMove = wantMouseMove;
*/
public native boolean getWantHiddenTabBarUpdate(); /*
return IMGUI_DOCK_NODE->WantHiddenTabBarUpdate;
*/
public native void setWantHiddenTabBarUpdate(boolean wantHiddenTabBarUpdate); /*
IMGUI_DOCK_NODE->WantHiddenTabBarUpdate = wantHiddenTabBarUpdate;
*/
public native boolean getWantHiddenTabBarToggle(); /*
return IMGUI_DOCK_NODE->WantHiddenTabBarToggle;
*/
public native void setWantHiddenTabBarToggle(boolean wantHiddenTabBarToggle); /*
IMGUI_DOCK_NODE->WantHiddenTabBarToggle = wantHiddenTabBarToggle;
*/
/**
* Update by DockNodeTreeUpdatePosSize() write-filtering
*/
public native boolean getMarkedForPosSizeWrite(); /*
return IMGUI_DOCK_NODE->MarkedForPosSizeWrite;
*/
/**
* Update by DockNodeTreeUpdatePosSize() write-filtering
*/
public native void setMarkedForPosSizeWrite(boolean markedForPosSizeWrite); /*
IMGUI_DOCK_NODE->MarkedForPosSizeWrite = markedForPosSizeWrite;
*/
public native boolean isRootNode(); /*
return IMGUI_DOCK_NODE->IsRootNode();
*/
public native boolean isDockSpace(); /*
return IMGUI_DOCK_NODE->IsDockSpace();
*/
public native boolean isFloatingNode(); /*
return IMGUI_DOCK_NODE->IsFloatingNode();
*/
public native boolean isCentralNode(); /*
return IMGUI_DOCK_NODE->IsCentralNode();
*/
/**
* Hidden tab bar can be shown back by clicking the small triangle
*/
public native boolean isHiddenTabBar(); /*
return IMGUI_DOCK_NODE->IsHiddenTabBar();
*/
/**
* Never show a tab bar
*/
public native boolean isNoTabBar(); /*
return IMGUI_DOCK_NODE->IsNoTabBar();
*/
public native boolean isSplitNode(); /*
return IMGUI_DOCK_NODE->IsSplitNode();
*/
public native boolean isLeafNode(); /*
return IMGUI_DOCK_NODE->IsLeafNode();
*/
public native boolean isEmpty(); /*
return IMGUI_DOCK_NODE->IsEmpty();
*/
public native int getMergedFlags(); /*
return IMGUI_DOCK_NODE->GetMergedFlags();
*/
public ImRect rect() {
nRect(RECT.min, RECT.max);
return RECT;
}
private native void nRect(ImVec2 minDstImVec2, ImVec2 maxDstImVec2); /*
ImRect rect = IMGUI_DOCK_NODE->Rect();
Jni::ImVec2Cpy(env, &rect.Min, minDstImVec2);
Jni::ImVec2Cpy(env, &rect.Max, maxDstImVec2);
*/
}
@@ -0,0 +1,64 @@
package imgui.internal;
import imgui.ImVec2;
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 {
/**
* Upper-left
*/
public final ImVec2 min = new ImVec2();
/**
* Lower-right
*/
public final ImVec2 max = new ImVec2();
public ImRect() {
}
public ImRect(final ImVec2 min, final ImVec2 max) {
this.min.x = min.x;
this.min.y = min.y;
this.max.x = max.x;
this.max.y = max.y;
}
public ImRect(final float x1, final float y1, final float x2, final float y2) {
min.x = x1;
min.y = y1;
max.x = x2;
max.y = y2;
}
@Override
public String toString() {
return "ImRect{"
+ "min=" + min
+ ", max=" + max
+ '}';
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final ImRect imRect = (ImRect) o;
return Objects.equals(min, imRect.min) && Objects.equals(max, imRect.max);
}
@Override
public int hashCode() {
return Objects.hash(min, max);
}
}
@@ -0,0 +1,10 @@
package imgui.internal.flag;
public final class ImGuiAxis {
private ImGuiAxis() {
}
public static final int None = -1;
public static final int X = 0;
public static final int Y = 1;
}
@@ -0,0 +1,50 @@
package imgui.internal.flag;
public final class ImGuiDockNodeFlags extends imgui.flag.ImGuiDockNodeFlags {
private ImGuiDockNodeFlags() {
}
/**
* A dockspace is a node that occupy space within an existing user window. Otherwise the node is floating and create its own window.
*/
public static final int DockSpace = 1 << 10;
/**
* The central node has 2 main properties: stay visible when empty, only use "remaining" spaces from its neighbor.
*/
public static final int CentralNode = 1 << 11;
/**
* Tab bar is completely unavailable. No triangle in the corner to enable it back.
*/
public static final int NoTabBar = 1 << 12;
/**
* Tab bar is hidden, with a triangle in the corner to show it again (NB: actual tab-bar instance may be destroyed as this is only used for single-window tab bar)
*/
public static final int HiddenTabBar = 1 << 13;
/**
* Disable window/docking menu (that one that appears instead of the collapse button)
*/
public static final int NoWindowMenuButton = 1 << 14;
public static final int NoCloseButton = 1 << 15;
/**
* Disable any form of docking in this dockspace or individual node. (On a whole dockspace, this pretty much defeat the purpose of using a dockspace at all). Note: when turned on, existing docked nodes will be preserved.
*/
public static final int NoDocking = 1 << 16;
/**
* [EXPERIMENTAL] Prevent another window/node from splitting this node.
*/
public static final int NoDockingSplitMe = 1 << 17;
/**
* [EXPERIMENTAL] Prevent this node from splitting another window/node.
*/
public static final int NoDockingSplitOther = 1 << 18;
/**
* [EXPERIMENTAL] Prevent another window/node to be docked over this node.
*/
public static final int NoDockingOverMe = 1 << 19;
/**
* [EXPERIMENTAL] Prevent this node to be docked over another window/node.
*/
public static final int NoDockingOverOther = 1 << 20;
public static final int NoResizeX = 1 << 21;
public static final int NoResizeY = 1 << 22;
}
@@ -0,0 +1,11 @@
package imgui.internal.flag;
public final class ImGuiDockNodeState {
private ImGuiDockNodeState() {
}
public static final int Unknown = 0;
public static final int HostWindowHiddenBecauseSingleWindow = 1;
public static final int HostWindowHiddenBecauseWindowsAreResizing = 2;
public static final int HostWindowVisible = 3;
}
+46 -4
View File
@@ -1,11 +1,15 @@
import imgui.ImGuiViewport;
import imgui.type.ImBoolean;
import imgui.ImColor;
import imgui.ImGui;
import imgui.type.ImString;
import imgui.flag.ImGuiColorEditFlags;
import imgui.flag.ImGuiCond;
import imgui.flag.ImGuiDir;
import imgui.flag.ImGuiInputTextFlags;
import imgui.flag.ImGuiStyleVar;
import imgui.flag.ImGuiWindowFlags;
import imgui.internal.ImGui;
import imgui.internal.flag.ImGuiDockNodeFlags;
import imgui.type.ImBoolean;
import imgui.ImColor;
import imgui.type.ImString;
import org.lwjgl.BufferUtils;
import javax.imageio.ImageIO;
@@ -31,6 +35,7 @@ final class ExampleUi {
// Resizable input example
private final ImString resizableStr = new ImString(5);
private final ImBoolean showBottomDockedWindow = new ImBoolean(true);
private final ImBoolean showDemoWindow = new ImBoolean();
// Attach image example
@@ -43,6 +48,42 @@ final class ExampleUi {
void render() {
final ImGuiViewport mainViewport = ImGui.getMainViewport();
int windowFlags = 0;
ImGui.setNextWindowPos(mainViewport.getWorkPosX(), mainViewport.getWorkPosY());
ImGui.setNextWindowSize(mainViewport.getWorkSizeX(), mainViewport.getWorkSizeY());
ImGui.setNextWindowViewport(mainViewport.getID());
ImGui.pushStyleVar(ImGuiStyleVar.WindowRounding, 0);
ImGui.pushStyleVar(ImGuiStyleVar.WindowBorderSize, 0);
windowFlags |= ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove;
windowFlags |= ImGuiWindowFlags.NoBringToFrontOnFocus | ImGuiWindowFlags.NoNavFocus | ImGuiWindowFlags.NoBackground;
ImGui.pushStyleVar(ImGuiStyleVar.WindowPadding, 0, 0);
ImGui.begin("Dockspace Demo", windowFlags);
ImGui.popStyleVar(3);
final int dockspaceId = ImGui.getID("MyDockSpace");
if (ImGui.dockBuilderGetNode(dockspaceId) == null) {
ImGui.dockBuilderRemoveNode(dockspaceId);
ImGui.dockBuilderAddNode(dockspaceId, ImGuiDockNodeFlags.DockSpace);
final int dockIdBottom = ImGui.dockBuilderSplitNode(dockspaceId, ImGuiDir.Down, .25f, null, null);
ImGui.dockBuilderDockWindow("Bottom Docked Window", dockIdBottom);
ImGui.dockBuilderSetNodeSize(dockIdBottom, 150f, 150f);
ImGui.dockBuilderFinish(dockspaceId);
}
ImGui.dockSpace(dockspaceId, 0, 0, ImGuiDockNodeFlags.PassthruCentralNode);
ImGui.end();
if (showBottomDockedWindow.get()) {
ImGui.begin("Bottom Docked Window", showBottomDockedWindow);
ImGui.text("An example of how to create docked windows.");
ImGui.end();
}
ImGui.setNextWindowSize(600, 300, ImGuiCond.Once);
ImGui.setNextWindowPos(mainViewport.getWorkPosX() + 10, mainViewport.getWorkPosY() + 10, ImGuiCond.Once);
@@ -54,6 +95,7 @@ final class ExampleUi {
ImGui.getWindowDrawList().addImage(dukeTexture, xPoint, yPoint - 180, xPoint + 100, yPoint);
// Checkbox to show demo window
ImGui.checkbox("Show bottom docked window", showBottomDockedWindow);
ImGui.checkbox("Show demo window", showDemoWindow);
ImGui.separator();