Cogs.Core
Classes | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
Cogs::Gestures Class Reference

Classes

struct  PointerState
 

Public Member Functions

void update ()
 
void setDisplayScale (float scale)
 
void pointerDown (PointerType pointerType, PointerId pointerId, MouseButton button, glm::ivec2 position, double timestamp_ms)
 
void pointerUp (PointerType pointerType, PointerId pointerId, MouseButton button, glm::ivec2 position, double timestamp_ms)
 
void pointerMove (PointerType pointerType, PointerId pointerId, glm::ivec2 position, double timestamp_ms)
 
void mouseWheelMove (int32_t delta)
 
void reset ()
 
PointerType getPointerType ()
 Get the type of pointer that was last registered.
 
const std::vector< Gesture > & getGestures () const
 Return all gestures recognised in the previous frame. Use id to differentiate between gestures.
 

Public Attributes

bool hoverEnable = true
 Allow/disallow hover gesture.
 
bool wheelEnable = true
 Allow/disallow mouse wheel gesture.
 
bool tapEnable = true
 Allow/disallow tap gesture.
 
bool doubleTapEnable = true
 Allow/disallow double tap gesture.
 
bool pressEnable = true
 Allow/disallow press gesture.
 
bool dragEnable = true
 Allow/disallow drag gesture.
 
bool swipeEnable = true
 Allow/disallow swipe gesture.
 
bool panEnable = true
 Allow/disallow pan gesture.
 
bool rotateEnable = true
 Allow/disallow rotate gesture.
 
bool pinchEnable = true
 Allow/disallow pinch gesture.
 
uint32_t tapMaxDuration = 250
 Millisecond threshold between classifying a press as a press or a tap.
 
uint32_t doubleTapTreshold = 300
 Number of milliseconds between taps to be classified as a single double tap event.
 
uint32_t swipeMaxDuration = 200
 Millisecond threshold between classifying a drag as a drag or a swipe.
 
float mouseMoveThreshold = 1.f
 Mouse pixel movement threshold before classifying move-based gestures.
 
float touchMoveThreshold = 16.f
 Touch pixel movement threshold before classifying move-based gestures.
 
float touchVelocityThreshold = 500.f
 Touch movement threshold between a swipe or a drag, in pixels/s.
 
float mouseVelocityThreshold = 100.f
 Mouse movement threshold between a swipe or a drag, in pixels/s.
 
float rotateThreshold = 0.05f
 Threshold in radians before classifying a gesture as a rotation.
 
float pinchThreshold = 0.1f
 Threshold of relative change before classifying a gesture as a pinch.
 

Private Member Functions

uint32_t nextGestureId ()
 
void endUpdatingGesture (std::optional< Gesture > &gesture, Gesture::State state)
 

Private Attributes

float displayScale = 1.0f
 
PointerType currPointerType = PointerType::Unknown
 
std::vector< GesturepresentedGestures
 
std::vector< GesturecurrentGestures
 
double lastTapTimestamp = 0
 
std::optional< GesturecurrPress = std::nullopt
 
std::optional< GesturecurrDrag = std::nullopt
 
std::optional< GesturecurrPan = std::nullopt
 
std::optional< GesturecurrRotate = std::nullopt
 
std::optional< GesturecurrPinch = std::nullopt
 
std::unordered_map< PointerId, PointerStatecurrentPointers
 Set of currently active pointers.
 
uint32_t idCounter = 0
 

Detailed Description

Definition at line 126 of file Gestures.h.

Constructor & Destructor Documentation

◆ Gestures()

Cogs::Gestures::Gestures ( )

Definition at line 13 of file Gestures.cpp.

Member Function Documentation

◆ endUpdatingGesture()

void Cogs::Gestures::endUpdatingGesture ( std::optional< Gesture > &  gesture,
Gesture::State  state 
)
private

Definition at line 350 of file Gestures.cpp.

◆ getGestures()

const std::vector< Gesture > & Cogs::Gestures::getGestures ( ) const
inline

Return all gestures recognised in the previous frame. Use id to differentiate between gestures.

Definition at line 166 of file Gestures.h.

◆ getPointerType()

Cogs::PointerType Cogs::Gestures::getPointerType ( )

Get the type of pointer that was last registered.

Definition at line 362 of file Gestures.cpp.

◆ mouseWheelMove()

void Cogs::Gestures::mouseWheelMove ( int32_t  delta)

Definition at line 337 of file Gestures.cpp.

◆ nextGestureId()

uint32_t Cogs::Gestures::nextGestureId ( )
inlineprivate

Definition at line 212 of file Gestures.h.

◆ pointerDown()

void Cogs::Gestures::pointerDown ( PointerType  pointerType,
PointerId  pointerId,
MouseButton  button,
glm::ivec2  position,
double  timestamp_ms 
)

Definition at line 35 of file Gestures.cpp.

◆ pointerMove()

void Cogs::Gestures::pointerMove ( PointerType  pointerType,
PointerId  pointerId,
glm::ivec2  position,
double  timestamp_ms 
)

Definition at line 216 of file Gestures.cpp.

◆ pointerUp()

void Cogs::Gestures::pointerUp ( PointerType  pointerType,
PointerId  pointerId,
MouseButton  button,
glm::ivec2  position,
double  timestamp_ms 
)

Definition at line 115 of file Gestures.cpp.

◆ reset()

void Cogs::Gestures::reset ( )

Definition at line 346 of file Gestures.cpp.

◆ setDisplayScale()

void Cogs::Gestures::setDisplayScale ( float  scale)
inline

Definition at line 154 of file Gestures.h.

◆ update()

void Cogs::Gestures::update ( )

Definition at line 19 of file Gestures.cpp.

Member Data Documentation

◆ currDrag

std::optional<Gesture> Cogs::Gestures::currDrag = std::nullopt
private

Definition at line 180 of file Gestures.h.

◆ currentGestures

std::vector<Gesture> Cogs::Gestures::currentGestures
private

Definition at line 174 of file Gestures.h.

◆ currentPointers

std::unordered_map<PointerId, PointerState> Cogs::Gestures::currentPointers
private

Set of currently active pointers.

Definition at line 209 of file Gestures.h.

◆ currPan

std::optional<Gesture> Cogs::Gestures::currPan = std::nullopt
private

Definition at line 181 of file Gestures.h.

◆ currPinch

std::optional<Gesture> Cogs::Gestures::currPinch = std::nullopt
private

Definition at line 183 of file Gestures.h.

◆ currPointerType

PointerType Cogs::Gestures::currPointerType = PointerType::Unknown
private

Definition at line 171 of file Gestures.h.

◆ currPress

std::optional<Gesture> Cogs::Gestures::currPress = std::nullopt
private

Definition at line 179 of file Gestures.h.

◆ currRotate

std::optional<Gesture> Cogs::Gestures::currRotate = std::nullopt
private

Definition at line 182 of file Gestures.h.

◆ displayScale

float Cogs::Gestures::displayScale = 1.0f
private

Definition at line 169 of file Gestures.h.

◆ doubleTapEnable

bool Cogs::Gestures::doubleTapEnable = true

Allow/disallow double tap gesture.

Definition at line 133 of file Gestures.h.

◆ doubleTapTreshold

uint32_t Cogs::Gestures::doubleTapTreshold = 300

Number of milliseconds between taps to be classified as a single double tap event.

Definition at line 143 of file Gestures.h.

◆ dragEnable

bool Cogs::Gestures::dragEnable = true

Allow/disallow drag gesture.

Definition at line 135 of file Gestures.h.

◆ hoverEnable

bool Cogs::Gestures::hoverEnable = true

Allow/disallow hover gesture.

Definition at line 130 of file Gestures.h.

◆ idCounter

uint32_t Cogs::Gestures::idCounter = 0
private

Definition at line 211 of file Gestures.h.

◆ lastTapTimestamp

double Cogs::Gestures::lastTapTimestamp = 0
private

Definition at line 177 of file Gestures.h.

◆ mouseMoveThreshold

float Cogs::Gestures::mouseMoveThreshold = 1.f

Mouse pixel movement threshold before classifying move-based gestures.

Definition at line 145 of file Gestures.h.

◆ mouseVelocityThreshold

float Cogs::Gestures::mouseVelocityThreshold = 100.f

Mouse movement threshold between a swipe or a drag, in pixels/s.

Touch duration is also a factor, see swipeMaxDuration.

Definition at line 148 of file Gestures.h.

◆ panEnable

bool Cogs::Gestures::panEnable = true

Allow/disallow pan gesture.

Definition at line 137 of file Gestures.h.

◆ pinchEnable

bool Cogs::Gestures::pinchEnable = true

Allow/disallow pinch gesture.

Definition at line 139 of file Gestures.h.

◆ pinchThreshold

float Cogs::Gestures::pinchThreshold = 0.1f

Threshold of relative change before classifying a gesture as a pinch.

Definition at line 150 of file Gestures.h.

◆ presentedGestures

std::vector<Gesture> Cogs::Gestures::presentedGestures
private

Definition at line 173 of file Gestures.h.

◆ pressEnable

bool Cogs::Gestures::pressEnable = true

Allow/disallow press gesture.

Definition at line 134 of file Gestures.h.

◆ rotateEnable

bool Cogs::Gestures::rotateEnable = true

Allow/disallow rotate gesture.

Definition at line 138 of file Gestures.h.

◆ rotateThreshold

float Cogs::Gestures::rotateThreshold = 0.05f

Threshold in radians before classifying a gesture as a rotation.

Definition at line 149 of file Gestures.h.

◆ swipeEnable

bool Cogs::Gestures::swipeEnable = true

Allow/disallow swipe gesture.

Definition at line 136 of file Gestures.h.

◆ swipeMaxDuration

uint32_t Cogs::Gestures::swipeMaxDuration = 200

Millisecond threshold between classifying a drag as a drag or a swipe.

Pointer speed is also a factor, see mouseVelocityThreshold and touchVelocityThreshold.

Definition at line 144 of file Gestures.h.

◆ tapEnable

bool Cogs::Gestures::tapEnable = true

Allow/disallow tap gesture.

Definition at line 132 of file Gestures.h.

◆ tapMaxDuration

uint32_t Cogs::Gestures::tapMaxDuration = 250

Millisecond threshold between classifying a press as a press or a tap.

Definition at line 142 of file Gestures.h.

◆ touchMoveThreshold

float Cogs::Gestures::touchMoveThreshold = 16.f

Touch pixel movement threshold before classifying move-based gestures.

Definition at line 146 of file Gestures.h.

◆ touchVelocityThreshold

float Cogs::Gestures::touchVelocityThreshold = 500.f

Touch movement threshold between a swipe or a drag, in pixels/s.

Touch duration is also a factor, see swipeMaxDuration.

Definition at line 147 of file Gestures.h.

◆ wheelEnable

bool Cogs::Gestures::wheelEnable = true

Allow/disallow mouse wheel gesture.

Definition at line 131 of file Gestures.h.


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