fix: draw context menu immediately after button

This commit is contained in:
goat 2021-08-15 16:43:55 +02:00
parent 6ae93f9348
commit b6f194cb98
No known key found for this signature in database
GPG key ID: F18F057873895461

View file

@ -506,7 +506,7 @@ namespace Dalamud.Interface.Internal.Windows
return ready; return ready;
} }
private bool DrawPluginCollapsingHeader(string label, PluginManifest manifest, bool trouble, bool updateAvailable, bool isNew, int index) private bool DrawPluginCollapsingHeader(string label, PluginManifest manifest, bool trouble, bool updateAvailable, bool isNew, Action drawContextMenuAction, int index)
{ {
ImGui.Separator(); ImGui.Separator();
@ -535,6 +535,8 @@ namespace Dalamud.Interface.Internal.Windows
isOpen = !isOpen; isOpen = !isOpen;
} }
drawContextMenuAction?.Invoke();
ImGui.PopStyleVar(); ImGui.PopStyleVar();
ImGui.PopStyleColor(3); ImGui.PopStyleColor(3);
@ -625,7 +627,7 @@ namespace Dalamud.Interface.Internal.Windows
ImGui.PushID($"available{index}{manifest.InternalName}"); ImGui.PushID($"available{index}{manifest.InternalName}");
if (this.DrawPluginCollapsingHeader(label, manifest, false, false, !wasSeen, index)) if (this.DrawPluginCollapsingHeader(label, manifest, false, false, !wasSeen, () => this.DrawAvailablePluginContextMenu(manifest), index))
{ {
if (!wasSeen) if (!wasSeen)
this.dalamud.Configuration.SeenPluginInternalName.Add(manifest.InternalName); this.dalamud.Configuration.SeenPluginInternalName.Add(manifest.InternalName);
@ -689,6 +691,11 @@ namespace Dalamud.Interface.Internal.Windows
ImGui.Unindent(); ImGui.Unindent();
} }
ImGui.PopID();
}
private void DrawAvailablePluginContextMenu(PluginManifest manifest)
{
if (ImGui.BeginPopupContextItem("ItemContextMenu")) if (ImGui.BeginPopupContextItem("ItemContextMenu"))
{ {
if (ImGui.Selectable(Locs.PluginContext_MarkAllSeen)) if (ImGui.Selectable(Locs.PluginContext_MarkAllSeen))
@ -730,8 +737,6 @@ namespace Dalamud.Interface.Internal.Windows
ImGui.EndPopup(); ImGui.EndPopup();
} }
ImGui.PopID();
} }
private void DrawInstalledPlugin(LocalPlugin plugin, int index, bool showInstalled = false) private void DrawInstalledPlugin(LocalPlugin plugin, int index, bool showInstalled = false)
@ -807,7 +812,7 @@ namespace Dalamud.Interface.Internal.Windows
ImGui.PushID($"installed{index}{plugin.Manifest.InternalName}"); ImGui.PushID($"installed{index}{plugin.Manifest.InternalName}");
if (this.DrawPluginCollapsingHeader(label, plugin.Manifest, trouble, availablePluginUpdate != default, false, index)) if (this.DrawPluginCollapsingHeader(label, plugin.Manifest, trouble, availablePluginUpdate != default, false, () => this.DrawInstalledPluginContextMenu(plugin), index))
{ {
if (!this.WasPluginSeen(plugin.Manifest.InternalName)) if (!this.WasPluginSeen(plugin.Manifest.InternalName))
this.dalamud.Configuration.SeenPluginInternalName.Add(plugin.Manifest.InternalName); this.dalamud.Configuration.SeenPluginInternalName.Add(plugin.Manifest.InternalName);
@ -894,6 +899,11 @@ namespace Dalamud.Interface.Internal.Windows
ImGui.Unindent(); ImGui.Unindent();
} }
ImGui.PopID();
}
private void DrawInstalledPluginContextMenu(LocalPlugin plugin)
{
if (ImGui.BeginPopupContextItem("InstalledItemContextMenu")) if (ImGui.BeginPopupContextItem("InstalledItemContextMenu"))
{ {
if (ImGui.Selectable(Locs.PluginContext_DeletePluginConfigReload)) if (ImGui.Selectable(Locs.PluginContext_DeletePluginConfigReload))
@ -913,8 +923,6 @@ namespace Dalamud.Interface.Internal.Windows
ImGui.EndPopup(); ImGui.EndPopup();
} }
ImGui.PopID();
} }
private void DrawPluginControlButton(LocalPlugin plugin) private void DrawPluginControlButton(LocalPlugin plugin)