Output context menu into current window (generally a popup) FIXME-TABLE: Ideally this should be writable by the user. Full programmatic access to that data? Sections to display are pulled from 'flags_for_section_to_display', which is typically == table->Flags. - ImGuiTableFlags_Resizable -> display Sizing menu items - ImGuiTableFlags_Reorderable -> display "Reset Order" /- ImGuiTableFlags_Sortab
| 3515 | // - ImGuiTableFlags_Hideable -> display columns visibility menu items |
| 3516 | // It means if you have a custom context menus you can call this section and omit some sections, and add your own. |
| 3517 | void ImGui::TableDrawDefaultContextMenu(ImGuiTable* table, ImGuiTableFlags flags_for_section_to_display) |
| 3518 | { |
| 3519 | ImGuiContext& g = *GImGui; |
| 3520 | ImGuiWindow* window = g.CurrentWindow; |
| 3521 | if (window->SkipItems) |
| 3522 | return; |
| 3523 | |
| 3524 | bool want_separator = false; |
| 3525 | const int column_n = (table->ContextPopupColumn >= 0 && table->ContextPopupColumn < table->ColumnsCount) ? table->ContextPopupColumn : -1; |
| 3526 | ImGuiTableColumn* column = (column_n != -1) ? &table->Columns[column_n] : NULL; |
| 3527 | |
| 3528 | // Sizing |
| 3529 | if (flags_for_section_to_display & ImGuiTableFlags_Resizable) |
| 3530 | { |
| 3531 | if (column != NULL) |
| 3532 | { |
| 3533 | const bool can_resize = !(column->Flags & ImGuiTableColumnFlags_NoResize) && column->IsEnabled; |
| 3534 | if (MenuItem(LocalizeGetMsg(ImGuiLocKey_TableSizeOne), NULL, false, can_resize)) // "###SizeOne" |
| 3535 | TableSetColumnWidthAutoSingle(table, column_n); |
| 3536 | } |
| 3537 | |
| 3538 | const char* size_all_desc; |
| 3539 | if (table->ColumnsEnabledFixedCount == table->ColumnsEnabledCount && (table->Flags & ImGuiTableFlags_SizingMask_) != ImGuiTableFlags_SizingFixedSame) |
| 3540 | size_all_desc = LocalizeGetMsg(ImGuiLocKey_TableSizeAllFit); // "###SizeAll" All fixed |
| 3541 | else |
| 3542 | size_all_desc = LocalizeGetMsg(ImGuiLocKey_TableSizeAllDefault); // "###SizeAll" All stretch or mixed |
| 3543 | if (MenuItem(size_all_desc, NULL)) |
| 3544 | TableSetColumnWidthAutoAll(table); |
| 3545 | want_separator = true; |
| 3546 | } |
| 3547 | |
| 3548 | // Ordering |
| 3549 | if (flags_for_section_to_display & ImGuiTableFlags_Reorderable) |
| 3550 | { |
| 3551 | if (MenuItem(LocalizeGetMsg(ImGuiLocKey_TableResetOrder), NULL, false, !table->IsDefaultDisplayOrder)) |
| 3552 | table->IsResetDisplayOrderRequest = true; |
| 3553 | want_separator = true; |
| 3554 | } |
| 3555 | |
| 3556 | // Reset all (should work but seems unnecessary/noisy to expose?) |
| 3557 | //if (MenuItem("Reset all")) |
| 3558 | // table->IsResetAllRequest = true; |
| 3559 | |
| 3560 | // Sorting |
| 3561 | // (modify TableOpenContextMenu() to add _Sortable flag if enabling this) |
| 3562 | #if 0 |
| 3563 | if ((flags_for_section_to_display & ImGuiTableFlags_Sortable) && column != NULL && (column->Flags & ImGuiTableColumnFlags_NoSort) == 0) |
| 3564 | { |
| 3565 | if (want_separator) |
| 3566 | Separator(); |
| 3567 | want_separator = true; |
| 3568 | |
| 3569 | bool append_to_sort_specs = g.IO.KeyShift; |
| 3570 | if (MenuItem("Sort in Ascending Order", NULL, column->SortOrder != -1 && column->SortDirection == ImGuiSortDirection_Ascending, (column->Flags & ImGuiTableColumnFlags_NoSortAscending) == 0)) |
| 3571 | TableSetColumnSortDirection(table, column_n, ImGuiSortDirection_Ascending, append_to_sort_specs); |
| 3572 | if (MenuItem("Sort in Descending Order", NULL, column->SortOrder != -1 && column->SortDirection == ImGuiSortDirection_Descending, (column->Flags & ImGuiTableColumnFlags_NoSortDescending) == 0)) |
| 3573 | TableSetColumnSortDirection(table, column_n, ImGuiSortDirection_Descending, append_to_sort_specs); |
| 3574 | } |
nothing calls this directly
no test coverage detected