1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-25 00:00:40 +01:00

ImGuiListClipper: Fix to behave within column (#661, #662, #716)

This commit is contained in:
ocornut 2016-06-29 10:19:01 +02:00
parent 74bbfcfaa6
commit b9b3dec7da

View File

@ -1622,12 +1622,14 @@ float ImGuiSimpleColumns::CalcExtraSpace(float avail_w)
static void SetCursorPosYAndSetupDummyPrevLine(float pos_y, float line_height) static void SetCursorPosYAndSetupDummyPrevLine(float pos_y, float line_height)
{ {
// Setting those fields so that SetScrollHere() can properly function after the end of our clipper usage. // Set cursor position and a few other things so that SetScrollHere() and Columns() can work when seeking cursor.
// If we end up needing more accurate data (to e.g. use SameLine) we may as well make the clipper have a fourth step to let user process and display the last item in their list. // FIXME: It is problematic that we have to do that here, because custom/equivalent end-user code would stumble on the same issue. Consider moving within SetCursorXXX functions?
ImGui::SetCursorPosY(pos_y); ImGui::SetCursorPosY(pos_y);
ImGuiWindow* window = ImGui::GetCurrentWindow(); ImGuiWindow* window = ImGui::GetCurrentWindow();
window->DC.CursorPosPrevLine.y = window->DC.CursorPos.y - line_height; window->DC.CursorPosPrevLine.y = window->DC.CursorPos.y - line_height; // Setting those fields so that SetScrollHere() can properly function after the end of our clipper usage.
window->DC.PrevLineHeight = (line_height - GImGui->Style.ItemSpacing.y); window->DC.PrevLineHeight = (line_height - GImGui->Style.ItemSpacing.y); // If we end up needing more accurate data (to e.g. use SameLine) we may as well make the clipper have a fourth step to let user process and display the last item in their list.
if (window->DC.ColumnsCount > 1)
window->DC.ColumnsCellMinY = window->DC.CursorPos.y; // Setting this so that cell Y position are set properly
} }
// Use case A: Begin() called from constructor with items_height<0, then called again from Sync() in StepNo 1 // Use case A: Begin() called from constructor with items_height<0, then called again from Sync() in StepNo 1