You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Introduce a configurable flag, RenderInCurrentWindow, to control whether the test engine renders within the existing UI instead of creating a separate floating window. By default, this flag will be set to false, maintaining the current behavior.
Context
This proposal aims to introduce a configurable flag to allow developers to toggle whether the test engine renders inside the existing UI rather than opening a new window. This provides greater flexibility while maintaining backward compatibility by keeping the current behavior as the default.
Tag
Test Engine UIConfigurable FlagRender In Current WindowNot spawn new window for test engine
Motivation
In certain projects, developers may already have custom inspector tools integrated into their UI. For these cases, automatically spawning a new floating window for testing can be redundant or disruptive. Allowing the option to render within an existing window would provide better flexibility and a more seamless user experience.
Call the only known public function that display the test engine
ImGuiTestEngine_ShowTestEngineWindows(e, p_open);
During the GUI rendering, you may add some tests to check the behaviour
if (ImGui::Button("Add new runtime test")) {
staticint counter = 0;
++counter;
ImGuiTestEngine *engine = HelloImGui::GetImGuiTestEngine();
const std::string testname = ("test" + std::to_string(counter));
testSimple = IM_REGISTER_TEST(engine, "Runtime Tests", testname.c_str());
testSimple->GuiFunc = [](ImGuiTestContext *ctx) // Optionally provide a GUI function in addition to your application GUI
{
ImGui::Begin("Test Window", NULL, ImGuiWindowFlags_NoSavedSettings);
ImGui::Text("Hello, automation world");
ImGui::Button("Click Me");
if (ImGui::TreeNode("Node")) {
staticbool b = false;
ImGui::Checkbox("Checkbox", &b);
ImGui::TreePop();
}
ImGui::End();
};
testSimple->TestFunc = [](ImGuiTestContext *ctx) // Generally provide a Test function which will drive the test.
{
ctx->SetRef("Test Window");
ctx->ItemClick("Click Me");
ctx->ItemOpen("Node"); // Optional as ItemCheck("Node/Checkbox") can do it automatically
ctx->ItemCheck("Node/Checkbox");
ctx->ItemUncheck("Node/Checkbox");
};
}
You may also use RegisterTests from hello_imgui, like this
enumclassImGuiTestEngineRenderOptions {
CurrentWindow, // everything rendered in current window, separated by separator
CurrentWindowTabbed, // same things, but tabbed for each of its tool
NewWindow, // everything rendered in a new window, separated by docks
NewWindowWithTabbed, // everything rendered in a new window, but separated by tabs
Custom, // define a custom VoidFunction to change the order of how it should be rendered
};
Futher Improvements
If it is appropriate, we can make it configurable at runtime via UI settings
Adding an option in the settings menu so users can toggle RenderInCurrentWindow without modifying code.
if (ImGui::Checkbox("Render in Current Window", &engine->RenderInCurrentWindow))
{
// Apply changes dynamically
}
As mentioned ealier, use callback for custom rendering so the user can define the order of imgui_te combined with their own inspector tools.
I successfully tested imgui_te with bool RenderInCurrentWindow = false;
Performance impact: None (too small to bring any undesirable effects)
Memory impact: None (only consume one more byte of memory for the flags)
Compatibility impact: None (things work just fine as before the changes, dependencies remained the same)
Before posting the issues, I have...
Searched for similar feature requests regarding configurable rendering options.
Explored alternative libraries such as hello_imgui and imm_app to determine if they support rendering within an existing window.
Tested possible workarounds but found that they either required modifying core behavior or lacked flexibility.
Exploit some APIs to see if I can enforce the behaviour to be inside current window.
Asking chatgpt o1 pro, deepseek r1, perplexity, claude, github copilot, gemini, meta bot, grek, ... given certain knowledge about imgui_te and its implementations
Literally devour (or to says, intergrate, mix, alternate, modify, ...) certain parts of original functions just to mimic the needed behaviours.
Tested the solution and benchmark for performance to verified the impact of the change on UI performance and usability.
Summary
Introduce a configurable flag,
RenderInCurrentWindow
, to control whether the test engine renders within the existing UI instead of creating a separate floating window. By default, this flag will be set tofalse
, maintaining the current behavior.Context
This proposal aims to introduce a configurable flag to allow developers to toggle whether the test engine renders inside the existing UI rather than opening a new window. This provides greater flexibility while maintaining backward compatibility by keeping the current behavior as the default.
Tag
Test Engine UI
Configurable Flag
Render In Current Window
Not spawn new window for test engine
Motivation
In certain projects, developers may already have custom inspector tools integrated into their UI. For these cases, automatically spawning a new floating window for testing can be redundant or disruptive. Allowing the option to render within an existing window would provide better flexibility and a more seamless user experience.
Steps to reproduce
ImGuiTestEngine_ShowTestEngineWindows(e, p_open);
hello_imgui
, like thisTradeoff
I think it has many applicable pros
false
as the default behavior.compare to its cons
Proposal Solution
In
imgui_te_internal.h
Then in
imgui_te_ui.cpp
we change to become
Alternative solutions
We can also use
ImGui::BeginChild()
instead of ignoring it completelyInstead of using a boolean, you may
the other options can be
Futher Improvements
If it is appropriate, we can make it configurable at runtime via UI settings
RenderInCurrentWindow
without modifying code.imgui_te
combined with their own inspector tools.Benchmarked Testing
With my System and Environment like this
I successfully tested
imgui_te
withbool RenderInCurrentWindow = false;
Before posting the issues, I have...
imgui_te
and its implementationsThe text was updated successfully, but these errors were encountered: