|
|
@@ -810,10 +810,13 @@ CODE
|
|
|
|
|
|
// Visual Studio warnings
|
|
|
#ifdef _MSC_VER
|
|
|
-#pragma warning (disable: 4127) // condition expression is constant
|
|
|
+#pragma warning (disable: 4127) // condition expression is constant
|
|
|
#pragma warning (disable: 4201) // nonstandard extension used: nameless struct/union
|
|
|
#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff)
|
|
|
-#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
|
|
|
+#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
|
|
|
+#if defined(_MSC_VER) && _MSC_VER >= 1922 // MSVC 2019 16.2 or later
|
|
|
+#pragma warning (disable: 5054) // operator '|': deprecated between enumerations of different types
|
|
|
+#endif
|
|
|
#endif
|
|
|
|
|
|
// Clang/GCC warnings with -Weverything
|
|
|
@@ -1356,7 +1359,6 @@ const char* ImStrSkipBlank(const char* str)
|
|
|
// You may set IMGUI_USE_STB_SPRINTF to use our default wrapper, or set IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS
|
|
|
// and setup the wrapper yourself. (FIXME-OPT: Some of our high-level operations such as ImGuiTextBuffer::appendfv() are
|
|
|
// designed using two-passes worst case, which probably could be improved using the stbsp_vsprintfcb() function.)
|
|
|
-//#define IMGUI_USE_STB_SPRINTF
|
|
|
#ifdef IMGUI_USE_STB_SPRINTF
|
|
|
#define STB_SPRINTF_IMPLEMENTATION
|
|
|
#include "stb_sprintf.h"
|
|
|
@@ -2754,27 +2756,6 @@ void ImGui::GcAwakeTransientWindowBuffers(ImGuiWindow* window)
|
|
|
window->MemoryDrawListIdxCapacity = window->MemoryDrawListVtxCapacity = 0;
|
|
|
}
|
|
|
|
|
|
-// FIXME-NAV: Refactor those functions into a single, more explicit one.
|
|
|
-void ImGui::SetNavID(ImGuiID id, int nav_layer, ImGuiID focus_scope_id)
|
|
|
-{
|
|
|
- ImGuiContext& g = *GImGui;
|
|
|
- IM_ASSERT(g.NavWindow);
|
|
|
- IM_ASSERT(nav_layer == 0 || nav_layer == 1);
|
|
|
- g.NavId = id;
|
|
|
- g.NavFocusScopeId = focus_scope_id;
|
|
|
- g.NavWindow->NavLastIds[nav_layer] = id;
|
|
|
-}
|
|
|
-
|
|
|
-void ImGui::SetNavIDWithRectRel(ImGuiID id, int nav_layer, ImGuiID focus_scope_id, const ImRect& rect_rel)
|
|
|
-{
|
|
|
- ImGuiContext& g = *GImGui;
|
|
|
- SetNavID(id, nav_layer, focus_scope_id);
|
|
|
- g.NavWindow->NavRectRel[nav_layer] = rect_rel;
|
|
|
- g.NavMousePosDirty = true;
|
|
|
- g.NavDisableHighlight = false;
|
|
|
- g.NavDisableMouseHover = true;
|
|
|
-}
|
|
|
-
|
|
|
void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window)
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
@@ -2807,31 +2788,6 @@ void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window)
|
|
|
g.ActiveIdUsingKeyInputMask = 0x00;
|
|
|
}
|
|
|
|
|
|
-// FIXME-NAV: The existence of SetNavID/SetNavIDWithRectRel/SetFocusID is incredibly messy and confusing and needs some explanation or refactoring.
|
|
|
-void ImGui::SetFocusID(ImGuiID id, ImGuiWindow* window)
|
|
|
-{
|
|
|
- ImGuiContext& g = *GImGui;
|
|
|
- IM_ASSERT(id != 0);
|
|
|
-
|
|
|
- // Assume that SetFocusID() is called in the context where its window->DC.NavLayerCurrent and window->DC.NavFocusScopeIdCurrent are valid.
|
|
|
- // Note that window may be != g.CurrentWindow (e.g. SetFocusID call in InputTextEx for multi-line text)
|
|
|
- const ImGuiNavLayer nav_layer = window->DC.NavLayerCurrent;
|
|
|
- if (g.NavWindow != window)
|
|
|
- g.NavInitRequest = false;
|
|
|
- g.NavWindow = window;
|
|
|
- g.NavId = id;
|
|
|
- g.NavLayer = nav_layer;
|
|
|
- g.NavFocusScopeId = window->DC.NavFocusScopeIdCurrent;
|
|
|
- window->NavLastIds[nav_layer] = id;
|
|
|
- if (window->DC.LastItemId == id)
|
|
|
- window->NavRectRel[nav_layer] = ImRect(window->DC.LastItemRect.Min - window->Pos, window->DC.LastItemRect.Max - window->Pos);
|
|
|
-
|
|
|
- if (g.ActiveIdSource == ImGuiInputSource_Nav)
|
|
|
- g.NavDisableMouseHover = true;
|
|
|
- else
|
|
|
- g.NavDisableHighlight = true;
|
|
|
-}
|
|
|
-
|
|
|
void ImGui::ClearActiveID()
|
|
|
{
|
|
|
SetActiveID(0, NULL);
|
|
|
@@ -2879,18 +2835,18 @@ static inline bool IsWindowContentHoverable(ImGuiWindow* window, ImGuiHoveredFla
|
|
|
// An active popup disable hovering on other windows (apart from its own children)
|
|
|
// FIXME-OPT: This could be cached/stored within the window.
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
- if (g.NavWindow)
|
|
|
- if (ImGuiWindow* focused_root_window = g.NavWindow->RootWindow)
|
|
|
- if (focused_root_window->WasActive && focused_root_window != window->RootWindow)
|
|
|
- {
|
|
|
- // For the purpose of those flags we differentiate "standard popup" from "modal popup"
|
|
|
- // NB: The order of those two tests is important because Modal windows are also Popups.
|
|
|
- if (focused_root_window->Flags & ImGuiWindowFlags_Modal)
|
|
|
- return false;
|
|
|
- if ((focused_root_window->Flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiHoveredFlags_AllowWhenBlockedByPopup))
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
+ if (!g.NavWindow)
|
|
|
+ return true;
|
|
|
+ if (ImGuiWindow* focused_root_window = g.NavWindow->RootWindow)
|
|
|
+ if (focused_root_window->WasActive && focused_root_window != window->RootWindow)
|
|
|
+ {
|
|
|
+ // For the purpose of those flags we differentiate "standard popup" from "modal popup"
|
|
|
+ // NB: The order of those two tests is important because Modal windows are also Popups.
|
|
|
+ if (focused_root_window->Flags & ImGuiWindowFlags_Modal)
|
|
|
+ return false;
|
|
|
+ if ((focused_root_window->Flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiHoveredFlags_AllowWhenBlockedByPopup))
|
|
|
+ return false;
|
|
|
+ }
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@@ -7860,6 +7816,52 @@ ImVec2 ImGui::FindBestWindowPosForPopup(ImGuiWindow* window)
|
|
|
// [SECTION] KEYBOARD/GAMEPAD NAVIGATION
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
+// FIXME-NAV: The existance of SetNavID vs SetNavIDWithRectRel vs SetFocusID is incredibly messy and confusing,
|
|
|
+// and needs some explanation or serious refactoring.
|
|
|
+void ImGui::SetNavID(ImGuiID id, int nav_layer, ImGuiID focus_scope_id)
|
|
|
+{
|
|
|
+ ImGuiContext& g = *GImGui;
|
|
|
+ IM_ASSERT(g.NavWindow);
|
|
|
+ IM_ASSERT(nav_layer == 0 || nav_layer == 1);
|
|
|
+ g.NavId = id;
|
|
|
+ g.NavFocusScopeId = focus_scope_id;
|
|
|
+ g.NavWindow->NavLastIds[nav_layer] = id;
|
|
|
+}
|
|
|
+
|
|
|
+void ImGui::SetNavIDWithRectRel(ImGuiID id, int nav_layer, ImGuiID focus_scope_id, const ImRect& rect_rel)
|
|
|
+{
|
|
|
+ ImGuiContext& g = *GImGui;
|
|
|
+ SetNavID(id, nav_layer, focus_scope_id);
|
|
|
+ g.NavWindow->NavRectRel[nav_layer] = rect_rel;
|
|
|
+ g.NavMousePosDirty = true;
|
|
|
+ g.NavDisableHighlight = false;
|
|
|
+ g.NavDisableMouseHover = true;
|
|
|
+}
|
|
|
+
|
|
|
+void ImGui::SetFocusID(ImGuiID id, ImGuiWindow* window)
|
|
|
+{
|
|
|
+ ImGuiContext& g = *GImGui;
|
|
|
+ IM_ASSERT(id != 0);
|
|
|
+
|
|
|
+ // Assume that SetFocusID() is called in the context where its window->DC.NavLayerCurrent and window->DC.NavFocusScopeIdCurrent are valid.
|
|
|
+ // Note that window may be != g.CurrentWindow (e.g. SetFocusID call in InputTextEx for multi-line text)
|
|
|
+ const ImGuiNavLayer nav_layer = window->DC.NavLayerCurrent;
|
|
|
+ if (g.NavWindow != window)
|
|
|
+ g.NavInitRequest = false;
|
|
|
+ g.NavWindow = window;
|
|
|
+ g.NavId = id;
|
|
|
+ g.NavLayer = nav_layer;
|
|
|
+ g.NavFocusScopeId = window->DC.NavFocusScopeIdCurrent;
|
|
|
+ window->NavLastIds[nav_layer] = id;
|
|
|
+ if (window->DC.LastItemId == id)
|
|
|
+ window->NavRectRel[nav_layer] = ImRect(window->DC.LastItemRect.Min - window->Pos, window->DC.LastItemRect.Max - window->Pos);
|
|
|
+
|
|
|
+ if (g.ActiveIdSource == ImGuiInputSource_Nav)
|
|
|
+ g.NavDisableMouseHover = true;
|
|
|
+ else
|
|
|
+ g.NavDisableHighlight = true;
|
|
|
+}
|
|
|
+
|
|
|
ImGuiDir ImGetDirQuadrantFromDelta(float dx, float dy)
|
|
|
{
|
|
|
if (ImFabs(dx) > ImFabs(dy))
|