| 3822 | } |
| 3823 | |
| 3824 | void ImGui::TableLoadSettings(ImGuiTable* table) |
| 3825 | { |
| 3826 | ImGuiContext& g = *GImGui; |
| 3827 | table->IsSettingsRequestLoad = false; |
| 3828 | if (table->Flags & ImGuiTableFlags_NoSavedSettings) |
| 3829 | return; |
| 3830 | |
| 3831 | // Bind settings |
| 3832 | ImGuiTableSettings* settings; |
| 3833 | if (table->SettingsOffset == -1) |
| 3834 | { |
| 3835 | settings = TableSettingsFindByID(table->ID); |
| 3836 | if (settings == NULL) |
| 3837 | return; |
| 3838 | if (settings->ColumnsCount != table->ColumnsCount) // Allow settings if columns count changed. We could otherwise decide to return... |
| 3839 | table->IsSettingsDirty = true; |
| 3840 | table->SettingsOffset = g.SettingsTables.offset_from_ptr(settings); |
| 3841 | } |
| 3842 | else |
| 3843 | { |
| 3844 | settings = TableGetBoundSettings(table); |
| 3845 | } |
| 3846 | |
| 3847 | table->SettingsLoadedFlags = settings->SaveFlags; |
| 3848 | table->RefScale = settings->RefScale; |
| 3849 | |
| 3850 | // Initialize default columns settings |
| 3851 | for (int column_n = 0; column_n < table->ColumnsCount; column_n++) |
| 3852 | { |
| 3853 | ImGuiTableColumn* column = &table->Columns[column_n]; |
| 3854 | TableInitColumnDefaults(table, column, ~0); |
| 3855 | column->AutoFitQueue = 0x00; |
| 3856 | } |
| 3857 | |
| 3858 | // Serialize ImGuiTableSettings/ImGuiTableColumnSettings into ImGuiTable/ImGuiTableColumn |
| 3859 | ImGuiTableColumnSettings* column_settings = settings->GetColumnSettings(); |
| 3860 | for (int data_n = 0; data_n < settings->ColumnsCount; data_n++, column_settings++) |
| 3861 | { |
| 3862 | int column_n = column_settings->Index; |
| 3863 | if (column_n < 0 || column_n >= table->ColumnsCount) |
| 3864 | continue; |
| 3865 | |
| 3866 | ImGuiTableColumn* column = &table->Columns[column_n]; |
| 3867 | if (settings->SaveFlags & ImGuiTableFlags_Resizable) |
| 3868 | { |
| 3869 | if (column_settings->IsStretch) |
| 3870 | column->StretchWeight = column_settings->WidthOrWeight; |
| 3871 | else |
| 3872 | column->WidthRequest = column_settings->WidthOrWeight; |
| 3873 | } |
| 3874 | if (settings->SaveFlags & ImGuiTableFlags_Reorderable) |
| 3875 | column->DisplayOrder = column_settings->DisplayOrder; |
| 3876 | if ((settings->SaveFlags & ImGuiTableFlags_Hideable) && column_settings->IsEnabled != -1) |
| 3877 | column->IsUserEnabled = column->IsUserEnabledNextFrame = column_settings->IsEnabled == 1; |
| 3878 | column->SortOrder = column_settings->SortOrder; |
| 3879 | column->SortDirection = column_settings->SortDirection; |
| 3880 | } |
| 3881 |
nothing calls this directly
no test coverage detected