Class Label

Inheritance Relationships

Base Type

Class Documentation

class Label : public nanogui::Widget

Text label widget.

The font and color can be customized. When Widget::setFixedWidth() is used, the text is wrapped when it surpasses the specified width.

Public Functions

Label(Widget *parent, const std::string &caption, const std::string &font = "sans", int fontSize = -1)
const std::string &caption() const

Get the label’s text caption.

void setCaption(const std::string &caption)

Set the label’s text caption.

void setFont(const std::string &font)

Set the currently active font (2 are available by default: ‘sans’ and ‘sans-bold’)

const std::string &font() const

Get the currently active font.

Color color() const

Get the label color.

void setColor(const Color &color)

Set the label color.

virtual void setTheme(Theme *theme)

Set the Theme used to draw this widget.

virtual Vector2i preferredSize(NVGcontext *ctx) const

Compute the size needed to fully display the label.

virtual void draw(NVGcontext *ctx)

Draw the label.

virtual void save(Serializer &s) const

Save the state of the widget into the given Serializer instance.

virtual bool load(Serializer &s)

Restore the state of the widget from the given Serializer instance.

Protected Attributes

std::string mCaption
std::string mFont
Color mColor