| 2245 | } |
| 2246 | |
| 2247 | static void SetCursorPosYAndSetupForPrevLine(float pos_y, float line_height) |
| 2248 | { |
| 2249 | // Set cursor position and a few other things so that SetScrollHereY() and Columns() can work when seeking cursor. |
| 2250 | // FIXME: It is problematic that we have to do that here, because custom/equivalent end-user code would stumble on the same issue. |
| 2251 | // The clipper should probably have a 4th step to display the last item in a regular manner. |
| 2252 | ImGuiContext& g = *GImGui; |
| 2253 | ImGuiWindow* window = g.CurrentWindow; |
| 2254 | float off_y = pos_y - window->DC.CursorPos.y; |
| 2255 | window->DC.CursorPos.y = pos_y; |
| 2256 | window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, pos_y); |
| 2257 | window->DC.CursorPosPrevLine.y = window->DC.CursorPos.y - line_height; // Setting those fields so that SetScrollHereY() can properly function after the end of our clipper usage. |
| 2258 | window->DC.PrevLineSize.y = (line_height - g.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. |
| 2259 | if (ImGuiOldColumns* columns = window->DC.CurrentColumns) |
| 2260 | columns->LineMinY = window->DC.CursorPos.y; // Setting this so that cell Y position are set properly |
| 2261 | if (ImGuiTable* table = g.CurrentTable) |
| 2262 | { |
| 2263 | if (table->IsInsideRow) |
| 2264 | ImGui::TableEndRow(table); |
| 2265 | table->RowPosY2 = window->DC.CursorPos.y; |
| 2266 | const int row_increase = (int)((off_y / line_height) + 0.5f); |
| 2267 | //table->CurrentRow += row_increase; // Can't do without fixing TableEndRow() |
| 2268 | table->RowBgColorCounter += row_increase; |
| 2269 | } |
| 2270 | } |
| 2271 | |
| 2272 | ImGuiListClipper::ImGuiListClipper() |
| 2273 | { |