-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
143 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Godot; | ||
|
||
namespace ImGuiGodot.Internal; | ||
|
||
internal sealed class BackendNative : IBackend | ||
{ | ||
public float JoyAxisDeadZone { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); } | ||
public float Scale { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); } | ||
|
||
public void AddFont(FontFile fontData, int fontSize, bool merge) | ||
{ | ||
throw new System.NotImplementedException(); | ||
} | ||
|
||
public void AddFontDefault() | ||
{ | ||
throw new System.NotImplementedException(); | ||
} | ||
|
||
public void Connect(Callable callable) | ||
{ | ||
throw new System.NotImplementedException(); | ||
} | ||
|
||
public void RebuildFontAtlas(float scale) | ||
{ | ||
throw new System.NotImplementedException(); | ||
} | ||
|
||
public void ResetFonts() | ||
{ | ||
throw new System.NotImplementedException(); | ||
} | ||
|
||
public bool SubViewportWidget(SubViewport svp) | ||
{ | ||
throw new System.NotImplementedException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using Godot; | ||
using ImGuiNET; | ||
using System; | ||
using Vector2 = System.Numerics.Vector2; | ||
|
||
namespace ImGuiGodot.Internal; | ||
|
||
internal sealed class BackendNet : IBackend | ||
{ | ||
public float JoyAxisDeadZone { get; set; } = 0.15f; | ||
public float Scale | ||
{ | ||
get => State.Instance.Scale; | ||
set => State.Instance.Scale = value; | ||
} | ||
|
||
public void AddFont(FontFile fontData, int fontSize, bool merge) | ||
{ | ||
State.Instance.Fonts.AddFont(fontData, fontSize, merge); | ||
} | ||
|
||
public void AddFontDefault() | ||
{ | ||
State.Instance.Fonts.AddFont(null, 13, false); | ||
} | ||
|
||
public void Connect(Callable callable) | ||
{ | ||
ImGuiLayer.Instance?.Signaler.Connect("imgui_layout", callable); | ||
} | ||
|
||
public void RebuildFontAtlas(float scale) | ||
{ | ||
State.Instance.Fonts.RebuildFontAtlas(scale); | ||
} | ||
|
||
public void ResetFonts() | ||
{ | ||
State.Instance.Fonts.ResetFonts(); | ||
} | ||
|
||
public bool SubViewportWidget(SubViewport vp) | ||
{ | ||
Vector2 vpSize = new(vp.Size.X, vp.Size.Y); | ||
var pos = ImGui.GetCursorScreenPos(); | ||
var pos_max = new Vector2(pos.X + vpSize.X, pos.Y + vpSize.Y); | ||
ImGui.GetWindowDrawList().AddImage((IntPtr)vp.GetTexture().GetRid().Id, pos, pos_max); | ||
|
||
ImGui.PushID(vp.NativeInstance); | ||
ImGui.InvisibleButton("godot_subviewport", vpSize); | ||
ImGui.PopID(); | ||
|
||
if (ImGui.IsItemHovered()) | ||
{ | ||
State.Instance.Input.CurrentSubViewport = vp; | ||
State.Instance.Input.CurrentSubViewportPos = pos; | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Godot; | ||
|
||
namespace ImGuiGodot.Internal; | ||
|
||
internal interface IBackend | ||
{ | ||
public float JoyAxisDeadZone { get; set; } | ||
public float Scale { get; set; } | ||
public void ResetFonts(); | ||
public void AddFont(FontFile fontData, int fontSize, bool merge); | ||
public void AddFontDefault(); | ||
public void RebuildFontAtlas(float scale); | ||
public void Connect(Callable callable); | ||
public bool SubViewportWidget(SubViewport svp); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters