MCPcopy Create free account
hub / github.com/RenderKit/embree / CalcScrollEdgeSnap

Function CalcScrollEdgeSnap

tutorials/common/imgui/imgui.cpp:9443–9450  ·  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

9441// When we refactor the scrolling API this may be configurable with a flag?
9442// Note that the effect for this won't be visible on X axis with default Style settings as WindowPadding.x == ItemSpacing.x by default.
9443static float CalcScrollEdgeSnap(float target, float snap_min, float snap_max, float snap_threshold, float center_ratio)
9444{
9445 if (target <= snap_min + snap_threshold)
9446 return ImLerp(snap_min, target, center_ratio);
9447 if (target >= snap_max - snap_threshold)
9448 return ImLerp(target, snap_max, center_ratio);
9449 return target;
9450}
9451
9452static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window)
9453{

Calls 1

ImLerpFunction · 0.85

Tested by

no test coverage detected