Class Label

Inheritance Relationships

Base Type

Class Documentation

class Label : public nanogui::Widget

Text label widget.

The font and color can be customized.

Tip

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 = "", int fontSize = -1)

Creates a Label with the specified parent.

Parameters
  • parent: The parent of this Label.
  • caption: The text this Label will draw.
  • font: The font face to use (default "" implies Theme::mDefaultFont, which will typically be "sans").
  • fontSize: The font size to use, -1 indicates the default font size specified by Theme::mStandardFontSize will be used.

const std::string &caption() const

Get the label’s text caption.

void setCaption(const std::string &caption)

Set the label’s text caption.

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, will change mColor when mColorExplicit is false (e.g., setColor was never called).

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

Saves the state of this Label provided the given Serializer.

virtual bool load(Serializer &s)

Sets the state of this Label provided the given Serializer.

Protected Attributes

std::string mCaption

The current text caption being drawn.

Color mColor

The color to draw mCaption with.

bool mColorExplicit

Whether or not setColor has been called.