Skip to content

Tables: Fix AddCallback() being ignored when last in column (#4843) #4844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Conversation

hoffstadt
Copy link
Contributor

Simple fix related to #4843.

Issue

Inside a table, calling ImGui::AddCallback(...) as the last item in a column has no effect.

Solution

In TableMergeDrawChannels(...) inside imgui_tables.cpp, just ensure the last command buffer doesn't include a callback before popping.

@ocornut
Copy link
Owner

ocornut commented Dec 30, 2021

Thank you very much! This looks good.

Interestingly/weirdly, ImDrawListSplitter::Merge() has similar code with an explicit comment:

// Equivalent of PopUnusedDrawCmd() for this channel's cmdbuffer and except we don't need to test for UserCallback.
if (ch._CmdBuffer.Size > 0 && ch._CmdBuffer.back().ElemCount == 0)
    ch._CmdBuffer.pop_back();

I am confused as to what why we did that.... git blaming...

Added the comment in 117d57d while refactoring but after the fact of writing the code like that... Actual logic comes from the very old 87ebe95. My opinion is that logic was wrong in the first place.

As a result I have amended your commit with the same change in ImDrawListSplitter::Merge() as well.

Thank you.

@hoffstadt
Copy link
Contributor Author

Appreciate the coauthor! I did see it in ImDrawListSplitter::Merge() but assumed there must have been a reason for it since it was mentioned that ".. we don't need to test for UserCallback..".

Either way, glad to have my first small commit!

@ocornut
Copy link
Owner

ocornut commented May 31, 2022

The PR was wrong, we didn't noticed as other flags which led to additional drawing (BordersH, RowBG) would strip that empty draw command in other places. Discovered by @rokups.
Pushed fix f58bd81 + amended our tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants