Skip to content

Instantly share code, notes, and snippets.

@attilaz
Created December 14, 2018 21:22
Show Gist options
  • Save attilaz/84bffcef613bff27cbdf053131e30adf to your computer and use it in GitHub Desktop.
Save attilaz/84bffcef613bff27cbdf053131e30adf to your computer and use it in GitHub Desktop.
ImGui Plan
#define BUTTON_ID 1
cButton* btn = new cButton(LOC"PLAY", "images/foo.png");
btn->setPosition(sGuiVec2(100,200));
btn->setScale(2.0f);
btn->setAnchorPoint(sGuiVec2(0,0));
btn->onPressed().addHandler(this, &onButtonPressed);
addChild(btn, 1, BUTTON_ID);
void onButtonPressed(cButton* btn)
{
if ( btn->getID() == BUTTON_ID)
{
//action
}
}
--------------------------------
if (ImButton("play", LOC"PLAY", "images/foo.png", float2(100,200), 1, ImScale(2.0f), ImAnchorPoint(0,0)))
{
//action
}
----------
API implementation:
bool ImButton(const char* id, locString text, const char* image, float2 pos, int zorder, Property& prop0, Property& prop1, Property& prop2, )
{
//create node if not found
//set default properties (update only if changed??)
//handle custom properties
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment