|
@@ -1,4 +1,4 @@
|
|
-// dear imgui, v1.90.1
|
|
|
|
|
|
+// dear imgui, v1.90.2 WIP
|
|
// (main code and documentation)
|
|
// (main code and documentation)
|
|
|
|
|
|
// Help:
|
|
// Help:
|
|
@@ -426,12 +426,13 @@ CODE
|
|
You can read releases logs https://github.com/ocornut/imgui/releases for more details.
|
|
You can read releases logs https://github.com/ocornut/imgui/releases for more details.
|
|
|
|
|
|
(Docking/Viewport Branch)
|
|
(Docking/Viewport Branch)
|
|
- - 2023/XX/XX (1.XXXX) - when multi-viewports are enabled, all positions will be in your natural OS coordinates space. It means that:
|
|
|
|
|
|
+ - 2024/XX/XX (1.XXXX) - when multi-viewports are enabled, all positions will be in your natural OS coordinates space. It means that:
|
|
- reference to hard-coded positions such as in SetNextWindowPos(ImVec2(0,0)) are probably not what you want anymore.
|
|
- reference to hard-coded positions such as in SetNextWindowPos(ImVec2(0,0)) are probably not what you want anymore.
|
|
you may use GetMainViewport()->Pos to offset hard-coded positions, e.g. SetNextWindowPos(GetMainViewport()->Pos)
|
|
you may use GetMainViewport()->Pos to offset hard-coded positions, e.g. SetNextWindowPos(GetMainViewport()->Pos)
|
|
- likewise io.MousePos and GetMousePos() will use OS coordinates.
|
|
- likewise io.MousePos and GetMousePos() will use OS coordinates.
|
|
If you query mouse positions to interact with non-imgui coordinates you will need to offset them, e.g. subtract GetWindowViewport()->Pos.
|
|
If you query mouse positions to interact with non-imgui coordinates you will need to offset them, e.g. subtract GetWindowViewport()->Pos.
|
|
|
|
|
|
|
|
+ - 2024/01/15 (1.90.2) - commented out obsolete ImGuiIO::ImeWindowHandle marked obsolete in 1.87, favor of writing to 'void* ImGuiViewport::PlatformHandleRaw'.
|
|
- 2023/12/19 (1.90.1) - commented out obsolete ImGuiKey_KeyPadEnter redirection to ImGuiKey_KeypadEnter.
|
|
- 2023/12/19 (1.90.1) - commented out obsolete ImGuiKey_KeyPadEnter redirection to ImGuiKey_KeypadEnter.
|
|
- 2023/11/06 (1.90.1) - removed CalcListClipping() marked obsolete in 1.86. Prefer using ImGuiListClipper which can return non-contiguous ranges.
|
|
- 2023/11/06 (1.90.1) - removed CalcListClipping() marked obsolete in 1.86. Prefer using ImGuiListClipper which can return non-contiguous ranges.
|
|
- 2023/11/05 (1.90.1) - imgui_freetype: commented out ImGuiFreeType::BuildFontAtlas() obsoleted in 1.81. prefer using #define IMGUI_ENABLE_FREETYPE or see commented code for manual calls.
|
|
- 2023/11/05 (1.90.1) - imgui_freetype: commented out ImGuiFreeType::BuildFontAtlas() obsoleted in 1.81. prefer using #define IMGUI_ENABLE_FREETYPE or see commented code for manual calls.
|
|
@@ -3133,7 +3134,7 @@ void ImGui::PopStyleColor(int count)
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
if (g.ColorStack.Size < count)
|
|
if (g.ColorStack.Size < count)
|
|
{
|
|
{
|
|
- IM_ASSERT_USER_ERROR(g.ColorStack.Size > count, "Calling PopStyleColor() too many times: stack underflow.");
|
|
|
|
|
|
+ IM_ASSERT_USER_ERROR(g.ColorStack.Size > count, "Calling PopStyleColor() too many times!");
|
|
count = g.ColorStack.Size;
|
|
count = g.ColorStack.Size;
|
|
}
|
|
}
|
|
while (count > 0)
|
|
while (count > 0)
|
|
@@ -3202,7 +3203,7 @@ void ImGui::PushStyleVar(ImGuiStyleVar idx, float val)
|
|
*pvar = val;
|
|
*pvar = val;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- IM_ASSERT_USER_ERROR(0, "Called PushStyleVar() variant with wrong type!");
|
|
|
|
|
|
+ IM_ASSERT_USER_ERROR(0, "Calling PushStyleVar() variant with wrong type!");
|
|
}
|
|
}
|
|
|
|
|
|
void ImGui::PushStyleVar(ImGuiStyleVar idx, const ImVec2& val)
|
|
void ImGui::PushStyleVar(ImGuiStyleVar idx, const ImVec2& val)
|
|
@@ -3216,7 +3217,7 @@ void ImGui::PushStyleVar(ImGuiStyleVar idx, const ImVec2& val)
|
|
*pvar = val;
|
|
*pvar = val;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- IM_ASSERT_USER_ERROR(0, "Called PushStyleVar() variant with wrong type!");
|
|
|
|
|
|
+ IM_ASSERT_USER_ERROR(0, "Calling PushStyleVar() variant with wrong type!");
|
|
}
|
|
}
|
|
|
|
|
|
void ImGui::PopStyleVar(int count)
|
|
void ImGui::PopStyleVar(int count)
|
|
@@ -3224,7 +3225,7 @@ void ImGui::PopStyleVar(int count)
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
if (g.StyleVarStack.Size < count)
|
|
if (g.StyleVarStack.Size < count)
|
|
{
|
|
{
|
|
- IM_ASSERT_USER_ERROR(g.StyleVarStack.Size > count, "Calling PopStyleVar() too many times: stack underflow.");
|
|
|
|
|
|
+ IM_ASSERT_USER_ERROR(g.StyleVarStack.Size > count, "Calling PopStyleVar() too many times!");
|
|
count = g.StyleVarStack.Size;
|
|
count = g.StyleVarStack.Size;
|
|
}
|
|
}
|
|
while (count > 0)
|
|
while (count > 0)
|
|
@@ -5276,18 +5277,7 @@ void ImGui::EndFrame()
|
|
IMGUI_DEBUG_LOG_IO("[io] Calling io.SetPlatformImeDataFn(): WantVisible: %d, InputPos (%.2f,%.2f)\n", ime_data->WantVisible, ime_data->InputPos.x, ime_data->InputPos.y);
|
|
IMGUI_DEBUG_LOG_IO("[io] Calling io.SetPlatformImeDataFn(): WantVisible: %d, InputPos (%.2f,%.2f)\n", ime_data->WantVisible, ime_data->InputPos.x, ime_data->InputPos.y);
|
|
if (viewport == NULL)
|
|
if (viewport == NULL)
|
|
viewport = GetMainViewport();
|
|
viewport = GetMainViewport();
|
|
-#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
|
|
|
- if (viewport->PlatformHandleRaw == NULL && g.IO.ImeWindowHandle != NULL)
|
|
|
|
- {
|
|
|
|
- viewport->PlatformHandleRaw = g.IO.ImeWindowHandle;
|
|
|
|
- g.IO.SetPlatformImeDataFn(viewport, ime_data);
|
|
|
|
- viewport->PlatformHandleRaw = NULL;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
-#endif
|
|
|
|
- {
|
|
|
|
- g.IO.SetPlatformImeDataFn(viewport, ime_data);
|
|
|
|
- }
|
|
|
|
|
|
+ g.IO.SetPlatformImeDataFn(viewport, ime_data);
|
|
}
|
|
}
|
|
|
|
|
|
// Hide implicit/fallback "Debug" window if it hasn't been used
|
|
// Hide implicit/fallback "Debug" window if it hasn't been used
|
|
@@ -6849,14 +6839,15 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
{
|
|
{
|
|
UpdateWindowParentAndRootLinks(window, flags, parent_window);
|
|
UpdateWindowParentAndRootLinks(window, flags, parent_window);
|
|
window->ParentWindowInBeginStack = parent_window_in_stack;
|
|
window->ParentWindowInBeginStack = parent_window_in_stack;
|
|
|
|
+
|
|
|
|
+ // There's little point to expose a flag to set this: because the interesting cases won't be using parent_window_in_stack,
|
|
|
|
+ // e.g. linking a tool window in a standalone viewport to a document window, regardless of their Begin() stack parenting. (#6798)
|
|
|
|
+ window->ParentWindowForFocusRoute = (flags & ImGuiWindowFlags_ChildWindow) ? parent_window_in_stack : NULL;
|
|
}
|
|
}
|
|
|
|
|
|
// Add to focus scope stack
|
|
// Add to focus scope stack
|
|
- // We intentionally set g.CurrentWindow to NULL to prevent usage until when the viewport is set, then will call SetCurrentWindow()
|
|
|
|
- if ((flags & ImGuiWindowFlags_NavFlattened) == 0)
|
|
|
|
- PushFocusScope(window->ID);
|
|
|
|
|
|
+ PushFocusScope((flags & ImGuiWindowFlags_NavFlattened) ? g.CurrentFocusScopeId : window->ID);
|
|
window->NavRootFocusScopeId = g.CurrentFocusScopeId;
|
|
window->NavRootFocusScopeId = g.CurrentFocusScopeId;
|
|
- g.CurrentWindow = NULL;
|
|
|
|
|
|
|
|
// Add to popup stack
|
|
// Add to popup stack
|
|
if (flags & ImGuiWindowFlags_Popup)
|
|
if (flags & ImGuiWindowFlags_Popup)
|
|
@@ -6924,6 +6915,9 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
if (window->Appearing)
|
|
if (window->Appearing)
|
|
SetWindowConditionAllowFlags(window, ImGuiCond_Appearing, false);
|
|
SetWindowConditionAllowFlags(window, ImGuiCond_Appearing, false);
|
|
|
|
|
|
|
|
+ // We intentionally set g.CurrentWindow to NULL to prevent usage until when the viewport is set, then will call SetCurrentWindow()
|
|
|
|
+ g.CurrentWindow = NULL;
|
|
|
|
+
|
|
// When reusing window again multiple times a frame, just append content (don't need to setup again)
|
|
// When reusing window again multiple times a frame, just append content (don't need to setup again)
|
|
if (first_begin_of_the_frame)
|
|
if (first_begin_of_the_frame)
|
|
{
|
|
{
|
|
@@ -7615,8 +7609,7 @@ void ImGui::End()
|
|
EndColumns();
|
|
EndColumns();
|
|
if (!(window->Flags & ImGuiWindowFlags_DockNodeHost)) // Pop inner window clip rectangle
|
|
if (!(window->Flags & ImGuiWindowFlags_DockNodeHost)) // Pop inner window clip rectangle
|
|
PopClipRect();
|
|
PopClipRect();
|
|
- if ((window->Flags & ImGuiWindowFlags_NavFlattened) == 0)
|
|
|
|
- PopFocusScope();
|
|
|
|
|
|
+ PopFocusScope();
|
|
|
|
|
|
// Stop logging
|
|
// Stop logging
|
|
if (!(window->Flags & ImGuiWindowFlags_ChildWindow)) // FIXME: add more options for scope of logging
|
|
if (!(window->Flags & ImGuiWindowFlags_ChildWindow)) // FIXME: add more options for scope of logging
|
|
@@ -7748,7 +7741,7 @@ void ImGui::FocusWindow(ImGuiWindow* window, ImGuiFocusRequestFlags flags)
|
|
g.NavMousePosDirty = true;
|
|
g.NavMousePosDirty = true;
|
|
g.NavId = window ? window->NavLastIds[0] : 0; // Restore NavId
|
|
g.NavId = window ? window->NavLastIds[0] : 0; // Restore NavId
|
|
g.NavLayer = ImGuiNavLayer_Main;
|
|
g.NavLayer = ImGuiNavLayer_Main;
|
|
- g.NavFocusScopeId = window ? window->NavRootFocusScopeId : 0;
|
|
|
|
|
|
+ SetNavFocusScope(window ? window->NavRootFocusScopeId : 0);
|
|
g.NavIdIsAlive = false;
|
|
g.NavIdIsAlive = false;
|
|
g.NavLastValidSelectionUserData = ImGuiSelectionUserData_Invalid;
|
|
g.NavLastValidSelectionUserData = ImGuiSelectionUserData_Invalid;
|
|
|
|
|
|
@@ -8411,16 +8404,50 @@ void ImGui::SetWindowFontScale(float scale)
|
|
void ImGui::PushFocusScope(ImGuiID id)
|
|
void ImGui::PushFocusScope(ImGuiID id)
|
|
{
|
|
{
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
- g.FocusScopeStack.push_back(id);
|
|
|
|
|
|
+ ImGuiFocusScopeData data;
|
|
|
|
+ data.ID = id;
|
|
|
|
+ data.WindowID = g.CurrentWindow->ID;
|
|
|
|
+ g.FocusScopeStack.push_back(data);
|
|
g.CurrentFocusScopeId = id;
|
|
g.CurrentFocusScopeId = id;
|
|
}
|
|
}
|
|
|
|
|
|
void ImGui::PopFocusScope()
|
|
void ImGui::PopFocusScope()
|
|
{
|
|
{
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
- IM_ASSERT(g.FocusScopeStack.Size > 0); // Too many PopFocusScope() ?
|
|
|
|
|
|
+ if (g.FocusScopeStack.Size == 0)
|
|
|
|
+ {
|
|
|
|
+ IM_ASSERT_USER_ERROR(g.FocusScopeStack.Size > 0, "Calling PopFocusScope() too many times!");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
g.FocusScopeStack.pop_back();
|
|
g.FocusScopeStack.pop_back();
|
|
- g.CurrentFocusScopeId = g.FocusScopeStack.Size ? g.FocusScopeStack.back() : 0;
|
|
|
|
|
|
+ g.CurrentFocusScopeId = g.FocusScopeStack.Size ? g.FocusScopeStack.back().ID : 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void ImGui::SetNavFocusScope(ImGuiID focus_scope_id)
|
|
|
|
+{
|
|
|
|
+ ImGuiContext& g = *GImGui;
|
|
|
|
+ g.NavFocusScopeId = focus_scope_id;
|
|
|
|
+ g.NavFocusScopePath.resize(0); // Invalidate
|
|
|
|
+ if (focus_scope_id == 0)
|
|
|
|
+ return;
|
|
|
|
+ IM_ASSERT(g.NavWindow != NULL);
|
|
|
|
+
|
|
|
|
+ // Store current path (in reverse order)
|
|
|
|
+ if (focus_scope_id == g.CurrentFocusScopeId)
|
|
|
|
+ {
|
|
|
|
+ // Top of focus stack contains local focus scopes inside current window
|
|
|
|
+ for (int n = g.FocusScopeStack.Size - 1; n >= 0 && g.FocusScopeStack.Data[n].WindowID == g.CurrentWindow->ID; n--)
|
|
|
|
+ g.NavFocusScopePath.push_back(g.FocusScopeStack.Data[n]);
|
|
|
|
+ }
|
|
|
|
+ else if (focus_scope_id == g.NavWindow->NavRootFocusScopeId)
|
|
|
|
+ g.NavFocusScopePath.push_back({ focus_scope_id, g.NavWindow->ID });
|
|
|
|
+ else
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ // Then follow on manually set ParentWindowForFocusRoute field (#6798)
|
|
|
|
+ for (ImGuiWindow* window = g.NavWindow->ParentWindowForFocusRoute; window != NULL; window = window->ParentWindowForFocusRoute)
|
|
|
|
+ g.NavFocusScopePath.push_back({ window->NavRootFocusScopeId, window->ID });
|
|
|
|
+ IM_ASSERT(g.NavFocusScopePath.Size < 100); // Maximum depth is technically 251 as per CalcRoutingScore(): 254 - 3
|
|
}
|
|
}
|
|
|
|
|
|
// Focus = move navigation cursor, set scrolling, set focus window.
|
|
// Focus = move navigation cursor, set scrolling, set focus window.
|
|
@@ -8759,18 +8786,18 @@ const char* ImGui::GetKeyName(ImGuiKey key)
|
|
}
|
|
}
|
|
|
|
|
|
// ImGuiMod_Shortcut is translated to either Ctrl or Super.
|
|
// ImGuiMod_Shortcut is translated to either Ctrl or Super.
|
|
-const char* ImGui::GetKeyChordName(ImGuiKeyChord key_chord, char* out_buf, int out_buf_size)
|
|
|
|
|
|
+const char* ImGui::GetKeyChordName(ImGuiKeyChord key_chord)
|
|
{
|
|
{
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
if (key_chord & ImGuiMod_Shortcut)
|
|
if (key_chord & ImGuiMod_Shortcut)
|
|
key_chord = ConvertShortcutMod(key_chord);
|
|
key_chord = ConvertShortcutMod(key_chord);
|
|
- ImFormatString(out_buf, (size_t)out_buf_size, "%s%s%s%s%s",
|
|
|
|
|
|
+ ImFormatString(g.TempKeychordName, IM_ARRAYSIZE(g.TempKeychordName), "%s%s%s%s%s",
|
|
(key_chord & ImGuiMod_Ctrl) ? "Ctrl+" : "",
|
|
(key_chord & ImGuiMod_Ctrl) ? "Ctrl+" : "",
|
|
(key_chord & ImGuiMod_Shift) ? "Shift+" : "",
|
|
(key_chord & ImGuiMod_Shift) ? "Shift+" : "",
|
|
(key_chord & ImGuiMod_Alt) ? "Alt+" : "",
|
|
(key_chord & ImGuiMod_Alt) ? "Alt+" : "",
|
|
(key_chord & ImGuiMod_Super) ? (g.IO.ConfigMacOSXBehaviors ? "Cmd+" : "Super+") : "",
|
|
(key_chord & ImGuiMod_Super) ? (g.IO.ConfigMacOSXBehaviors ? "Cmd+" : "Super+") : "",
|
|
GetKeyName((ImGuiKey)(key_chord & ~ImGuiMod_Mask_)));
|
|
GetKeyName((ImGuiKey)(key_chord & ~ImGuiMod_Mask_)));
|
|
- return out_buf;
|
|
|
|
|
|
+ return g.TempKeychordName;
|
|
}
|
|
}
|
|
|
|
|
|
// t0 = previous time (e.g.: g.Time - g.IO.DeltaTime)
|
|
// t0 = previous time (e.g.: g.Time - g.IO.DeltaTime)
|
|
@@ -8837,6 +8864,7 @@ static void ImGui::UpdateKeyRoutingTable(ImGuiKeyRoutingTable* rt)
|
|
for (int old_routing_idx = rt->Index[key - ImGuiKey_NamedKey_BEGIN]; old_routing_idx != -1; old_routing_idx = routing_entry->NextEntryIndex)
|
|
for (int old_routing_idx = rt->Index[key - ImGuiKey_NamedKey_BEGIN]; old_routing_idx != -1; old_routing_idx = routing_entry->NextEntryIndex)
|
|
{
|
|
{
|
|
routing_entry = &rt->Entries[old_routing_idx];
|
|
routing_entry = &rt->Entries[old_routing_idx];
|
|
|
|
+ routing_entry->RoutingCurrScore = routing_entry->RoutingNextScore;
|
|
routing_entry->RoutingCurr = routing_entry->RoutingNext; // Update entry
|
|
routing_entry->RoutingCurr = routing_entry->RoutingNext; // Update entry
|
|
routing_entry->RoutingNext = ImGuiKeyOwner_None;
|
|
routing_entry->RoutingNext = ImGuiKeyOwner_None;
|
|
routing_entry->RoutingNextScore = 255;
|
|
routing_entry->RoutingNextScore = 255;
|
|
@@ -8918,37 +8946,30 @@ ImGuiKeyRoutingData* ImGui::GetShortcutRoutingData(ImGuiKeyChord key_chord)
|
|
// - 254: ImGuiInputFlags_RouteGlobalLow
|
|
// - 254: ImGuiInputFlags_RouteGlobalLow
|
|
// - 255: never route
|
|
// - 255: never route
|
|
// 'flags' should include an explicit routing policy
|
|
// 'flags' should include an explicit routing policy
|
|
-static int CalcRoutingScore(ImGuiWindow* location, ImGuiID owner_id, ImGuiInputFlags flags)
|
|
|
|
|
|
+static int CalcRoutingScore(ImGuiID focus_scope_id, ImGuiID owner_id, ImGuiInputFlags flags)
|
|
{
|
|
{
|
|
if (flags & ImGuiInputFlags_RouteFocused)
|
|
if (flags & ImGuiInputFlags_RouteFocused)
|
|
{
|
|
{
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
- ImGuiWindow* focused = g.NavWindow;
|
|
|
|
|
|
|
|
// ActiveID gets top priority
|
|
// ActiveID gets top priority
|
|
// (we don't check g.ActiveIdUsingAllKeys here. Routing is applied but if input ownership is tested later it may discard it)
|
|
// (we don't check g.ActiveIdUsingAllKeys here. Routing is applied but if input ownership is tested later it may discard it)
|
|
if (owner_id != 0 && g.ActiveId == owner_id)
|
|
if (owner_id != 0 && g.ActiveId == owner_id)
|
|
return 1;
|
|
return 1;
|
|
|
|
|
|
- // Early out when not in focus stack
|
|
|
|
- if (focused == NULL || focused->RootWindowDockTree != location->RootWindowDockTree)
|
|
|
|
- return 255;
|
|
|
|
-
|
|
|
|
// Score based on distance to focused window (lower is better)
|
|
// Score based on distance to focused window (lower is better)
|
|
// Assuming both windows are submitting a routing request,
|
|
// Assuming both windows are submitting a routing request,
|
|
// - When Window....... is focused -> Window scores 3 (best), Window/ChildB scores 255 (no match)
|
|
// - When Window....... is focused -> Window scores 3 (best), Window/ChildB scores 255 (no match)
|
|
// - When Window/ChildB is focused -> Window scores 4, Window/ChildB scores 3 (best)
|
|
// - When Window/ChildB is focused -> Window scores 4, Window/ChildB scores 3 (best)
|
|
// Assuming only WindowA is submitting a routing request,
|
|
// Assuming only WindowA is submitting a routing request,
|
|
// - When Window/ChildB is focused -> Window scores 4 (best), Window/ChildB doesn't have a score.
|
|
// - When Window/ChildB is focused -> Window scores 4 (best), Window/ChildB doesn't have a score.
|
|
- for (int next_score = 3; focused != NULL; next_score++)
|
|
|
|
- {
|
|
|
|
- if (focused == location)
|
|
|
|
- {
|
|
|
|
- IM_ASSERT(next_score < 255);
|
|
|
|
- return next_score;
|
|
|
|
- }
|
|
|
|
- focused = (focused->RootWindowDockTree != focused) ? focused->ParentWindow : NULL; // FIXME: This could be later abstracted as a focus path
|
|
|
|
- }
|
|
|
|
|
|
+ // This essentially follow the window->ParentWindowForFocusRoute chain.
|
|
|
|
+ if (focus_scope_id == 0)
|
|
|
|
+ return 255;
|
|
|
|
+ for (int index_in_focus_path = 0; index_in_focus_path < g.NavFocusScopePath.Size; index_in_focus_path++)
|
|
|
|
+ if (g.NavFocusScopePath.Data[index_in_focus_path].ID == focus_scope_id)
|
|
|
|
+ return 3 + index_in_focus_path;
|
|
|
|
+
|
|
return 255;
|
|
return 255;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -8976,7 +8997,7 @@ bool ImGui::SetShortcutRouting(ImGuiKeyChord key_chord, ImGuiID owner_id, ImGuiI
|
|
IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiInputFlags_RouteMask_)); // Check that only 1 routing flag is used
|
|
IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiInputFlags_RouteMask_)); // Check that only 1 routing flag is used
|
|
|
|
|
|
// [DEBUG] Debug break requested by user
|
|
// [DEBUG] Debug break requested by user
|
|
- if (g.DebugBreakInShortcutRouting == key_chord)
|
|
|
|
|
|
+ if (g.DebugBreakInShortcutRouting != 0 && g.DebugBreakInShortcutRouting == ConvertShortcutMod(key_chord))
|
|
IM_DEBUG_BREAK();
|
|
IM_DEBUG_BREAK();
|
|
|
|
|
|
if (flags & ImGuiInputFlags_RouteUnlessBgFocused)
|
|
if (flags & ImGuiInputFlags_RouteUnlessBgFocused)
|
|
@@ -8984,9 +9005,13 @@ bool ImGui::SetShortcutRouting(ImGuiKeyChord key_chord, ImGuiID owner_id, ImGuiI
|
|
return false;
|
|
return false;
|
|
// Note how ImGuiInputFlags_RouteAlways won't set routing and thus won't set owner. May want to rework this?
|
|
// Note how ImGuiInputFlags_RouteAlways won't set routing and thus won't set owner. May want to rework this?
|
|
if (flags & ImGuiInputFlags_RouteAlways)
|
|
if (flags & ImGuiInputFlags_RouteAlways)
|
|
|
|
+ {
|
|
|
|
+ IMGUI_DEBUG_LOG_INPUTROUTING("SetShortcutRouting(%s, owner_id=0x%08X, flags=%04X) -> always\n", GetKeyChordName(key_chord), owner_id, flags);
|
|
return true;
|
|
return true;
|
|
|
|
+ }
|
|
|
|
|
|
- const int score = CalcRoutingScore(g.CurrentWindow, owner_id, flags);
|
|
|
|
|
|
+ const int score = CalcRoutingScore(g.CurrentFocusScopeId, owner_id, flags);
|
|
|
|
+ IMGUI_DEBUG_LOG_INPUTROUTING("SetShortcutRouting(%s, owner_id=0x%08X, flags=%04X) -> score %d\n", GetKeyChordName(key_chord), owner_id, flags, score);
|
|
if (score == 255)
|
|
if (score == 255)
|
|
return false;
|
|
return false;
|
|
|
|
|
|
@@ -9002,6 +9027,8 @@ bool ImGui::SetShortcutRouting(ImGuiKeyChord key_chord, ImGuiID owner_id, ImGuiI
|
|
}
|
|
}
|
|
|
|
|
|
// Return routing state for CURRENT frame
|
|
// Return routing state for CURRENT frame
|
|
|
|
+ if (routing_data->RoutingCurr == routing_id)
|
|
|
|
+ IMGUI_DEBUG_LOG_INPUTROUTING("--> granting current route\n");
|
|
return routing_data->RoutingCurr == routing_id;
|
|
return routing_data->RoutingCurr == routing_id;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -11429,6 +11456,8 @@ bool ImGui::BeginPopupEx(ImGuiID id, ImGuiWindowFlags flags)
|
|
if (!is_open) // NB: Begin can return false when the popup is completely clipped (e.g. zero size display)
|
|
if (!is_open) // NB: Begin can return false when the popup is completely clipped (e.g. zero size display)
|
|
EndPopup();
|
|
EndPopup();
|
|
|
|
|
|
|
|
+ //g.CurrentWindow->FocusRouteParentWindow = g.CurrentWindow->ParentWindowInBeginStack;
|
|
|
|
+
|
|
return is_open;
|
|
return is_open;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -11753,7 +11782,7 @@ void ImGui::SetNavID(ImGuiID id, ImGuiNavLayer nav_layer, ImGuiID focus_scope_id
|
|
IM_ASSERT(nav_layer == ImGuiNavLayer_Main || nav_layer == ImGuiNavLayer_Menu);
|
|
IM_ASSERT(nav_layer == ImGuiNavLayer_Main || nav_layer == ImGuiNavLayer_Menu);
|
|
g.NavId = id;
|
|
g.NavId = id;
|
|
g.NavLayer = nav_layer;
|
|
g.NavLayer = nav_layer;
|
|
- g.NavFocusScopeId = focus_scope_id;
|
|
|
|
|
|
+ SetNavFocusScope(focus_scope_id);
|
|
g.NavWindow->NavLastIds[nav_layer] = id;
|
|
g.NavWindow->NavLastIds[nav_layer] = id;
|
|
g.NavWindow->NavRectRel[nav_layer] = rect_rel;
|
|
g.NavWindow->NavRectRel[nav_layer] = rect_rel;
|
|
|
|
|
|
@@ -11775,7 +11804,7 @@ void ImGui::SetFocusID(ImGuiID id, ImGuiWindow* window)
|
|
const ImGuiNavLayer nav_layer = window->DC.NavLayerCurrent;
|
|
const ImGuiNavLayer nav_layer = window->DC.NavLayerCurrent;
|
|
g.NavId = id;
|
|
g.NavId = id;
|
|
g.NavLayer = nav_layer;
|
|
g.NavLayer = nav_layer;
|
|
- g.NavFocusScopeId = g.CurrentFocusScopeId;
|
|
|
|
|
|
+ SetNavFocusScope(g.CurrentFocusScopeId);
|
|
window->NavLastIds[nav_layer] = id;
|
|
window->NavLastIds[nav_layer] = id;
|
|
if (g.LastItemData.ID == id)
|
|
if (g.LastItemData.ID == id)
|
|
window->NavRectRel[nav_layer] = WindowRectAbsToRel(window, g.LastItemData.NavRect);
|
|
window->NavRectRel[nav_layer] = WindowRectAbsToRel(window, g.LastItemData.NavRect);
|
|
@@ -12033,6 +12062,7 @@ static void ImGui::NavProcessItem()
|
|
if (g.NavWindow != window)
|
|
if (g.NavWindow != window)
|
|
SetNavWindow(window); // Always refresh g.NavWindow, because some operations such as FocusItem() may not have a window.
|
|
SetNavWindow(window); // Always refresh g.NavWindow, because some operations such as FocusItem() may not have a window.
|
|
g.NavLayer = window->DC.NavLayerCurrent;
|
|
g.NavLayer = window->DC.NavLayerCurrent;
|
|
|
|
+ SetNavFocusScope(g.CurrentFocusScopeId); // Will set g.NavFocusScopeId AND store g.NavFocusScopePath
|
|
g.NavFocusScopeId = g.CurrentFocusScopeId;
|
|
g.NavFocusScopeId = g.CurrentFocusScopeId;
|
|
g.NavIdIsAlive = true;
|
|
g.NavIdIsAlive = true;
|
|
if (g.LastItemData.InFlags & ImGuiItemFlags_HasSelectionUserData)
|
|
if (g.LastItemData.InFlags & ImGuiItemFlags_HasSelectionUserData)
|
|
@@ -12056,10 +12086,12 @@ void ImGui::NavProcessItemForTabbingRequest(ImGuiID id, ImGuiItemFlags item_flag
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
|
|
|
|
if ((move_flags & ImGuiNavMoveFlags_FocusApi) == 0)
|
|
if ((move_flags & ImGuiNavMoveFlags_FocusApi) == 0)
|
|
|
|
+ {
|
|
if (g.NavLayer != g.CurrentWindow->DC.NavLayerCurrent)
|
|
if (g.NavLayer != g.CurrentWindow->DC.NavLayerCurrent)
|
|
return;
|
|
return;
|
|
- if (g.NavFocusScopeId != g.CurrentFocusScopeId)
|
|
|
|
- return;
|
|
|
|
|
|
+ if (g.NavFocusScopeId != g.CurrentFocusScopeId)
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
|
|
// - Can always land on an item when using API call.
|
|
// - Can always land on an item when using API call.
|
|
// - Tabbing with _NavEnableKeyboard (space/enter/arrows): goes through every item.
|
|
// - Tabbing with _NavEnableKeyboard (space/enter/arrows): goes through every item.
|
|
@@ -12264,7 +12296,7 @@ void ImGui::NavInitWindow(ImGuiWindow* window, bool force_reinit)
|
|
if (window->Flags & ImGuiWindowFlags_NoNavInputs)
|
|
if (window->Flags & ImGuiWindowFlags_NoNavInputs)
|
|
{
|
|
{
|
|
g.NavId = 0;
|
|
g.NavId = 0;
|
|
- g.NavFocusScopeId = window->NavRootFocusScopeId;
|
|
|
|
|
|
+ SetNavFocusScope(window->NavRootFocusScopeId);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -12283,7 +12315,7 @@ void ImGui::NavInitWindow(ImGuiWindow* window, bool force_reinit)
|
|
else
|
|
else
|
|
{
|
|
{
|
|
g.NavId = window->NavLastIds[0];
|
|
g.NavId = window->NavLastIds[0];
|
|
- g.NavFocusScopeId = window->NavRootFocusScopeId;
|
|
|
|
|
|
+ SetNavFocusScope(window->NavRootFocusScopeId);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -20024,6 +20056,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|
{
|
|
{
|
|
ImGuiDebugAllocInfo* info = &g.DebugAllocInfo;
|
|
ImGuiDebugAllocInfo* info = &g.DebugAllocInfo;
|
|
Text("%d current allocations", info->TotalAllocCount - info->TotalFreeCount);
|
|
Text("%d current allocations", info->TotalAllocCount - info->TotalFreeCount);
|
|
|
|
+ if (SmallButton("GC now")) { g.GcCompactAll = true; }
|
|
Text("Recent frames with allocations:");
|
|
Text("Recent frames with allocations:");
|
|
int buf_size = IM_ARRAYSIZE(info->LastEntriesBuf);
|
|
int buf_size = IM_ARRAYSIZE(info->LastEntriesBuf);
|
|
for (int n = buf_size - 1; n >= 0; n--)
|
|
for (int n = buf_size - 1; n >= 0; n--)
|
|
@@ -20111,10 +20144,9 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|
ImGuiKeyRoutingTable* rt = &g.KeysRoutingTable;
|
|
ImGuiKeyRoutingTable* rt = &g.KeysRoutingTable;
|
|
for (ImGuiKeyRoutingIndex idx = rt->Index[key - ImGuiKey_NamedKey_BEGIN]; idx != -1; )
|
|
for (ImGuiKeyRoutingIndex idx = rt->Index[key - ImGuiKey_NamedKey_BEGIN]; idx != -1; )
|
|
{
|
|
{
|
|
- char key_chord_name[64];
|
|
|
|
ImGuiKeyRoutingData* routing_data = &rt->Entries[idx];
|
|
ImGuiKeyRoutingData* routing_data = &rt->Entries[idx];
|
|
ImGuiKeyChord key_chord = key | routing_data->Mods;
|
|
ImGuiKeyChord key_chord = key | routing_data->Mods;
|
|
- Text("%s: 0x%08X", GetKeyChordName(key_chord, key_chord_name, IM_ARRAYSIZE(key_chord_name)), routing_data->RoutingCurr);
|
|
|
|
|
|
+ Text("%s: 0x%08X (scored %d)", GetKeyChordName(key_chord), routing_data->RoutingCurr, routing_data->RoutingCurrScore);
|
|
DebugLocateItemOnHover(routing_data->RoutingCurr);
|
|
DebugLocateItemOnHover(routing_data->RoutingCurr);
|
|
if (g.IO.ConfigDebugIsDebuggerPresent)
|
|
if (g.IO.ConfigDebugIsDebuggerPresent)
|
|
{
|
|
{
|
|
@@ -20168,6 +20200,14 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|
Text("NavActivateFlags: %04X", g.NavActivateFlags);
|
|
Text("NavActivateFlags: %04X", g.NavActivateFlags);
|
|
Text("NavDisableHighlight: %d, NavDisableMouseHover: %d", g.NavDisableHighlight, g.NavDisableMouseHover);
|
|
Text("NavDisableHighlight: %d, NavDisableMouseHover: %d", g.NavDisableHighlight, g.NavDisableMouseHover);
|
|
Text("NavFocusScopeId = 0x%08X", g.NavFocusScopeId);
|
|
Text("NavFocusScopeId = 0x%08X", g.NavFocusScopeId);
|
|
|
|
+ Text("NavFocusScopePath[] = ");
|
|
|
|
+ for (int path_n = g.NavFocusScopePath.Size - 1; path_n >= 0; path_n--)
|
|
|
|
+ {
|
|
|
|
+ const ImGuiFocusScopeData& focus_scope = g.NavFocusScopePath[path_n];
|
|
|
|
+ SameLine(0.0f, 0.0f);
|
|
|
|
+ Text("0x%08X/", focus_scope.ID);
|
|
|
|
+ SetItemTooltip("In window \"%s\"", FindWindowByID(focus_scope.WindowID)->Name);
|
|
|
|
+ }
|
|
Text("NavWindowingTarget: '%s'", g.NavWindowingTarget ? g.NavWindowingTarget->Name : "NULL");
|
|
Text("NavWindowingTarget: '%s'", g.NavWindowingTarget ? g.NavWindowingTarget->Name : "NULL");
|
|
Unindent();
|
|
Unindent();
|
|
|
|
|
|
@@ -20777,10 +20817,11 @@ void ImGui::DebugNodeWindow(ImGuiWindow* window, const char* label)
|
|
if (window->DockNode || window->DockNodeAsHost)
|
|
if (window->DockNode || window->DockNodeAsHost)
|
|
DebugNodeDockNode(window->DockNodeAsHost ? window->DockNodeAsHost : window->DockNode, window->DockNodeAsHost ? "DockNodeAsHost" : "DockNode");
|
|
DebugNodeDockNode(window->DockNodeAsHost ? window->DockNodeAsHost : window->DockNode, window->DockNodeAsHost ? "DockNodeAsHost" : "DockNode");
|
|
|
|
|
|
- if (window->RootWindow != window) { DebugNodeWindow(window->RootWindow, "RootWindow"); }
|
|
|
|
|
|
+ if (window->RootWindow != window) { DebugNodeWindow(window->RootWindow, "RootWindow"); }
|
|
if (window->RootWindowDockTree != window->RootWindow) { DebugNodeWindow(window->RootWindowDockTree, "RootWindowDockTree"); }
|
|
if (window->RootWindowDockTree != window->RootWindow) { DebugNodeWindow(window->RootWindowDockTree, "RootWindowDockTree"); }
|
|
- if (window->ParentWindow != NULL) { DebugNodeWindow(window->ParentWindow, "ParentWindow"); }
|
|
|
|
- if (window->DC.ChildWindows.Size > 0) { DebugNodeWindowsList(&window->DC.ChildWindows, "ChildWindows"); }
|
|
|
|
|
|
+ if (window->ParentWindow != NULL) { DebugNodeWindow(window->ParentWindow, "ParentWindow"); }
|
|
|
|
+ if (window->ParentWindowForFocusRoute != NULL) { DebugNodeWindow(window->ParentWindowForFocusRoute, "ParentWindowForFocusRoute"); }
|
|
|
|
+ if (window->DC.ChildWindows.Size > 0) { DebugNodeWindowsList(&window->DC.ChildWindows, "ChildWindows"); }
|
|
if (window->ColumnsStorage.Size > 0 && TreeNode("Columns", "Columns sets (%d)", window->ColumnsStorage.Size))
|
|
if (window->ColumnsStorage.Size > 0 && TreeNode("Columns", "Columns sets (%d)", window->ColumnsStorage.Size))
|
|
{
|
|
{
|
|
for (ImGuiOldColumns& columns : window->ColumnsStorage)
|
|
for (ImGuiOldColumns& columns : window->ColumnsStorage)
|
|
@@ -20893,16 +20934,20 @@ void ImGui::ShowDebugLogWindow(bool* p_open)
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- CheckboxFlags("All", &g.DebugLogFlags, ImGuiDebugLogFlags_EventMask_);
|
|
|
|
|
|
+ ImGuiDebugLogFlags all_enable_flags = ImGuiDebugLogFlags_EventMask_ & ~ImGuiDebugLogFlags_EventInputRouting;
|
|
|
|
+ CheckboxFlags("All", &g.DebugLogFlags, all_enable_flags);
|
|
|
|
+ SetItemTooltip("(except InputRouting which is spammy)");
|
|
|
|
+
|
|
ShowDebugLogFlag("ActiveId", ImGuiDebugLogFlags_EventActiveId);
|
|
ShowDebugLogFlag("ActiveId", ImGuiDebugLogFlags_EventActiveId);
|
|
ShowDebugLogFlag("Clipper", ImGuiDebugLogFlags_EventClipper);
|
|
ShowDebugLogFlag("Clipper", ImGuiDebugLogFlags_EventClipper);
|
|
|
|
+ ShowDebugLogFlag("Docking", ImGuiDebugLogFlags_EventDocking);
|
|
ShowDebugLogFlag("Focus", ImGuiDebugLogFlags_EventFocus);
|
|
ShowDebugLogFlag("Focus", ImGuiDebugLogFlags_EventFocus);
|
|
ShowDebugLogFlag("IO", ImGuiDebugLogFlags_EventIO);
|
|
ShowDebugLogFlag("IO", ImGuiDebugLogFlags_EventIO);
|
|
ShowDebugLogFlag("Nav", ImGuiDebugLogFlags_EventNav);
|
|
ShowDebugLogFlag("Nav", ImGuiDebugLogFlags_EventNav);
|
|
ShowDebugLogFlag("Popup", ImGuiDebugLogFlags_EventPopup);
|
|
ShowDebugLogFlag("Popup", ImGuiDebugLogFlags_EventPopup);
|
|
//ShowDebugLogFlag("Selection", ImGuiDebugLogFlags_EventSelection);
|
|
//ShowDebugLogFlag("Selection", ImGuiDebugLogFlags_EventSelection);
|
|
- ShowDebugLogFlag("Docking", ImGuiDebugLogFlags_EventDocking);
|
|
|
|
ShowDebugLogFlag("Viewport", ImGuiDebugLogFlags_EventViewport);
|
|
ShowDebugLogFlag("Viewport", ImGuiDebugLogFlags_EventViewport);
|
|
|
|
+ ShowDebugLogFlag("InputRouting", ImGuiDebugLogFlags_EventInputRouting);
|
|
|
|
|
|
if (SmallButton("Clear"))
|
|
if (SmallButton("Clear"))
|
|
{
|
|
{
|