MCPcopy Create free account
hub / github.com/VictorGordan/opengl-tutorials / EndTable

Method EndTable

ImGUI GLFW Tutorial/imgui/imgui_tables.cpp:1199–1398  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1197}
1198
1199void ImGui::EndTable()
1200{
1201 ImGuiContext& g = *GImGui;
1202 ImGuiTable* table = g.CurrentTable;
1203 IM_ASSERT(table != NULL && "Only call EndTable() if BeginTable() returns true!");
1204
1205 // This assert would be very useful to catch a common error... unfortunately it would probably trigger in some
1206 // cases, and for consistency user may sometimes output empty tables (and still benefit from e.g. outer border)
1207 //IM_ASSERT(table->IsLayoutLocked && "Table unused: never called TableNextRow(), is that the intent?");
1208
1209 // If the user never got to call TableNextRow() or TableNextColumn(), we call layout ourselves to ensure all our
1210 // code paths are consistent (instead of just hoping that TableBegin/TableEnd will work), get borders drawn, etc.
1211 if (!table->IsLayoutLocked)
1212 TableUpdateLayout(table);
1213
1214 const ImGuiTableFlags flags = table->Flags;
1215 ImGuiWindow* inner_window = table->InnerWindow;
1216 ImGuiWindow* outer_window = table->OuterWindow;
1217 ImGuiTableTempData* temp_data = table->TempData;
1218 IM_ASSERT(inner_window == g.CurrentWindow);
1219 IM_ASSERT(outer_window == inner_window || outer_window == inner_window->ParentWindow);
1220
1221 if (table->IsInsideRow)
1222 TableEndRow(table);
1223
1224 // Context menu in columns body
1225 if (flags & ImGuiTableFlags_ContextMenuInBody)
1226 if (table->HoveredColumnBody != -1 && !IsAnyItemHovered() && IsMouseReleased(ImGuiMouseButton_Right))
1227 TableOpenContextMenu((int)table->HoveredColumnBody);
1228
1229 // Finalize table height
1230 inner_window->DC.PrevLineSize = temp_data->HostBackupPrevLineSize;
1231 inner_window->DC.CurrLineSize = temp_data->HostBackupCurrLineSize;
1232 inner_window->DC.CursorMaxPos = temp_data->HostBackupCursorMaxPos;
1233 const float inner_content_max_y = table->RowPosY2;
1234 IM_ASSERT(table->RowPosY2 == inner_window->DC.CursorPos.y);
1235 if (inner_window != outer_window)
1236 inner_window->DC.CursorMaxPos.y = inner_content_max_y;
1237 else if (!(flags & ImGuiTableFlags_NoHostExtendY))
1238 table->OuterRect.Max.y = table->InnerRect.Max.y = ImMax(table->OuterRect.Max.y, inner_content_max_y); // Patch OuterRect/InnerRect height
1239 table->WorkRect.Max.y = ImMax(table->WorkRect.Max.y, table->OuterRect.Max.y);
1240 table->LastOuterHeight = table->OuterRect.GetHeight();
1241
1242 // Setup inner scrolling range
1243 // FIXME: This ideally should be done earlier, in BeginTable() SetNextWindowContentSize call, just like writing to inner_window->DC.CursorMaxPos.y,
1244 // but since the later is likely to be impossible to do we'd rather update both axises together.
1245 if (table->Flags & ImGuiTableFlags_ScrollX)
1246 {
1247 const float outer_padding_for_border = (table->Flags & ImGuiTableFlags_BordersOuterV) ? TABLE_BORDER_SIZE : 0.0f;
1248 float max_pos_x = table->InnerWindow->DC.CursorMaxPos.x;
1249 if (table->RightMostEnabledColumn != -1)
1250 max_pos_x = ImMax(max_pos_x, table->Columns[table->RightMostEnabledColumn].WorkMaxX + table->CellPaddingX + table->OuterPaddingX - outer_padding_for_border);
1251 if (table->ResizedColumn != -1)
1252 max_pos_x = ImMax(max_pos_x, table->ResizeLockMinContentsX2);
1253 table->InnerWindow->DC.CursorMaxPos.x = max_pos_x;
1254 }
1255
1256 // Pop clipping rect

Callers

nothing calls this directly

Calls 6

ImMaxFunction · 0.70
ImFloorFunction · 0.70
ImMinFunction · 0.70
PopClipRectMethod · 0.45
SetCurrentChannelMethod · 0.45
MergeMethod · 0.45

Tested by

no test coverage detected