mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Nav: No scrolling while using windowing functionalities (#323)
This commit is contained in:
parent
a88d189f18
commit
769a1dd748
12
imgui.cpp
12
imgui.cpp
@ -2549,23 +2549,23 @@ static void NavUpdate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Scrolling
|
// Scrolling
|
||||||
if (g.FocusedWindow && !(g.FocusedWindow->Flags & ImGuiWindowFlags_NoNavInputs))
|
if (g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs) && !g.NavWindowingTarget)
|
||||||
{
|
{
|
||||||
// Fallback manual-scroll with NavUp/NavDown when window has no navigable item
|
// Fallback manual-scroll with NavUp/NavDown when window has no navigable item
|
||||||
const float scroll_speed = ImFloor(g.FocusedWindow->CalcFontSize() * 100 * g.IO.DeltaTime + 0.5f); // We need round the scrolling speed because sub-pixel scroll isn't reliably supported.
|
const float scroll_speed = ImFloor(g.NavWindow->CalcFontSize() * 100 * g.IO.DeltaTime + 0.5f); // We need round the scrolling speed because sub-pixel scroll isn't reliably supported.
|
||||||
if (!g.FocusedWindow->DC.NavLayerActiveFlags && g.FocusedWindow->DC.NavHasScroll && g.NavMoveRequest && (g.NavMoveDir == ImGuiNavDir_Up || g.NavMoveDir == ImGuiNavDir_Down))
|
if (!g.NavWindow->DC.NavLayerActiveFlags && g.NavWindow->DC.NavHasScroll && g.NavMoveRequest && (g.NavMoveDir == ImGuiNavDir_Up || g.NavMoveDir == ImGuiNavDir_Down))
|
||||||
SetWindowScrollY(g.FocusedWindow, ImFloor(g.FocusedWindow->Scroll.y + ((g.NavMoveDir == ImGuiNavDir_Up) ? -1.0f : +1.0f) * scroll_speed));
|
SetWindowScrollY(g.NavWindow, ImFloor(g.NavWindow->Scroll.y + ((g.NavMoveDir == ImGuiNavDir_Up) ? -1.0f : +1.0f) * scroll_speed));
|
||||||
|
|
||||||
// Manual scroll with NavScrollXXX keys
|
// Manual scroll with NavScrollXXX keys
|
||||||
ImVec2 scroll_dir = ImGui::NavGetMovingDir(1, 1.0f/10.0f, 10.0f);
|
ImVec2 scroll_dir = ImGui::NavGetMovingDir(1, 1.0f/10.0f, 10.0f);
|
||||||
if (scroll_dir.x != 0.0f && g.NavWindow->ScrollbarX)
|
if (scroll_dir.x != 0.0f && g.NavWindow->ScrollbarX)
|
||||||
{
|
{
|
||||||
SetWindowScrollX(g.FocusedWindow, ImFloor(g.FocusedWindow->Scroll.x + scroll_dir.x * scroll_speed));
|
SetWindowScrollX(g.NavWindow, ImFloor(g.NavWindow->Scroll.x + scroll_dir.x * scroll_speed));
|
||||||
g.NavMoveFromClampedRefRect = true;
|
g.NavMoveFromClampedRefRect = true;
|
||||||
}
|
}
|
||||||
if (scroll_dir.y != 0.0f)
|
if (scroll_dir.y != 0.0f)
|
||||||
{
|
{
|
||||||
SetWindowScrollY(g.FocusedWindow, ImFloor(g.FocusedWindow->Scroll.y + scroll_dir.y * scroll_speed));
|
SetWindowScrollY(g.NavWindow, ImFloor(g.NavWindow->Scroll.y + scroll_dir.y * scroll_speed));
|
||||||
g.NavMoveFromClampedRefRect = true;
|
g.NavMoveFromClampedRefRect = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user