From d002eaed1ab50696b74b3d1ee42f73256e1ac5ed Mon Sep 17 00:00:00 2001 From: Patrick Dawson Date: Fri, 2 Dec 2022 20:52:44 +0100 Subject: [PATCH] cleanup --- addons/imgui-godot/ImGuiGodot/ImGuiGD.cs | 18 +++++++++--------- .../ImGuiGodot/InternalViewports.cs | 1 - project.godot | 1 + src/MySecondNode.cs | 3 ++- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/addons/imgui-godot/ImGuiGodot/ImGuiGD.cs b/addons/imgui-godot/ImGuiGodot/ImGuiGD.cs index 273b6c0..611e545 100644 --- a/addons/imgui-godot/ImGuiGodot/ImGuiGD.cs +++ b/addons/imgui-godot/ImGuiGodot/ImGuiGD.cs @@ -127,16 +127,16 @@ public static void ExperimentalEnableViewports() io.BackendFlags |= ImGuiBackendFlags.PlatformHasViewports; io.ConfigFlags |= ImGuiConfigFlags.ViewportsEnable; - switch (OS.GetName()) + if (OS.GetName() != "Windows") { - case "Windows": - break; - case "macOS": - GD.PushError("ImGui Viewports are currently very broken on macOS"); - break; - default: - GD.PushWarning("ImGui Viewports are probably broken on Linux/BSD https://github.com/ocornut/imgui/wiki/Multi-Viewports#issues"); - break; + GD.PushWarning("ImGui Viewports have issues on macOS and Linux https://github.com/ocornut/imgui/wiki/Multi-Viewports#issues"); + } + + var mainvp = ImGuiLayer.Instance.GetViewport(); + if (mainvp.GuiEmbedSubwindows) + { + GD.PushWarning("ImGui Viewports: 'display/window/subwindows/embed_subwindows' needs to be disabled"); + mainvp.GuiEmbedSubwindows = false; } } diff --git a/addons/imgui-godot/ImGuiGodot/InternalViewports.cs b/addons/imgui-godot/ImGuiGodot/InternalViewports.cs index 4a90887..1fb7e63 100644 --- a/addons/imgui-godot/ImGuiGodot/InternalViewports.cs +++ b/addons/imgui-godot/ImGuiGodot/InternalViewports.cs @@ -21,7 +21,6 @@ public GodotImGuiWindow(ImGuiViewportPtr vp) _vp.PlatformHandle = (IntPtr)_gcHandle; Rect2i winRect = new(_vp.Pos.ToVector2i(), _vp.Size.ToVector2i()); - GD.Print(winRect); ImGuiLayer.Instance.GetViewport().GuiEmbedSubwindows = false; diff --git a/project.godot b/project.godot index 57f706d..fbb6de0 100644 --- a/project.godot +++ b/project.godot @@ -23,6 +23,7 @@ ImGuiLayer="*res://addons/imgui-godot/ImGuiLayer.tscn" window/size/viewport_width=1280 window/size/viewport_height=720 +window/subwindows/embed_subwindows=false window/stretch/mode="canvas_items" window/stretch/aspect="expand" diff --git a/src/MySecondNode.cs b/src/MySecondNode.cs index f0ef4e3..8e51b81 100644 --- a/src/MySecondNode.cs +++ b/src/MySecondNode.cs @@ -59,7 +59,8 @@ private void OnImGuiLayout() float fh = ImGui.GetFrameHeight(); - ImGui.SetNextWindowPos(new(10, 10)); + var mainVpPos = ImGui.GetMainViewport().WorkPos; + ImGui.SetNextWindowPos(new(mainVpPos.X + 10, mainVpPos.Y + 10)); ImGui.Begin("change scene window", cswinflags); if (ImGui.Button("change scene")) {