MCPcopy Create free account
hub / github.com/DISTRHO/Cardinal / CalcScrollEdgeSnap

Function CalcScrollEdgeSnap

plugins/Cardinal/src/DearImGui/imgui.cpp:8178–8185  ·  view source on GitHub ↗

Helper to snap on edges when aiming at an item very close to the edge, So the difference between WindowPadding and ItemSpacing will be in the visible area after scrolling. When we refactor the scrolling API this may be configurable with a flag? Note that the effect for this won't be visible on X axis with default Style settings as WindowPadding.x == ItemSpacing.x by default.

Source from the content-addressed store, hash-verified

8176// When we refactor the scrolling API this may be configurable with a flag?
8177// Note that the effect for this won't be visible on X axis with default Style settings as WindowPadding.x == ItemSpacing.x by default.
8178static float CalcScrollEdgeSnap(float target, float snap_min, float snap_max, float snap_threshold, float center_ratio)
8179{
8180 if (target <= snap_min + snap_threshold)
8181 return ImLerp(snap_min, target, center_ratio);
8182 if (target >= snap_max - snap_threshold)
8183 return ImLerp(target, snap_max, center_ratio);
8184 return target;
8185}
8186
8187static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window)
8188{

Calls 1

ImLerpFunction · 0.85

Tested by

no test coverage detected