MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / BeginTableEx

Method BeginTableEx

extern/imgui/imgui_tables.cpp:310–562  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 15

GetCurrentWindowFunction · 0.85
ImMaxFunction · 0.85
ItemSizeFunction · 0.85
TableFixFlagsFunction · 0.85
ImVec2Function · 0.85
ImMinFunction · 0.85
ImGuiTableColumnClass · 0.85
GetOrAddByKeyMethod · 0.80
GetIndexMethod · 0.80
GetSizeMethod · 0.80
ImGuiTableTempDataFunction · 0.70

Tested by

no test coverage detected