Tag manager - Horizon-NTH/HorizonGUI GitHub Wiki
TagManager
Overview
The TagManager
class in the hgui
namespace is a utility class that provides functionality to manage and
organize tags within your application. Tags can be associated with various elements, such as widgets,
to categorize and group them. This class allows you to create, retrieve, and set the current tag.
It's a useful tool for implementing features like rendering specific groups of elements or applying effects
to elements with certain tags. The class is defined as a static class in the header file TagManager.h
.
Note: The library use by default a tag that globe all the widgets until you add your customs owns. You can find the id of this main tag here.
Member Functions
-
static std::string create_tag(const std::string& newTag)
: Creates a new tag with the provided name. -
static const std::vector<std::string>& get_tags()
: Retrieves a vector containing all the created tags. -
static const std::string& get_current_tag()
: Retrieves the current active tag. -
static void set_current_tag(const std::string& tag)
: Sets the current active tag to the specified tag.
Example Usage
#include <hgui/header/TagManager.h>
int main() {
// Create tags
std::string tag1 = hgui::TagManager::create_tag("Tag1");
std::string tag2 = hgui::TagManager::create_tag("Tag2");
std::string tag3 = hgui::TagManager::create_tag("Tag3");
// Set the current tag to "Tag2"
hgui::TagManager::set_current_tag("Tag2");
// Get the list of all created tags
const std::vector<std::string>& allTags = hgui::TagManager::get_tags();
// Get the current active tag
const std::string& currentTag = hgui::TagManager::get_current_tag();
// Output the list of tags and the current tag
std::cout << "All Tags: ";
for (const std::string& tag : allTags) {
std::cout << tag << " ";
}
std::cout << "\nCurrent Tag: " << currentTag << std::endl;
return 0;
}
Note: In the "Example Usage" section, we demonstrate how to create tags, set the current tag, and retrieve the list of all created tags and the current active tag using the
TagManager
class. This class is useful for managing and categorizing various elements within your application under different tags.