MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ drag_to_offset_delta()

MAYAFLUX_API glm::vec2 MayaFlux::Kinesis::drag_to_offset_delta ( glm::vec2  pixel_delta,
glm::vec2  visible_extent,
glm::vec2  viewport_size_pixels 
)
noexcept

Convert a pixel-space drag delta into a content-space delta.

Scales the fraction of the viewport a pointer moved by the content extent currently visible, so drag speed stays proportionate to scale: more content in view moves the result further per pixel than less. No sign convention is imposed; a caller applies whatever sign its own semantics need (a grabbed canvas moves opposite the drag, a dragged scrollbar thumb moves with it).

Shared by PanZoom2DState::apply_pan_zoom_pan and any CPU-side drag scroll: both are "drag the content by moving the viewport's frame over it," differing only in what consumes the result (a GPU ViewTransform versus a CPU layout offset).

Parameters
pixel_deltaPixel-space delta.
visible_extentCurrently visible content extent (width, height), same units as the return value.
viewport_size_pixelsViewport size in pixels the delta was measured against.

Definition at line 5 of file ScrollState.cpp.

9{
10 return (pixel_delta / viewport_size_pixels) * visible_extent;
11}

Referenced by apply_pan_zoom_pan().

+ Here is the caller graph for this function: