Class TabHeader

Inheritance Relationships

Base Type

Class Documentation

class TabHeader : public nanogui::Widget

A Tab navigable widget.

Public Functions

TabHeader(Widget *parent, const std::string &font = "sans-bold")
void setFont(const std::string &font)
const std::string &font() const
bool overflowing() const
void setCallback(const std::function<void(int)> &callback)

Sets the callable objects which is invoked when a tab button is pressed. The argument provided to the callback is the index of the tab.

const std::function<void(int)> &callback() const
void setActiveTab(int tabIndex)
int activeTab() const
bool isTabVisible(int index) const
int tabCount() const
void addTab(const std::string &label)

Inserts a tab at the end of the tabs collection.

void addTab(int index, const std::string &label)

Inserts a tab into the tabs collection at the specified index.

int removeTab(const std::string &label)

Removes the tab with the specified label and returns the index of the label. Returns -1 if there was no such tab

void removeTab(int index)

Removes the tab with the specified index.

const std::string &tabLabelAt(int index) const

Retrieves the label of the tab at a specific index.

int tabIndex(const std::string &label)

Retrieves the index of a specific tab label. Returns the number of tabs (tabsCount) if there is no such tab.

void ensureTabVisible(int index)

Recalculate the visible range of tabs so that the tab with the specified index is visible. The tab with the specified index will either be the first or last visible one depending on the position relative to the old visible range.

std::pair<Vector2i, Vector2i> visibleButtonArea() const

Returns a pair of Vectors describing the top left (pair.first) and the bottom right (pair.second) positions of the rectangle containing the visible tab buttons.

std::pair<Vector2i, Vector2i> activeButtonArea() const

Returns a pair of Vectors describing the top left (pair.first) and the bottom right (pair.second) positions of the rectangle containing the active tab button. Returns two zero vectors if the active button is not visible.

virtual void performLayout(NVGcontext *ctx)

Invoke the associated layout generator to properly place child widgets, if any.

virtual Vector2i preferredSize(NVGcontext *ctx) const

Compute the preferred size of the widget.

virtual bool mouseButtonEvent(const Vector2i &p, int button, bool down, int modifiers)

Handle a mouse button event (default implementation: propagate to children)

virtual void draw(NVGcontext *ctx)

Draw the widget (and all child widgets)