MCPcopy Create free account
hub / github.com/DISTRHO/Cardinal / TableUpdateLayout

Method TableUpdateLayout

plugins/Cardinal/src/DearImGui/imgui_tables.cpp:714–1129  ·  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

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

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected