Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit dfd1bc3

Browse files
committedJan 29, 2025
Tables, Menus: Fixed using BeginTable() in menu layer (any menu bar). (ocornut#8355)
1 parent 4230e98 commit dfd1bc3

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed
 

‎docs/CHANGELOG.txt

+3
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ Other changes:
7171
scrollbar when using thick border sizes. (#8267, #7887)
7272
- Windows: Fixed IsItemXXXX() functions not working on append-version of EndChild(). (#8350)
7373
Also made some of the fields accessible after BeginChild() to match Begin() logic.
74+
- Tables, Menus: Fixed using BeginTable() in menu layer (any menu bar). (#8355)
75+
It previously overrode the current layer back to main layer, which caused an issue
76+
with MainMenuBar attempted to release focus when leaving the menu layer.
7477
- ColorEdit, ColorPicker: Fixed alpha preview broken in 1.91.7. (#8336, #8241). [@PathogenDavid]
7578
- Tabs, Style: reworked selected overline rendering to better accommodate
7679
for rounded tabs. Reduced default thickness (style.TabBarOverlineSize),

‎imgui_internal.h

+1
Original file line numberDiff line numberDiff line change
@@ -2877,6 +2877,7 @@ struct IMGUI_API ImGuiTable
28772877
ImGuiTableDrawChannelIdx DummyDrawChannel; // Redirect non-visible columns here.
28782878
ImGuiTableDrawChannelIdx Bg2DrawChannelCurrent; // For Selectable() and other widgets drawing across columns after the freezing line. Index within DrawSplitter.Channels[]
28792879
ImGuiTableDrawChannelIdx Bg2DrawChannelUnfrozen;
2880+
ImS8 NavLayer; // ImGuiNavLayer at the time of BeginTable().
28802881
bool IsLayoutLocked; // Set by TableUpdateLayout() which is called when beginning the first row.
28812882
bool IsInsideRow; // Set when inside TableBeginRow()/TableEndRow().
28822883
bool IsInitializing;

‎imgui_tables.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
374374
table->ColumnsCount = columns_count;
375375
table->IsLayoutLocked = false;
376376
table->InnerWidth = inner_width;
377+
table->NavLayer = (ImS8)outer_window->DC.NavLayerCurrent;
377378
temp_data->UserOuterSize = outer_size;
378379

379380
// Instance data (for instance 0, TableID == TableInstanceID)
@@ -1050,7 +1051,8 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
10501051
const int column_n = table->DisplayOrderToIndex[order_n];
10511052
ImGuiTableColumn* column = &table->Columns[column_n];
10521053

1053-
column->NavLayerCurrent = (ImS8)(table->FreezeRowsCount > 0 ? ImGuiNavLayer_Menu : ImGuiNavLayer_Main); // Use Count NOT request so Header line changes layer when frozen
1054+
// Initial nav layer: using FreezeRowsCount, NOT FreezeRowsRequest, so Header line changes layer when frozen
1055+
column->NavLayerCurrent = (ImS8)(table->FreezeRowsCount > 0 ? ImGuiNavLayer_Menu : table->NavLayer);
10541056

10551057
if (offset_x_frozen && table->FreezeColumnsCount == visible_n)
10561058
{
@@ -1493,7 +1495,7 @@ void ImGui::EndTable()
14931495
if (inner_window != outer_window)
14941496
{
14951497
short backup_nav_layers_active_mask = inner_window->DC.NavLayersActiveMask;
1496-
inner_window->DC.NavLayersActiveMask |= 1 << ImGuiNavLayer_Main; // So empty table don't appear to navigate differently.
1498+
inner_window->DC.NavLayersActiveMask |= 1 << table->NavLayer; // So empty table don't appear to navigate differently.
14971499
g.CurrentTable = NULL; // To avoid error recovery recursing
14981500
EndChild();
14991501
g.CurrentTable = table;
@@ -2032,7 +2034,7 @@ void ImGui::TableEndRow(ImGuiTable* table)
20322034
if (unfreeze_rows_request)
20332035
{
20342036
for (int column_n = 0; column_n < table->ColumnsCount; column_n++)
2035-
table->Columns[column_n].NavLayerCurrent = ImGuiNavLayer_Main;
2037+
table->Columns[column_n].NavLayerCurrent = table->NavLayer;
20362038
const float y0 = ImMax(table->RowPosY2 + 1, table->InnerClipRect.Min.y);
20372039
table_instance->LastFrozenHeight = y0 - table->OuterRect.Min.y;
20382040

0 commit comments

Comments
 (0)
Please sign in to comment.