ImQuick is a single header ImGui extension library for clearer separation of interface from logic. ImQuick renders ImGui UI elements automagically based only on the variable type.
ImQuick requires ImGui and C++11.
- Create windows during the initialization.
- Create custom render functions for custom types (or skip this step if using basic C++ types).
- Register variables to be rendered automagically by ImQuick.
- Simply let ImQuick handle the UI rendering based on the variable type.
- Create the ImQuick context by calling
ImQuick::CreateContext()
right after callingImGui::CreateContext()
. - (Optional) Call
ImQuick::Initialize()
after creating the context to initialize the render functions for the basic C++ types. - Initialize all windows by calling
ImQuick::InitializeWindow("WINDOW NAME", "WINDOW CATEGORY")
- (Optional) You can register a custom rendering function by calling
ImQuick::RegisterFunction<TYPE>(std::bind<YourTYPERenderingFunction, std::placeholders::_1, std::placeholders::_2)
. You can register a rendering function of any type. - You can then register an existing property by calling
ImQuick::RegisterProperty<TYPE>("PROPERTY LABEL", &propertyVariableOfTYPE, "WINDOW NAME")
. Or you can create a new property usingImQuick::RegisterProperty<TYPE>("PROPERTY LABEL", "WINDOW NAME")
. You can get any property value by callingImQuick::GetPropertyValue<TYPE>("PROPERTY LABEL")
. - Call
ImQuick::DestroyContext()
before callingImGui::DestroyContext()
.
- Call
ImQuick::Render()
before callingImGui::Render()
.
Let's say you have a class named Character which you want to render inside the Main Window. The character class looks something like:
class CCharacter
{
public:
int age = 0;
float stamina = 0.0f;
double skill = 0.0;
}
First, you need to write a rendering function for the character class, either inside the class or in the global scope. It would look something like:
void Render_TypeCharacter(const char* label, void* value)
{
IMQ_STATIC_CAST(CCharacter, value, character);
ImGui::InputInt("Age", &character->age);
ImGui::InputFloat("Stamina", &character->stamina);
ImGui::InputDouble("Skill", &character->skill);
}
Then, you register the render function with ImQuick like so:
ImQuick::RegisterFunction<CCharacter>(std::bind(&Render_TypeCharacter, std::placeholders::_1, std::placeholders::_2));
Finally, you register the character property you want rendered like so:
CCharacter cJohn;
ImQuick::RegisterProperty<CCharacter>("John", &cJohn, "John", "Main Window");
And your all set without even touching the render loop at all!
ImQuick is licensed under the MIT license, see License.txt for more information.