|
@@ -48,7 +48,8 @@ Index of this file:
|
|
|
// - TableUpdateLayout() [Internal] followup to BeginTable(): setup everything: widths, columns positions, clipping rectangles. Automatically called by the FIRST call to TableNextRow() or TableHeadersRow().
|
|
|
// | TableSetupDrawChannels() - setup ImDrawList channels
|
|
|
// | TableUpdateBorders() - detect hovering columns for resize, ahead of contents submission
|
|
|
-// | TableDrawContextMenu() - draw right-click context menu
|
|
|
+// | TableBeginContextMenuPopup()
|
|
|
+// | - TableDrawContextMenu() - draw right-click context menu contents
|
|
|
//-----------------------------------------------------------------------------
|
|
|
// - TableHeadersRow() or TableHeader() user submit a headers row (optional)
|
|
|
// | TableSortSpecsClickColumn() - when left-clicked: alter sort order and sort direction
|
|
@@ -1190,10 +1191,14 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
|
|
if (g.ActiveId == 0 || (table->IsActiveIdInTable || g.DragDropActive))
|
|
|
table->HighlightColumnHeader = table->HoveredColumnBody;
|
|
|
|
|
|
- // [Part 11] Context menu
|
|
|
- if (TableBeginContextMenuPopup(table))
|
|
|
+ // [Part 11] Default context menu
|
|
|
+ // - To append to this menu: you can call TableBeginContextMenuPopup()/.../EndPopup().
|
|
|
+ // - To modify or replace this: set table->IsContextPopupNoDefaultContents = true, then call TableBeginContextMenuPopup()/.../EndPopup().
|
|
|
+ // - You may call TableDrawContextMenu() with selected flags to display specific sections of the default menu,
|
|
|
+ // e.g. TableDrawContextMenu(table, table->Flags & ~ImGuiTableFlags_Hideable) will display everything EXCEPT columns visibility options.
|
|
|
+ if (table->DisableDefaultContextMenu == false && TableBeginContextMenuPopup(table))
|
|
|
{
|
|
|
- TableDrawContextMenu(table);
|
|
|
+ TableDrawContextMenu(table, table->Flags);
|
|
|
EndPopup();
|
|
|
}
|
|
|
|
|
@@ -3293,7 +3298,13 @@ bool ImGui::TableBeginContextMenuPopup(ImGuiTable* table)
|
|
|
|
|
|
// 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?
|
|
|
-void ImGui::TableDrawContextMenu(ImGuiTable* table)
|
|
|
+// 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_Sortable -> display sorting options (disabled)
|
|
|
+// - ImGuiTableFlags_Hideable -> display columns visibility menu items
|
|
|
+// It means if you have a custom context menus you can call this section and omit some sections, and add your own.
|
|
|
+void ImGui::TableDrawContextMenu(ImGuiTable* table, ImGuiTableFlags flags_for_section_to_display)
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
ImGuiWindow* window = g.CurrentWindow;
|
|
@@ -3305,7 +3316,7 @@ void ImGui::TableDrawContextMenu(ImGuiTable* table)
|
|
|
ImGuiTableColumn* column = (column_n != -1) ? &table->Columns[column_n] : NULL;
|
|
|
|
|
|
// Sizing
|
|
|
- if (table->Flags & ImGuiTableFlags_Resizable)
|
|
|
+ if (flags_for_section_to_display & ImGuiTableFlags_Resizable)
|
|
|
{
|
|
|
if (column != NULL)
|
|
|
{
|
|
@@ -3325,7 +3336,7 @@ void ImGui::TableDrawContextMenu(ImGuiTable* table)
|
|
|
}
|
|
|
|
|
|
// Ordering
|
|
|
- if (table->Flags & ImGuiTableFlags_Reorderable)
|
|
|
+ if (flags_for_section_to_display & ImGuiTableFlags_Reorderable)
|
|
|
{
|
|
|
if (MenuItem(LocalizeGetMsg(ImGuiLocKey_TableResetOrder), NULL, false, !table->IsDefaultDisplayOrder))
|
|
|
table->IsResetDisplayOrderRequest = true;
|
|
@@ -3339,7 +3350,7 @@ void ImGui::TableDrawContextMenu(ImGuiTable* table)
|
|
|
// Sorting
|
|
|
// (modify TableOpenContextMenu() to add _Sortable flag if enabling this)
|
|
|
#if 0
|
|
|
- if ((table->Flags & ImGuiTableFlags_Sortable) && column != NULL && (column->Flags & ImGuiTableColumnFlags_NoSort) == 0)
|
|
|
+ if ((flags_for_section_to_display & ImGuiTableFlags_Sortable) && column != NULL && (column->Flags & ImGuiTableColumnFlags_NoSort) == 0)
|
|
|
{
|
|
|
if (want_separator)
|
|
|
Separator();
|
|
@@ -3354,7 +3365,7 @@ void ImGui::TableDrawContextMenu(ImGuiTable* table)
|
|
|
#endif
|
|
|
|
|
|
// Hiding / Visibility
|
|
|
- if (table->Flags & ImGuiTableFlags_Hideable)
|
|
|
+ if (flags_for_section_to_display & ImGuiTableFlags_Hideable)
|
|
|
{
|
|
|
if (want_separator)
|
|
|
Separator();
|