|
@@ -24,7 +24,7 @@
|
|
// For first-time users having issues compiling/linking/running:
|
|
// For first-time users having issues compiling/linking/running:
|
|
// please post in https://github.com/ocornut/imgui/discussions if you cannot find a solution in resources above.
|
|
// please post in https://github.com/ocornut/imgui/discussions if you cannot find a solution in resources above.
|
|
// Everything else should be asked in 'Issues'! We are building a database of cross-linked knowledge there.
|
|
// Everything else should be asked in 'Issues'! We are building a database of cross-linked knowledge there.
|
|
-// Since 1.92, we encourage font loading question to also be posted in 'Issues'.
|
|
|
|
|
|
+// Since 1.92, we encourage font loading questions to also be posted in 'Issues'.
|
|
|
|
|
|
// Copyright (c) 2014-2025 Omar Cornut
|
|
// Copyright (c) 2014-2025 Omar Cornut
|
|
// Developed by Omar Cornut and every direct or indirect contributors to the GitHub.
|
|
// Developed by Omar Cornut and every direct or indirect contributors to the GitHub.
|
|
@@ -1307,7 +1307,7 @@ static float NavUpdatePageUpPageDown();
|
|
static inline void NavUpdateAnyRequestFlag();
|
|
static inline void NavUpdateAnyRequestFlag();
|
|
static void NavUpdateCreateWrappingRequest();
|
|
static void NavUpdateCreateWrappingRequest();
|
|
static void NavEndFrame();
|
|
static void NavEndFrame();
|
|
-static bool NavScoreItem(ImGuiNavItemData* result);
|
|
|
|
|
|
+static bool NavScoreItem(ImGuiNavItemData* result, const ImRect& nav_bb);
|
|
static void NavApplyItemToResult(ImGuiNavItemData* result);
|
|
static void NavApplyItemToResult(ImGuiNavItemData* result);
|
|
static void NavProcessItem();
|
|
static void NavProcessItem();
|
|
static void NavProcessItemForTabbingRequest(ImGuiID id, ImGuiItemFlags item_flags, ImGuiNavMoveFlags move_flags);
|
|
static void NavProcessItemForTabbingRequest(ImGuiID id, ImGuiItemFlags item_flags, ImGuiNavMoveFlags move_flags);
|
|
@@ -4766,7 +4766,6 @@ static ImGuiHoveredFlags ApplyHoverFlagsForTooltip(ImGuiHoveredFlags user_flags,
|
|
}
|
|
}
|
|
|
|
|
|
// This is roughly matching the behavior of internal-facing ItemHoverable()
|
|
// This is roughly matching the behavior of internal-facing ItemHoverable()
|
|
-// - we allow hovering to be true when ActiveId==window->MoveID, so that clicking on non-interactive items such as a Text() item still returns true with IsItemHovered()
|
|
|
|
// - this should work even for non-interactive items that have no ID, so we cannot use LastItemId
|
|
// - this should work even for non-interactive items that have no ID, so we cannot use LastItemId
|
|
bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
|
|
bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
|
|
{
|
|
{
|
|
@@ -4808,8 +4807,7 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
|
|
const ImGuiID id = g.LastItemData.ID;
|
|
const ImGuiID id = g.LastItemData.ID;
|
|
if ((flags & ImGuiHoveredFlags_AllowWhenBlockedByActiveItem) == 0)
|
|
if ((flags & ImGuiHoveredFlags_AllowWhenBlockedByActiveItem) == 0)
|
|
if (g.ActiveId != 0 && g.ActiveId != id && !g.ActiveIdAllowOverlap)
|
|
if (g.ActiveId != 0 && g.ActiveId != id && !g.ActiveIdAllowOverlap)
|
|
- if (g.ActiveId != window->MoveId && g.ActiveId != window->TabId)
|
|
|
|
- return false;
|
|
|
|
|
|
+ return false;
|
|
|
|
|
|
// Test if interactions on this window are blocked by an active popup or modal.
|
|
// Test if interactions on this window are blocked by an active popup or modal.
|
|
// The ImGuiHoveredFlags_AllowWhenBlockedByPopup flag will be tested here.
|
|
// The ImGuiHoveredFlags_AllowWhenBlockedByPopup flag will be tested here.
|
|
@@ -10790,13 +10788,17 @@ void ImGui::SetNextFrameWantCaptureMouse(bool want_capture_mouse)
|
|
static const char* GetInputSourceName(ImGuiInputSource source)
|
|
static const char* GetInputSourceName(ImGuiInputSource source)
|
|
{
|
|
{
|
|
const char* input_source_names[] = { "None", "Mouse", "Keyboard", "Gamepad" };
|
|
const char* input_source_names[] = { "None", "Mouse", "Keyboard", "Gamepad" };
|
|
- IM_ASSERT(IM_ARRAYSIZE(input_source_names) == ImGuiInputSource_COUNT && source >= 0 && source < ImGuiInputSource_COUNT);
|
|
|
|
|
|
+ IM_ASSERT(IM_ARRAYSIZE(input_source_names) == ImGuiInputSource_COUNT);
|
|
|
|
+ if (source < 0 || source >= ImGuiInputSource_COUNT)
|
|
|
|
+ return "Unknown";
|
|
return input_source_names[source];
|
|
return input_source_names[source];
|
|
}
|
|
}
|
|
static const char* GetMouseSourceName(ImGuiMouseSource source)
|
|
static const char* GetMouseSourceName(ImGuiMouseSource source)
|
|
{
|
|
{
|
|
const char* mouse_source_names[] = { "Mouse", "TouchScreen", "Pen" };
|
|
const char* mouse_source_names[] = { "Mouse", "TouchScreen", "Pen" };
|
|
- IM_ASSERT(IM_ARRAYSIZE(mouse_source_names) == ImGuiMouseSource_COUNT && source >= 0 && source < ImGuiMouseSource_COUNT);
|
|
|
|
|
|
+ IM_ASSERT(IM_ARRAYSIZE(mouse_source_names) == ImGuiMouseSource_COUNT);
|
|
|
|
+ if (source < 0 || source >= ImGuiMouseSource_COUNT)
|
|
|
|
+ return "Unknown";
|
|
return mouse_source_names[source];
|
|
return mouse_source_names[source];
|
|
}
|
|
}
|
|
static void DebugPrintInputEvent(const char* prefix, const ImGuiInputEvent* e)
|
|
static void DebugPrintInputEvent(const char* prefix, const ImGuiInputEvent* e)
|
|
@@ -13563,7 +13565,7 @@ static float inline NavScoreItemDistInterval(float cand_min, float cand_max, flo
|
|
}
|
|
}
|
|
|
|
|
|
// Scoring function for keyboard/gamepad directional navigation. Based on https://gist.github.com/rygorous/6981057
|
|
// Scoring function for keyboard/gamepad directional navigation. Based on https://gist.github.com/rygorous/6981057
|
|
-static bool ImGui::NavScoreItem(ImGuiNavItemData* result)
|
|
|
|
|
|
+static bool ImGui::NavScoreItem(ImGuiNavItemData* result, const ImRect& nav_bb)
|
|
{
|
|
{
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiWindow* window = g.CurrentWindow;
|
|
ImGuiWindow* window = g.CurrentWindow;
|
|
@@ -13571,7 +13573,7 @@ static bool ImGui::NavScoreItem(ImGuiNavItemData* result)
|
|
return false;
|
|
return false;
|
|
|
|
|
|
// FIXME: Those are not good variables names
|
|
// FIXME: Those are not good variables names
|
|
- ImRect cand = g.LastItemData.NavRect; // Current item nav rectangle
|
|
|
|
|
|
+ ImRect cand = nav_bb; // Current item nav rectangle
|
|
const ImRect curr = g.NavScoringRect; // Current modified source rect (NB: we've applied Max.x = Min.x in NavUpdate() to inhibit the effect of having varied item width)
|
|
const ImRect curr = g.NavScoringRect; // Current modified source rect (NB: we've applied Max.x = Min.x in NavUpdate() to inhibit the effect of having varied item width)
|
|
g.NavScoringDebugCount++;
|
|
g.NavScoringDebugCount++;
|
|
|
|
|
|
@@ -13738,13 +13740,13 @@ static void ImGui::NavProcessItem()
|
|
const ImGuiID id = g.LastItemData.ID;
|
|
const ImGuiID id = g.LastItemData.ID;
|
|
const ImGuiItemFlags item_flags = g.LastItemData.ItemFlags;
|
|
const ImGuiItemFlags item_flags = g.LastItemData.ItemFlags;
|
|
|
|
|
|
- // When inside a container that isn't scrollable with Left<>Right, clip NavRect accordingly (#2221)
|
|
|
|
|
|
+ // When inside a container that isn't scrollable with Left<>Right, clip NavRect accordingly (#2221, #8816)
|
|
|
|
+ ImRect nav_bb = g.LastItemData.NavRect;
|
|
if (window->DC.NavIsScrollPushableX == false)
|
|
if (window->DC.NavIsScrollPushableX == false)
|
|
{
|
|
{
|
|
- g.LastItemData.NavRect.Min.x = ImClamp(g.LastItemData.NavRect.Min.x, window->ClipRect.Min.x, window->ClipRect.Max.x);
|
|
|
|
- g.LastItemData.NavRect.Max.x = ImClamp(g.LastItemData.NavRect.Max.x, window->ClipRect.Min.x, window->ClipRect.Max.x);
|
|
|
|
|
|
+ nav_bb.Min.x = ImClamp(nav_bb.Min.x, window->ClipRect.Min.x, window->ClipRect.Max.x);
|
|
|
|
+ nav_bb.Max.x = ImClamp(nav_bb.Max.x, window->ClipRect.Min.x, window->ClipRect.Max.x);
|
|
}
|
|
}
|
|
- const ImRect nav_bb = g.LastItemData.NavRect;
|
|
|
|
|
|
|
|
// Process Init Request
|
|
// Process Init Request
|
|
if (g.NavInitRequest && g.NavLayer == window->DC.NavLayerCurrent && (item_flags & ImGuiItemFlags_Disabled) == 0)
|
|
if (g.NavInitRequest && g.NavLayer == window->DC.NavLayerCurrent && (item_flags & ImGuiItemFlags_Disabled) == 0)
|
|
@@ -13776,14 +13778,14 @@ static void ImGui::NavProcessItem()
|
|
else if (g.NavId != id || (g.NavMoveFlags & ImGuiNavMoveFlags_AllowCurrentNavId))
|
|
else if (g.NavId != id || (g.NavMoveFlags & ImGuiNavMoveFlags_AllowCurrentNavId))
|
|
{
|
|
{
|
|
ImGuiNavItemData* result = (window == g.NavWindow) ? &g.NavMoveResultLocal : &g.NavMoveResultOther;
|
|
ImGuiNavItemData* result = (window == g.NavWindow) ? &g.NavMoveResultLocal : &g.NavMoveResultOther;
|
|
- if (NavScoreItem(result))
|
|
|
|
|
|
+ if (NavScoreItem(result, nav_bb))
|
|
NavApplyItemToResult(result);
|
|
NavApplyItemToResult(result);
|
|
|
|
|
|
// Features like PageUp/PageDown need to maintain a separate score for the visible set of items.
|
|
// Features like PageUp/PageDown need to maintain a separate score for the visible set of items.
|
|
const float VISIBLE_RATIO = 0.70f;
|
|
const float VISIBLE_RATIO = 0.70f;
|
|
if ((g.NavMoveFlags & ImGuiNavMoveFlags_AlsoScoreVisibleSet) && window->ClipRect.Overlaps(nav_bb))
|
|
if ((g.NavMoveFlags & ImGuiNavMoveFlags_AlsoScoreVisibleSet) && window->ClipRect.Overlaps(nav_bb))
|
|
if (ImClamp(nav_bb.Max.y, window->ClipRect.Min.y, window->ClipRect.Max.y) - ImClamp(nav_bb.Min.y, window->ClipRect.Min.y, window->ClipRect.Max.y) >= (nav_bb.Max.y - nav_bb.Min.y) * VISIBLE_RATIO)
|
|
if (ImClamp(nav_bb.Max.y, window->ClipRect.Min.y, window->ClipRect.Max.y) - ImClamp(nav_bb.Min.y, window->ClipRect.Min.y, window->ClipRect.Max.y) >= (nav_bb.Max.y - nav_bb.Min.y) * VISIBLE_RATIO)
|
|
- if (NavScoreItem(&g.NavMoveResultLocalVisible))
|
|
|
|
|
|
+ if (NavScoreItem(&g.NavMoveResultLocalVisible, nav_bb))
|
|
NavApplyItemToResult(&g.NavMoveResultLocalVisible);
|
|
NavApplyItemToResult(&g.NavMoveResultLocalVisible);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -14447,6 +14449,7 @@ void ImGui::NavUpdateCreateMoveRequest()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Prepare scoring rectangle.
|
|
// For scoring we use a single segment on the left side our current item bounding box (not touching the edge to avoid box overlap with zero-spaced items)
|
|
// For scoring we use a single segment on the left side our current item bounding box (not touching the edge to avoid box overlap with zero-spaced items)
|
|
ImRect scoring_rect;
|
|
ImRect scoring_rect;
|
|
if (window != NULL)
|
|
if (window != NULL)
|
|
@@ -14860,6 +14863,7 @@ static void ImGui::NavUpdateWindowingApplyFocus(ImGuiWindow* apply_focus_window)
|
|
SetNavCursorVisibleAfterMove();
|
|
SetNavCursorVisibleAfterMove();
|
|
ClosePopupsOverWindow(apply_focus_window, false);
|
|
ClosePopupsOverWindow(apply_focus_window, false);
|
|
FocusWindow(apply_focus_window, ImGuiFocusRequestFlags_RestoreFocusedChild);
|
|
FocusWindow(apply_focus_window, ImGuiFocusRequestFlags_RestoreFocusedChild);
|
|
|
|
+ IM_ASSERT(g.NavWindow != NULL);
|
|
apply_focus_window = g.NavWindow;
|
|
apply_focus_window = g.NavWindow;
|
|
if (apply_focus_window->NavLastIds[0] == 0)
|
|
if (apply_focus_window->NavLastIds[0] == 0)
|
|
NavInitWindow(apply_focus_window, false);
|
|
NavInitWindow(apply_focus_window, false);
|