MCPcopy Create free account
hub / github.com/VictorGordan/opengl-tutorials / TableUpdateLayout

Method TableUpdateLayout

ImGUI GLFW Tutorial/imgui/imgui_tables.cpp:719–1132  ·  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

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

Callers

nothing calls this directly

Calls 8

ImMaxFunction · 0.70
TableSetupColumnFlagsFunction · 0.70
ImFloorFunction · 0.70
ImMinFunction · 0.70
ImClampFunction · 0.70
ImHashStrFunction · 0.70
SetCurrentChannelMethod · 0.45
PushClipRectMethod · 0.45

Tested by

no test coverage detected