Bar menu: front-order, queue-full reply, BarMenu contract const

Bring the dropdown to the display front each frame (igBringWindowToDisplayFront,
no focus change), reply in chat when the command queue is full, add
PluginContractVersion.BarMenu for plugins to pin against, drop a redundant Trim,
point a comment at the SectionManifest header, and list all bar menu tests
in the changelog.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Daniel Wallace 2026-11-07 20:29:11 -08:00
commit f8c41cddd7
4 changed files with 55 additions and 5 deletions

View file

@ -601,6 +601,9 @@ internal static class ImGuiBar
{
if (begun)
{
// NoFocusOnAppearing leaves a re-shown menu behind a panel focused since: lift it
// every frame (no focus change, so another window's text edit stays active).
MenuToFront();
_overMenu = ImGuiNET.ImGui.IsWindowHovered(ImGuiHoveredFlags.AllowWhenBlockedByActiveItem);
foreach (UI.Sections.SectionBarMenuItem item in items)
{
@ -608,7 +611,8 @@ internal static class ImGuiBar
string glyph = letter ? FirstLetter(item.Tooltip) : item.Icon;
if (IconButton(owner.Id + "_m_" + item.Id, letter ? letterFont : iconFont, glyph, square, RynthTheme.BarText))
{
AcMainThreadQueue.EnqueueChatCommand(item.Command.Trim(), ChatCommandOrigin.Player);
if (!AcMainThreadQueue.EnqueueChatCommand(item.Command, ChatCommandOrigin.Player))
AcMainThreadQueue.EnqueueWriteToChat("[RynthCore] Bar menu: the chat command queue is full; try again.", 1);
clicked = true;
}
SafeImGui.SetItemTooltip(item.Tooltip);
@ -624,6 +628,36 @@ internal static class ImGuiBar
if (clicked) { _menuHover.Close(); _overMenu = false; }
}
private static IntPtr _getCurrentWindow, _bringToFront;
private static int _frontState; // 0 = not resolved, 1 = available, -1 = off
/// <summary>
/// Brings the current window (the bar menu) to the display front without focusing it, through
/// cimgui's igGetCurrentWindow and igBringWindowToDisplayFront (resolved once, as ImGuiStackGuard
/// does). Missing exports: logged once, and the menu keeps its normal order. Inside the menu's Begin.
/// </summary>
private static unsafe void MenuToFront()
{
if (_frontState == 0)
{
_frontState = -1;
IntPtr module = EntryPoint.ImGuiNativeHandle;
if (module != IntPtr.Zero
&& System.Runtime.InteropServices.NativeLibrary.TryGetExport(module, "igGetCurrentWindow", out IntPtr get)
&& System.Runtime.InteropServices.NativeLibrary.TryGetExport(module, "igBringWindowToDisplayFront", out IntPtr bring))
{
_getCurrentWindow = get;
_bringToFront = bring;
_frontState = 1;
}
else
RynthLog.UI("ImGuiBar: this cimgui.dll has no igGetCurrentWindow / igBringWindowToDisplayFront exports; the bar menu can draw behind a panel focused since.");
}
if (_frontState < 0) return;
void* window = ((delegate* unmanaged[Cdecl]<void*>)_getCurrentWindow)();
if (window != null) ((delegate* unmanaged[Cdecl]<void*, void>)_bringToFront)(window);
}
/// <summary>
/// Places the next icon: beside the last one, or at the start of a new row (under the first
/// icon) every <paramref name="perRow"/> icons. Leaving the first row, RL and pop out go at
@ -918,7 +952,7 @@ internal static class ImGuiBar
string icon = IconFor(title, out bool letter);
list.Add(new ButtonInfo(title, "##bar_" + title, icon, letter, title, BarOpenState.KeyFor(title, null)));
}
// Windows plugins draw (their manifests' "windows" with "bar", docs/PLUGIN_WINDOWS.md): the
// Windows plugins draw (their manifests' "windows" with "bar", UI/Sections/SectionManifest.cs header): the
// icon they name (a Phosphor glyph), else the title's letter; the button toggles the panel.
foreach (UI.Sections.SectionWindowDecl w in UI.Sections.PluginWindows.BarWindows)
{

View file

@ -55,5 +55,8 @@ internal static class PluginContractVersion
// bar icon: up to 6 items of id, tooltip, icon and a /command the engine runs on click). Engines
// before v94 ignore the key. The number is PROVISIONAL, as 93 is: upstream may take 94 first,
// in which case this renumbers on merge.
/// <summary>The API version that added the "barMenu" manifest key; a plugin declaring it pins its own copy against this.</summary>
public const uint BarMenu = 94;
public const uint Current = 94;
}