Bar: hover dropdown for a plugin window's barMenu

BarMenuHover (pure timer: 0.15 s open, 0.30 s close, switch at once, no reopen after a click until the icon is left), the dropdown drawn under the bar icon, and a barMenu-only plugin reload now reaches the bar (WindowPlan.MenuSignature, refreshed in PluginWindows.Sync without re-registering the panel).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Daniel Wallace 2026-11-07 20:09:48 -08:00
commit 60a7bddf59
7 changed files with 266 additions and 9 deletions

View file

@ -34,6 +34,8 @@ internal static class Program
WindowTakeOver();
WindowFrameless();
ManifestBarMenu();
BarMenuHoverTiming();
BarMenuReload();
StackCheckAfterPluginDraw();
Console.WriteLine();
@ -586,7 +588,7 @@ internal static class Program
"chrome and fitHeight are in the signature (a change re-registers)");
}
// -- Bar icon dropdown (v94) --──────
// -- Bar icon dropdown (v94) --
private static string BarMenuManifest(string windowExtra) =>
"{ \"version\": 1, \"windows\": [ { \"id\": \"server\", \"title\": \"DreamWeave\", \"surface\": \"window:server\", \"bar\": true"
@ -644,8 +646,84 @@ internal static class Program
Check(err.Length == 0 && m.Windows.Length == 1 && m.Windows[0].Menu.Length == 0, "barMenu not an array: window kept, no menu");
m = SectionManifestParser.Parse("DW", BarMenuManifest(""), out err);
Check(err.Length == 0 && m.Windows.Length == 1 && m.Windows[0].Menu.Length == 0, "no barMenu key: no menu");
m = SectionManifestParser.Parse("DW", BarMenuManifest(", \"barMenu\": [ { \"id\": \"x\", \"tooltip\": \"X\", \"icon\": \"x\", \"command\": \"/rserver x\" } ]"), out err);
Check(err.Length == 0 && m.Windows[0].Menu.Length == 1 && m.Windows[0].Menu[0].Icon == "" && m.Windows[0].Menu[0].Command == "/rserver x",
"a non-glyph icon keeps the item with Icon \"\"");
}
private static void BarMenuHoverTiming()
{
Case("bar dropdown: hover timer");
var h = new BarMenuHover();
h.Update("a", false, 0.0);
h.Update("a", false, 0.10);
Check(h.OpenFor == null, "hovering for 0.10 s: not open yet");
h.Update("a", false, 0.16);
Check(h.OpenFor == "a", "hovering for 0.16 s: open");
h = new BarMenuHover();
h.Update("a", false, 0.0);
h.Update("a", false, 0.10);
h.Update(null, false, 0.11);
h.Update(null, false, 0.20);
h.Update(null, false, 0.30);
Check(h.OpenFor == null, "a sweep across the icon (0.10 s) never opens it");
h = new BarMenuHover();
h.Update("a", false, 0.0);
h.Update("a", false, 0.20);
Check(h.OpenFor == "a", "(setup) open on a");
h.Update(null, false, 1.0);
h.Update(null, false, 1.10);
h.Update(null, true, 1.20);
h.Update(null, true, 1.25);
Check(h.OpenFor == "a", "leaving the icon and reaching the dropdown 0.20 s later: still open (the gap is covered)");
h = new BarMenuHover();
h.Update("a", false, 0.0);
h.Update("a", false, 0.20);
h.Update(null, false, 1.0);
h.Update(null, false, 1.29);
Check(h.OpenFor == "a", "gone for 0.29 s: still open");
h.Update(null, false, 1.31);
Check(h.OpenFor == null, "gone for 0.31 s: closed");
h = new BarMenuHover();
h.Update("a", false, 0.0);
h.Update("a", false, 0.20);
h.Update("b", false, 2.0);
Check(h.OpenFor == "b", "an open dropdown switches to another icon at once");
h = new BarMenuHover();
h.Update("a", false, 0.0);
h.Update("a", false, 0.20);
h.Close();
Check(h.OpenFor == null, "Close() closes");
h.Update("a", false, 0.30);
h.Update("a", false, 5.0);
Check(h.OpenFor == null, "still hovering the same icon: not reopened");
h.Update(null, false, 5.10);
h.Update("a", false, 6.0);
Check(h.OpenFor == null, "hovered again but not for OpenDelay yet");
h.Update("a", false, 6.16);
Check(h.OpenFor == "a", "left and hovered again for OpenDelay: reopens");
Check(BarMenuHover.OpenDelay == 0.15 && BarMenuHover.CloseDelay == 0.30, "delays are 0.15 s and 0.30 s");
}
private static void BarMenuReload()
{
Case("bar dropdown: a barMenu-only change is seen by the host");
string one = BarMenuManifest(", \"barMenu\": [ { \"id\": \"a\", \"tooltip\": \"A\", \"icon\": \"\", \"command\": \"/rserver a\" } ]");
SectionWindowDecl w1 = SectionManifestParser.Parse("DW", one, out _).Windows[0];
SectionWindowDecl w1Again = SectionManifestParser.Parse("DW", one, out _).Windows[0];
SectionWindowDecl w2 = SectionManifestParser.Parse("DW", one.Replace("/rserver a", "/rserver b"), out _).Windows[0];
SectionWindowDecl w3 = SectionManifestParser.Parse("DW", BarMenuManifest(""), out _).Windows[0];
Check(WindowPlan.Signature(w1) == WindowPlan.Signature(w2), "(the panel signature ignores the menu: no re-registration)");
Check(WindowPlan.MenuSignature(w1) == WindowPlan.MenuSignature(w1Again), "the same menu parsed twice: same menu signature");
Check(WindowPlan.MenuSignature(w1) != WindowPlan.MenuSignature(w2), "a changed command: new menu signature");
Check(WindowPlan.MenuSignature(w1) != WindowPlan.MenuSignature(w3), "menu removed: new menu signature");
Check(WindowPlan.MenuSignature(w3) == WindowPlan.MenuSignature(w3 with { BarMenu = null }), "no menu is always the same signature");
}
// ImGui 1.91.6's ImGuiErrorRecoveryState, in field order: windows, IDs, tree nodes, colours,
// style vars, fonts, focus scopes, groups, item flags, popups, disabled. The base values are
// the ones a 32-bit probe of our cimgui.dll read inside a panel's body child (2026-10-21).