MCPcopy Create free account
hub / github.com/Overload-Technologies/Overload / FindBestWheelingWindow

Function FindBestWheelingWindow

Dependencies/ImGui/src/imgui.cpp:10885–10922  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10883}
10884
10885static ImGuiWindow* FindBestWheelingWindow(const ImVec2& wheel)
10886{
10887 // For each axis, find window in the hierarchy that may want to use scrolling
10888 ImGuiContext& g = *GImGui;
10889 ImGuiWindow* windows[2] = { NULL, NULL };
10890 for (int axis = 0; axis < 2; axis++)
10891 if (wheel[axis] != 0.0f)
10892 for (ImGuiWindow* window = windows[axis] = g.HoveredWindow; window->Flags & ImGuiWindowFlags_ChildWindow; window = windows[axis] = window->ParentWindow)
10893 {
10894 // Bubble up into parent window if:
10895 // - a child window doesn't allow any scrolling.
10896 // - a child window has the ImGuiWindowFlags_NoScrollWithMouse flag.
10897 //// - a child window doesn't need scrolling because it is already at the edge for the direction we are going in (FIXME-WIP)
10898 const bool has_scrolling = (window->ScrollMax[axis] != 0.0f);
10899 const bool inputs_disabled = (window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs);
10900 //const bool scrolling_past_limits = (wheel_v < 0.0f) ? (window->Scroll[axis] <= 0.0f) : (window->Scroll[axis] >= window->ScrollMax[axis]);
10901 if (has_scrolling && !inputs_disabled) // && !scrolling_past_limits)
10902 break; // select this window
10903 }
10904 if (windows[0] == NULL && windows[1] == NULL)
10905 return NULL;
10906
10907 // If there's only one window or only one axis then there's no ambiguity
10908 if (windows[0] == windows[1] || windows[0] == NULL || windows[1] == NULL)
10909 return windows[1] ? windows[1] : windows[0];
10910
10911 // If candidate are different windows we need to decide which one to prioritize
10912 // - First frame: only find a winner if one axis is zero.
10913 // - Subsequent frames: only find a winner when one is more than the other.
10914 if (g.WheelingWindowStartFrame == -1)
10915 g.WheelingWindowStartFrame = g.FrameCount;
10916 if ((g.WheelingWindowStartFrame == g.FrameCount && wheel.x != 0.0f && wheel.y != 0.0f) || (g.WheelingAxisAvg.x == g.WheelingAxisAvg.y))
10917 {
10918 g.WheelingWindowWheelRemainder = wheel;
10919 return NULL;
10920 }
10921 return (g.WheelingAxisAvg.x > g.WheelingAxisAvg.y) ? windows[0] : windows[1];
10922}
10923
10924// Called by NewFrame()
10925void ImGui::UpdateMouseWheel()

Callers 1

UpdateMouseWheelMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected