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
| 3567 | // - ImGuiTableFlags_Hideable -> display columns visibility menu items |
| 3568 | // It means if you have a custom context menus you can call this section and omit some sections, and add your own. |
| 3569 | void ImGui::TableDrawDefaultContextMenu(ImGuiTable* table, ImGuiTableFlags flags_for_section_to_display) |
| 3570 | { |
| 3571 | ImGuiContext& g = *GImGui; |
| 3572 | ImGuiWindow* window = g.CurrentWindow; |
| 3573 | if (window->SkipItems) |
| 3574 | return; |
| 3575 | |
| 3576 | bool want_separator = false; |
| 3577 | const int context_column_n = (table->ContextPopupColumn >= 0 && table->ContextPopupColumn < table->ColumnsCount) ? table->ContextPopupColumn : -1; |
| 3578 | ImGuiTableColumn* context_column = (context_column_n != -1) ? &table->Columns[context_column_n] : NULL; |
| 3579 | |
| 3580 | // Sizing |
| 3581 | if (flags_for_section_to_display & ImGuiTableFlags_Resizable) |
| 3582 | { |
| 3583 | if (context_column != NULL) |
| 3584 | { |
| 3585 | const bool can_resize = !(context_column->Flags & ImGuiTableColumnFlags_NoResize) && context_column->IsEnabled; |
| 3586 | if (MenuItem(LocalizeGetMsg(ImGuiLocKey_TableSizeOne), NULL, false, can_resize)) // "###SizeOne" |
| 3587 | TableSetColumnWidthAutoSingle(table, context_column_n); |
| 3588 | } |
| 3589 | |
| 3590 | const char* size_all_desc; |
| 3591 | if (table->ColumnsEnabledFixedCount == table->ColumnsEnabledCount && (table->Flags & ImGuiTableFlags_SizingMask_) != ImGuiTableFlags_SizingFixedSame) |
| 3592 | size_all_desc = LocalizeGetMsg(ImGuiLocKey_TableSizeAllFit); // "###SizeAll" All fixed |
| 3593 | else |
| 3594 | size_all_desc = LocalizeGetMsg(ImGuiLocKey_TableSizeAllDefault); // "###SizeAll" All stretch or mixed |
| 3595 | if (MenuItem(size_all_desc, NULL)) |
| 3596 | TableSetColumnWidthAutoAll(table); |
| 3597 | want_separator = true; |
| 3598 | } |
| 3599 | |
| 3600 | // Ordering |
| 3601 | if (flags_for_section_to_display & ImGuiTableFlags_Reorderable) |
| 3602 | { |
| 3603 | if (MenuItem(LocalizeGetMsg(ImGuiLocKey_TableResetOrder), NULL, false, !table->IsDefaultDisplayOrder)) |
| 3604 | table->IsResetDisplayOrderRequest = true; |
| 3605 | want_separator = true; |
| 3606 | } |
| 3607 | |
| 3608 | // Reset all (should work but seems unnecessary/noisy to expose?) |
| 3609 | //if (MenuItem("Reset all")) |
| 3610 | // table->IsResetAllRequest = true; |
| 3611 | |
| 3612 | // Sorting |
| 3613 | // (modify TableOpenContextMenu() to add _Sortable flag if enabling this) |
| 3614 | #if 0 |
| 3615 | if ((flags_for_section_to_display & ImGuiTableFlags_Sortable) && column != NULL && (column->Flags & ImGuiTableColumnFlags_NoSort) == 0) |
| 3616 | { |
| 3617 | if (want_separator) |
| 3618 | Separator(); |
| 3619 | want_separator = true; |
| 3620 | |
| 3621 | bool append_to_sort_specs = g.IO.KeyShift; |
| 3622 | if (MenuItem("Sort in Ascending Order", NULL, column->SortOrder != -1 && column->SortDirection == ImGuiSortDirection_Ascending, (column->Flags & ImGuiTableColumnFlags_NoSortAscending) == 0)) |
| 3623 | TableSetColumnSortDirection(table, column_n, ImGuiSortDirection_Ascending, append_to_sort_specs); |
| 3624 | if (MenuItem("Sort in Descending Order", NULL, column->SortOrder != -1 && column->SortDirection == ImGuiSortDirection_Descending, (column->Flags & ImGuiTableColumnFlags_NoSortDescending) == 0)) |
| 3625 | TableSetColumnSortDirection(table, column_n, ImGuiSortDirection_Descending, append_to_sort_specs); |
| 3626 | } |
nothing calls this directly
no test coverage detected