Replace all PushTextWrapPos with using version
This commit is contained in:
@@ -33,7 +33,7 @@ internal sealed class About : ISettingsTab
|
||||
|
||||
public void Draw(bool changed)
|
||||
{
|
||||
ImGui.PushTextWrapPos();
|
||||
using var wrap = ImGuiUtil.TextWrapPos();
|
||||
|
||||
ImGui.TextUnformatted(string.Format(Language.Options_About_Opening, Plugin.PluginName));
|
||||
|
||||
@@ -93,8 +93,6 @@ internal sealed class About : ISettingsTab
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.PopTextWrapPos();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ internal sealed class ChatLog : ISettingsTab
|
||||
|
||||
public void Draw(bool changed)
|
||||
{
|
||||
ImGui.PushTextWrapPos();
|
||||
|
||||
using (ImGuiUtil.TextWrapPos())
|
||||
{
|
||||
ImGuiUtil.OptionCheckbox(ref Mutable.KeepInputFocus, Language.Options_KeepInputFocus_Name, Language.Options_KeepInputFocus_Description);
|
||||
ImGui.Spacing();
|
||||
|
||||
@@ -76,7 +76,7 @@ internal sealed class ChatLog : ISettingsTab
|
||||
Plugin.ChatLogWindow.Position = pos;
|
||||
ImGuiUtil.WarningText(Language.Options_AdjustPosition_Warning);
|
||||
ImGui.Spacing();
|
||||
ImGui.PopTextWrapPos();
|
||||
}
|
||||
|
||||
if (!Mutable.OverrideStyle)
|
||||
return;
|
||||
|
||||
@@ -147,9 +147,9 @@ internal sealed class Database : ISettingsTab
|
||||
return;
|
||||
|
||||
using var treeNode = ImRaii.TreeNode(Language.Options_Database_Advanced);
|
||||
ImGui.PushTextWrapPos();
|
||||
ImGuiUtil.WarningText(Language.Options_Database_Advanced_Warning);
|
||||
using var wrap = ImGuiUtil.TextWrapPos();
|
||||
|
||||
ImGuiUtil.WarningText(Language.Options_Database_Advanced_Warning);
|
||||
if (ImGuiUtil.CtrlShiftButton("Perform maintenance", "Ctrl+Shift: MessageManager.Store.PerformMaintenance()"))
|
||||
Plugin.MessageManager.Store.PerformMaintenance();
|
||||
|
||||
@@ -161,8 +161,6 @@ internal sealed class Database : ISettingsTab
|
||||
|
||||
if (ImGuiUtil.CtrlShiftButton("Inject 10,000 messages", "Ctrl+Shift: creates 10,000 unique messages (async)"))
|
||||
new Thread(() => InsertMessages(10_000)).Start();
|
||||
|
||||
ImGui.PopTextWrapPos();
|
||||
ImGui.Spacing();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ internal sealed class Display : ISettingsTab
|
||||
|
||||
public void Draw(bool changed)
|
||||
{
|
||||
ImGui.PushTextWrapPos();
|
||||
using var wrap = ImGuiUtil.TextWrapPos();
|
||||
|
||||
ImGuiUtil.OptionCheckbox(ref Mutable.HideChat, Language.Options_HideChat_Name, Language.Options_HideChat_Description);
|
||||
ImGui.Spacing();
|
||||
@@ -52,7 +52,5 @@ internal sealed class Display : ISettingsTab
|
||||
|
||||
ImGuiUtil.OptionCheckbox(ref Mutable.CollapseDuplicateMessages, Language.Options_CollapseDuplicateMessages_Name, Language.Options_CollapseDuplicateMessages_Description);
|
||||
ImGui.Spacing();
|
||||
|
||||
ImGui.PopTextWrapPos();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ internal sealed class Emote : ISettingsTab
|
||||
|
||||
public void Draw(bool changed)
|
||||
{
|
||||
ImGui.PushTextWrapPos();
|
||||
using var wrap = ImGuiUtil.TextWrapPos();
|
||||
|
||||
ImGuiUtil.OptionCheckbox(ref Mutable.ShowEmotes, Language.Options_ShowEmotes_Name, Language.Options_ShowEmotes_Desc);
|
||||
ImGui.Spacing();
|
||||
@@ -109,7 +109,5 @@ internal sealed class Emote : ISettingsTab
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.PopTextWrapPos();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class Fonts : ISettingsTab
|
||||
if (changed)
|
||||
UpdateFonts();
|
||||
|
||||
ImGui.PushTextWrapPos();
|
||||
using var wrap = ImGuiUtil.TextWrapPos();
|
||||
|
||||
ImGui.Checkbox(Language.Options_FontsEnabled, ref Mutable.FontsEnabled);
|
||||
ImGui.Spacing();
|
||||
@@ -118,6 +118,5 @@ public class Fonts : ISettingsTab
|
||||
ImGuiUtil.HelpText(Language.Options_SymbolsFontSize_Description);
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.PopTextWrapPos();
|
||||
}
|
||||
}
|
||||
|
||||
+12
-10
@@ -200,11 +200,11 @@ internal static class ImGuiUtil
|
||||
internal static void HelpText(string text)
|
||||
{
|
||||
var colour = ImGui.GetStyle().Colors[(int) ImGuiCol.TextDisabled];
|
||||
|
||||
using (TextWrapPos())
|
||||
using (ImRaii.PushColor(ImGuiCol.Text, colour))
|
||||
{
|
||||
ImGui.PushTextWrapPos();
|
||||
ImGui.TextUnformatted(text);
|
||||
ImGui.PopTextWrapPos();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,15 +215,11 @@ internal static class ImGuiUtil
|
||||
|
||||
var push = dalamudOrange != null;
|
||||
var color = dalamudOrange ?? Vector4.Zero;
|
||||
|
||||
using (TextWrapPos(wrap))
|
||||
using (ImRaii.PushColor(ImGuiCol.Text, color, push))
|
||||
{
|
||||
if (wrap)
|
||||
ImGui.PushTextWrapPos();
|
||||
|
||||
ImGui.TextUnformatted(text);
|
||||
|
||||
if (wrap)
|
||||
ImGui.PopTextWrapPos();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,9 +438,15 @@ internal static class ImGuiUtil
|
||||
return new EndUnconditionally(ImGui.PopTextWrapPos, true);
|
||||
}
|
||||
|
||||
public static ImRaii.IEndObject TextWrapPos(float wrapLocalPosX)
|
||||
public static ImRaii.IEndObject TextWrapPos(bool condition)
|
||||
{
|
||||
ImGui.PushTextWrapPos(wrapLocalPosX);
|
||||
if (!condition)
|
||||
return new EndUnconditionally(Nop, false);
|
||||
|
||||
ImGui.PushTextWrapPos();
|
||||
return new EndUnconditionally(ImGui.PopTextWrapPos, true);
|
||||
}
|
||||
|
||||
// Used to avoid pops if condition is false for Push.
|
||||
private static void Nop() { }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user