Skip to content

Instantly share code, notes, and snippets.

@therocode
Last active August 29, 2015 14:20
Show Gist options
  • Save therocode/494af91092ed1f35890a to your computer and use it in GitHub Desktop.
Save therocode/494af91092ed1f35890a to your computer and use it in GitHub Desktop.
GimGui adding attributes
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