From 9cc20e1e57462b844b8b4f0c0fbda1ef2a15ce58 Mon Sep 17 00:00:00 2001 From: Koen Date: Thu, 16 Feb 2023 20:16:03 +0100 Subject: [PATCH] Add Support for Enum ImGuiDockNodeFlags --- DearGenerator/TypeMaps/TypeMapEnumImGui.tt | 3 ++- DearImGui/ImGui.g.cs | 16 ++++++++-------- SampleApplication.OpenTK/MyGameWindow.cs | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/DearGenerator/TypeMaps/TypeMapEnumImGui.tt b/DearGenerator/TypeMaps/TypeMapEnumImGui.tt index 7611da2..6da9622 100644 --- a/DearGenerator/TypeMaps/TypeMapEnumImGui.tt +++ b/DearGenerator/TypeMaps/TypeMapEnumImGui.tt @@ -35,7 +35,8 @@ "ImGuiTableRowFlags", "ImGuiTreeNodeFlags", "ImGuiViewportFlags", - "ImGuiWindowFlags" + "ImGuiWindowFlags", + "ImGuiDockNodeFlags" }; Generate(types, "Constants.ImGuiNamespace"); diff --git a/DearImGui/ImGui.g.cs b/DearImGui/ImGui.g.cs index 4ef1625..92704ac 100644 --- a/DearImGui/ImGui.g.cs +++ b/DearImGui/ImGui.g.cs @@ -6325,7 +6325,7 @@ internal partial struct __Internal internal ImGuiViewportFlags ViewportFlagsOverrideSet; internal ImGuiViewportFlags ViewportFlagsOverrideClear; internal ImGuiTabItemFlags TabItemFlagsOverrideSet; - internal int DockNodeFlagsOverrideSet; + internal ImGuiDockNodeFlags DockNodeFlagsOverrideSet; internal byte DockingAlwaysTabBar; internal byte DockingAllowUnclassed; } @@ -6542,7 +6542,7 @@ public ImGuiTabItemFlags TabItemFlagsOverrideSet } /// [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!).
https://github.com/ocornut/imgui/blob/9cd9c2eff99877a3f10a7f9c2a3a5b9c15ea36c6/imgui.h#L2222.
- public int DockNodeFlagsOverrideSet + public ImGuiDockNodeFlags DockNodeFlagsOverrideSet { get { @@ -18756,10 +18756,10 @@ private partial struct __Internal32 internal static extern void SetTabItemClosed([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string tab_or_docked_window_label); [SuppressUnmanagedCodeSecurity, DllImport("imgui", EntryPoint = "?DockSpace@ImGui@@YAIIABUImVec2@@HPBUImGuiWindowClass@@@Z", CallingConvention = CallingConvention.Cdecl)] - internal static extern uint DockSpace(uint id, IntPtr size, int flags, IntPtr window_class); + internal static extern uint DockSpace(uint id, IntPtr size, ImGuiDockNodeFlags flags, IntPtr window_class); [SuppressUnmanagedCodeSecurity, DllImport("imgui", EntryPoint = "?DockSpaceOverViewport@ImGui@@YAIPBUImGuiViewport@@HPBUImGuiWindowClass@@@Z", CallingConvention = CallingConvention.Cdecl)] - internal static extern uint DockSpaceOverViewport(IntPtr viewport, int flags, IntPtr window_class); + internal static extern uint DockSpaceOverViewport(IntPtr viewport, ImGuiDockNodeFlags flags, IntPtr window_class); [SuppressUnmanagedCodeSecurity, DllImport("imgui", EntryPoint = "?SetNextWindowDockID@ImGui@@YAXIH@Z", CallingConvention = CallingConvention.Cdecl)] internal static extern void SetNextWindowDockID(uint dock_id, ImGuiCond cond); @@ -20069,10 +20069,10 @@ private partial struct __Internal64 internal static extern void SetTabItemClosed([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string tab_or_docked_window_label); [SuppressUnmanagedCodeSecurity, DllImport("imgui", EntryPoint = "?DockSpace@ImGui@@YAIIAEBUImVec2@@HPEBUImGuiWindowClass@@@Z", CallingConvention = CallingConvention.Cdecl)] - internal static extern uint DockSpace(uint id, IntPtr size, int flags, IntPtr window_class); + internal static extern uint DockSpace(uint id, IntPtr size, ImGuiDockNodeFlags flags, IntPtr window_class); [SuppressUnmanagedCodeSecurity, DllImport("imgui", EntryPoint = "?DockSpaceOverViewport@ImGui@@YAIPEBUImGuiViewport@@HPEBUImGuiWindowClass@@@Z", CallingConvention = CallingConvention.Cdecl)] - internal static extern uint DockSpaceOverViewport(IntPtr viewport, int flags, IntPtr window_class); + internal static extern uint DockSpaceOverViewport(IntPtr viewport, ImGuiDockNodeFlags flags, IntPtr window_class); [SuppressUnmanagedCodeSecurity, DllImport("imgui", EntryPoint = "?SetNextWindowDockID@ImGui@@YAXIH@Z", CallingConvention = CallingConvention.Cdecl)] internal static extern void SetNextWindowDockID(uint dock_id, ImGuiCond cond); @@ -24164,7 +24164,7 @@ public static void SetTabItemClosed(string tab_or_docked_window_label) /// 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!
- Drag from window title bar or their tab to dock/undock. Hold SHIFT to disable docking/undocking.
- Drag from window menu button (upper-left button) to undock an entire node (all windows).
- When io.ConfigDockingWithShift == true, you instead need to hold SHIFT to _enable_ docking/undocking.
About dockspaces:.
- Use DockSpace() to create an explicit dock node _within_ an existing window. See Docking demo for details.
- Use DockSpaceOverViewport() to create an explicit dock node covering the screen or a specific viewport.
This is often used with ImGuiDockNodeFlags_PassthruCentralNode.
- Important: Dockspaces need to be submitted _before_ any window they can host. Submit it early in your frame!
- Important: Dockspaces need to be kept alive if hidden, otherwise windows docked into it will be undocked.
E.g. if you have multiple tabs with a dockspace inside each tab: submit the non-visible dockspaces with ImGuiDockNodeFlags_KeepAliveOnly.
https://github.com/ocornut/imgui/blob/9cd9c2eff99877a3f10a7f9c2a3a5b9c15ea36c6/imgui.h#L805.
// DEBUG: ImGuiID DockSpace(ImGuiID id, const ImVec2& size = ImVec2(0, 0), ImGuiDockNodeFlags flags = 0, const ImGuiWindowClass* window_class = NULL) - public static uint DockSpace(uint id, Vector2 size, int flags = (int)(0), ImGuiWindowClass window_class = default) + public static uint DockSpace(uint id, Vector2 size, ImGuiDockNodeFlags flags = (ImGuiDockNodeFlags)(0), ImGuiWindowClass window_class = default) { var __arg1 = new IntPtr(Unsafe.AsPointer(ref size)) /* DEBUG: TypeMapImVec2.CSharpMarshalToNative: Case 3 */ @@ -24177,7 +24177,7 @@ public static uint DockSpace(uint id, Vector2 size, int flags = (int)(0), ImGuiW /// https://github.com/ocornut/imgui/blob/9cd9c2eff99877a3f10a7f9c2a3a5b9c15ea36c6/imgui.h#L806. // DEBUG: ImGuiID DockSpaceOverViewport(const ImGuiViewport* viewport = NULL, ImGuiDockNodeFlags flags = 0, const ImGuiWindowClass* window_class = NULL) - public static uint DockSpaceOverViewport(ImGuiViewport viewport = default, int flags = (int)(0), ImGuiWindowClass window_class = default) + public static uint DockSpaceOverViewport(ImGuiViewport viewport = default, ImGuiDockNodeFlags flags = (ImGuiDockNodeFlags)(0), ImGuiWindowClass window_class = default) { var __arg0 = viewport is null ? IntPtr.Zero : viewport.__Instance; var __arg2 = window_class is null ? IntPtr.Zero : window_class.__Instance; diff --git a/SampleApplication.OpenTK/MyGameWindow.cs b/SampleApplication.OpenTK/MyGameWindow.cs index 94ed077..2fa9210 100644 --- a/SampleApplication.OpenTK/MyGameWindow.cs +++ b/SampleApplication.OpenTK/MyGameWindow.cs @@ -72,7 +72,6 @@ protected override void OnRenderFrame(FrameEventArgs args) if (ShowDockingDemo) { DrawDockSpaceOptionsBar(ref ShowDockingDemo); - ImGui.DockSpaceOverViewport(ImGui.GetMainViewport(), (int)dockspace_flags); } @@ -131,6 +130,7 @@ protected override void OnResize(ResizeEventArgs e) void DrawDockSpaceOptionsBar(ref bool p_open) { + ImGui.DockSpaceOverViewport(ImGui.GetMainViewport(), dockspace_flags); if (ImGui.BeginMainMenuBar()) { if (ImGui.BeginMenu("Options"))