| 3340 | } |
| 3341 | |
| 3342 | void ImGui::TableLoadSettings(ImGuiTable* table) |
| 3343 | { |
| 3344 | ImGuiContext& g = *GImGui; |
| 3345 | table->IsSettingsRequestLoad = false; |
| 3346 | if (table->Flags & ImGuiTableFlags_NoSavedSettings) |
| 3347 | return; |
| 3348 | |
| 3349 | // Bind settings |
| 3350 | ImGuiTableSettings* settings; |
| 3351 | if (table->SettingsOffset == -1) |
| 3352 | { |
| 3353 | settings = TableSettingsFindByID(table->ID); |
| 3354 | if (settings == NULL) |
| 3355 | return; |
| 3356 | if (settings->ColumnsCount != table->ColumnsCount) // Allow settings if columns count changed. We could otherwise decide to return... |
| 3357 | table->IsSettingsDirty = true; |
| 3358 | table->SettingsOffset = g.SettingsTables.offset_from_ptr(settings); |
| 3359 | } |
| 3360 | else |
| 3361 | { |
| 3362 | settings = TableGetBoundSettings(table); |
| 3363 | } |
| 3364 | |
| 3365 | table->SettingsLoadedFlags = settings->SaveFlags; |
| 3366 | table->RefScale = settings->RefScale; |
| 3367 | |
| 3368 | // Serialize ImGuiTableSettings/ImGuiTableColumnSettings into ImGuiTable/ImGuiTableColumn |
| 3369 | ImGuiTableColumnSettings* column_settings = settings->GetColumnSettings(); |
| 3370 | ImU64 display_order_mask = 0; |
| 3371 | for (int data_n = 0; data_n < settings->ColumnsCount; data_n++, column_settings++) |
| 3372 | { |
| 3373 | int column_n = column_settings->Index; |
| 3374 | if (column_n < 0 || column_n >= table->ColumnsCount) |
| 3375 | continue; |
| 3376 | |
| 3377 | ImGuiTableColumn* column = &table->Columns[column_n]; |
| 3378 | if (settings->SaveFlags & ImGuiTableFlags_Resizable) |
| 3379 | { |
| 3380 | if (column_settings->IsStretch) |
| 3381 | column->StretchWeight = column_settings->WidthOrWeight; |
| 3382 | else |
| 3383 | column->WidthRequest = column_settings->WidthOrWeight; |
| 3384 | column->AutoFitQueue = 0x00; |
| 3385 | } |
| 3386 | if (settings->SaveFlags & ImGuiTableFlags_Reorderable) |
| 3387 | column->DisplayOrder = column_settings->DisplayOrder; |
| 3388 | else |
| 3389 | column->DisplayOrder = (ImGuiTableColumnIdx)column_n; |
| 3390 | display_order_mask |= (ImU64)1 << column->DisplayOrder; |
| 3391 | column->IsUserEnabled = column->IsUserEnabledNextFrame = column_settings->IsEnabled; |
| 3392 | column->SortOrder = column_settings->SortOrder; |
| 3393 | column->SortDirection = column_settings->SortDirection; |
| 3394 | } |
| 3395 | |
| 3396 | // Validate and fix invalid display order data |
| 3397 | const ImU64 expected_display_order_mask = (settings->ColumnsCount == 64) ? ~0 : ((ImU64)1 << settings->ColumnsCount) - 1; |
| 3398 | if (display_order_mask != expected_display_order_mask) |
| 3399 | for (int column_n = 0; column_n < table->ColumnsCount; column_n++) |
nothing calls this directly
no test coverage detected