Skip to content

Commit

Permalink
zzre: Upgrade ImGui to 1.90.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Helco committed Feb 12, 2024
1 parent b9e099b commit b078042
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
<RestoreSources>$(RestoreSources);../nuget-feed;https://api.nuget.org/v3/index.json</RestoreSources>
<VeldridHash>g603c7f2521</VeldridHash>
<DefaultEcsHash>0e92bb5</DefaultEcsHash>
<ImguiHash>beeb8dd</ImguiHash>
<ImguiHash>9b51cce</ImguiHash>
<MlangHash>331cf83</MlangHash>
<VeldridVersion>4.9.0-$(VeldridHash)</VeldridVersion>
<VeldridRenderdocVersion>1.0.1-$(VeldridHash)</VeldridRenderdocVersion>
<DefaultEcsVersion>1.0.0-$(DefaultEcsHash)</DefaultEcsVersion>
<DefaultEcsSafeVersion>1.0.0-safe-$(DefaultEcsHash)</DefaultEcsSafeVersion>
<ImguiVersion>1.88.0-$(ImguiHash)</ImguiVersion>
<ImguiVersion>1.90.1.1-$(ImguiHash)</ImguiVersion>
<ImguizmoVersion>1.61.0-$(ImguiHash)</ImguizmoVersion>
<MlangVersion>1.0.0-$(MlangHash)</MlangVersion>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion extern/ImGui.NET
Submodule ImGui.NET updated 65 files
+14 −3 .github/workflows/build.yml
+5 −5 README.md
+ deps/cimgui/linux-x64/cimgui.so
+ deps/cimgui/osx/cimgui.dylib
+ deps/cimgui/win-arm64/cimgui.dll
+ deps/cimgui/win-x64/cimgui.dll
+ deps/cimgui/win-x86/cimgui.dll
+10 −0 src/CodeGenerator/CSharpCodeWriter.cs
+1 −1 src/CodeGenerator/CodeGenerator.csproj
+47 −13 src/CodeGenerator/ImguiDefinitions.cs
+78 −19 src/CodeGenerator/Program.cs
+12 −2 src/CodeGenerator/TypeInfo.cs
+37,922 −35,191 src/CodeGenerator/definitions/cimgui/definitions.json
+11,264 −10,007 src/CodeGenerator/definitions/cimgui/structs_and_enums.json
+86 −43 src/ImGui.NET.SampleProgram.XNA/ImGuiRenderer.cs
+1 −0 src/ImGui.NET.SampleProgram/ImGui.NET.SampleProgram.csproj
+81 −92 src/ImGui.NET.SampleProgram/ImGuiController.cs
+35 −4 src/ImGui.NET.SampleProgram/Program.cs
+15 −1 src/ImGui.NET.sln
+17 −0 src/ImGui.NET/Delegates.cs
+7 −2 src/ImGui.NET/Generated/ImDrawData.gen.cs
+248 −0 src/ImGui.NET/Generated/ImDrawList.gen.cs
+322 −2 src/ImGui.NET/Generated/ImFont.gen.cs
+205 −12 src/ImGui.NET/Generated/ImFontAtlas.gen.cs
+2 −0 src/ImGui.NET/Generated/ImFontConfig.gen.cs
+29 −2 src/ImGui.NET/Generated/ImFontGlyphRangesBuilder.gen.cs
+20,672 −6,836 src/ImGui.NET/Generated/ImGui.gen.cs
+16 −0 src/ImGui.NET/Generated/ImGuiChildFlags.gen.cs
+1 −0 src/ImGui.NET/Generated/ImGuiComboFlags.gen.cs
+3 −2 src/ImGui.NET/Generated/ImGuiDockNodeFlags.gen.cs
+12 −4 src/ImGui.NET/Generated/ImGuiHoveredFlags.gen.cs
+71 −522 src/ImGui.NET/Generated/ImGuiIO.gen.cs
+31 −2 src/ImGui.NET/Generated/ImGuiInputTextCallbackData.gen.cs
+1 −0 src/ImGui.NET/Generated/ImGuiInputTextFlags.gen.cs
+94 −66 src/ImGui.NET/Generated/ImGuiKey.gen.cs
+4 −2 src/ImGui.NET/Generated/ImGuiListClipper.gen.cs
+10 −0 src/ImGui.NET/Generated/ImGuiMouseSource.gen.cs
+60 −34 src/ImGui.NET/Generated/ImGuiNative.gen.cs
+1 −5 src/ImGui.NET/Generated/ImGuiNavInput.gen.cs
+29 −0 src/ImGui.NET/Generated/ImGuiPayload.gen.cs
+2 −0 src/ImGui.NET/Generated/ImGuiPlatformMonitor.gen.cs
+1 −1 src/ImGui.NET/Generated/ImGuiSelectableFlags.gen.cs
+22 −0 src/ImGui.NET/Generated/ImGuiStyle.gen.cs
+8 −3 src/ImGui.NET/Generated/ImGuiStyleVar.gen.cs
+1 −0 src/ImGui.NET/Generated/ImGuiTabItemFlags.gen.cs
+1 −0 src/ImGui.NET/Generated/ImGuiTableColumnFlags.gen.cs
+1 −0 src/ImGui.NET/Generated/ImGuiTableFlags.gen.cs
+57 −2 src/ImGui.NET/Generated/ImGuiTextBuffer.gen.cs
+89 −2 src/ImGui.NET/Generated/ImGuiTextFilter.gen.cs
+3 −2 src/ImGui.NET/Generated/ImGuiTreeNodeFlags.gen.cs
+2 −0 src/ImGui.NET/Generated/ImGuiViewport.gen.cs
+5 −4 src/ImGui.NET/Generated/ImGuiViewportFlags.gen.cs
+6 −7 src/ImGui.NET/Generated/ImGuiWindowFlags.gen.cs
+0 −7 src/ImGui.NET/ImDrawData.Manual.cs
+0 −37 src/ImGui.NET/ImDrawList.Manual.cs
+485 −0 src/ImGui.NET/ImGui.Manual.ReadOnlySpan.cs
+1 −40 src/ImGui.NET/ImGui.Manual.cs
+1 −1 src/ImGui.NET/ImGui.NET.csproj
+13 −0 src/ImGui.NET/ImGuiNative.Manual.cs
+7 −0 src/ImGui.NET/ImVector.cs
+25 −0 src/ImGui.NET/Util.cs
+168 −0 src/ImNodes.NET/Generated/ImNodes.gen.cs
+51,176 −10,736 src/ImPlot.NET/Generated/ImPlot.gen.cs
+11 −0 src/TestDotNetStandardLib/TestDotNetStandardLib.csproj
+14 −0 src/TestDotNetStandardLib/TestStringParameterOnDotNetStandard.cs
4 changes: 2 additions & 2 deletions get-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ if [[ "$1" != "no-submodule-update" ]]; then
fi

if [[ "$OSTYPE" == "msys" ]]; then
powershell -executionpolicy bypass -File "extern/ImGui.NET/download-native-deps.ps1" -tag 1.88 -repository "https://github.com/Helco/ImGui.NET-nativebuild"
powershell -executionpolicy bypass -File "extern/ImGui.NET/download-native-deps.ps1" -tag 1.90.1 -repository "https://github.com/Helco/ImGui.NET-nativebuild"
else
bash extern/ImGui.NET/download-native-deps.sh 1.88
bash extern/ImGui.NET/download-native-deps.sh 1.90.1
fi

DefaultEcsHash=`git -C extern/DefaultEcs rev-parse --short HEAD`
Expand Down
12 changes: 9 additions & 3 deletions zzre.core/imgui/ImGuiRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ public void BeginEventUpdate(float deltaSeconds)
}

SetPerFrameImGuiData(deltaSeconds);
ImGui.GetIO().MouseWheel = 0f;
}

public void UseWith(SdlWindow window)
Expand All @@ -380,6 +381,7 @@ private unsafe bool HandleEvent(SdlWindow window, Event ev)
{
case EventType.Mousemotion when ev.Motion.WindowID == window.WindowID:
io.AddMousePosEvent(ev.Motion.X, ev.Motion.Y);
io.MousePos = new(ev.Motion.X, ev.Motion.Y);
return true;

case EventType.Mousebuttondown or EventType.Mousebuttonup when ev.Motion.WindowID == window.WindowID:
Expand All @@ -391,11 +393,15 @@ private unsafe bool HandleEvent(SdlWindow window, Event ev)
_ => ImGuiMouseButton.COUNT
};
if (button != ImGuiMouseButton.COUNT)
io.AddMouseButtonEvent((int)button, ev.Type == (uint)EventType.Mousebuttondown);
{
var isDown = ev.Type == (uint)EventType.Mousebuttondown;
io.AddMouseButtonEvent((int)button, isDown);
}
return button != ImGuiMouseButton.COUNT;

case EventType.Mousewheel when ev.Wheel.WindowID == window.WindowID:
io.AddMouseWheelEvent(ev.Wheel.PreciseX, ev.Wheel.PreciseY);
io.MouseWheel = ev.Wheel.PreciseY;
return true;

case EventType.Keydown or EventType.Keyup when ev.Key.WindowID == window.WindowID:
Expand Down Expand Up @@ -637,7 +643,7 @@ private unsafe void RenderImDrawData(ImDrawDataPtr draw_data, GraphicsDevice gd,

for (int i = 0; i < draw_data.CmdListsCount; i++)
{
ImDrawListPtr cmd_list = ((ImDrawList**)draw_data.CmdLists)[i];
ImDrawListPtr cmd_list = draw_data.CmdLists[i];

cl.UpdateBuffer(
_vertexBuffer,
Expand Down Expand Up @@ -682,7 +688,7 @@ private unsafe void RenderImDrawData(ImDrawDataPtr draw_data, GraphicsDevice gd,
int idx_offset = 0;
for (int n = 0; n < draw_data.CmdListsCount; n++)
{
ImDrawListPtr cmd_list = ((ImDrawList**)draw_data.CmdLists)[n];
ImDrawListPtr cmd_list = draw_data.CmdLists[n];
for (int cmd_i = 0; cmd_i < cmd_list.CmdBuffer.Size; cmd_i++)
{
ImDrawCmdPtr pcmd = cmd_list.CmdBuffer[cmd_i];
Expand Down
18 changes: 13 additions & 5 deletions zzre.core/imgui/MouseEventArea.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ public class MouseEventArea
private Vector2? lastPosition;
private readonly Vector2[] lastDragDelta = new Vector2[(int)ImGuiMouseButton.COUNT];
private readonly bool[] triggerClickEvent = new bool[(int)ImGuiMouseButton.COUNT];
private readonly Vector2[] mouseLastDownPos = new Vector2[(int)ImGuiMouseButton.COUNT];
private readonly bool[] mouseLastDownState = new bool[(int)ImGuiMouseButton.COUNT];
private Rect validBounds = Rect.Zero;

public Vector2 MousePosition => GetIO().MousePos - validBounds.Min;
public Vector2 MousePosition => GetMousePos() - validBounds.Min;

public event Action<MouseButton, Vector2>? OnDrag;
public event Action<float>? OnScroll;
Expand All @@ -28,7 +30,7 @@ public MouseEventArea(Window parent)
parent.AddTag(this);
}

public void Content()
public unsafe void Content()
{
if (!window.IsOpen || !window.IsFocused)
return;
Expand All @@ -53,18 +55,24 @@ public void Content()
else
lastPosition = null;

// Drag event
// Drag and button events
for (int i = 0; i < (int)ImGuiMouseButton.COUNT; i++)
{
var button = (ImGuiMouseButton)i;
if (!validBounds.IsInside(GetIO().MouseClickedPos[i]))

var isDown = IsMouseDown(button);
if (isDown && !mouseLastDownState[i])
mouseLastDownPos[i] = GetIO().MousePos;
mouseLastDownState[i] = isDown;

if (!validBounds.IsInside(mouseLastDownPos[i]))
continue;

if (triggerClickEvent[i] != IsMouseDown(button))
{
((triggerClickEvent[i] = IsMouseDown(button))
? OnButtonDown
: OnButtonUp)?.Invoke(ToSDL(button), validBounds.RelativePos(GetIO().MouseClickedPos[i]));
: OnButtonUp)?.Invoke(ToSDL(button), validBounds.RelativePos(mouseLastDownPos[i]));
}

if (!IsMouseDragging(button))
Expand Down
2 changes: 1 addition & 1 deletion zzre/imgui/OpenFileModal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private void HandleContent()
PopItemWidth();
SetNextWindowSizeConstraints(Vector2.One * FileTreeSize, Vector2.One * FileTreeSize * 10);
var initialTreeSize = GetContentRegionAvail() - GetTextLineHeightWithSpacing() * 2 * Vector2.UnitY;
BeginChild("TreeChildWindow", initialTreeSize, true, ImGuiWindowFlags.HorizontalScrollbar);
BeginChild("TreeChildWindow", initialTreeSize, ImGuiChildFlags.Border, ImGuiWindowFlags.HorizontalScrollbar);
TreeContent();
EndChild();

Expand Down
2 changes: 1 addition & 1 deletion zzre/imgui/TwoColumnEditorTag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private void HandleContent()
ImGui.SetColumnWidth(0, Window.InitialBounds.Size.X * 0.3f);
didSetColumnWidth++;
}
ImGui.BeginChild("LeftColumn", ImGui.GetContentRegionAvail(), false, ImGuiWindowFlags.HorizontalScrollbar);
ImGui.BeginChild("LeftColumn", ImGui.GetContentRegionAvail(), ImGuiChildFlags.None, ImGuiWindowFlags.HorizontalScrollbar);
var i = 0;
foreach (var (name, content, isDefaultOpen, preContent) in infoSections)
{
Expand Down

0 comments on commit b078042

Please sign in to comment.