Vixen
feb85697
csharp
public sealed class DeclaredMenus

Turns a set of menu declarations into lines, submenus and separators, in one pass.

Read the guide page for this →

Remarks

Doc 50 § D5, and the one piece of the declaration path both tiers share. [EditorMenu] and [EditorSubmenu] are read two ways — by the reflective scan a disk plugin or a project script gets, and by Vixen.Editor.Plugin.Generator, which writes an in-tree module's Declared.Register at compile time. Where a path lands, which submenu two declarations share, what order the lines come in and where a separator goes is decided here and only here, so the two readers cannot disagree about any of it: what they can disagree about is what they found, and DeclaredParityTests holds them to that.

⚠ Collected, then applied. Priority orders declarations against each other, and a declaration a reader finds later may belong above one it found first — so nothing is placed until Apply has seen them all. Registering as they arrive would make the order the one types happened to be enumerated in.

⚠ Everything it adds goes through the context's registration scope, so it is taken out when the plugin is unloaded — the lines, the separators and the submenus it created, and none of what it merely joined.

Fields and properties (1)

  • public const string DerivedCommandPrefix

    The prefix a command declared with no Id is given.

Methods (7)

  • public DeclaredMenus(PluginContext context)

    Turns a set of menu declarations into lines, submenus and separators, in one pass.

  • public void Submenu(string path, StringId? title = null, string? after = null, int priority = 0)

    Declares a submenu: what it is called and where among its siblings it goes.

  • public void Command(string path, Action run, string? id = null, StringId? title = null, int priority = 0, bool separator = false)

    Declares a verb: a command, and its line at the end of a path.

  • public void Line(string path, string commandId, int priority = 0, bool separator = false)

    Declares a line for a command something else registers — a mode's, say.

  • public void Lines(string path, IEnumerable<string> commandIds, int priority = 0, bool separator = false)

    Declares a run of lines for commands something else registers, in the order given.

  • public void Apply()

    Registers every command and places every line and submenu declared so far.

  • public static string Derive(string prefix, string text)

    The id something with no declared one gets.

Used by (6)

  • DeclaredVixen.Editor.Terrain
  • DeclaredVixen.Editor.Texturing
  • DeclaredVixen.Editor.Blockout
  • DeclaredVixen.Editor.Water
  • DeclaredContributionsVixen.Editor.App
  • DeclaredMenuTestsVixen.Editor.Plugin.Tests