Velvet 0.1a
A beginner-friendly C++ GUI framework built on SFML.
Loading...
Searching...
No Matches
Label Class Reference

Text display widget with simple style map support. More...

#include <Label.hpp>

+ Inheritance diagram for Label:

Public Member Functions

void render (sf::RenderWindow &window) override
 Render the label.
 
void setPosition (float x, float y) override
 Set top-left position of label text/background.
 
sf::Vector2f getDimensions () override
 Get current text bounds.
 
 Label (std::string text, std::unordered_map< std::string, std::variant< unsigned int, float, std::string > > styling={})
 Create label with text and optional style overrides.
 
void setText (const std::string txt)
 Replace displayed string.
 
void overrideStyling (std::unordered_map< std::string, std::variant< unsigned int, float, std::string > > styling)
 Apply/override style properties.
 
- Public Member Functions inherited from Widget
 Widget ()
 Construct a widget with default font loading.
 
virtual void handleEvent (const sf::Event &event, sf::RenderWindow &window)
 Handle an SFML event.
 

Additional Inherited Members

- Public Attributes inherited from Widget
sf::Font font
 Shared font loaded by the base widget.
 
- Protected Attributes inherited from Widget
float x
 
float y
 

Detailed Description

Text display widget with simple style map support.

Supported style keys (std::unordered_map<std::string, std::variant<unsigned int, float, std::string>>):

  • fontPath (std::string)
  • fontSize (float)
  • lineSpacing (float)
  • letterSpacing (float)
  • fillColor (unsigned int, RGBA hex like 0xRRGGBBAA)
  • outlineColor (unsigned int)
  • outlineThickness (float)
  • fontStyle (std::string: regular|bold|italic|underlined|strikethrough)
  • backgroundColor (unsigned int)

Constructor & Destructor Documentation

◆ Label()

Label::Label ( std::string  text,
std::unordered_map< std::string, std::variant< unsigned int, float, std::string > >  styling = {} 
)

Create label with text and optional style overrides.

Member Function Documentation

◆ getDimensions()

sf::Vector2f Label::getDimensions ( )
overridevirtual

Get current text bounds.

Implements Widget.

◆ overrideStyling()

void Label::overrideStyling ( std::unordered_map< std::string, std::variant< unsigned int, float, std::string > >  styling)

Apply/override style properties.

Unknown keys are ignored with a warning.

◆ render()

void Label::render ( sf::RenderWindow &  window)
overridevirtual

Render the label.

Reimplemented from Widget.

◆ setPosition()

void Label::setPosition ( float  x,
float  y 
)
overridevirtual

Set top-left position of label text/background.

Implements Widget.

◆ setText()

void Label::setText ( const std::string  txt)

Replace displayed string.


The documentation for this class was generated from the following file: