Skip to main content

TabSet

tab-set

See the TabSetDemo.cs.

using System.Collections.Generic;
namespace Gridrand.RimGui.Manual
{
/// <summary>
/// Demonstrates the use of TabSet.
/// </summary>
class TabSetDemo : ManualBase, IManual
{
readonly List<string> tabs = new();

public TabSetDemo(ManualBaseResource p) : base(p)
{
tabs.Add("0");
tabs.Add("1");
tabs.Add("2");
}

public void Draw()
{
if (Gui.Button("Add Tab"))
{
// Adds a new tab with the next index as its label
tabs.Add(tabs.Count.ToString());
}

if (Gui.Button("Remove Tab"))
{
// Removes the last tab
tabs.Remove(((tabs.Count - 1).ToString()));
}

// Begin drawing the TabSet.
if (Gui.BeginTabSet(tabs.Count))
{
for (int i = 0; i < tabs.Count; i++)
{
// Begin drawing the Tab.
// Must be executed between BeginTabSet() and EndTabSet().
if (Gui.BeginTab(tabs[i]))
{
Gui.Text($"{i}");
Gui.EndTab();
}
}

// End the TabSet.
Gui.EndTabSet();
}
}
}

}