mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-19 22:37:43 +01:00
- Apply ImRaii to FontAwesomeTestWidget
- Adjust array init
This commit is contained in:
parent
5a0257e40e
commit
a1d2e275a7
1 changed files with 10 additions and 10 deletions
|
|
@ -5,9 +5,11 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
using Dalamud.Bindings.ImGui;
|
using Dalamud.Bindings.ImGui;
|
||||||
using Dalamud.Interface.Components;
|
using Dalamud.Interface.Components;
|
||||||
|
using Dalamud.Interface.ImGuiSeStringRenderer;
|
||||||
using Dalamud.Interface.Textures.Internal;
|
using Dalamud.Interface.Textures.Internal;
|
||||||
using Dalamud.Interface.Utility;
|
using Dalamud.Interface.Utility;
|
||||||
using Dalamud.Interface.Utility.Internal;
|
using Dalamud.Interface.Utility.Internal;
|
||||||
|
using Dalamud.Interface.Utility.Raii;
|
||||||
|
|
||||||
using Lumina.Text.ReadOnly;
|
using Lumina.Text.ReadOnly;
|
||||||
|
|
||||||
|
|
@ -18,13 +20,15 @@ namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class FontAwesomeTestWidget : IDataWindowWidget
|
internal class FontAwesomeTestWidget : IDataWindowWidget
|
||||||
{
|
{
|
||||||
|
private static readonly string[] First = ["(Show All)", "(Undefined)"];
|
||||||
|
|
||||||
private List<FontAwesomeIcon>? icons;
|
private List<FontAwesomeIcon>? icons;
|
||||||
private List<string>? iconNames;
|
private List<string>? iconNames;
|
||||||
private string[]? iconCategories;
|
private string[]? iconCategories;
|
||||||
private int selectedIconCategory;
|
private int selectedIconCategory;
|
||||||
private string iconSearchInput = string.Empty;
|
private string iconSearchInput = string.Empty;
|
||||||
private bool iconSearchChanged = true;
|
private bool iconSearchChanged = true;
|
||||||
private bool useFixedWidth = false;
|
private bool useFixedWidth;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string[]? CommandShortcuts { get; init; } = { "fa", "fatest", "fontawesome" };
|
public string[]? CommandShortcuts { get; init; } = { "fa", "fatest", "fontawesome" };
|
||||||
|
|
@ -44,11 +48,9 @@ internal class FontAwesomeTestWidget : IDataWindowWidget
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Draw()
|
public void Draw()
|
||||||
{
|
{
|
||||||
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, Vector2.Zero);
|
using var pushedStyle = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, Vector2.Zero);
|
||||||
|
|
||||||
this.iconCategories ??= new[] { "(Show All)", "(Undefined)" }
|
this.iconCategories ??= First.Concat(FontAwesomeHelpers.GetCategories().Skip(1)).ToArray();
|
||||||
.Concat(FontAwesomeHelpers.GetCategories().Skip(1))
|
|
||||||
.ToArray();
|
|
||||||
|
|
||||||
if (this.iconSearchChanged)
|
if (this.iconSearchChanged)
|
||||||
{
|
{
|
||||||
|
|
@ -101,7 +103,8 @@ internal class FontAwesomeTestWidget : IDataWindowWidget
|
||||||
ImGuiHelpers.ScaledRelativeSameLine(50f);
|
ImGuiHelpers.ScaledRelativeSameLine(50f);
|
||||||
ImGui.Text($"{this.iconNames?[i]}");
|
ImGui.Text($"{this.iconNames?[i]}");
|
||||||
ImGuiHelpers.ScaledRelativeSameLine(280f);
|
ImGuiHelpers.ScaledRelativeSameLine(280f);
|
||||||
ImGui.PushFont(this.useFixedWidth ? InterfaceManager.IconFontFixedWidth : InterfaceManager.IconFont);
|
|
||||||
|
using var pushedFont = ImRaii.PushFont(this.useFixedWidth ? InterfaceManager.IconFontFixedWidth : InterfaceManager.IconFont);
|
||||||
ImGui.Text(this.icons[i].ToIconString());
|
ImGui.Text(this.icons[i].ToIconString());
|
||||||
ImGuiHelpers.ScaledRelativeSameLine(320f);
|
ImGuiHelpers.ScaledRelativeSameLine(320f);
|
||||||
if (this.useFixedWidth
|
if (this.useFixedWidth
|
||||||
|
|
@ -114,13 +117,10 @@ internal class FontAwesomeTestWidget : IDataWindowWidget
|
||||||
Task.FromResult(
|
Task.FromResult(
|
||||||
Service<TextureManager>.Get().CreateTextureFromSeString(
|
Service<TextureManager>.Get().CreateTextureFromSeString(
|
||||||
ReadOnlySeString.FromText(this.icons[i].ToIconString()),
|
ReadOnlySeString.FromText(this.icons[i].ToIconString()),
|
||||||
new() { Font = ImGui.GetFont(), FontSize = ImGui.GetFontSize(), ScreenOffset = Vector2.Zero })));
|
new SeStringDrawParams { Font = ImGui.GetFont(), FontSize = ImGui.GetFontSize(), ScreenOffset = Vector2.Zero })));
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.PopFont();
|
|
||||||
ImGuiHelpers.ScaledDummy(2f);
|
ImGuiHelpers.ScaledDummy(2f);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.PopStyleVar();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue