Simplify ImGuiListClipper initialization

This commit is contained in:
Haselnussbomber 2025-07-17 01:54:40 +02:00
parent d25b16aa93
commit a1b8dbcf27
No known key found for this signature in database
GPG key ID: BB905BB49E7295D1
7 changed files with 12 additions and 31 deletions

View file

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

View file

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

View file

@ -112,10 +112,7 @@ internal class ConsoleWindow : Window, IDisposable
this.configuration.DalamudConfigurationSaved += this.OnDalamudConfigurationSaved;
unsafe
{
this.clipperPtr = new(ImGui.ImGuiListClipper());
}
this.clipperPtr = ImGui.ImGuiListClipper();
}
/// <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>() ??
throw new InvalidOperationException("Addon sheet not loaded.");
var clipper = new ImGuiListClipperPtr(ImGui.ImGuiListClipper());
var clipper = ImGui.ImGuiListClipper();
clipper.Begin(addon.Count);
while (clipper.Step())
{

View file

@ -449,7 +449,7 @@ internal class TexWidget : IDataWindowWidget
sortSpecs.SpecsDirty = false;
}
var clipper = new ImGuiListClipperPtr(ImGui.ImGuiListClipper());
var clipper = ImGui.ImGuiListClipper();
clipper.Begin(allBlames.Count);
while (clipper.Step())
@ -538,7 +538,7 @@ internal class TexWidget : IDataWindowWidget
(ImGui.GetStyle().ItemSpacing.X * 1 * numIcons));
ImGui.TableHeadersRow();
var clipper = new ImGuiListClipperPtr(ImGui.ImGuiListClipper());
var clipper = ImGui.ImGuiListClipper();
clipper.Begin(textures.Count);
using (var enu = textures.GetEnumerator())

View file

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

View file

@ -34,11 +34,7 @@ public static class ImGuiClip
// Uses ImGuiListClipper and thus handles start- and end-dummies itself.
public static void ClippedDraw<T>(IReadOnlyList<T> data, Action<T> draw, float lineHeight)
{
ImGuiListClipperPtr clipper;
unsafe
{
clipper = new ImGuiListClipperPtr(ImGui.ImGuiListClipper());
}
var clipper = ImGui.ImGuiListClipper();
clipper.Begin(data.Count, lineHeight);
while (clipper.Step())
@ -69,11 +65,7 @@ public static class ImGuiClip
/// <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)
{
ImGuiListClipperPtr clipper;
unsafe
{
clipper = new ImGuiListClipperPtr(ImGui.ImGuiListClipper());
}
var clipper = ImGui.ImGuiListClipper();
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.
public static void ClippedDraw<T>(IReadOnlyList<T> data, Action<T, int> draw, float lineHeight)
{
ImGuiListClipperPtr clipper;
unsafe
{
clipper = new ImGuiListClipperPtr(ImGui.ImGuiListClipper());
}
var clipper = ImGui.ImGuiListClipper();
clipper.Begin(data.Count, lineHeight);
while (clipper.Step())