MCPcopy Create free account
hub / github.com/KebsCS/KBotExt / EndTable

Method EndTable

KBotExt/imgui/imgui_tables.cpp:1236–1444  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1234}
1235
1236void ImGui::EndTable()
1237{
1238 ImGuiContext& g = *GImGui;
1239 ImGuiTable* table = g.CurrentTable;
1240 IM_ASSERT(table != NULL && "Only call EndTable() if BeginTable() returns true!");
1241
1242 // This assert would be very useful to catch a common error... unfortunately it would probably trigger in some
1243 // cases, and for consistency user may sometimes output empty tables (and still benefit from e.g. outer border)
1244 //IM_ASSERT(table->IsLayoutLocked && "Table unused: never called TableNextRow(), is that the intent?");
1245
1246 // If the user never got to call TableNextRow() or TableNextColumn(), we call layout ourselves to ensure all our
1247 // code paths are consistent (instead of just hoping that TableBegin/TableEnd will work), get borders drawn, etc.
1248 if (!table->IsLayoutLocked)
1249 TableUpdateLayout(table);
1250
1251 const ImGuiTableFlags flags = table->Flags;
1252 ImGuiWindow* inner_window = table->InnerWindow;
1253 ImGuiWindow* outer_window = table->OuterWindow;
1254 ImGuiTableTempData* temp_data = table->TempData;
1255 IM_ASSERT(inner_window == g.CurrentWindow);
1256 IM_ASSERT(outer_window == inner_window || outer_window == inner_window->ParentWindow);
1257
1258 if (table->IsInsideRow)
1259 TableEndRow(table);
1260
1261 // Context menu in columns body
1262 if (flags & ImGuiTableFlags_ContextMenuInBody)
1263 if (table->HoveredColumnBody != -1 && !IsAnyItemHovered() && IsMouseReleased(ImGuiMouseButton_Right))
1264 TableOpenContextMenu((int)table->HoveredColumnBody);
1265
1266 // Finalize table height
1267 ImGuiTableInstanceData* table_instance = TableGetInstanceData(table, table->InstanceCurrent);
1268 inner_window->DC.PrevLineSize = temp_data->HostBackupPrevLineSize;
1269 inner_window->DC.CurrLineSize = temp_data->HostBackupCurrLineSize;
1270 inner_window->DC.CursorMaxPos = temp_data->HostBackupCursorMaxPos;
1271 const float inner_content_max_y = table->RowPosY2;
1272 IM_ASSERT(table->RowPosY2 == inner_window->DC.CursorPos.y);
1273 if (inner_window != outer_window)
1274 inner_window->DC.CursorMaxPos.y = inner_content_max_y;
1275 else if (!(flags & ImGuiTableFlags_NoHostExtendY))
1276 table->OuterRect.Max.y = table->InnerRect.Max.y = ImMax(table->OuterRect.Max.y, inner_content_max_y); // Patch OuterRect/InnerRect height
1277 table->WorkRect.Max.y = ImMax(table->WorkRect.Max.y, table->OuterRect.Max.y);
1278 table_instance->LastOuterHeight = table->OuterRect.GetHeight();
1279
1280 // Setup inner scrolling range
1281 // FIXME: This ideally should be done earlier, in BeginTable() SetNextWindowContentSize call, just like writing to inner_window->DC.CursorMaxPos.y,
1282 // but since the later is likely to be impossible to do we'd rather update both axises together.
1283 if (table->Flags & ImGuiTableFlags_ScrollX)
1284 {
1285 const float outer_padding_for_border = (table->Flags & ImGuiTableFlags_BordersOuterV) ? TABLE_BORDER_SIZE : 0.0f;
1286 float max_pos_x = table->InnerWindow->DC.CursorMaxPos.x;
1287 if (table->RightMostEnabledColumn != -1)
1288 max_pos_x = ImMax(max_pos_x, table->Columns[table->RightMostEnabledColumn].WorkMaxX + table->CellPaddingX + table->OuterPaddingX - outer_padding_for_border);
1289 if (table->ResizedColumn != -1)
1290 max_pos_x = ImMax(max_pos_x, table->ResizeLockMinContentsX2);
1291 table->InnerWindow->DC.CursorMaxPos.x = max_pos_x;
1292 }
1293

Callers

nothing calls this directly

Calls 11

TableGetInstanceDataFunction · 0.85
ImMaxFunction · 0.85
ImFloorFunction · 0.85
ItemSizeFunction · 0.85
ImMinFunction · 0.85
SetCurrentChannelMethod · 0.80
MergeMethod · 0.80
GetSizeMethod · 0.80
GetByIndexMethod · 0.80
GetIndexMethod · 0.80
PopClipRectMethod · 0.45

Tested by

no test coverage detected