Skip to content

Commit

Permalink
Added two new helpers, one for PushItemWidth and the other for PushTe…
Browse files Browse the repository at this point in the history
…xtWrapPos.
  • Loading branch information
jlkeesey committed Aug 18, 2024
1 parent fdfdee1 commit 0acab69
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion Dalamud/Interface/Utility/Raii/EndObjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,30 @@ public static IEndObject Tooltip()
return new EndUnconditionally(ImGui.EndTooltip, true);
}

/// <summary>
/// Pushes the item width for the next widget and returns an <c>IDisposable</c> that pops
/// the width when done.
/// </summary>
/// <param name="width">The width to set the next widget to.</param>
/// <returns>An <see cref="IDisposable"/> for use in a <c>using</c> statement.</returns>
public static IEndObject ItemWidth(float width)
{
ImGui.PushItemWidth(width);
return new EndUnconditionally(ImGui.PopItemWidth, true);
}

/// <summary>
/// Pushes the item wrapping width for the next string written and returns an <c>IDisposable</c>
/// that pops the wrap width when done.
/// </summary>
/// <param name="pos">The wrap width to set the next text written to.</param>
/// <returns>An <see cref="IDisposable"/> for use in a <c>using</c> statement.</returns>
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));

Expand Down Expand Up @@ -110,7 +134,7 @@ public static unsafe IEndObject TabItem(byte* label, ImGuiTabItemFlags flags)
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;

Expand Down

0 comments on commit 0acab69

Please sign in to comment.