ocornut / ocornut/imgui_test_engine
Imgui test engine cant find BeginChildEx because of '/'
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 629
- Forks
- 83
- PR merge metrics
- No merged PRs in 30d
Description
BeginChildEx cant be found because the child window name contains a '/'. If I change these lines in BegindChildEx:
if (name)
ImFormatStringToTempBuffer(&temp_window_name, NULL, "%s/%s_%08X", parent_window->Name, name, id);
else
ImFormatStringToTempBuffer(&temp_window_name, NULL, "%/%08X", parent_window->Name, id);
to
if (name)
ImFormatStringToTempBuffer(&temp_window_name, NULL, "%s_%s_%08X", parent_window->Name, name, id);
else
ImFormatStringToTempBuffer(&temp_window_name, NULL, "%s_%08X", parent_window->Name, id);
i.e replace the slash with an underscore then ImGuiTestContext::ItemInfo can find the child window and doesn't chop off the name_id part.
ImGuiTestItemInfo ImGuiTestContext::ItemInfo(ImGuiTestRef ref, ImGuiTestOpFlags flags)
This is important for scrolling as otherwise items off screen in child windows can't be found as the current work around of serarching via **/name doesn't work.
This has allowed me to do this to scroll the item onto screen in the test framework:
ImGuiWindow* window = ImGui::FindWindowByName(file_dialog);
constexpr const char* child = "##files";
ImGuiID id = window->GetID(child);
std::string child_name = std::format("{}_{}_{:08X}", file_dialog, child, id);
ctx.SetRef(child_name.c_str());
ctx.ScrollToItemY(std::format("##folder_{}", folder).c_str());
There is also a line in
ImGuiTestItemInfo ImGuiTestContext::WindowInfo(ImGuiTestRef ref, ImGuiTestOpFlags flags)
that needs to be changed here:
ImGuiID child_window_id = 0;
ImGuiWindow* child_window = NULL;
{
// Child: Attempt 1: Try to BeginChild(const char*) variant and mimic its logic.
Str128 child_window_full_name;
#if (IMGUI_VERSION_NUM >= 18996) && (IMGUI_VERSION_NUM < 18999)
if (window_idstack_back == window->ID)
{
child_window_full_name.setf("%s/%s", window->Name, part_name.c_str());
}
else
#endif
{
ImGuiID child_item_id = GetID(part_name.c_str(), window_idstack_back);
**** child_window_full_name.setf("%s_%s_%08X", window->Name, part_name.c_str(), child_item_id); ****
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the BeginChildEx name construction and the ImGuiTestContext::ItemInfo and WindowInfo functions mentioned in the issue. Trace how child-window names are built and parsed, then verify that child windows containing '/' can be found and that off-screen items in them can be scrolled into view.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100