Merge ce147543742b27f3d2cecf676f461f42371456cc into a1af3c1a59fe81f7a1cac10dcead0a383b99f245

This commit is contained in:
Siddhant 2026-11-05 11:45:28 +01:00 committed by GitHub
commit 58abdbfa44
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 25 additions and 9 deletions

View File

@ -66,6 +66,8 @@ Autumn cleanup of stuff marked obsolete more than two years ago:
Other Changes:
- Tables: added a context-menu option to reset column sizing to the values passed to `TableSetupColumn()`.
Renamed "Size all columns to default" to "Size all columns to fit" to clarify that it performs content fitting.
- Style:
- `StyleColorsDark()`: tweaked WindowBg to be darker than in 1.93.0.
- Added `style.SymbolArrowSizeFactor`, `style.SymbolArrowThicknessFactor` to tweak the

View File

@ -4305,9 +4305,10 @@ static const ImGuiLocEntry GLocalizationEntriesEnUS[] =
{ ImGuiLocKey_VersionStr, "Dear ImGui " IMGUI_VERSION " (" IM_STRINGIFY(IMGUI_VERSION_NUM) ")" },
{ ImGuiLocKey_TableSizeOne, "Size column to fit###SizeOne" },
{ ImGuiLocKey_TableSizeAllFit, "Size all columns to fit###SizeAll" },
{ ImGuiLocKey_TableSizeAllDefault, "Size all columns to default###SizeAll" },
{ ImGuiLocKey_TableSizeAllDefault, "Size all columns to fit###SizeAll" },
{ ImGuiLocKey_TableReset, "Reset" },
//{ ImGuiLocKey_TableResetAll, "Reset to default###ResetAll" },
{ ImGuiLocKey_TableResetSizing, "Reset column sizing###ResetSizing" },
{ ImGuiLocKey_TableResetOrder, "Reset order###ResetOrder" },
{ ImGuiLocKey_TableResetVisibility, "Reset visibility###ResetVisibility" },
{ ImGuiLocKey_WindowingMainMenuBar, "(Main menu bar)" },

View File

@ -7383,13 +7383,14 @@ static void DemoWindowTables()
// [2.3] Right-click in columns to open another custom popup
HelpMarker(
"Demonstrate mixing table context menu (over header), item context button (over button) "
"and custom per-column context menu (over column body).");
"and custom per-column context menu (over column body). The table context menu can reset "
"column sizing to the values passed to TableSetupColumn().");
ImGuiTableFlags flags2 = ImGuiTableFlags_Resizable | ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Borders;
if (ImGui::BeginTable("table_context_menu_2", COLUMNS_COUNT, flags2))
{
ImGui::TableSetupColumn("One");
ImGui::TableSetupColumn("Two");
ImGui::TableSetupColumn("Three");
ImGui::TableSetupColumn("One", ImGuiTableColumnFlags_WidthFixed, 100.0f);
ImGui::TableSetupColumn("Two", ImGuiTableColumnFlags_WidthFixed, 140.0f);
ImGui::TableSetupColumn("Three", ImGuiTableColumnFlags_WidthStretch, 1.0f);
// [2.1] Right-click on the TableHeadersRow() line to open the default table context menu.
ImGui::TableHeadersRow();

View File

@ -2156,6 +2156,7 @@ enum ImGuiLocKey : int
ImGuiLocKey_TableSizeAllDefault,
ImGuiLocKey_TableReset,
//ImGuiLocKey_TableResetAll,
ImGuiLocKey_TableResetSizing,
ImGuiLocKey_TableResetOrder,
ImGuiLocKey_TableResetVisibility,
ImGuiLocKey_WindowingMainMenuBar,
@ -3236,6 +3237,7 @@ struct IMGUI_API ImGuiTable
bool IsDefaultDisplayOrder; // Set when display order is unchanged from default (DisplayOrder contains 0...Count-1)
bool IsDefaultVisibility; // Set when enabled/visibility is unchanged from default
bool IsResetAllRequest; // Set to queue a call to TableResetSettings() in BeginTable()
bool IsResetSizingRequest; // Set to restore sizing from TableSetupColumn() values
bool IsResetDisplayOrderRequest;
bool IsResetVisibilityRequest;
bool IsUnfrozenRows; // Set when we got past the frozen row.

View File

@ -720,6 +720,13 @@ void ImGui::TableApplyQueuedRequests(ImGuiTable* table)
table->IsResetVisibilityRequest = false;
table->IsSettingsDirty = true;
}
if (table->IsResetSizingRequest)
{
for (ImGuiTableColumn& column : table->Columns)
TableInitColumnDefaults(table, &column, ImGuiTableFlags_Resizable);
table->IsResetSizingRequest = false;
table->IsSettingsDirty = true;
}
}
// Apply immediately. See TableQueueSetColumnDisplayOrder() for additional checks/constraints.
@ -3722,8 +3729,8 @@ static bool MenuItemForColumnReorder(const char* label, bool selected, bool enab
// 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_Resizable -> display Sizing menu items and "Reset column sizing"
// - 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.
@ -3758,12 +3765,15 @@ void ImGui::TableDrawDefaultContextMenu(ImGuiTable* table, ImGuiTableFlags flags
want_separator = true;
}
// Reset Order/Visibility etc.
if (flags_for_section_to_display & (ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable))
// Reset sizing/order/visibility etc.
if (flags_for_section_to_display & (ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable))
if (BeginMenu(LocalizeGetMsg(ImGuiLocKey_TableReset)))
{
//if (MenuItem(LocalizeGetMsg(ImGuiLocKey_TableResetAll))) // FIXME: Hiding because altering Sort Order + requesting auto-fit simultaneously has a tendency to exhibit a sizing glitch.
// table->IsResetAllRequest = true;
if (flags_for_section_to_display & ImGuiTableFlags_Resizable)
if (MenuItem(LocalizeGetMsg(ImGuiLocKey_TableResetSizing)))
table->IsResetSizingRequest = true;
if (flags_for_section_to_display & ImGuiTableFlags_Reorderable)
if (MenuItem(LocalizeGetMsg(ImGuiLocKey_TableResetOrder), NULL, false, !table->IsDefaultDisplayOrder)) // PS: cannot be hidden because it would mess with drag reordering.
table->IsResetDisplayOrderRequest = true;