Last active
August 29, 2015 14:20
-
-
Save therocode/494af91092ed1f35890a to your computer and use it in GitHub Desktop.
GimGui adding attributes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gim::Element element({"example_element"}, | |
{ | |
//here follows a list of name-value pairs to initialize the attributes. | |
//the values can be of any type. | |
{"position", Vec2(23, 10)}, | |
{"size", Vec2(64, 64)}, | |
{"name", "Health meter"s}, | |
{"health", 100}, | |
}, {/*children go here*/}); | |
//attributes can be added afterwards | |
element.createAttribute("color", Color(255, 255, 0)); | |
//we can now get attributes... | |
std::cout << element.getAttribute<std::string>("name"); | |
//outputs: "Health meter" | |
//...and set them | |
element.setAttribute("health", 56); | |
//elements with all their children and attributes can | |
//even be deep copied very easily | |
gim::Element copy = element; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment