Merge pull request #2315 from Haselnussbomber/imgui-bindings-fixes

[imgui-bindings] Fixes and removals
This commit is contained in:
goat 2025-07-17 02:08:49 +02:00 committed by GitHub
commit 6efbb71790
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 41 additions and 145 deletions

View file

@ -72,8 +72,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Bindings", "Bindings", "{A2
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StandaloneImGuiTestbed", "imgui\StandaloneImGuiTestbed\StandaloneImGuiTestbed.csproj", "{4702A911-2513-478C-A434-2776393FDE77}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StandaloneImGuiTestbed", "imgui\StandaloneImGuiTestbed\StandaloneImGuiTestbed.csproj", "{4702A911-2513-478C-A434-2776393FDE77}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImGui.NET-472", "lib\ImGui.NET\src\ImGui.NET-472\ImGui.NET-472.csproj", "{FAD7F842-2E81-456F-8AE8-DFFEDC258EC3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImGuiScene", "imgui\ImGuiScene\ImGuiScene.csproj", "{66753AC7-0029-4373-9CC4-7760B1F46141}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImGuiScene", "imgui\ImGuiScene\ImGuiScene.csproj", "{66753AC7-0029-4373-9CC4-7760B1F46141}"
EndProject EndProject
Global Global
@ -166,10 +164,6 @@ Global
{4702A911-2513-478C-A434-2776393FDE77}.Debug|Any CPU.Build.0 = Debug|x64 {4702A911-2513-478C-A434-2776393FDE77}.Debug|Any CPU.Build.0 = Debug|x64
{4702A911-2513-478C-A434-2776393FDE77}.Release|Any CPU.ActiveCfg = Release|x64 {4702A911-2513-478C-A434-2776393FDE77}.Release|Any CPU.ActiveCfg = Release|x64
{4702A911-2513-478C-A434-2776393FDE77}.Release|Any CPU.Build.0 = Release|x64 {4702A911-2513-478C-A434-2776393FDE77}.Release|Any CPU.Build.0 = Release|x64
{FAD7F842-2E81-456F-8AE8-DFFEDC258EC3}.Debug|Any CPU.ActiveCfg = Debug|x64
{FAD7F842-2E81-456F-8AE8-DFFEDC258EC3}.Debug|Any CPU.Build.0 = Debug|x64
{FAD7F842-2E81-456F-8AE8-DFFEDC258EC3}.Release|Any CPU.ActiveCfg = Release|x64
{FAD7F842-2E81-456F-8AE8-DFFEDC258EC3}.Release|Any CPU.Build.0 = Release|x64
{66753AC7-0029-4373-9CC4-7760B1F46141}.Debug|Any CPU.ActiveCfg = Debug|x64 {66753AC7-0029-4373-9CC4-7760B1F46141}.Debug|Any CPU.ActiveCfg = Debug|x64
{66753AC7-0029-4373-9CC4-7760B1F46141}.Debug|Any CPU.Build.0 = Debug|x64 {66753AC7-0029-4373-9CC4-7760B1F46141}.Debug|Any CPU.Build.0 = Debug|x64
{66753AC7-0029-4373-9CC4-7760B1F46141}.Release|Any CPU.ActiveCfg = Release|x64 {66753AC7-0029-4373-9CC4-7760B1F46141}.Release|Any CPU.ActiveCfg = Release|x64
@ -196,7 +190,6 @@ Global
{5E6EDD75-AE95-43A6-9D67-95B840EB4B71} = {A217B3DF-607A-4EFB-B107-3C4809348043} {5E6EDD75-AE95-43A6-9D67-95B840EB4B71} = {A217B3DF-607A-4EFB-B107-3C4809348043}
{9C70BD06-D52C-425E-9C14-5D66BC6046EF} = {A217B3DF-607A-4EFB-B107-3C4809348043} {9C70BD06-D52C-425E-9C14-5D66BC6046EF} = {A217B3DF-607A-4EFB-B107-3C4809348043}
{4702A911-2513-478C-A434-2776393FDE77} = {A217B3DF-607A-4EFB-B107-3C4809348043} {4702A911-2513-478C-A434-2776393FDE77} = {A217B3DF-607A-4EFB-B107-3C4809348043}
{FAD7F842-2E81-456F-8AE8-DFFEDC258EC3} = {DBE5345E-6594-4A59-B183-1C3D5592269D}
{66753AC7-0029-4373-9CC4-7760B1F46141} = {A217B3DF-607A-4EFB-B107-3C4809348043} {66753AC7-0029-4373-9CC4-7760B1F46141} = {A217B3DF-607A-4EFB-B107-3C4809348043}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution

View file

@ -381,11 +381,7 @@ public partial class FileDialog
if (this.filteredFiles.Count > 0) if (this.filteredFiles.Count > 0)
{ {
ImGuiListClipperPtr clipper; var clipper = ImGui.ImGuiListClipper();
unsafe
{
clipper = new ImGuiListClipperPtr(ImGui.ImGuiListClipper());
}
lock (this.filesLock) lock (this.filesLock)
{ {

View file

@ -689,7 +689,7 @@ public sealed class SingleFontChooserDialog : IDisposable
if (ImGui.BeginChild("##familyList", ImGui.GetContentRegionAvail())) if (ImGui.BeginChild("##familyList", ImGui.GetContentRegionAvail()))
{ {
var clipper = new ImGuiListClipperPtr(ImGui.ImGuiListClipper()); var clipper = ImGui.ImGuiListClipper();
var lineHeight = ImGui.GetTextLineHeightWithSpacing(); var lineHeight = ImGui.GetTextLineHeightWithSpacing();
if ((changed || this.firstDrawAfterRefresh) && this.selectedFamilyIndex != -1) if ((changed || this.firstDrawAfterRefresh) && this.selectedFamilyIndex != -1)
@ -856,7 +856,7 @@ public sealed class SingleFontChooserDialog : IDisposable
if (ImGui.BeginChild("##fontList")) if (ImGui.BeginChild("##fontList"))
{ {
var clipper = new ImGuiListClipperPtr(ImGui.ImGuiListClipper()); var clipper = ImGui.ImGuiListClipper();
var lineHeight = ImGui.GetTextLineHeightWithSpacing(); var lineHeight = ImGui.GetTextLineHeightWithSpacing();
if ((changed || this.firstDrawAfterRefresh) && this.selectedFontIndex != -1) if ((changed || this.firstDrawAfterRefresh) && this.selectedFontIndex != -1)
@ -960,7 +960,7 @@ public sealed class SingleFontChooserDialog : IDisposable
if (ImGui.BeginChild("##fontSizeList")) if (ImGui.BeginChild("##fontSizeList"))
{ {
var clipper = new ImGuiListClipperPtr(ImGui.ImGuiListClipper()); var clipper = ImGui.ImGuiListClipper();
var lineHeight = ImGui.GetTextLineHeightWithSpacing(); var lineHeight = ImGui.GetTextLineHeightWithSpacing();
if (changed && this.selectedFontIndex != -1) if (changed && this.selectedFontIndex != -1)

View file

@ -112,10 +112,7 @@ internal class ConsoleWindow : Window, IDisposable
this.configuration.DalamudConfigurationSaved += this.OnDalamudConfigurationSaved; this.configuration.DalamudConfigurationSaved += this.OnDalamudConfigurationSaved;
unsafe this.clipperPtr = ImGui.ImGuiListClipper();
{
this.clipperPtr = new(ImGui.ImGuiListClipper());
}
} }
/// <summary>Gets the queue where log entries that are not processed yet are stored.</summary> /// <summary>Gets the queue where log entries that are not processed yet are stored.</summary>

View file

@ -190,7 +190,7 @@ internal unsafe class SeStringRendererTestWidget : IDataWindowWidget
var addon = Service<DataManager>.GetNullable()?.GetExcelSheet<Addon>() ?? var addon = Service<DataManager>.GetNullable()?.GetExcelSheet<Addon>() ??
throw new InvalidOperationException("Addon sheet not loaded."); throw new InvalidOperationException("Addon sheet not loaded.");
var clipper = new ImGuiListClipperPtr(ImGui.ImGuiListClipper()); var clipper = ImGui.ImGuiListClipper();
clipper.Begin(addon.Count); clipper.Begin(addon.Count);
while (clipper.Step()) while (clipper.Step())
{ {

View file

@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Numerics; using System.Numerics;
@ -449,7 +449,7 @@ internal class TexWidget : IDataWindowWidget
sortSpecs.SpecsDirty = false; sortSpecs.SpecsDirty = false;
} }
var clipper = new ImGuiListClipperPtr(ImGui.ImGuiListClipper()); var clipper = ImGui.ImGuiListClipper();
clipper.Begin(allBlames.Count); clipper.Begin(allBlames.Count);
while (clipper.Step()) while (clipper.Step())
@ -469,7 +469,7 @@ internal class TexWidget : IDataWindowWidget
{ {
_ = Service<DevTextureSaveMenu>.Get().ShowTextureSaveMenuAsync( _ = Service<DevTextureSaveMenu>.Get().ShowTextureSaveMenuAsync(
this.DisplayName, this.DisplayName,
$"{wrap.ImGuiHandle:X16}", $"{wrap.Handle.Handle:X16}",
Task.FromResult(wrap.CreateWrapSharingLowLevelResource())); Task.FromResult(wrap.CreateWrapSharingLowLevelResource()));
} }
@ -538,7 +538,7 @@ internal class TexWidget : IDataWindowWidget
(ImGui.GetStyle().ItemSpacing.X * 1 * numIcons)); (ImGui.GetStyle().ItemSpacing.X * 1 * numIcons));
ImGui.TableHeadersRow(); ImGui.TableHeadersRow();
var clipper = new ImGuiListClipperPtr(ImGui.ImGuiListClipper()); var clipper = ImGui.ImGuiListClipper();
clipper.Begin(textures.Count); clipper.Begin(textures.Count);
using (var enu = textures.GetEnumerator()) using (var enu = textures.GetEnumerator())

View file

@ -64,7 +64,7 @@ internal class UiColorWidget : IDataWindowWidget
ImGui.TableSetupColumn("Clear Blue", ImGuiTableColumnFlags.WidthFixed, colorw); ImGui.TableSetupColumn("Clear Blue", ImGuiTableColumnFlags.WidthFixed, colorw);
ImGui.TableHeadersRow(); ImGui.TableHeadersRow();
var clipper = new ImGuiListClipperPtr(ImGui.ImGuiListClipper()); var clipper = ImGui.ImGuiListClipper();
clipper.Begin(colors.Count, ImGui.GetFrameHeightWithSpacing()); clipper.Begin(colors.Count, ImGui.GetFrameHeightWithSpacing());
while (clipper.Step()) while (clipper.Step())
{ {

View file

@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Dalamud.Bindings.ImGui; using Dalamud.Bindings.ImGui;
@ -158,7 +158,7 @@ internal sealed class DelegateFontHandle : FontHandle
{ {
toolkitPreBuild.Font = default; toolkitPreBuild.Font = default;
k.CallOnBuildStepChange(toolkitPreBuild); k.CallOnBuildStepChange(toolkitPreBuild);
if (toolkitPreBuild.Font.IsNull()) if (toolkitPreBuild.Font.IsNull)
{ {
if (fontCountPrevious == fontsVector.Length) if (fontCountPrevious == fontsVector.Length)
{ {

View file

@ -116,7 +116,7 @@ internal sealed partial class FontAtlasFactory
foreach (var s in this.data.Substances) foreach (var s in this.data.Substances)
{ {
var f = s.GetFontPtr(fontHandle); var f = s.GetFontPtr(fontHandle);
if (!f.IsNull()) if (!f.IsNull)
return f; return f;
} }
@ -215,7 +215,7 @@ internal sealed partial class FontAtlasFactory
} }
catch catch
{ {
if (!font.IsNull()) if (!font.IsNull)
{ {
// Note that for both RemoveAt calls, corresponding destructors will be called. // Note that for both RemoveAt calls, corresponding destructors will be called.
@ -331,14 +331,14 @@ internal sealed partial class FontAtlasFactory
} }
} }
if (font.IsNull()) if (font.IsNull)
{ {
// fall back to AXIS fonts // fall back to AXIS fonts
font = this.AddGameGlyphs(new(GameFontFamily.Axis, sizePx), glyphRanges, default); font = this.AddGameGlyphs(new(GameFontFamily.Axis, sizePx), glyphRanges, default);
} }
this.AttachExtraGlyphsForDalamudLanguage(new() { SizePx = sizePx, MergeFont = font }); this.AttachExtraGlyphsForDalamudLanguage(new() { SizePx = sizePx, MergeFont = font });
if (this.Font.IsNull()) if (this.Font.IsNull)
this.Font = font; this.Font = font;
return font; return font;
} }
@ -413,9 +413,9 @@ internal sealed partial class FontAtlasFactory
int style = (int)DWRITE_FONT_STYLE.DWRITE_FONT_STYLE_NORMAL) int style = (int)DWRITE_FONT_STYLE.DWRITE_FONT_STYLE_NORMAL)
{ {
var targetFont = fontConfig.MergeFont; var targetFont = fontConfig.MergeFont;
if (targetFont.IsNull()) if (targetFont.IsNull)
targetFont = this.Font; targetFont = this.Font;
if (targetFont.IsNull()) if (targetFont.IsNull)
return; return;
// https://learn.microsoft.com/en-us/windows/apps/design/globalizing/loc-international-fonts // https://learn.microsoft.com/en-us/windows/apps/design/globalizing/loc-international-fonts
@ -556,9 +556,9 @@ internal sealed partial class FontAtlasFactory
public void AttachExtraGlyphsForDalamudLanguage(in SafeFontConfig fontConfig) public void AttachExtraGlyphsForDalamudLanguage(in SafeFontConfig fontConfig)
{ {
var targetFont = fontConfig.MergeFont; var targetFont = fontConfig.MergeFont;
if (targetFont.IsNull()) if (targetFont.IsNull)
targetFont = this.Font; targetFont = this.Font;
if (targetFont.IsNull()) if (targetFont.IsNull)
return; return;
var dalamudConfiguration = Service<DalamudConfiguration>.Get(); var dalamudConfiguration = Service<DalamudConfiguration>.Get();

View file

@ -182,7 +182,7 @@ internal abstract class FontHandle : IFontHandle
} }
var fontPtr = substance.GetFontPtr(this); var fontPtr = substance.GetFontPtr(this);
if (fontPtr.IsNull()) if (fontPtr.IsNull)
{ {
// The font for the requested handle is unavailable. Release the reference and try again. // The font for the requested handle is unavailable. Release the reference and try again.
substance.DataRoot.Release(); substance.DataRoot.Release();

View file

@ -1,4 +1,4 @@
using System.Buffers; using System.Buffers;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
@ -250,7 +250,7 @@ internal class GamePrebakedFontHandle : FontHandle
GameFontStyle style, GameFontStyle style,
ushort[]? glyphRanges = null) ushort[]? glyphRanges = null)
{ {
if (font.IsNull()) if (font.IsNull)
font = this.CreateTemplateFont(toolkitPreBuild, style.SizePx); font = this.CreateTemplateFont(toolkitPreBuild, style.SizePx);
this.attachments.Add((font, style, glyphRanges)); this.attachments.Add((font, style, glyphRanges));
return font; return font;

View file

@ -1,4 +1,3 @@
using Dalamud.Interface.Internal;
using Dalamud.Interface.Textures.TextureWraps; using Dalamud.Interface.Textures.TextureWraps;
namespace Dalamud.Interface.Textures; namespace Dalamud.Interface.Textures;
@ -17,6 +16,6 @@ public static class DalamudTextureWrapExtensions
return false; return false;
if (a is null) if (a is null)
return false; return false;
return a.ImGuiHandle == b.ImGuiHandle; return a.Handle == b.Handle;
} }
} }

View file

@ -66,7 +66,7 @@ internal sealed partial class TextureManager
try try
{ {
if (textureWrap.ImGuiHandle == nint.Zero) if (textureWrap.Handle.IsNull)
return textureWrap; return textureWrap;
} }
catch (ObjectDisposedException) catch (ObjectDisposedException)
@ -103,7 +103,7 @@ internal sealed partial class TextureManager
try try
{ {
if (textureWrap.ImGuiHandle == nint.Zero) if (textureWrap.Handle.IsNull)
return textureWrap; return textureWrap;
} }
catch (ObjectDisposedException) catch (ObjectDisposedException)

View file

@ -2,7 +2,6 @@ using System.Numerics;
using Dalamud.Bindings.ImGui; using Dalamud.Bindings.ImGui;
using Dalamud.Interface.Textures.TextureWraps.Internal; using Dalamud.Interface.Textures.TextureWraps.Internal;
using Dalamud.Utility;
using TerraFX.Interop.Windows; using TerraFX.Interop.Windows;
@ -19,10 +18,6 @@ public interface IDalamudTextureWrap : IDisposable
/// <summary>Gets a texture handle suitable for direct use with ImGui functions.</summary> /// <summary>Gets a texture handle suitable for direct use with ImGui functions.</summary>
ImTextureID Handle { get; } ImTextureID Handle { get; }
/// <summary>Gets a texture handle suitable for direct use with ImGui functions.</summary>
[ImGuiBindingsToDo("Remove.")]
IntPtr ImGuiHandle => new((long)this.Handle.Handle);
/// <summary>Gets the width of the texture.</summary> /// <summary>Gets the width of the texture.</summary>
int Width { get; } int Width { get; }
@ -38,7 +33,7 @@ public interface IDalamudTextureWrap : IDisposable
/// <returns>The new reference to this texture wrap.</returns> /// <returns>The new reference to this texture wrap.</returns>
/// <remarks> /// <remarks>
/// On calling this function, a new instance of <see cref="IDalamudTextureWrap"/> will be returned, but with /// On calling this function, a new instance of <see cref="IDalamudTextureWrap"/> will be returned, but with
/// the same <see cref="ImGuiHandle"/>. The new instance must be <see cref="IDisposable.Dispose"/>d, as the backing /// the same <see cref="Handle"/>. The new instance must be <see cref="IDisposable.Dispose"/>d, as the backing
/// resource will stay alive until all the references are released. The old instance may be disposed as needed, /// resource will stay alive until all the references are released. The old instance may be disposed as needed,
/// once this function returns; the new instance will stay alive regardless of whether the old instance has been /// once this function returns; the new instance will stay alive regardless of whether the old instance has been
/// disposed.<br /> /// disposed.<br />
@ -46,7 +41,7 @@ public interface IDalamudTextureWrap : IDisposable
/// across plugin boundaries for use for an indeterminate duration, the receiver should call this function to /// across plugin boundaries for use for an indeterminate duration, the receiver should call this function to
/// obtain a new reference to the texture received, so that it gets its own "copy" of the texture and the caller /// obtain a new reference to the texture received, so that it gets its own "copy" of the texture and the caller
/// may dispose the texture anytime without any care for the receiver.<br /> /// may dispose the texture anytime without any care for the receiver.<br />
/// The default implementation will treat <see cref="ImGuiHandle"/> as an <see cref="IUnknown"/>. /// The default implementation will treat <see cref="Handle"/> as an <see cref="IUnknown"/>.
/// </remarks> /// </remarks>
unsafe IDalamudTextureWrap CreateWrapSharingLowLevelResource() unsafe IDalamudTextureWrap CreateWrapSharingLowLevelResource()
{ {

View file

@ -60,7 +60,7 @@ internal sealed unsafe partial class DrawListTextureWrap : IDrawListTextureWrap,
this.device.Get()->GetImmediateContext(pdc); this.device.Get()->GetImmediateContext(pdc);
this.emptyTexture = emptyTexture; this.emptyTexture = emptyTexture;
this.srv = new((ID3D11ShaderResourceView*)emptyTexture.ImGuiHandle); this.srv = new((ID3D11ShaderResourceView*)emptyTexture.Handle.Handle);
} }
/// <summary>Finalizes an instance of the <see cref="DrawListTextureWrap"/> class.</summary> /// <summary>Finalizes an instance of the <see cref="DrawListTextureWrap"/> class.</summary>
@ -226,7 +226,7 @@ internal sealed unsafe partial class DrawListTextureWrap : IDrawListTextureWrap,
this.rtvPremultiplied.Reset(); this.rtvPremultiplied.Reset();
this.width = newWidth; this.width = newWidth;
this.Height = newHeight; this.Height = newHeight;
this.srv = new((ID3D11ShaderResourceView*)this.emptyTexture.ImGuiHandle); this.srv = new((ID3D11ShaderResourceView*)this.emptyTexture.Handle.Handle);
return S.S_FALSE; return S.S_FALSE;
} }

View file

@ -34,11 +34,7 @@ public static class ImGuiClip
// Uses ImGuiListClipper and thus handles start- and end-dummies itself. // Uses ImGuiListClipper and thus handles start- and end-dummies itself.
public static void ClippedDraw<T>(IReadOnlyList<T> data, Action<T> draw, float lineHeight) public static void ClippedDraw<T>(IReadOnlyList<T> data, Action<T> draw, float lineHeight)
{ {
ImGuiListClipperPtr clipper; var clipper = ImGui.ImGuiListClipper();
unsafe
{
clipper = new ImGuiListClipperPtr(ImGui.ImGuiListClipper());
}
clipper.Begin(data.Count, lineHeight); clipper.Begin(data.Count, lineHeight);
while (clipper.Step()) while (clipper.Step())
@ -69,11 +65,7 @@ public static class ImGuiClip
/// <typeparam name="T">The type of data to draw.</typeparam> /// <typeparam name="T">The type of data to draw.</typeparam>
public static void ClippedDraw<T>(IReadOnlyList<T> data, Action<T> draw, int itemsPerLine, float lineHeight) public static void ClippedDraw<T>(IReadOnlyList<T> data, Action<T> draw, int itemsPerLine, float lineHeight)
{ {
ImGuiListClipperPtr clipper; var clipper = ImGui.ImGuiListClipper();
unsafe
{
clipper = new ImGuiListClipperPtr(ImGui.ImGuiListClipper());
}
var maxRows = (int)MathF.Ceiling((float)data.Count / itemsPerLine); var maxRows = (int)MathF.Ceiling((float)data.Count / itemsPerLine);
@ -113,11 +105,7 @@ public static class ImGuiClip
// Uses ImGuiListClipper and thus handles start- and end-dummies itself, but acts on type and index. // Uses ImGuiListClipper and thus handles start- and end-dummies itself, but acts on type and index.
public static void ClippedDraw<T>(IReadOnlyList<T> data, Action<T, int> draw, float lineHeight) public static void ClippedDraw<T>(IReadOnlyList<T> data, Action<T, int> draw, float lineHeight)
{ {
ImGuiListClipperPtr clipper; var clipper = ImGui.ImGuiListClipper();
unsafe
{
clipper = new ImGuiListClipperPtr(ImGui.ImGuiListClipper());
}
clipper.Begin(data.Count, lineHeight); clipper.Begin(data.Count, lineHeight);
while (clipper.Step()) while (clipper.Step())

View file

@ -1,5 +1,4 @@
using System.Numerics; using System.Numerics;
using System.Text;
using Dalamud.Bindings.ImGui; using Dalamud.Bindings.ImGui;
@ -52,36 +51,4 @@ public static class ImGuiExtensions
drawListPtr.AddText(ImGui.GetFont(), ImGui.GetFontSize(), pos, ImGui.GetColorU32(ImGuiCol.Text), text); drawListPtr.AddText(ImGui.GetFont(), ImGui.GetFontSize(), pos, ImGui.GetColorU32(ImGuiCol.Text), text);
} }
} }
/// <summary>
/// Add text to a draw list.
/// </summary>
/// <param name="drawListPtr">Pointer to the draw list.</param>
/// <param name="font">Font to use.</param>
/// <param name="fontSize">Font size.</param>
/// <param name="pos">Position to draw at.</param>
/// <param name="col">Color to use.</param>
/// <param name="textBegin">Text to draw.</param>
/// <param name="cpuFineClipRect">Clip rect to use.</param>
// TODO: This should go into ImDrawList.Manual.cs in ImGui.NET...
public static unsafe void AddText(this ImDrawListPtr drawListPtr, ImFontPtr font, float fontSize, Vector2 pos, uint col, string textBegin, ref Vector4 cpuFineClipRect)
{
var nativeFont = font.Handle;
var textBeginByteCount = Encoding.UTF8.GetByteCount(textBegin);
var nativeTextBegin = stackalloc byte[textBeginByteCount + 1];
fixed (char* textBeginPtr = textBegin)
{
var nativeTextBeginOffset = Encoding.UTF8.GetBytes(textBeginPtr, textBegin.Length, nativeTextBegin, textBeginByteCount);
nativeTextBegin[nativeTextBeginOffset] = 0;
}
byte* nativeTextEnd = null;
var wrapWidth = 0.0f;
fixed (Vector4* nativeCpuFineClipRect = &cpuFineClipRect)
{
drawListPtr.AddText(nativeFont, fontSize, pos, col, nativeTextBegin, nativeTextEnd, wrapWidth, nativeCpuFineClipRect);
}
}
} }

View file

@ -634,25 +634,11 @@ public static partial class ImGuiHelpers
.ToArray(); .ToArray();
/// <summary> /// <summary>
/// Determines whether <paramref name="ptr"/> is empty. /// Determines whether <paramref name="ptr"/> is not empty and loaded.
/// </summary> /// </summary>
/// <param name="ptr">The pointer.</param> /// <param name="ptr">The pointer.</param>
/// <returns>Whether it is empty.</returns> /// <returns>Whether it is not null and loaded.</returns>
public static unsafe bool IsNull(this ImFontPtr ptr) => ptr.Handle == null; public static unsafe bool IsNotNullAndLoaded(this ImFontPtr ptr) => !ptr.IsNull && ptr.IsLoaded();
/// <summary>
/// Determines whether <paramref name="ptr"/> is empty.
/// </summary>
/// <param name="ptr">The pointer.</param>
/// <returns>Whether it is empty.</returns>
public static unsafe bool IsNotNullAndLoaded(this ImFontPtr ptr) => ptr.Handle != null && ptr.IsLoaded();
/// <summary>
/// Determines whether <paramref name="ptr"/> is empty.
/// </summary>
/// <param name="ptr">The pointer.</param>
/// <returns>Whether it is empty.</returns>
public static unsafe bool IsNull(this ImFontAtlasPtr ptr) => ptr.Handle == null;
/// <summary> /// <summary>
/// If <paramref name="self"/> is default, then returns <paramref name="other"/>. /// If <paramref name="self"/> is default, then returns <paramref name="other"/>.
@ -661,7 +647,7 @@ public static partial class ImGuiHelpers
/// <param name="other">The other.</param> /// <param name="other">The other.</param>
/// <returns><paramref name="self"/> if it is not default; otherwise, <paramref name="other"/>.</returns> /// <returns><paramref name="self"/> if it is not default; otherwise, <paramref name="other"/>.</returns>
public static unsafe ImFontPtr OrElse(this ImFontPtr self, ImFontPtr other) => public static unsafe ImFontPtr OrElse(this ImFontPtr self, ImFontPtr other) =>
self.Handle is null ? other : self; self.IsNull ? other : self;
/// <summary> /// <summary>
/// Mark 4K page as used, after adding a codepoint to a font. /// Mark 4K page as used, after adding a codepoint to a font.

View file

@ -64,7 +64,7 @@ internal sealed class DevTextureSaveMenu : IInternalDisposableService
var initiatorScreenOffset = ImGui.GetMousePos(); var initiatorScreenOffset = ImGui.GetMousePos();
using var textureWrap = await texture; using var textureWrap = await texture;
var textureManager = await Service<TextureManager>.GetAsync(); var textureManager = await Service<TextureManager>.GetAsync();
var popupName = $"{nameof(this.ShowTextureSaveMenuAsync)}_{textureWrap.ImGuiHandle:X}"; var popupName = $"{nameof(this.ShowTextureSaveMenuAsync)}_{textureWrap.Handle.Handle:X}";
BitmapCodecInfo? encoder; BitmapCodecInfo? encoder;
{ {

View file

@ -1,5 +1,4 @@
{ {
"$schema": "https://aka.ms/CsWin32.schema.json", "$schema": "https://aka.ms/CsWin32.schema.json",
"allowMarshaling": false, "allowMarshaling": false
"public": true
} }

View file

@ -1,24 +0,0 @@
namespace Dalamud.Utility;
/// <summary>
/// Utility class for marking something to be changed for when the new bindings are fully adopted, for ease of lookup.
/// </summary>
[AttributeUsage(AttributeTargets.All, Inherited = false)]
internal sealed class ImGuiBindingsToDoAttribute : Attribute
{
/// <summary>
/// Marks that this should be made internal.
/// </summary>
public const string MakeInternal = "Make internal.";
/// <summary>
/// Initializes a new instance of the <see cref="ImGuiBindingsToDoAttribute"/> class.
/// </summary>
/// <param name="what">The explanation.</param>
/// <param name="what2">The explanation 2.</param>
public ImGuiBindingsToDoAttribute(string what, string what2 = "")
{
_ = what;
_ = what2;
}
}