MCPcopy Create free account
hub / github.com/RenderKit/embree / TableDrawContextMenu

Method TableDrawContextMenu

tutorials/common/imgui/imgui_tables.cpp:3057–3144  ·  view source on GitHub ↗

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?

Source from the content-addressed store, hash-verified

3055// Output context menu into current window (generally a popup)
3056// FIXME-TABLE: Ideally this should be writable by the user. Full programmatic access to that data?
3057void ImGui::TableDrawContextMenu(ImGuiTable* table)
3058{
3059 ImGuiContext& g = *GImGui;
3060 ImGuiWindow* window = g.CurrentWindow;
3061 if (window->SkipItems)
3062 return;
3063
3064 bool want_separator = false;
3065 const int column_n = (table->ContextPopupColumn >= 0 && table->ContextPopupColumn < table->ColumnsCount) ? table->ContextPopupColumn : -1;
3066 ImGuiTableColumn* column = (column_n != -1) ? &table->Columns[column_n] : NULL;
3067
3068 // Sizing
3069 if (table->Flags & ImGuiTableFlags_Resizable)
3070 {
3071 if (column != NULL)
3072 {
3073 const bool can_resize = !(column->Flags & ImGuiTableColumnFlags_NoResize) && column->IsEnabled;
3074 if (MenuItem(LocalizeGetMsg(ImGuiLocKey_TableSizeOne), NULL, false, can_resize)) // "###SizeOne"
3075 TableSetColumnWidthAutoSingle(table, column_n);
3076 }
3077
3078 const char* size_all_desc;
3079 if (table->ColumnsEnabledFixedCount == table->ColumnsEnabledCount && (table->Flags & ImGuiTableFlags_SizingMask_) != ImGuiTableFlags_SizingFixedSame)
3080 size_all_desc = LocalizeGetMsg(ImGuiLocKey_TableSizeAllFit); // "###SizeAll" All fixed
3081 else
3082 size_all_desc = LocalizeGetMsg(ImGuiLocKey_TableSizeAllDefault); // "###SizeAll" All stretch or mixed
3083 if (MenuItem(size_all_desc, NULL))
3084 TableSetColumnWidthAutoAll(table);
3085 want_separator = true;
3086 }
3087
3088 // Ordering
3089 if (table->Flags & ImGuiTableFlags_Reorderable)
3090 {
3091 if (MenuItem(LocalizeGetMsg(ImGuiLocKey_TableResetOrder), NULL, false, !table->IsDefaultDisplayOrder))
3092 table->IsResetDisplayOrderRequest = true;
3093 want_separator = true;
3094 }
3095
3096 // Reset all (should work but seems unnecessary/noisy to expose?)
3097 //if (MenuItem("Reset all"))
3098 // table->IsResetAllRequest = true;
3099
3100 // Sorting
3101 // (modify TableOpenContextMenu() to add _Sortable flag if enabling this)
3102#if 0
3103 if ((table->Flags & ImGuiTableFlags_Sortable) && column != NULL && (column->Flags & ImGuiTableColumnFlags_NoSort) == 0)
3104 {
3105 if (want_separator)
3106 Separator();
3107 want_separator = true;
3108
3109 bool append_to_sort_specs = g.IO.KeyShift;
3110 if (MenuItem("Sort in Ascending Order", NULL, column->SortOrder != -1 && column->SortDirection == ImGuiSortDirection_Ascending, (column->Flags & ImGuiTableColumnFlags_NoSortAscending) == 0))
3111 TableSetColumnSortDirection(table, column_n, ImGuiSortDirection_Ascending, append_to_sort_specs);
3112 if (MenuItem("Sort in Descending Order", NULL, column->SortOrder != -1 && column->SortDirection == ImGuiSortDirection_Descending, (column->Flags & ImGuiTableColumnFlags_NoSortDescending) == 0))
3113 TableSetColumnSortDirection(table, column_n, ImGuiSortDirection_Descending, append_to_sort_specs);
3114 }

Callers

nothing calls this directly

Calls 1

LocalizeGetMsgFunction · 0.85

Tested by

no test coverage detected