GUI: improvements to inertial scrolling
This commit is contained in:
parent
1ac507a39f
commit
855fbfce1b
|
@ -6896,13 +6896,17 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||
|
||||
// Inertial scroll
|
||||
if (g.IO.ConfigFlags & ImGuiConfigFlags_InertialScrollEnable) {
|
||||
if (g.HoveredWindow == window) {
|
||||
if (g.IO.MouseClicked[ImGuiMouseButton_Left] && (g.NavWindowingTarget ? g.NavWindowingTarget : g.NavWindow) == window) {
|
||||
g.InertialScrollId = window->ID;
|
||||
printf("changing the ID to %d\n",window->ID);
|
||||
}
|
||||
if ((g.NavWindowingTarget ? g.NavWindowingTarget : g.NavWindow) == window) {
|
||||
if (g.IO.MouseDown[ImGuiMouseButton_Left] || g.IO.MouseReleased[ImGuiMouseButton_Left]) {
|
||||
// launch inertial scroll
|
||||
if (g.IO.MouseClicked[ImGuiMouseButton_Left]) {
|
||||
g.HoveredWindow->InertialScrollSpeed=ImVec2(0.0f,0.0f);
|
||||
window->InertialScrollSpeed=ImVec2(0.0f,0.0f);
|
||||
} else {
|
||||
g.HoveredWindow->InertialScrollSpeed=ImVec2(-g.IO.MouseDelta.x,-g.IO.MouseDelta.y);
|
||||
window->InertialScrollSpeed=ImVec2(window->ScrollbarX?-g.IO.MouseDelta.x:0.0f,window->ScrollbarY?-g.IO.MouseDelta.y:0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1817,6 +1817,7 @@ struct ImGuiContext
|
|||
ImGuiWindow* WheelingWindow; // Track the window we started mouse-wheeling on. Until a timer elapse or mouse has moved, generally keep scrolling the same window even if during the course of scrolling the mouse ends up hovering a child window.
|
||||
ImVec2 WheelingWindowRefMousePos;
|
||||
float WheelingWindowTimer;
|
||||
ImGuiID InertialScrollId; // The last window in where to apply inertial scroll
|
||||
|
||||
// Item/widgets state and tracking information
|
||||
ImGuiID DebugHookIdInfo; // Will call core hooks: DebugHookIdInfo() from GetID functions, used by Stack Tool [next HoveredId/ActiveId to not pull in an extra cache-line]
|
||||
|
|
Loading…
Reference in New Issue