Class TabHeader¶
- Defined in File tabheader.h
Page Contents
Inheritance Relationships¶
Base Type¶
public nanogui::Widget
(Class Widget)
Class Documentation¶
-
class
TabHeader
: public nanogui::Widget¶ A Tab navigable widget.
Public Functions
-
TabHeader
(Widget *parent, const std::string &font = "")¶ Creates a TabHeader with the specified parent.
- Parameters
parent
: The parent of this TabHeader.font
: The font face to use (default""
implies Theme::mDefaultBoldFont, which will typically be"sans-bold"
).
-
virtual std::string
defaultFont
() const¶ TabHeaders use a bold font face by default.
When Widget::mFont is not set, this will result in Theme::mDefaultBoldFont.
-
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)
Private Types
Private Functions
-
TabIterator
visibleBegin
()¶
-
TabIterator
visibleEnd
()¶
-
TabIterator
activeIterator
()¶
-
TabIterator
tabIterator
(int index)¶
-
ConstTabIterator
visibleBegin
() const¶
-
ConstTabIterator
visibleEnd
() const¶
-
ConstTabIterator
activeIterator
() const¶
-
ConstTabIterator
tabIterator
(int index) const¶
-
void
calculateVisibleEnd
()¶ Given the beginning of the visible tabs, calculate the end.
-
void
drawControls
(NVGcontext *ctx)¶
-
ClickLocation
locateClick
(const Vector2i &p)¶
-
void
onArrowLeft
()¶
-
void
onArrowRight
()¶
Private Members
-
std::function<void(int)>
mCallback
¶
-
int
mVisibleStart
= 0¶
-
int
mVisibleEnd
= 0¶
-
int
mActiveTab
= 0¶
-
bool
mOverflowing
= false¶
-
class
TabButton
¶ Implementation class of the actual tab buttons.
Public Functions
-
void
setLabel
(const std::string &label)¶
-
const std::string &
label
() const¶
-
void
setSize
(const Vector2i &size)¶
-
const Vector2i &
size
() const¶
-
Vector2i
preferredSize
(NVGcontext *ctx) const¶
-
void
calculateVisibleString
(NVGcontext *ctx)¶
-
void
drawAtPosition
(NVGcontext *ctx, const Vector2i &position, bool active)¶
Public Static Attributes
-
constexpr const char *
dots
= "..."¶
-
void
-