MCPcopy Create free account
hub / github.com/cinder/Cinder / TableUpdateLayout

Method TableUpdateLayout

src/imgui/imgui_tables.cpp:803–1281  ·  view source on GitHub ↗

Layout columns for the frame. This is in essence the followup to BeginTable() and this is our largest function. Runs on the first call to TableNextRow(), to give a chance for TableSetupColumn() and other TableSetupXXXXX() functions 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 wi

Source from the content-addressed store, hash-verified

801// FIXME-TABLE: Our width (and therefore our WorkRect) will be minimal in the first frame for _WidthAuto columns.
802// Increase feedback side-effect with widgets relying on WorkRect.Max.x... Maybe provide a default distribution for _WidthAuto columns?
803void ImGui::TableUpdateLayout(ImGuiTable* table)
804{
805 ImGuiContext& g = *GImGui;
806 IM_ASSERT(table->IsLayoutLocked == false);
807
808 const ImGuiTableFlags table_sizing_policy = (table->Flags & ImGuiTableFlags_SizingMask_);
809 table->IsDefaultDisplayOrder = true;
810 table->ColumnsEnabledCount = 0;
811 ImBitArrayClearAllBits(table->EnabledMaskByIndex, table->ColumnsCount);
812 ImBitArrayClearAllBits(table->EnabledMaskByDisplayOrder, table->ColumnsCount);
813 table->LeftMostEnabledColumn = -1;
814 table->MinColumnWidth = ImMax(1.0f, g.Style.FramePadding.x * 1.0f); // g.Style.ColumnsMinSpacing; // FIXME-TABLE
815
816 // [Part 1] Apply/lock Enabled and Order states. Calculate auto/ideal width for columns. Count fixed/stretch columns.
817 // Process columns in their visible orders as we are building the Prev/Next indices.
818 int count_fixed = 0; // Number of columns that have fixed sizing policies
819 int count_stretch = 0; // Number of columns that have stretch sizing policies
820 int prev_visible_column_idx = -1;
821 bool has_auto_fit_request = false;
822 bool has_resizable = false;
823 float stretch_sum_width_auto = 0.0f;
824 float fixed_max_width_auto = 0.0f;
825 for (int order_n = 0; order_n < table->ColumnsCount; order_n++)
826 {
827 const int column_n = table->DisplayOrderToIndex[order_n];
828 if (column_n != order_n)
829 table->IsDefaultDisplayOrder = false;
830 ImGuiTableColumn* column = &table->Columns[column_n];
831
832 // Clear column setup if not submitted by user. Currently we make it mandatory to call TableSetupColumn() every frame.
833 // It would easily work without but we're not ready to guarantee it since e.g. names need resubmission anyway.
834 // We take a slight shortcut but in theory we could be calling TableSetupColumn() here with dummy values, it should yield the same effect.
835 if (table->DeclColumnsCount <= column_n)
836 {
837 TableSetupColumnFlags(table, column, ImGuiTableColumnFlags_None);
838 column->NameOffset = -1;
839 column->UserID = 0;
840 column->InitStretchWeightOrWidth = -1.0f;
841 }
842
843 // Update Enabled state, mark settings and sort specs dirty
844 if (!(table->Flags & ImGuiTableFlags_Hideable) || (column->Flags & ImGuiTableColumnFlags_NoHide))
845 column->IsUserEnabledNextFrame = true;
846 if (column->IsUserEnabled != column->IsUserEnabledNextFrame)
847 {
848 column->IsUserEnabled = column->IsUserEnabledNextFrame;
849 table->IsSettingsDirty = true;
850 }
851 column->IsEnabled = column->IsUserEnabled && (column->Flags & ImGuiTableColumnFlags_Disabled) == 0;
852
853 if (column->SortOrder != -1 && !column->IsEnabled)
854 table->IsSortSpecsDirty = true;
855 if (column->SortOrder > 0 && !(table->Flags & ImGuiTableFlags_SortMulti))
856 table->IsSortSpecsDirty = true;
857
858 // Auto-fit unsized columns
859 const bool start_auto_fit = (column->Flags & ImGuiTableColumnFlags_WidthFixed) ? (column->WidthRequest < 0.0f) : (column->StretchWeight < 0.0f);
860 if (start_auto_fit)

Callers

nothing calls this directly

Calls 10

ImBitArrayClearAllBitsFunction · 0.85
ImMaxFunction · 0.85
TableSetupColumnFlagsFunction · 0.85
ImBitArraySetBitFunction · 0.85
ImTruncFunction · 0.85
TableGetInstanceDataFunction · 0.85
ImMinFunction · 0.85
ImClampFunction · 0.85
SetCurrentChannelMethod · 0.80
PushClipRectMethod · 0.45

Tested by

no test coverage detected