Skip to content

Commit

Permalink
move another thing
Browse files Browse the repository at this point in the history
  • Loading branch information
pkdawson committed Dec 3, 2022
1 parent 6b5430c commit 429033c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 26 deletions.
3 changes: 1 addition & 2 deletions addons/imgui-godot/ImGuiGodot/ImGuiLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ public override void _EnterTree()
ImGuiGD.AddFontDefault();
}
ImGuiGD.RebuildFontAtlas();

Internal.State.AddLayerSubViewport(this, out _subViewportContainer, out _subViewport);
Internal.Util.AddLayerSubViewport(this, out _subViewportContainer, out _subViewport);

Internal.State.Renderer.InitViewport(_subViewport);

Expand Down
23 changes: 0 additions & 23 deletions addons/imgui-godot/ImGuiGodot/Internal/State.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,29 +75,6 @@ public static unsafe void SetIniFilename(ImGuiIOPtr io, string fileName)
}
}

public static void AddLayerSubViewport(Node parent, out SubViewportContainer subViewportContainer, out SubViewport subViewport)
{
subViewportContainer = new SubViewportContainer
{
Name = "ImGuiLayer_SubViewportContainer",
AnchorsPreset = 15,
MouseFilter = Control.MouseFilterEnum.Ignore,
Stretch = true
};

subViewport = new SubViewport
{
Name = "ImGuiLayer_SubViewport",
TransparentBg = true,
HandleInputLocally = false,
GuiDisableInput = true,
RenderTargetUpdateMode = SubViewport.UpdateMode.Always
};

subViewportContainer.AddChild(subViewport);
parent.AddChild(subViewportContainer);
}

public static void Render(Viewport vp)
{
ImGui.Render();
Expand Down
23 changes: 23 additions & 0 deletions addons/imgui-godot/ImGuiGodot/Internal/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,27 @@ static Util()
il.Emit(OpCodes.Ret);
ConstructRID = dm.CreateDelegate<Func<ulong, RID>>();
}

public static void AddLayerSubViewport(Node parent, out SubViewportContainer subViewportContainer, out SubViewport subViewport)
{
subViewportContainer = new SubViewportContainer
{
Name = "ImGuiLayer_SubViewportContainer",
AnchorsPreset = (int)Control.LayoutPreset.FullRect,
MouseFilter = Control.MouseFilterEnum.Ignore,
Stretch = true
};

subViewport = new SubViewport
{
Name = "ImGuiLayer_SubViewport",
TransparentBg = true,
HandleInputLocally = false,
GuiDisableInput = true,
RenderTargetUpdateMode = SubViewport.UpdateMode.Always
};

subViewportContainer.AddChild(subViewport);
parent.AddChild(subViewportContainer);
}
}
2 changes: 1 addition & 1 deletion addons/imgui-godot/ImGuiGodot/Internal/Viewports.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public GodotImGuiWindow(ImGuiViewportPtr vp)
// need to do this after AddChild
GodotWindow.Transparent = true;

State.AddLayerSubViewport(GodotWindow, out SubViewportContainer svpContainer, out SubViewport svp);
Util.AddLayerSubViewport(GodotWindow, out SubViewportContainer svpContainer, out SubViewport svp);
LayerSvp = svp;

State.Renderer.InitViewport(LayerSvp);
Expand Down

0 comments on commit 429033c

Please sign in to comment.