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