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

Method BeginTableEx

KBotExt/imgui/imgui_tables.cpp:306–580  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 15

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

Tested by

no test coverage detected