Class TabContainer

Namespace
Forma
Assembly
Forma.dll

Displays one child page at a time and provides tabs for switching the selected page.

public sealed class TabContainer : TemplatedControl, IAddChild<Control>, IAddChild, INotifyPropertyChanged, IDisposable
Inheritance
TabContainer
Implements
Inherited Members

Constructors

TabContainer()

public TabContainer()

Properties

AccessibilityRole

public override AccessibilityRole AccessibilityRole { get; }

Property Value

AccessibilityRole

ContentPadding

Insets the selected page from the tab body chrome.

public Thickness ContentPadding { get; set; }

Property Value

Thickness

CurrentTab

public int CurrentTab { get; set; }

Property Value

int

DeselectEnabled

Allows CurrentTab to become -1, matching Godot's deselect_enabled property.

public bool DeselectEnabled { get; set; }

Property Value

bool

DragToRearrangeEnabled

public bool DragToRearrangeEnabled { get; set; }

Property Value

bool

Font

public SpriteFont Font { get; set; }

Property Value

SpriteFont

MaxTabScroll

The largest useful TabScrollOffset: zero when every tab fits.

public int MaxTabScroll { get; }

Property Value

int

MaxTabWidth

A ceiling on any one tab's width, or zero for none. A long file name is truncated rather than pushing every other tab off the strip.

public int MaxTabWidth { get; set; }

Property Value

int

TabAlignment

Where the tabs sit when they do not fill the strip. Ignored when they do.

public TabBarAlignment TabAlignment { get; set; }

Property Value

TabBarAlignment

TabHeight

Minimum tab-header height. The effective height grows to fit the active font with balanced vertical padding.

public float TabHeight { get; set; }

Property Value

float

TabScrollOffset

How far the tab strip is scrolled sideways, in pixels. Zero unless the tabs overflow.

public int TabScrollOffset { get; set; }

Property Value

int

Remarks

Tabs keep their natural width and the strip scrolls, rather than the tabs shrinking to fit: a strip of twenty documents squeezed into the window is a strip of twenty titles nobody can read. The tab clipped at the edge is what says there is more, which is what VS Code does and costs none of an already short strip's height.

TabSizing

Enables pointer drag reordering of tab pages, like Godot's TabContainer.

public TabBarSizingMode TabSizing { get; set; }

Property Value

TabBarSizingMode

Remarks

This used to be Justify with no way out: every tab took an equal share of the full width, so two tabs each took half the window however short their titles. TabBar has offered the choice since it was written, and a container that wraps the same idea should not answer differently.

The modes match TabSizing: fit to content, uniform at the widest tab's size, justify to fill regardless of content, or expand -- fit to content, then share out any leftover.

TabsRearrangeGroup

Optional group identifier reserved for compatibility with Godot tab-container rearrangement groups.

public int TabsRearrangeGroup { get; set; }

Property Value

int

UIFont

public UIFont UIFont { get; set; }

Property Value

UIFont

Methods

ArrangeChildren()

protected override void ArrangeChildren()

GetCurrentTabControl()

Returns the currently selected page Control, or null when deselected, matching Godot's get_current_tab_control.

public Control GetCurrentTabControl()

Returns

Control

GetDeselectEnabled()

public bool GetDeselectEnabled()

Returns

bool

GetMinimumSize()

Matches Godot's TabContainer::_get_minimum_size: the tab-bar height plus (by default) only the CURRENT page's minimum size, not the max over every page - Godot only folds in every page when use_hidden_tabs_for_min_size is enabled, which this port doesn't model. The popup button, when attached, adds its width like Godot's popup_button branch.

public override Vector2 GetMinimumSize()

Returns

Vector2

GetPopup()

Returns the popup attached with SetPopup(Popup), matching Godot's TabContainer::get_popup.

public Popup GetPopup()

Returns

Popup

GetPopupButtonRectangle()

Returns the header rectangle of the popup button, empty when no popup is attached.

public Rectangle GetPopupButtonRectangle()

Returns

Rectangle

GetPreviousTab()

The tab selected immediately before the current one, matching Godot's get_previous_tab.

public int GetPreviousTab()

Returns

int

GetTabButtonIcon(int)

public Texture2D GetTabButtonIcon(int tab)

Parameters

tab int

Returns

Texture2D

GetTabControl(int)

Returns the page Control at the given tab index, matching Godot's get_tab_control.

public Control GetTabControl(int tab)

Parameters

tab int

Returns

Control

GetTabIcon(int)

public Texture2D GetTabIcon(int tab)

Parameters

tab int

Returns

Texture2D

GetTabIconMaxWidth(int)

public int GetTabIconMaxWidth(int tab)

Parameters

tab int

Returns

int

GetTabMetadata(int)

public object GetTabMetadata(int tab)

Parameters

tab int

Returns

object

GetTabRect(int)

Where a tab is drawn, in global coordinates, or Microsoft.Xna.Framework.Rectangle.Empty when it is hidden or out of range. Public to match GetTabRect(int).

public Rectangle GetTabRect(int tab)

Parameters

tab int

Returns

Rectangle

GetTabTitle(int)

public string GetTabTitle(int tab)

Parameters

tab int

Returns

string

GetTabTooltip(int)

public string GetTabTooltip(int tab)

Parameters

tab int

Returns

string

GetTooltip(Point)

Returns the tooltip at a global pointer position. Override to provide dynamic help text.

public override string GetTooltip(Point position)

Parameters

position Point

Returns

string

IsTabDisabled(int)

public bool IsTabDisabled(int tab)

Parameters

tab int

Returns

bool

IsTabHidden(int)

public bool IsTabHidden(int tab)

Parameters

tab int

Returns

bool

MoveTab(int, int)

Moves a tab page while preserving the selected page.

public void MoveTab(int from, int to)

Parameters

from int
to int

NextTab()

public void NextTab()

PointerMoved(Point)

The pointer moved over this control, in global coordinates.

protected override void PointerMoved(Point point)

Parameters

point Point

PointerPressed(Point)

A pointer press landed on this control, in global coordinates.

Protected as well as internal so a control defined outside this assembly can take part in pointer input. Without that, an app hosting its own drawing surface has to read raw mouse state instead, which bypasses hit-testing, modal gating and the injection side-channel — so such a surface cannot be driven by a test at all.

protected override void PointerPressed(Point point)

Parameters

point Point

PointerReleased(Point, bool)

The pointer was released, with whether it was still inside this control.

protected override void PointerReleased(Point point, bool isInside)

Parameters

point Point
isInside bool

PreviousTab()

public void PreviousTab()

ScrollTabIntoView(int)

Scrolls until a tab is fully visible, if it is not already.

public void ScrollTabIntoView(int tab)

Parameters

tab int

Remarks

Selecting a tab you cannot see -- with Ctrl+Tab, by opening a document, or by closing the one in front -- has to bring it into view, or the strip shows one tab as active while a different one is on screen.

SelectNextAvailable()

Selects the nearest available tab after the current one, wrapping around; returns whether one was found, matching Godot's select_next_available.

public bool SelectNextAvailable()

Returns

bool

SelectPreviousAvailable()

Selects the nearest available tab before the current one, wrapping around; returns whether one was found, matching Godot's select_previous_available.

public bool SelectPreviousAvailable()

Returns

bool

SetDeselectEnabled(bool)

public void SetDeselectEnabled(bool enabled)

Parameters

enabled bool

SetPopup(Popup)

Attaches an arbitrary popup opened from a header button, matching Godot's TabContainer::set_popup.

public void SetPopup(Popup popup)

Parameters

popup Popup

SetTabButtonIcon(int, Texture2D)

public void SetTabButtonIcon(int tab, Texture2D icon)

Parameters

tab int
icon Texture2D

SetTabDisabled(int, bool)

public void SetTabDisabled(int tab, bool disabled)

Parameters

tab int
disabled bool

SetTabHidden(int, bool)

public void SetTabHidden(int tab, bool hidden)

Parameters

tab int
hidden bool

SetTabIcon(int, Texture2D)

public void SetTabIcon(int tab, Texture2D icon)

Parameters

tab int
icon Texture2D

SetTabIconMaxWidth(int, int)

public void SetTabIconMaxWidth(int tab, int width)

Parameters

tab int
width int

SetTabMetadata(int, object)

public void SetTabMetadata(int tab, object metadata)

Parameters

tab int
metadata object

SetTabTitle(int, string)

public void SetTabTitle(int tab, string title)

Parameters

tab int
title string

SetTabTooltip(int, string)

public void SetTabTooltip(int tab, string tooltip)

Parameters

tab int
tooltip string

Events

ActiveTabRearranged

Raised while the selected tab page is moved through the header strip.

public event Action<TabContainer, int> ActiveTabRearranged

Event Type

Action<TabContainer, int>

PrePopupPressed

Raised immediately before the attached popup is shown, matching Godot's pre_popup_pressed signal.

public event EventHandler PrePopupPressed

Event Type

EventHandler

TabButtonPressed

Raised when a tab's configured button icon is pressed.

public event Action<TabContainer, int> TabButtonPressed

Event Type

Action<TabContainer, int>

TabChanged

public event Action<TabContainer, int> TabChanged

Event Type

Action<TabContainer, int>

TabClicked

Raised when a (non-disabled) tab is clicked, matching Godot's tab_clicked signal.

public event Action<TabContainer, int> TabClicked

Event Type

Action<TabContainer, int>

TabHovered

Raised when the pointer enters a tab header, matching Godot's tab_hovered signal.

public event Action<TabContainer, int> TabHovered

Event Type

Action<TabContainer, int>

TabSelected

Raised on every tab selection attempt, even reselecting the current tab, matching Godot's tab_selected signal (TabChanged only fires when the selection actually changes).

public event Action<TabContainer, int> TabSelected

Event Type

Action<TabContainer, int>