While there’s been a ton of Dear ImGui implementations created by many, all of those I’ve seen have employed some degree of steamrolling over the existing UI (ie. new subsystem that doesn’t play nice, directly hooking ImGui samples code, etc).
This implementation is as a UIElement that largely plays nice with the existing Urho3D UI, respecting z-order, mouse-mode, touch as left-button, renders through UIBatch, etc. Cludge hacks are always demanding fullscreen size (which is pretty much the dear imgui way) and cheating with screen->element coordinates. While multiple instances sort of work (font issues … debatable), it’s not really intended for that or for being a child of anything but the root … seems to work though. (all the cludge has notes in the sources)
Playing nice with the main UI keeps it handy as a debug tool rather than an outright UI replacement, doesn’t mangle the usability of a HUD, legible dev interface without juggling multiple UI skins, etc.
Takes a function pointer or overload to render the UI as well as sends an event. Use from Angelscript is via subscribing to the event and then pumping out stuff.
// Angelscript code
...
SubscribeToEvent("IMGUIDraw", "HandleIMGUIDraw");
...
void HandleIMGUIDraw(StringHash eventType, VariantMap& eventData)
{
// superficially retains the dear imgui API, &inout instead of *s
// because a window isn't being made it's goes to the automatic "Debug" window
ImGui::Button("This button added by Angelscript!");
ImGui::Text("This text came from angelscript too!");
ImGui::ColorEdit3("Color Editor", imButtonColor);
ImGui::ColorButton("Colors", imButtonColor);
if (testStrArray.length == 0)
{
testStrArray.Push("Roger");
testStrArray.Push("Moore");
testStrArray.Push("Timothy");
testStrArray.Push("Dalton");
}
ImGui::Combo("Testing this out", comboIdx, testStrArray);
}
Angelscript bindings are ~90%, most of what’s missing are flags in the Begin__XXX__
functions and varargs fun, note the use of a namespace so it’s still ImGui::Text()
in Angelscript. C++11 required for the bindings as that’s how I had the robot spit everything out from the imgui headers.
No lua-bindings as the amount of pass by pointer/ref involved isn’t something Lua’s type-system can cope with - without pumping a ton of multi-valued returns or tables+keys (messy either way).