feat(sidebar): restore tab rename via shared context menu

This commit is contained in:
2026-06-10 11:42:44 +02:00
parent c7047407f5
commit ac7f74b227
5 changed files with 106 additions and 12 deletions
+1 -6
View File
@@ -159,12 +159,7 @@ internal sealed class Sidebar
if (expanded)
dl.AddText(origin + new Vector2(32f, 8f), textAbgr, tab.Name);
if (ImGui.BeginPopupContextItem("ctx"))
{
if (ImGui.MenuItem("Pop Out"))
_pool.TryOpen(tab);
ImGui.EndPopup();
}
TabContextMenu.Draw(tab, "ctx", _pool);
var popHovered = false;
if (hasPopOut)
@@ -0,0 +1,44 @@
using Dalamud.Bindings.ImGui;
using Dalamud.Interface.Utility;
namespace HellionChat.Ui.Components;
// Shared right-click menu for both tab layouts (Sidebar rows + TopTabBar). One
// source of truth instead of two divergent inline blocks. Static: it has no own
// state and reaches the live Config/Plugin through Plugin.Instance/Plugin.Config.
internal static class TabContextMenu
{
// MUST be called immediately after the row-carrying ImGui item (Sidebar
// "row" InvisibleButton / TopTabBar Selectable). popupId only names the
// popup; the open trigger is a right-click on the LAST submitted item
// (g.LastItemData via IsItemHovered) — any interactive item in between
// would steal the trigger. Only DrawList ops may sit between.
public static void Draw(Tab tab, string popupId, Windows.ChannelPopoutPool pool)
{
if (!ImGui.BeginPopupContextItem(popupId))
return;
// Rename: focus the field the first frame the popup appears.
if (ImGui.IsWindowAppearing())
ImGui.SetKeyboardFocusHere();
ImGui.SetNextItemWidth(250f * ImGuiHelpers.GlobalScale);
var name = tab.Name;
if (ImGui.InputText("##tab-name", ref name, 512) && ApplyTabRename(tab, name))
Plugin.Instance.SaveConfig();
if (ImGui.MenuItem("Pop Out"))
pool.TryOpen(tab);
ImGui.EndPopup();
}
// Factored out so the SelfTest drives the real rename path, not a field poke.
// Returns true when the name actually changed (gates the SaveConfig write).
internal static bool ApplyTabRename(Tab tab, string newName)
{
if (string.IsNullOrEmpty(newName) || newName == tab.Name)
return false;
tab.Name = newName;
return true;
}
}
+1 -6
View File
@@ -38,12 +38,7 @@ internal sealed class TopTabBar
TabLifecycleHelpers.EnsureCurrentChannel(tab);
}
if (ImGui.BeginPopupContextItem($"toptab_ctx_{i}"))
{
if (ImGui.MenuItem("Pop Out"))
_pool.TryOpen(tab);
ImGui.EndPopup();
}
TabContextMenu.Draw(tab, $"toptab_ctx_{i}", _pool);
}
ImGui.Separator();