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

Method TableUpdateLayout

KBotExt/imgui/imgui_tables.cpp:739–1171  ·  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

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

Callers

nothing calls this directly

Calls 10

ImBitArrayClearAllBitsFunction · 0.85
ImMaxFunction · 0.85
TableSetupColumnFlagsFunction · 0.85
ImBitArraySetBitFunction · 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