Expose docking API
This commit is contained in:
1 parent
af836193da
commit
5458a03757
8 files changed
+360
-15
No files matched your search
@@ -28,7 +28,6 @@ public final class ImFontGlyph implements ImDestroyable {
|
||||
/*JNI
|
||||
#include <stdint.h>
|
||||
#include <imgui.h>
|
||||
#include "jni_common.h"
|
||||
|
||||
jfieldID imFontGlyphPtrID;
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ public final class ImGui {
|
||||
ImFontGlyph.nInit();
|
||||
ImFont.nInit();
|
||||
ImGuiStyle.nInit();
|
||||
ImGuiWindowClass.nInit();
|
||||
nInitInputTextData();
|
||||
}
|
||||
|
||||
@@ -474,6 +475,13 @@ public final class ImGui {
|
||||
return (intptr_t)ImGui::GetWindowDrawList();
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get DPI scale currently associated to the current window's viewport.
|
||||
*/
|
||||
public static native float getWindowDpiScale(); /*
|
||||
return ImGui::GetWindowDpiScale();
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get current window position in screen space (useful if you want to do your own drawing via the DrawList API)
|
||||
*/
|
||||
@@ -3989,6 +3997,7 @@ public final class ImGui {
|
||||
*/
|
||||
|
||||
// Tab Bars, Tabs
|
||||
// Note: Tabs are automatically created by the docking system. Use this to create tab bars/tabs yourself without docking being involved.
|
||||
|
||||
/**
|
||||
* Create and append into a TabBar
|
||||
@@ -4062,6 +4071,73 @@ public final class ImGui {
|
||||
ImGui::SetTabItemClosed(tabOrDockedWindowLabel);
|
||||
*/
|
||||
|
||||
// Docking
|
||||
// [BETA API] Enable with io.ConfigFlags |= ImGuiConfigFlags_DockingEnable.
|
||||
// Note: You can use most Docking facilities without calling any API. You DO NOT need to call DockSpace() to use Docking!
|
||||
// - To dock windows: if io.ConfigDockingWithShift == false (default) drag window from their title bar.
|
||||
// - To dock windows: if io.ConfigDockingWithShift == true: hold SHIFT anywhere while moving windows.
|
||||
// About DockSpace:
|
||||
// - Use DockSpace() to create an explicit dock node _within_ an existing window. See Docking demo for details.
|
||||
// - DockSpace() needs to be submitted _before_ any window they can host. If you use a dockspace, submit it early in your app.
|
||||
|
||||
public static void dockSpace(int imGuiID) {
|
||||
nDockSpace(imGuiID, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
public static void dockSpace(int imGuiID, float sizeX, float sizeY) {
|
||||
nDockSpace(imGuiID, sizeX, sizeY, 0, 0);
|
||||
}
|
||||
|
||||
public static void dockSpace(int imGuiID, float sizeX, float sizeY, int imGuiDockNodeFlags) {
|
||||
nDockSpace(imGuiID, sizeX, sizeY, imGuiDockNodeFlags, 0);
|
||||
}
|
||||
|
||||
public static void dockSpace(int imGuiID, float sizeX, float sizeY, int imGuiDockNodeFlags, ImGuiWindowClass imGuiWindowClass) {
|
||||
nDockSpace(imGuiID, sizeX, sizeY, imGuiDockNodeFlags, imGuiWindowClass.ptr);
|
||||
}
|
||||
|
||||
private static native void nDockSpace(int imGuiID, float sizeX, float sizeY, int imGuiDockNodeFlags, long windowClassPtr); /*
|
||||
ImGui::DockSpace(imGuiID, ImVec2(sizeX, sizeY), imGuiDockNodeFlags, windowClassPtr != 0 ? (ImGuiWindowClass*)windowClassPtr : NULL);
|
||||
*/
|
||||
|
||||
// TODO: DockSpaceOverViewport
|
||||
|
||||
/**
|
||||
* Set next window dock id
|
||||
*/
|
||||
public static native void setNextWindowDockID(int dockId); /*
|
||||
ImGui::SetNextWindowDockID(dockId);
|
||||
*/
|
||||
|
||||
/**
|
||||
* Set next window dock id
|
||||
*/
|
||||
public static native void setNextWindowDockID(int dockId, int imGuiCond); /*
|
||||
ImGui::SetNextWindowDockID(dockId, imGuiCond);
|
||||
*/
|
||||
|
||||
/**
|
||||
* set next window class (rare/advanced uses: provide hints to the platform back-end via altered viewport flags and parent/child info)
|
||||
*/
|
||||
public static void setNextWindowClass(ImGuiWindowClass windowClass) {
|
||||
nSetNextWindowClass(windowClass.ptr);
|
||||
}
|
||||
|
||||
private static native void nSetNextWindowClass(long windowClassPtr); /*
|
||||
ImGui::SetNextWindowClass((ImGuiWindowClass*)windowClassPtr);
|
||||
*/
|
||||
|
||||
public static native int getWindowDockID(); /*
|
||||
return ImGui::GetWindowDockID();
|
||||
*/
|
||||
|
||||
/**
|
||||
* Is current window docked into another window?
|
||||
*/
|
||||
public static native boolean isWindowDocked(); /*
|
||||
return ImGui::IsWindowDocked();
|
||||
*/
|
||||
|
||||
// Logging/Capture
|
||||
// - All text output from the interface can be captured into tty/file/clipboard. By default, tree nodes are automatically opened during logging.
|
||||
|
||||
@@ -4432,6 +4508,7 @@ public final class ImGui {
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get background draw list for the viewport associated to the current window.
|
||||
* This draw list will be the first rendering one. Useful to quickly draw shapes/text behind dear imgui contents.
|
||||
*/
|
||||
public static ImDrawList getBackgroundDrawList() {
|
||||
@@ -4446,7 +4523,8 @@ public final class ImGui {
|
||||
*/
|
||||
|
||||
/**
|
||||
* This draw list will be the last rendered one. Useful to quickly draw shapes/text over dear imgui contents.
|
||||
* Get foreground draw list for the viewport associated to the current window.
|
||||
* This draw list will be the first rendering one. Useful to quickly draw shapes/text behind dear imgui contents.
|
||||
*/
|
||||
public static ImDrawList getForegroundDrawList() {
|
||||
if (foregroundDrawList == null) {
|
||||
|
||||
@@ -465,6 +465,68 @@ public final class ImGuiIO {
|
||||
ImGui::GetIO().DisplayFramebufferScale.y = y;
|
||||
*/
|
||||
|
||||
// Docking options (when ImGuiConfigFlags_DockingEnable is set)
|
||||
|
||||
/**
|
||||
* Simplified docking mode: disable window splitting, so docking is limited to merging multiple windows together into tab-bars.
|
||||
*/
|
||||
public native boolean getConfigDockingNoSplit(); /*
|
||||
return ImGui::GetIO().ConfigDockingNoSplit;
|
||||
*/
|
||||
|
||||
/**
|
||||
* Simplified docking mode: disable window splitting, so docking is limited to merging multiple windows together into tab-bars.
|
||||
*/
|
||||
public native void setConfigDockingNoSplit(boolean value); /*
|
||||
ImGui::GetIO().ConfigDockingNoSplit = value;
|
||||
*/
|
||||
|
||||
/**
|
||||
* Enable docking with holding Shift key (reduce visual noise, allows dropping in wider space)
|
||||
*/
|
||||
public native boolean getConfigDockingWithShift(); /*
|
||||
return ImGui::GetIO().ConfigDockingWithShift;
|
||||
*/
|
||||
|
||||
/**
|
||||
* Enable docking with holding Shift key (reduce visual noise, allows dropping in wider space)
|
||||
*/
|
||||
public native void setConfigDockingWithShift(boolean value); /*
|
||||
ImGui::GetIO().ConfigDockingWithShift = value;
|
||||
*/
|
||||
|
||||
/**
|
||||
* [BETA] [FIXME: This currently creates regression with auto-sizing and general overhead]
|
||||
* Make every single floating window display within a docking node.
|
||||
*/
|
||||
public native boolean getConfigDockingAlwaysTabBar(); /*
|
||||
return ImGui::GetIO().ConfigDockingAlwaysTabBar;
|
||||
*/
|
||||
|
||||
/**
|
||||
* [BETA] [FIXME: This currently creates regression with auto-sizing and general overhead]
|
||||
* Make every single floating window display within a docking node.
|
||||
*/
|
||||
public native void setConfigDockingAlwaysTabBar(boolean value); /*
|
||||
ImGui::GetIO().ConfigDockingAlwaysTabBar = value;
|
||||
*/
|
||||
|
||||
/**
|
||||
* [BETA] Make window or viewport transparent when docking and only display docking boxes on the target viewport.
|
||||
* Useful if rendering of multiple viewport cannot be synced. Best used with ConfigViewportsNoAutoMerge.
|
||||
*/
|
||||
public native boolean getConfigDockingTransparentPayload(); /*
|
||||
return ImGui::GetIO().ConfigDockingTransparentPayload;
|
||||
*/
|
||||
|
||||
/**
|
||||
* [BETA] Make window or viewport transparent when docking and only display docking boxes on the target viewport.
|
||||
* Useful if rendering of multiple viewport cannot be synced. Best used with ConfigViewportsNoAutoMerge.
|
||||
*/
|
||||
public native void setConfigDockingTransparentPayload(boolean value); /*
|
||||
ImGui::GetIO().ConfigDockingTransparentPayload = value;
|
||||
*/
|
||||
|
||||
/**
|
||||
* Time elapsed since last frame, in seconds.
|
||||
* <p>
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
package imgui;
|
||||
|
||||
/**
|
||||
* [ALPHA] Rarely used / very advanced uses only. Use with SetNextWindowClass() and DockSpace() functions.
|
||||
* Important: the content of this class is still highly WIP and likely to change and be refactored
|
||||
* before we stabilize Docking features. Please be mindful if using this.
|
||||
* Provide hints:
|
||||
* - To the platform back-end via altered viewport flags (enable/disable OS decoration, OS task bar icons, etc.)
|
||||
* - To the platform back-end for OS level parent/child relationships of viewport.
|
||||
* - To the docking system for various options and filtering.
|
||||
*/
|
||||
public final class ImGuiWindowClass implements ImDestroyable {
|
||||
final long ptr;
|
||||
|
||||
/**
|
||||
* This class will create a native structure.
|
||||
* Call {@link #destroy()} method to manually free used memory.
|
||||
*/
|
||||
public ImGuiWindowClass() {
|
||||
ImGui.touch();
|
||||
ptr = nCreate();
|
||||
}
|
||||
|
||||
ImGuiWindowClass(final long ptr) {
|
||||
this.ptr = ptr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
nDestroy(ptr);
|
||||
}
|
||||
|
||||
/*JNI
|
||||
#include <stdint.h>
|
||||
#include <imgui.h>
|
||||
|
||||
jfieldID imGuiWindowClassPtrID;
|
||||
|
||||
#define IMGUI_WINDOW_CLASS ((ImGuiWindowClass*)env->GetLongField(object, imGuiWindowClassPtrID))
|
||||
*/
|
||||
|
||||
static native void nInit(); /*
|
||||
jclass jImGuiWindowClassClass = env->FindClass("imgui/ImGuiWindowClass");
|
||||
imGuiWindowClassPtrID = env->GetFieldID(jImGuiWindowClassClass, "ptr", "J");
|
||||
*/
|
||||
|
||||
private native long nCreate(); /*
|
||||
ImGuiWindowClass* imGuiWindowClass = new ImGuiWindowClass();
|
||||
return (intptr_t)imGuiWindowClass;
|
||||
*/
|
||||
|
||||
private native void nDestroy(long ptr); /*
|
||||
delete (ImGuiWindowClass*)ptr;
|
||||
*/
|
||||
|
||||
/**
|
||||
* User data. 0 = Default class (unclassed). Windows of different classes cannot be docked with each others.
|
||||
*/
|
||||
public native int geClassId(); /*
|
||||
return IMGUI_WINDOW_CLASS->ClassId;
|
||||
*/
|
||||
|
||||
/**
|
||||
* User data. 0 = Default class (unclassed). Windows of different classes cannot be docked with each others.
|
||||
*/
|
||||
public native void setClassId(int classId); /*
|
||||
IMGUI_WINDOW_CLASS->ClassId = classId;
|
||||
*/
|
||||
|
||||
/**
|
||||
* Hint for the platform back-end. If non-zero, the platform back-end can create a parent<>child relationship between the platform windows.
|
||||
* Not conforming back-ends are free to e.g. parent every viewport to the main viewport or not.
|
||||
*/
|
||||
public native int getParentViewportId(); /*
|
||||
return IMGUI_WINDOW_CLASS->ParentViewportId;
|
||||
*/
|
||||
|
||||
/**
|
||||
* Hint for the platform back-end. If non-zero, the platform back-end can create a parent<>child relationship between the platform windows.
|
||||
* Not conforming back-ends are free to e.g. parent every viewport to the main viewport or not.
|
||||
*/
|
||||
public native void setParentViewportId(int parentViewportId); /*
|
||||
IMGUI_WINDOW_CLASS->ParentViewportId = parentViewportId;
|
||||
*/
|
||||
|
||||
// TODO: ViewportFlagsOverrideSet, 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!)
|
||||
*/
|
||||
public native int getDockNodeFlagsOverrideSet(); /*
|
||||
return IMGUI_WINDOW_CLASS->DockNodeFlagsOverrideSet;
|
||||
*/
|
||||
|
||||
/**
|
||||
* [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!)
|
||||
*/
|
||||
public native void setDockNodeFlagsOverrideSet(int dockNodeFlagsOverrideSet); /*
|
||||
IMGUI_WINDOW_CLASS->DockNodeFlagsOverrideSet = dockNodeFlagsOverrideSet;
|
||||
*/
|
||||
|
||||
/**
|
||||
* [EXPERIMENTAL]
|
||||
*/
|
||||
public native int getDockNodeFlagsOverrideClear(); /*
|
||||
return IMGUI_WINDOW_CLASS->DockNodeFlagsOverrideClear;
|
||||
*/
|
||||
|
||||
/**
|
||||
* [EXPERIMENTAL]
|
||||
*/
|
||||
public native void setDockNodeFlagsOverrideClear(int dockNodeFlagsOverrideClear); /*
|
||||
IMGUI_WINDOW_CLASS->DockNodeFlagsOverrideClear = dockNodeFlagsOverrideClear;
|
||||
*/
|
||||
|
||||
/**
|
||||
* Set to true to enforce single floating windows of this class always having their own docking node
|
||||
* (equivalent of setting the global io.ConfigDockingAlwaysTabBar)
|
||||
*/
|
||||
public native boolean getDockingAlwaysTabBar(); /*
|
||||
return IMGUI_WINDOW_CLASS->DockingAlwaysTabBar;
|
||||
*/
|
||||
|
||||
/**
|
||||
* Set to true to enforce single floating windows of this class always having their own docking node
|
||||
* (equivalent of setting the global io.ConfigDockingAlwaysTabBar)
|
||||
*/
|
||||
public native void setDockingAlwaysTabBar(boolean dockingAlwaysTabBar); /*
|
||||
IMGUI_WINDOW_CLASS->DockingAlwaysTabBar = dockingAlwaysTabBar;
|
||||
*/
|
||||
|
||||
/**
|
||||
* Set to true to allow windows of this class to be docked/merged with an unclassed window.
|
||||
*/
|
||||
public native boolean getDockingAllowUnclassed(); /*
|
||||
return IMGUI_WINDOW_CLASS->DockingAllowUnclassed;
|
||||
*/
|
||||
|
||||
/**
|
||||
* Set to true to allow windows of this class to be docked/merged with an unclassed window.
|
||||
*/
|
||||
public native void setDockingAllowUnclassed(boolean dockingAllowUnclassed); /*
|
||||
IMGUI_WINDOW_CLASS->DockingAllowUnclassed = dockingAllowUnclassed;
|
||||
*/
|
||||
}
|
||||
@@ -12,7 +12,7 @@ public final class ImGuiCol {
|
||||
/**
|
||||
* Background of normal windows
|
||||
*/
|
||||
public static final int WindowBg = 2; //
|
||||
public static final int WindowBg = 2;
|
||||
/**
|
||||
* Background of child windows
|
||||
*/
|
||||
@@ -60,28 +60,35 @@ public final class ImGuiCol {
|
||||
public static final int TabActive = 35;
|
||||
public static final int TabUnfocused = 36;
|
||||
public static final int TabUnfocusedActive = 37;
|
||||
public static final int PlotLines = 38;
|
||||
public static final int PlotLinesHovered = 39;
|
||||
public static final int PlotHistogram = 40;
|
||||
public static final int PlotHistogramHovered = 41;
|
||||
public static final int TextSelectedBg = 42;
|
||||
public static final int DragDropTarget = 43;
|
||||
/**
|
||||
* Preview overlay color when about to docking something
|
||||
*/
|
||||
public static final int DockingPreview = 38;
|
||||
/**
|
||||
* Background color for empty node (e.g. CentralNode with no window docked into it)
|
||||
*/
|
||||
public static final int DockingEmptyBg = 39;
|
||||
public static final int PlotLines = 40;
|
||||
public static final int PlotLinesHovered = 41;
|
||||
public static final int PlotHistogram = 42;
|
||||
public static final int PlotHistogramHovered = 43;
|
||||
public static final int TextSelectedBg = 44;
|
||||
public static final int DragDropTarget = 45;
|
||||
/**
|
||||
* Gamepad/keyboard: current highlighted item
|
||||
*/
|
||||
public static final int NavHighlight = 44;
|
||||
public static final int NavHighlight = 46;
|
||||
/**
|
||||
* Highlight window when using CTRL+TAB
|
||||
*/
|
||||
public static final int NavWindowingHighlight = 45;
|
||||
public static final int NavWindowingHighlight = 47;
|
||||
/**
|
||||
* Darken/colorize entire screen behind the CTRL+TAB window list, when active
|
||||
*/
|
||||
public static final int NavWindowingDimBg = 46;
|
||||
public static final int NavWindowingDimBg = 48;
|
||||
/**
|
||||
* Darken/colorize entire screen behind a modal window, when one is active
|
||||
*/
|
||||
public static final int ModalWindowDimBg = 47;
|
||||
public static final int COUNT = 48;
|
||||
|
||||
public static final int ModalWindowDimBg = 49;
|
||||
public static final int COUNT = 49;
|
||||
}
|
||||
@@ -37,6 +37,12 @@ public final class ImGuiConfigFlags {
|
||||
*/
|
||||
public static final int NoMouseCursorChange = 1 << 5;
|
||||
|
||||
/**
|
||||
* [BETA] Docking
|
||||
* Docking enable flags.
|
||||
*/
|
||||
public static final int DockingEnable = 1 << 6;
|
||||
|
||||
// User storage (to allow your back-end/engine to communicate to code that may be shared between multiple projects. Those flags are not used by core Dear ImGui)
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package imgui.enums;
|
||||
|
||||
/**
|
||||
* Flags for ImGui::DockSpace(), shared/inherited by child nodes.
|
||||
* (Some flags can be applied to individual nodes directly)
|
||||
*/
|
||||
public final class ImGuiDockNodeFlags {
|
||||
private 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.
|
||||
*/
|
||||
public static final int KeepAliveOnly = 1;
|
||||
/**
|
||||
* Disable Central Node (the node which can stay empty)
|
||||
*/
|
||||
public static final int NoCentralNode = 1 << 1;
|
||||
/**
|
||||
* Disable docking inside the Central Node, which will be always kept empty.
|
||||
*/
|
||||
public static final int NoDockingInCentralNode = 1 << 2;
|
||||
/**
|
||||
* Enable passthru dockspace: 1) DockSpace() will render a ImGuiCol_WindowBg background covering everything excepted the Central
|
||||
* Node when empty. Meaning the host window should probably use SetNextWindowBgAlpha(0.0f) prior to Begin() when using this. 2)
|
||||
* When Central Node is empty: let inputs pass-through + won't display a DockingEmptyBg background. See demo for details.
|
||||
*/
|
||||
public static final int PassthruCentralNode = 1 << 3;
|
||||
/**
|
||||
* Disable splitting the node into smaller nodes.
|
||||
* Useful e.g. when embedding dockspaces into a main root one (the root one may have splitting disabled to reduce confusion).
|
||||
* Note: when turned off, existing splits will be preserved.
|
||||
*/
|
||||
public static final int NoSplit = 1 << 4;
|
||||
/**
|
||||
* Disable resizing node using the splitter/separators. Useful with programatically setup dockspaces.
|
||||
*/
|
||||
public static final int NoResize = 1 << 5;
|
||||
/**
|
||||
* Tab bar will automatically hide when there is a single window in the dock node.
|
||||
*/
|
||||
public static final int AutoHideTabBar = 1 << 6;
|
||||
}
|
||||
@@ -85,6 +85,10 @@ public final class ImGuiWindowFlags {
|
||||
* Append '*' to title without affecting the ID, as a convenience to avoid using the ### operator. When used in a tab/docking context, tab is selected on closure and closure is deferred by one frame to allow code to cancel the closure (with a confirmation popup, etc.) without flicker.
|
||||
*/
|
||||
public static final int UnsavedDocument = 1 << 20;
|
||||
/**
|
||||
* Disable docking of this window
|
||||
*/
|
||||
public static final int NoDocking = 1 << 21;
|
||||
public static final int NoNav = NoNavInputs | NoNavFocus;
|
||||
public static final int NoDecoration = NoTitleBar | NoResize | NoScrollbar | NoCollapse;
|
||||
public static final int NoInputs = NoMouseInputs | NoNavInputs | NoNavFocus;
|
||||
|
||||
Reference in new issue
Block a user