Skip to content

Commit 0825952

Browse files
committed
Merge branch 'master' into docking
# Conflicts: # imgui.cpp # imgui_internal.h
2 parents 75d9965 + dabc990 commit 0825952

6 files changed

+35
-23
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.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -14353,7 +14353,7 @@ static void ImGui::NavUpdateWindowing()
1435314353

1435414354
// Start CTRL+Tab or Square+L/R window selection
1435514355
// (g.ConfigNavWindowingKeyNext/g.ConfigNavWindowingKeyPrev defaults are ImGuiMod_Ctrl|ImGuiKey_Tab and ImGuiMod_Ctrl|ImGuiMod_Shift|ImGuiKey_Tab)
14356-
const ImGuiID owner_id = ImHashStr("###NavUpdateWindowing");
14356+
const ImGuiID owner_id = ImHashStr("##NavUpdateWindowing");
1435714357
const bool nav_gamepad_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 && (io.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0;
1435814358
const bool nav_keyboard_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) != 0;
1435914359
const bool keyboard_next_window = allow_windowing && g.ConfigNavWindowingKeyNext && Shortcut(g.ConfigNavWindowingKeyNext, ImGuiInputFlags_Repeat | ImGuiInputFlags_RouteAlways, owner_id);
@@ -14563,12 +14563,12 @@ void ImGui::NavUpdateWindowingOverlay()
1456314563
return;
1456414564

1456514565
if (g.NavWindowingListWindow == NULL)
14566-
g.NavWindowingListWindow = FindWindowByName("###NavWindowingList");
14566+
g.NavWindowingListWindow = FindWindowByName("##NavWindowingOverlay");
1456714567
const ImGuiViewport* viewport = /*g.NavWindow ? g.NavWindow->Viewport :*/ GetMainViewport();
1456814568
SetNextWindowSizeConstraints(ImVec2(viewport->Size.x * 0.20f, viewport->Size.y * 0.20f), ImVec2(FLT_MAX, FLT_MAX));
1456914569
SetNextWindowPos(viewport->GetCenter(), ImGuiCond_Always, ImVec2(0.5f, 0.5f));
1457014570
PushStyleVar(ImGuiStyleVar_WindowPadding, g.Style.WindowPadding * 2.0f);
14571-
Begin("###NavWindowingList", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings);
14571+
Begin("##NavWindowingOverlay", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings);
1457214572
if (g.ContextName[0] != 0)
1457314573
SeparatorText(g.ContextName);
1457414574
for (int n = g.WindowsFocusOrder.Size - 1; n >= 0; n--)

imgui.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
// Library Version
3030
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
3131
#define IMGUI_VERSION "1.91.8 WIP"
32-
#define IMGUI_VERSION_NUM 19173
32+
#define IMGUI_VERSION_NUM 19174
3333
#define IMGUI_HAS_TABLE
3434
#define IMGUI_HAS_VIEWPORT // Viewport WIP branch
3535
#define IMGUI_HAS_DOCK // Docking WIP branch

imgui_internal.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ extern IMGUI_API ImGuiContext* GImGui; // Current implicit context pointer
238238
#endif
239239

240240
// Debug Logging for ShowDebugLogWindow(). This is designed for relatively rare events so please don't spam.
241-
#define IMGUI_DEBUG_LOG_ERROR(...) do { ImGuiContext& g2 = *GImGui; if (g2.DebugLogFlags & ImGuiDebugLogFlags_EventError) IMGUI_DEBUG_LOG(__VA_ARGS__); else g2.DebugLogSkippedErrors++; } while (0)
241+
#define IMGUI_DEBUG_LOG_ERROR(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventError) IMGUI_DEBUG_LOG(__VA_ARGS__); else g.DebugLogSkippedErrors++; } while (0)
242242
#define IMGUI_DEBUG_LOG_ACTIVEID(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventActiveId) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
243243
#define IMGUI_DEBUG_LOG_FOCUS(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventFocus) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
244244
#define IMGUI_DEBUG_LOG_POPUP(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventPopup) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
@@ -3115,6 +3115,7 @@ struct IMGUI_API ImGuiTable
31153115
ImGuiTableDrawChannelIdx DummyDrawChannel; // Redirect non-visible columns here.
31163116
ImGuiTableDrawChannelIdx Bg2DrawChannelCurrent; // For Selectable() and other widgets drawing across columns after the freezing line. Index within DrawSplitter.Channels[]
31173117
ImGuiTableDrawChannelIdx Bg2DrawChannelUnfrozen;
3118+
ImS8 NavLayer; // ImGuiNavLayer at the time of BeginTable().
31183119
bool IsLayoutLocked; // Set by TableUpdateLayout() which is called when beginning the first row.
31193120
bool IsInsideRow; // Set when inside TableBeginRow()/TableEndRow().
31203121
bool IsInitializing;
@@ -3257,6 +3258,7 @@ namespace ImGui
32573258
// Fonts, drawing
32583259
IMGUI_API void SetCurrentFont(ImFont* font);
32593260
inline ImFont* GetDefaultFont() { ImGuiContext& g = *GImGui; return g.IO.FontDefault ? g.IO.FontDefault : g.IO.Fonts->Fonts[0]; }
3261+
IMGUI_API void PushPasswordFont();
32603262
inline ImDrawList* GetForegroundDrawList(ImGuiWindow* window) { return GetForegroundDrawList(window->Viewport); }
32613263
IMGUI_API void AddDrawListToDrawDataEx(ImDrawData* draw_data, ImVector<ImDrawList*>* out_list, ImDrawList* draw_list);
32623264

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

imgui_widgets.cpp

+20-15
Original file line numberDiff line numberDiff line change
@@ -4252,6 +4252,23 @@ void ImGuiInputTextCallbackData::InsertChars(int pos, const char* new_text, cons
42524252
BufTextLen += new_text_len;
42534253
}
42544254

4255+
void ImGui::PushPasswordFont()
4256+
{
4257+
ImGuiContext& g = *GImGui;
4258+
ImFont* in_font = g.Font;
4259+
ImFont* out_font = &g.InputTextPasswordFont;
4260+
const ImFontGlyph* glyph = in_font->FindGlyph('*');
4261+
out_font->FontSize = in_font->FontSize;
4262+
out_font->Scale = in_font->Scale;
4263+
out_font->Ascent = in_font->Ascent;
4264+
out_font->Descent = in_font->Descent;
4265+
out_font->ContainerAtlas = in_font->ContainerAtlas;
4266+
out_font->FallbackGlyph = glyph;
4267+
out_font->FallbackAdvanceX = glyph->AdvanceX;
4268+
IM_ASSERT(out_font->Glyphs.Size == 0 && out_font->IndexAdvanceX.Size == 0 && out_font->IndexLookup.Size == 0);
4269+
PushFont(out_font);
4270+
}
4271+
42554272
// Return false to discard a character.
42564273
static bool InputTextFilterCharacter(ImGuiContext* ctx, unsigned int* p_char, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data, bool input_source_is_clipboard)
42574274
{
@@ -4662,19 +4679,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
46624679

46634680
// Password pushes a temporary font with only a fallback glyph
46644681
if (is_password && !is_displaying_hint)
4665-
{
4666-
const ImFontGlyph* glyph = g.Font->FindGlyph('*');
4667-
ImFont* password_font = &g.InputTextPasswordFont;
4668-
password_font->FontSize = g.Font->FontSize;
4669-
password_font->Scale = g.Font->Scale;
4670-
password_font->Ascent = g.Font->Ascent;
4671-
password_font->Descent = g.Font->Descent;
4672-
password_font->ContainerAtlas = g.Font->ContainerAtlas;
4673-
password_font->FallbackGlyph = glyph;
4674-
password_font->FallbackAdvanceX = glyph->AdvanceX;
4675-
IM_ASSERT(password_font->Glyphs.empty() && password_font->IndexAdvanceX.empty() && password_font->IndexLookup.empty());
4676-
PushFont(password_font);
4677-
}
4682+
PushPasswordFont();
46784683

46794684
// Process mouse inputs and character inputs
46804685
if (g.ActiveId == id)
@@ -8632,7 +8637,7 @@ bool ImGui::BeginMenuBar()
86328637

86338638
IM_ASSERT(!window->DC.MenuBarAppending);
86348639
BeginGroup(); // Backup position on layer 0 // FIXME: Misleading to use a group for that backup/restore
8635-
PushID("##menubar");
8640+
PushID("##MenuBar");
86368641

86378642
// We don't clip with current window clipping rectangle as it is already set to the area below. However we clip with window full rect.
86388643
// We remove 1 worth of rounding to Max.x to that text in long menus and small windows don't tend to display over the lower-right rounded area, which looks particularly glitchy.
@@ -8776,7 +8781,7 @@ void ImGui::EndMainMenuBar()
87768781
// When the user has left the menu layer (typically: closed menus through activation of an item), we restore focus to the previous window
87778782
// FIXME: With this strategy we won't be able to restore a NULL focus.
87788783
ImGuiContext& g = *GImGui;
8779-
if (g.CurrentWindow == g.NavWindow && g.NavLayer == ImGuiNavLayer_Main && !g.NavAnyRequest)
8784+
if (g.CurrentWindow == g.NavWindow && g.NavLayer == ImGuiNavLayer_Main && !g.NavAnyRequest && g.ActiveId == 0)
87808785
FocusTopMostWindowUnderOne(g.NavWindow, NULL, NULL, ImGuiFocusRequestFlags_UnlessBelowModal | ImGuiFocusRequestFlags_RestoreFocusedChild);
87818786

87828787
End();

0 commit comments

Comments
 (0)