Vixen
02b45cc4
csharp
public sealed class EditorModes

Which modes the editor has, and which one the viewport's input means right now.

Read the guide page for this →

Remarks

The registry behind the mode bar, and it is a registry for the same reason the command table is one. A mode adds a button to the strip, a radio entry to the palette, a context to the keymap and a claim on viewport input, and all four come from one Add — because the alternative, four places that each know what Blockout is, is what doc 20's A1 calls "six mutually-exclusive booleans on the viewport".

⚠ Exactly one mode is active whenever there is a mode at all. The first one added becomes active, and removing the active one falls back rather than leaving none — a viewport whose input means nothing is not a state any gesture knows how to be in. An editor with no modes registered is the shell on its own, which is the arrangement every test and every sample uses.

⚠ Activation is idempotent and a re-activation does nothing. The mode bar's buttons are ordinary commands and a command runs whenever it is clicked, so pressing the button of the mode you are already in must not put a tool through Deactivated and back.

Fields and properties (3)

  • public IReadOnlyList<IEditorMode> Modes

    The modes, in the order they were registered.

  • public IEditorMode? Active

    The one the viewport's input means, or if there are none.

  • public string? Context

    Which command context is in force because of the active mode, if any.

Events (1)

  • public Action<EditorModes>? Changed

    Raised when the set changes or a different mode becomes active.

Methods (9)

  • public EditorModes(EditorShell shell)

    Creates the registry over a shell.

  • public static string ModeCommand(string modeId)

    What the command that enters a mode is called.

  • public IEditorMode Add(IEditorMode mode)

    Registers a mode.

  • public bool Next()

    Enters the next mode along the strip, wrapping at the end.

  • public bool Remove(string modeId)

    Takes a mode back out.

  • public bool TryGet(string modeId, out IEditorMode? mode)

    Looks a mode up.

  • public bool IsActive(string modeId)

    Whether a mode is the active one.

  • public bool Activate(string modeId)

    Makes a mode the active one.

  • public IReadOnlyList<ToolbarEntry> Bar()

    What the mode bar shows: the mode buttons, then the active mode's own strip.

Used by (20)

  • BlockoutModeVixen.Editor.Blockout
  • BlockoutModeTestsVixen.Editor.Blockout.Tests
  • BlockoutSelectionTestsVixen.Editor.Blockout.Tests
  • EditorApplicationVixen.Editor.App
  • EditorModeTestsVixen.Editor.App.Tests
  • EditorShellVixen.Editor.Ui
  • FoliageModeVixen.Editor.Terrain
  • FoliageModeTestsVixen.Editor.Terrain.Tests
  • LoadingTestsVixen.Editor.Plugin.Tests
  • ModeInputVixen.Editor.App
  • ModeStripTestsVixen.Editor.Ui.Tests
  • ModeTestsVixen.Editor.Ui.Tests
  • PluginContextVixen.Editor.Plugin
  • SceneMenuTestsVixen.Editor.App.Tests
  • SculptSessionTestsVixen.Editor.Terrain.Tests
  • TerrainModeVixen.Editor.Terrain
  • TerrainModeTestsVixen.Editor.Terrain.Tests
  • TerrainModuleVixen.Editor.Terrain
  • TerrainPanelTestsVixen.Editor.App.Tests
  • TerrainSessionTestsVixen.Editor.App.Tests