diff --git a/addons/imgui-godot/ImGuiGodot/ImGuiGD.cs b/addons/imgui-godot/ImGuiGodot/ImGuiGD.cs index a2b0beb..965d1e8 100644 --- a/addons/imgui-godot/ImGuiGodot/ImGuiGD.cs +++ b/addons/imgui-godot/ImGuiGodot/ImGuiGD.cs @@ -103,7 +103,14 @@ public static void RebuildFontAtlas() public static void Update(double delta, Viewport vp) { - Internal.State.Update(delta, vp); + var io = ImGui.GetIO(); + var vpSize = vp.GetVisibleRect().Size; + io.DisplaySize = new(vpSize.x, vpSize.y); + io.DeltaTime = (float)delta; + + Internal.Input.Update(io); + + ImGui.NewFrame(); } public static void Render(Viewport vp) diff --git a/addons/imgui-godot/ImGuiGodot/ImGuiLayer.cs b/addons/imgui-godot/ImGuiGodot/ImGuiLayer.cs index fad5ccd..87862f4 100644 --- a/addons/imgui-godot/ImGuiGodot/ImGuiLayer.cs +++ b/addons/imgui-godot/ImGuiGodot/ImGuiLayer.cs @@ -195,7 +195,7 @@ public override void _Process(double delta) public override void _Notification(long what) { - Internal.State.ProcessNotification(what); + Internal.Input.ProcessNotification(what); } public override void _Input(InputEvent e) diff --git a/addons/imgui-godot/ImGuiGodot/Internal/Input.cs b/addons/imgui-godot/ImGuiGodot/Internal/Input.cs index 97cd04d..7839baa 100644 --- a/addons/imgui-godot/ImGuiGodot/Internal/Input.cs +++ b/addons/imgui-godot/ImGuiGodot/Internal/Input.cs @@ -189,6 +189,19 @@ public static bool ProcessInput(InputEvent evt, Window window) return consumed; } + public static void ProcessNotification(long what) + { + switch (what) + { + case MainLoop.NotificationApplicationFocusIn: + ImGui.GetIO().AddFocusEvent(true); + break; + case MainLoop.NotificationApplicationFocusOut: + ImGui.GetIO().AddFocusEvent(false); + break; + }; + } + private static void UpdateKeyMods(ImGuiIOPtr io) { io.AddKeyEvent(ImGuiKey.ModCtrl, Godot.Input.IsKeyPressed(Key.Ctrl)); diff --git a/addons/imgui-godot/ImGuiGodot/Internal/State.cs b/addons/imgui-godot/ImGuiGodot/Internal/State.cs index a61b98a..0fae5e6 100644 --- a/addons/imgui-godot/ImGuiGodot/Internal/State.cs +++ b/addons/imgui-godot/ImGuiGodot/Internal/State.cs @@ -75,31 +75,6 @@ public static unsafe void SetIniFilename(ImGuiIOPtr io, string fileName) } } - public static void Update(double delta, Viewport vp) - { - var io = ImGui.GetIO(); - var vpSize = vp.GetVisibleRect().Size; - io.DisplaySize = new(vpSize.x, vpSize.y); - io.DeltaTime = (float)delta; - - Input.Update(io); - - ImGui.NewFrame(); - } - - public static void ProcessNotification(long what) - { - switch (what) - { - case MainLoop.NotificationApplicationFocusIn: - ImGui.GetIO().AddFocusEvent(true); - break; - case MainLoop.NotificationApplicationFocusOut: - ImGui.GetIO().AddFocusEvent(false); - break; - }; - } - public static void AddLayerSubViewport(Node parent, out SubViewportContainer subViewportContainer, out SubViewport subViewport) { subViewportContainer = new SubViewportContainer