feat(settings): add TabSidebar with seven entries
This commit is contained in:
@@ -143,6 +143,9 @@ internal static class PluginHostFactory
|
||||
sp.GetRequiredService<ILogger<Ui.Components.InputBar>>(),
|
||||
() => sp.GetRequiredService<Plugin>().SettingsWindow.Toggle()
|
||||
));
|
||||
services.AddSingleton(sp => new Ui.Components.Settings.TabSidebar(
|
||||
sp.GetRequiredService<FontManager>()
|
||||
));
|
||||
services.AddSingleton(sp => new Ui.Components.StatusBar(
|
||||
sp.GetRequiredService<ThemeRegistry>(),
|
||||
sp.GetRequiredService<FontManager>()
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
using System.Numerics;
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
|
||||
namespace HellionChat.Ui.Components.Settings;
|
||||
|
||||
internal sealed class TabSidebar
|
||||
{
|
||||
private readonly FontManager _fonts;
|
||||
|
||||
public event Action<string>? OnTabSelected;
|
||||
public string ActiveTab { get; private set; } = "general";
|
||||
|
||||
public TabSidebar(FontManager fonts)
|
||||
{
|
||||
_fonts = fonts;
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
using var child = ImRaii.Child("##settings-tab-sidebar", new Vector2(170, 0), true);
|
||||
if (!child.Success)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DrawEntry("general", FontAwesomeIcon.SlidersH, "General");
|
||||
DrawEntry("appearance", FontAwesomeIcon.Palette, "Appearance");
|
||||
DrawEntry("chat", FontAwesomeIcon.Comments, "Chat");
|
||||
DrawEntry("window", FontAwesomeIcon.WindowMaximize, "Window");
|
||||
DrawEntry("channels", FontAwesomeIcon.Hashtag, "Channels");
|
||||
DrawEntry("data-privacy", FontAwesomeIcon.Shield, "Data & Privacy");
|
||||
DrawEntry("about", FontAwesomeIcon.InfoCircle, "About");
|
||||
}
|
||||
|
||||
private void DrawEntry(string id, FontAwesomeIcon icon, string label)
|
||||
{
|
||||
using (_fonts.FontAwesome.Push())
|
||||
{
|
||||
ImGui.TextUnformatted(icon.ToIconString());
|
||||
}
|
||||
ImGui.SameLine();
|
||||
|
||||
var selected = ActiveTab == id;
|
||||
if (ImGui.Selectable($" {label}##tab-{id}", selected))
|
||||
{
|
||||
ActiveTab = id;
|
||||
OnTabSelected?.Invoke(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user