AUI Framework  master
Cross-platform module-based framework for developing C++20 desktop applications
ATouchScroller Class Reference

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

Detailed Description

Utility object that helps with touchscreen scroll events.

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

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. More...
 
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.
 

Member Function Documentation

◆ gatherKineticScrollValue()

AOptional< glm::ivec2 > ATouchScroller::gatherKineticScrollValue ( )
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)

Handles pointer move events.

Parameters
posposition of the event in relation to view that used ATouchScroller.
Returns
the amount of scroll in pixels.

#include <AUI/Util/ATouchScroller.h>


The documentation for this class was generated from the following files:
Collaboration diagram for ATouchScroller: