MCPcopy Create free account
hub / github.com/KebsCS/KBotExt / TableDrawContextMenu

Method TableDrawContextMenu

KBotExt/imgui/imgui_tables.cpp:3111–3198  ·  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

3109// Output context menu into current window (generally a popup)
3110// FIXME-TABLE: Ideally this should be writable by the user. Full programmatic access to that data?
3111void ImGui::TableDrawContextMenu(ImGuiTable* table)
3112{
3113 ImGuiContext& g = *GImGui;
3114 ImGuiWindow* window = g.CurrentWindow;
3115 if (window->SkipItems)
3116 return;
3117
3118 bool want_separator = false;
3119 const int column_n = (table->ContextPopupColumn >= 0 && table->ContextPopupColumn < table->ColumnsCount) ? table->ContextPopupColumn : -1;
3120 ImGuiTableColumn* column = (column_n != -1) ? &table->Columns[column_n] : NULL;
3121
3122 // Sizing
3123 if (table->Flags & ImGuiTableFlags_Resizable)
3124 {
3125 if (column != NULL)
3126 {
3127 const bool can_resize = !(column->Flags & ImGuiTableColumnFlags_NoResize) && column->IsEnabled;
3128 if (MenuItem(LocalizeGetMsg(ImGuiLocKey_TableSizeOne), NULL, false, can_resize)) // "###SizeOne"
3129 TableSetColumnWidthAutoSingle(table, column_n);
3130 }
3131
3132 const char* size_all_desc;
3133 if (table->ColumnsEnabledFixedCount == table->ColumnsEnabledCount && (table->Flags & ImGuiTableFlags_SizingMask_) != ImGuiTableFlags_SizingFixedSame)
3134 size_all_desc = LocalizeGetMsg(ImGuiLocKey_TableSizeAllFit); // "###SizeAll" All fixed
3135 else
3136 size_all_desc = LocalizeGetMsg(ImGuiLocKey_TableSizeAllDefault); // "###SizeAll" All stretch or mixed
3137 if (MenuItem(size_all_desc, NULL))
3138 TableSetColumnWidthAutoAll(table);
3139 want_separator = true;
3140 }
3141
3142 // Ordering
3143 if (table->Flags & ImGuiTableFlags_Reorderable)
3144 {
3145 if (MenuItem(LocalizeGetMsg(ImGuiLocKey_TableResetOrder), NULL, false, !table->IsDefaultDisplayOrder))
3146 table->IsResetDisplayOrderRequest = true;
3147 want_separator = true;
3148 }
3149
3150 // Reset all (should work but seems unnecessary/noisy to expose?)
3151 //if (MenuItem("Reset all"))
3152 // table->IsResetAllRequest = true;
3153
3154 // Sorting
3155 // (modify TableOpenContextMenu() to add _Sortable flag if enabling this)
3156#if 0
3157 if ((table->Flags & ImGuiTableFlags_Sortable) && column != NULL && (column->Flags & ImGuiTableColumnFlags_NoSort) == 0)
3158 {
3159 if (want_separator)
3160 Separator();
3161 want_separator = true;
3162
3163 bool append_to_sort_specs = g.IO.KeyShift;
3164 if (MenuItem("Sort in Ascending Order", NULL, column->SortOrder != -1 && column->SortDirection == ImGuiSortDirection_Ascending, (column->Flags & ImGuiTableColumnFlags_NoSortAscending) == 0))
3165 TableSetColumnSortDirection(table, column_n, ImGuiSortDirection_Ascending, append_to_sort_specs);
3166 if (MenuItem("Sort in Descending Order", NULL, column->SortOrder != -1 && column->SortDirection == ImGuiSortDirection_Descending, (column->Flags & ImGuiTableColumnFlags_NoSortDescending) == 0))
3167 TableSetColumnSortDirection(table, column_n, ImGuiSortDirection_Descending, append_to_sort_specs);
3168 }

Callers

nothing calls this directly

Calls 1

LocalizeGetMsgFunction · 0.85

Tested by

no test coverage detected