Vixen
02b45cc4
csharp
public sealed class Tabs

A strip of tabs and the panels behind them.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

Two parts, and the tabs are not the parents of their panels. A tab is in the strip and its panel is below it, so the two cannot be one element — which is why AddTab exists and why Panel is a reference rather than a child.

⚠ The unselected panels stay in the tree with display: none. They keep their scroll position, their focus history and their state, and re-selecting a tab costs a restyle rather than a rebuild — which is what makes a tabbed inspector usable. The cost is that ten tabs is ten panels' worth of elements whether or not anybody looks at them, and a panel that is genuinely expensive should be built on first selection by the application. Said plainly rather than solved with a lazy mode nobody would find.

Arrows select rather than only moving the focus, for the reason a radio group's do: the strip is one tab stop, so a keyboard that could move without choosing could not choose at all.

Fields and properties (8)

  • protected override string TagName

    The element name this type answers to when a caller does not choose one.

  • protected override bool AcceptsFocus

    Whether the focus can rest on this kind of control at all.

  • public UiElement Strip

    The strip the headers are in.

  • public UiElement Panels

    The area the panels are in.

  • public IReadOnlyList<TabItem> Items

    The tabs, in order.

  • public int SelectedIndex
  • public TabItem? Selected

    The tab that is showing, if one is.

  • public static readonly UiPropertyKey SelectedIndexProperty

    Identity for SelectedIndex.

Events (1)

  • public Action<Tabs, int>? SelectionChanged

    Raised when a different tab is shown.

Methods (4)

  • protected override void OnCreated()

    Builds whatever this element is made of, once, as it joins a document.

  • public TabItem AddTab(string? label = null)

    Adds a tab and the panel behind it.

  • public bool RemoveTab(TabItem tab)

    Takes a tab and its panel out.

  • public void ClearSelectedIndex()

    Unsets SelectedIndex, so it takes its default or its ancestor's value again.

Used by (8)

  • ShellHelloUi
  • ControlVisualTestsVixen.Ui.Controls.Tests
  • NavigationInteractionTestsVixen.Ui.Controls.Tests
  • SelectionTestsVixen.Ui.Controls.Tests
  • PrefabViewVixen.Editor.AssetEditors
  • SceneEditorFactoryVixen.Editor.AssetEditors
  • SpriteViewTestsVixen.Editor.AssetEditors.Tests
  • TextureImportViewVixen.Editor.AssetEditors