Label Manager - Horizon-NTH/HorizonGUI GitHub Wiki

LabelManager

Overview

The LabelManager class, located in the hgui namespace=, provides a flexible way to manage Labels in your graphical application. The class can be found inside the header file LabelManager.h.

Member Functions

  • std::shared_ptr<kernel::Label> create(const std::string& text, const point& position, const std::shared_ptr<kernel::Font>& font, bool align = true, const std::tuple<unsigned int, color, float>& textOptions = {12u, HGUI_COLOR_WHITE, 1.0f}, float rotation = 0.0f): Creates a new label by specifying text, position, font, text options, rotation and alignement.

Example Usage

#include <hgui/header/LabelManager.h>

{ // Example Usage of LabelManager
    std::string labelText = "Hello, World!";
    hgui::point labelPosition(100, 100);
    std::shared_ptr<hgui::kernel::Font> labelFont = /* initialize font */;
    std::tuple<unsigned int, color, float> textOptions = {12u, HGUI_COLOR_WHITE, 1.0f};

    // Create a label
    std::shared_ptr<hgui::kernel::Label> customLabel = hgui::LabelManager::create(labelText, labelPosition, labelFont, true, textOptions, 0.0f);

    // Use the label as needed
    // (Render text using the custom label here)
} // Here the custom label is destroyed

Note: In the "Example Usage" section, we demonstrate how to create a custom label with the LabelManager class.