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

Method TableUpdateLayout

extern/imgui/imgui_tables.cpp:716–1133  ·  view source on GitHub ↗

Layout columns for the frame. This is in essence the followup to BeginTable(). Runs on the first call to TableNextRow(), to give a chance for TableSetupColumn() to be called first. FIXME-TABLE: Our width (and therefore our WorkRect) will be minimal in the first frame for _WidthAuto columns. Increase feedback side-effect with widgets relying on WorkRect.Max.x... Maybe provide a default distribution

Source from the content-addressed store, hash-verified

714// FIXME-TABLE: Our width (and therefore our WorkRect) will be minimal in the first frame for _WidthAuto columns.
715// Increase feedback side-effect with widgets relying on WorkRect.Max.x... Maybe provide a default distribution for _WidthAuto columns?
716void ImGui::TableUpdateLayout(ImGuiTable* table)
717{
718 ImGuiContext& g = *GImGui;
719 IM_ASSERT(table->IsLayoutLocked == false);
720
721 const ImGuiTableFlags table_sizing_policy = (table->Flags & ImGuiTableFlags_SizingMask_);
722 table->IsDefaultDisplayOrder = true;
723 table->ColumnsEnabledCount = 0;
724 table->EnabledMaskByIndex = 0x00;
725 table->EnabledMaskByDisplayOrder = 0x00;
726 table->LeftMostEnabledColumn = -1;
727 table->MinColumnWidth = ImMax(1.0f, g.Style.FramePadding.x * 1.0f); // g.Style.ColumnsMinSpacing; // FIXME-TABLE
728
729 // [Part 1] Apply/lock Enabled and Order states. Calculate auto/ideal width for columns. Count fixed/stretch columns.
730 // Process columns in their visible orders as we are building the Prev/Next indices.
731 int count_fixed = 0; // Number of columns that have fixed sizing policies
732 int count_stretch = 0; // Number of columns that have stretch sizing policies
733 int prev_visible_column_idx = -1;
734 bool has_auto_fit_request = false;
735 bool has_resizable = false;
736 float stretch_sum_width_auto = 0.0f;
737 float fixed_max_width_auto = 0.0f;
738 for (int order_n = 0; order_n < table->ColumnsCount; order_n++)
739 {
740 const int column_n = table->DisplayOrderToIndex[order_n];
741 if (column_n != order_n)
742 table->IsDefaultDisplayOrder = false;
743 ImGuiTableColumn* column = &table->Columns[column_n];
744
745 // Clear column setup if not submitted by user. Currently we make it mandatory to call TableSetupColumn() every frame.
746 // It would easily work without but we're not ready to guarantee it since e.g. names need resubmission anyway.
747 // We take a slight shortcut but in theory we could be calling TableSetupColumn() here with dummy values, it should yield the same effect.
748 if (table->DeclColumnsCount <= column_n)
749 {
750 TableSetupColumnFlags(table, column, ImGuiTableColumnFlags_None);
751 column->NameOffset = -1;
752 column->UserID = 0;
753 column->InitStretchWeightOrWidth = -1.0f;
754 }
755
756 // Update Enabled state, mark settings and sort specs dirty
757 if (!(table->Flags & ImGuiTableFlags_Hideable) || (column->Flags & ImGuiTableColumnFlags_NoHide))
758 column->IsUserEnabledNextFrame = true;
759 if (column->IsUserEnabled != column->IsUserEnabledNextFrame)
760 {
761 column->IsUserEnabled = column->IsUserEnabledNextFrame;
762 table->IsSettingsDirty = true;
763 }
764 column->IsEnabled = column->IsUserEnabled && (column->Flags & ImGuiTableColumnFlags_Disabled) == 0;
765
766 if (column->SortOrder != -1 && !column->IsEnabled)
767 table->IsSortSpecsDirty = true;
768 if (column->SortOrder > 0 && !(table->Flags & ImGuiTableFlags_SortMulti))
769 table->IsSortSpecsDirty = true;
770
771 // Auto-fit unsized columns
772 const bool start_auto_fit = (column->Flags & ImGuiTableColumnFlags_WidthFixed) ? (column->WidthRequest < 0.0f) : (column->StretchWeight < 0.0f);
773 if (start_auto_fit)

Callers

nothing calls this directly

Calls 8

ImMaxFunction · 0.85
TableSetupColumnFlagsFunction · 0.85
ImFloorFunction · 0.85
TableGetInstanceDataFunction · 0.85
ImMinFunction · 0.85
ImClampFunction · 0.85
SetCurrentChannelMethod · 0.80
PushClipRectMethod · 0.45

Tested by

no test coverage detected