AUI Framework  develop
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
ATouchScroller Class Reference

Utility object that helps with touchscreen scroll events. More...

#include <AUI/Util/ATouchScroller.h>

Public Member Functions#

void handlePointerPressed (const APointerPressedEvent &e)
 Handles pointer pressed events.
 
void handlePointerReleased (const APointerReleasedEvent &e)
 Handles pointer released events.
 
glm::ivec2 handlePointerMove (glm::vec2 pos)
 Handles pointer move events.
 
glm::ivec2 origin () const noexcept
 
AOptional< glm::ivec2 > gatherKineticScrollValue ()
 

Static Public Member Functions#

static float deceleration ()
 

Static Public Attributes#

static constexpr float BASE_DECELERATION = 1600.f
 
static constexpr float INITIAL_ACCELERATION_COEFFICIENT = 60.f
 Initial acceleration after pointer released is defined by direction of pointer moving and this coefficient.
 
static constexpr AMetric THRESHOLD = 8_dp
 Distance that pointer have to pass in order to treat pointer move events as scroll events.
 

Detailed Description#

To use this class, you have to pass APointerPressedEvent APointerReleasedEvent to handlePointerPressed and handlePointerReleased methods accordingly. To receive scroll value, use handlePointerMove method.

Member Function Documentation#

◆ gatherKineticScrollValue()#

AOptional< glm::ivec2 > ATouchScroller::gatherKineticScrollValue ( )
nodiscard
Returns
std::nullopt if ATouchScroller is not in kinetic scroll state; value for kinetic scroll otherwise.

This method should be called every render frame in order to make continuous kinetic scroll.

◆ handlePointerMove()#

glm::ivec2 ATouchScroller::handlePointerMove ( glm::vec2 pos)
Parameters
posposition of the event in relation to view that used ATouchScroller.
Returns
the amount of scroll in pixels.