From 0acab6935a30b9c30c2684d6dda042af9d6cb2fe Mon Sep 17 00:00:00 2001 From: James Keesey Date: Sat, 17 Aug 2024 18:03:42 -0700 Subject: [PATCH] Added two new helpers, one for PushItemWidth and the other for PushTextWrapPos. --- Dalamud/Interface/Utility/Raii/EndObjects.cs | 26 +++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/Dalamud/Interface/Utility/Raii/EndObjects.cs b/Dalamud/Interface/Utility/Raii/EndObjects.cs index 401af5415..261c071c3 100644 --- a/Dalamud/Interface/Utility/Raii/EndObjects.cs +++ b/Dalamud/Interface/Utility/Raii/EndObjects.cs @@ -77,6 +77,30 @@ public static partial class ImRaii return new EndUnconditionally(ImGui.EndTooltip, true); } + /// + /// Pushes the item width for the next widget and returns an IDisposable that pops + /// the width when done. + /// + /// The width to set the next widget to. + /// An for use in a using statement. + public static IEndObject ItemWidth(float width) + { + ImGui.PushItemWidth(width); + return new EndUnconditionally(ImGui.PopItemWidth, true); + } + + /// + /// Pushes the item wrapping width for the next string written and returns an IDisposable + /// that pops the wrap width when done. + /// + /// The wrap width to set the next text written to. + /// An for use in a using statement. + public static IEndObject TextWrapPos(float pos) + { + ImGui.PushTextWrapPos(pos); + return new EndUnconditionally(ImGui.PopTextWrapPos, true); + } + public static IEndObject ListBox(string label) => new EndConditionally(ImGui.EndListBox, ImGui.BeginListBox(label)); @@ -110,7 +134,7 @@ public static partial class ImRaii public static unsafe IEndObject TabItem(string label, ImGuiTabItemFlags flags) { ArgumentNullException.ThrowIfNull(label); - + // One-off for now, we should make this into a generic solution if we need it more often const int labelMaxAlloc = 2048;