| 3746 | } |
| 3747 | |
| 3748 | void ImGui::TableLoadSettings(ImGuiTable* table) |
| 3749 | { |
| 3750 | ImGuiContext& g = *GImGui; |
| 3751 | table->IsSettingsRequestLoad = false; |
| 3752 | if (table->Flags & ImGuiTableFlags_NoSavedSettings) |
| 3753 | return; |
| 3754 | |
| 3755 | // Bind settings |
| 3756 | ImGuiTableSettings* settings; |
| 3757 | if (table->SettingsOffset == -1) |
| 3758 | { |
| 3759 | settings = TableSettingsFindByID(table->ID); |
| 3760 | if (settings == NULL) |
| 3761 | return; |
| 3762 | if (settings->ColumnsCount != table->ColumnsCount) // Allow settings if columns count changed. We could otherwise decide to return... |
| 3763 | table->IsSettingsDirty = true; |
| 3764 | table->SettingsOffset = g.SettingsTables.offset_from_ptr(settings); |
| 3765 | } |
| 3766 | else |
| 3767 | { |
| 3768 | settings = TableGetBoundSettings(table); |
| 3769 | } |
| 3770 | |
| 3771 | table->SettingsLoadedFlags = settings->SaveFlags; |
| 3772 | table->RefScale = settings->RefScale; |
| 3773 | |
| 3774 | // Initialize default columns settings |
| 3775 | for (int column_n = 0; column_n < table->ColumnsCount; column_n++) |
| 3776 | { |
| 3777 | ImGuiTableColumn* column = &table->Columns[column_n]; |
| 3778 | TableInitColumnDefaults(table, column, ~0); |
| 3779 | column->AutoFitQueue = 0x00; |
| 3780 | } |
| 3781 | |
| 3782 | // Serialize ImGuiTableSettings/ImGuiTableColumnSettings into ImGuiTable/ImGuiTableColumn |
| 3783 | ImGuiTableColumnSettings* column_settings = settings->GetColumnSettings(); |
| 3784 | ImU64 display_order_mask = 0; |
| 3785 | for (int data_n = 0; data_n < settings->ColumnsCount; data_n++, column_settings++) |
| 3786 | { |
| 3787 | int column_n = column_settings->Index; |
| 3788 | if (column_n < 0 || column_n >= table->ColumnsCount) |
| 3789 | continue; |
| 3790 | |
| 3791 | ImGuiTableColumn* column = &table->Columns[column_n]; |
| 3792 | if (settings->SaveFlags & ImGuiTableFlags_Resizable) |
| 3793 | { |
| 3794 | if (column_settings->IsStretch) |
| 3795 | column->StretchWeight = column_settings->WidthOrWeight; |
| 3796 | else |
| 3797 | column->WidthRequest = column_settings->WidthOrWeight; |
| 3798 | } |
| 3799 | if (settings->SaveFlags & ImGuiTableFlags_Reorderable) |
| 3800 | column->DisplayOrder = column_settings->DisplayOrder; |
| 3801 | display_order_mask |= (ImU64)1 << column->DisplayOrder; |
| 3802 | if ((settings->SaveFlags & ImGuiTableFlags_Hideable) && column_settings->IsEnabled != -1) |
| 3803 | column->IsUserEnabled = column->IsUserEnabledNextFrame = column_settings->IsEnabled == 1; |
| 3804 | column->SortOrder = column_settings->SortOrder; |
| 3805 | column->SortDirection = column_settings->SortDirection; |
nothing calls this directly
no test coverage detected