MCPcopy Create free account
hub / github.com/RenderKit/embree / BeginTableEx

Method BeginTableEx

tutorials/common/imgui/imgui_tables.cpp:311–563  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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