| 3445 | } |
| 3446 | |
| 3447 | static void TableSettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line) |
| 3448 | { |
| 3449 | // "Column 0 UserID=0x42AD2D21 Width=100 Visible=1 Order=0 Sort=0v" |
| 3450 | ImGuiTableSettings* settings = (ImGuiTableSettings*)entry; |
| 3451 | float f = 0.0f; |
| 3452 | int column_n = 0, r = 0, n = 0; |
| 3453 | |
| 3454 | if (sscanf(line, "RefScale=%f", &f) == 1) { settings->RefScale = f; return; } |
| 3455 | |
| 3456 | if (sscanf(line, "Column %d%n", &column_n, &r) == 1) |
| 3457 | { |
| 3458 | if (column_n < 0 || column_n >= settings->ColumnsCount) |
| 3459 | return; |
| 3460 | line = ImStrSkipBlank(line + r); |
| 3461 | char c = 0; |
| 3462 | ImGuiTableColumnSettings* column = settings->GetColumnSettings() + column_n; |
| 3463 | column->Index = (ImGuiTableColumnIdx)column_n; |
| 3464 | if (sscanf(line, "UserID=0x%08X%n", (ImU32*)&n, &r) == 1) { line = ImStrSkipBlank(line + r); column->UserID = (ImGuiID)n; } |
| 3465 | if (sscanf(line, "Width=%d%n", &n, &r) == 1) { line = ImStrSkipBlank(line + r); column->WidthOrWeight = (float)n; column->IsStretch = 0; settings->SaveFlags |= ImGuiTableFlags_Resizable; } |
| 3466 | if (sscanf(line, "Weight=%f%n", &f, &r) == 1) { line = ImStrSkipBlank(line + r); column->WidthOrWeight = f; column->IsStretch = 1; settings->SaveFlags |= ImGuiTableFlags_Resizable; } |
| 3467 | if (sscanf(line, "Visible=%d%n", &n, &r) == 1) { line = ImStrSkipBlank(line + r); column->IsEnabled = (ImU8)n; settings->SaveFlags |= ImGuiTableFlags_Hideable; } |
| 3468 | if (sscanf(line, "Order=%d%n", &n, &r) == 1) { line = ImStrSkipBlank(line + r); column->DisplayOrder = (ImGuiTableColumnIdx)n; settings->SaveFlags |= ImGuiTableFlags_Reorderable; } |
| 3469 | if (sscanf(line, "Sort=%d%c%n", &n, &c, &r) == 2) { line = ImStrSkipBlank(line + r); column->SortOrder = (ImGuiTableColumnIdx)n; column->SortDirection = (c == '^') ? ImGuiSortDirection_Descending : ImGuiSortDirection_Ascending; settings->SaveFlags |= ImGuiTableFlags_Sortable; } |
| 3470 | } |
| 3471 | } |
| 3472 | |
| 3473 | static void TableSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf) |
| 3474 | { |
nothing calls this directly
no test coverage detected