| 313 | } |
| 314 | |
| 315 | bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImGuiTableFlags flags, const ImVec2& outer_size, float inner_width) |
| 316 | { |
| 317 | ImGuiContext& g = *GImGui; |
| 318 | ImGuiWindow* outer_window = GetCurrentWindow(); |
| 319 | if (outer_window->SkipItems) // Consistent with other tables + beneficial side effect that assert on miscalling EndTable() will be more visible. |
| 320 | return false; |
| 321 | |
| 322 | // Sanity checks |
| 323 | IM_ASSERT(columns_count > 0 && columns_count <= IMGUI_TABLE_MAX_COLUMNS && "Only 1..64 columns allowed!"); |
| 324 | if (flags & ImGuiTableFlags_ScrollX) |
| 325 | IM_ASSERT(inner_width >= 0.0f); |
| 326 | |
| 327 | // If an outer size is specified ahead we will be able to early out when not visible. Exact clipping rules may evolve. |
| 328 | const bool use_child_window = (flags & (ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY)) != 0; |
| 329 | const ImVec2 avail_size = GetContentRegionAvail(); |
| 330 | ImVec2 actual_outer_size = CalcItemSize(outer_size, ImMax(avail_size.x, 1.0f), use_child_window ? ImMax(avail_size.y, 1.0f) : 0.0f); |
| 331 | ImRect outer_rect(outer_window->DC.CursorPos, outer_window->DC.CursorPos + actual_outer_size); |
| 332 | if (use_child_window && IsClippedEx(outer_rect, 0, false)) |
| 333 | { |
| 334 | ItemSize(outer_rect); |
| 335 | return false; |
| 336 | } |
| 337 | |
| 338 | // Acquire storage for the table |
| 339 | ImGuiTable* table = g.Tables.GetOrAddByKey(id); |
| 340 | const int instance_no = (table->LastFrameActive != g.FrameCount) ? 0 : table->InstanceCurrent + 1; |
| 341 | const ImGuiID instance_id = id + instance_no; |
| 342 | const ImGuiTableFlags table_last_flags = table->Flags; |
| 343 | if (instance_no > 0) |
| 344 | IM_ASSERT(table->ColumnsCount == columns_count && "BeginTable(): Cannot change columns count mid-frame while preserving same ID"); |
| 345 | |
| 346 | // Acquire temporary buffers |
| 347 | const int table_idx = g.Tables.GetIndex(table); |
| 348 | g.CurrentTableStackIdx++; |
| 349 | if (g.CurrentTableStackIdx + 1 > g.TablesTempDataStack.Size) |
| 350 | g.TablesTempDataStack.resize(g.CurrentTableStackIdx + 1, ImGuiTableTempData()); |
| 351 | ImGuiTableTempData* temp_data = table->TempData = &g.TablesTempDataStack[g.CurrentTableStackIdx]; |
| 352 | temp_data->TableIndex = table_idx; |
| 353 | table->DrawSplitter = &table->TempData->DrawSplitter; |
| 354 | table->DrawSplitter->Clear(); |
| 355 | |
| 356 | // Fix flags |
| 357 | table->IsDefaultSizingPolicy = (flags & ImGuiTableFlags_SizingMask_) == 0; |
| 358 | flags = TableFixFlags(flags, outer_window); |
| 359 | |
| 360 | // Initialize |
| 361 | table->ID = id; |
| 362 | table->Flags = flags; |
| 363 | table->InstanceCurrent = (ImS16)instance_no; |
| 364 | table->LastFrameActive = g.FrameCount; |
| 365 | table->OuterWindow = table->InnerWindow = outer_window; |
| 366 | table->ColumnsCount = columns_count; |
| 367 | table->IsLayoutLocked = false; |
| 368 | table->InnerWidth = inner_width; |
| 369 | temp_data->UserOuterSize = outer_size; |
| 370 | |
| 371 | // When not using a child window, WorkRect.Max will grow as we append contents. |
| 372 | if (use_child_window) |
nothing calls this directly
no test coverage detected