Snapper
touchgfx/mixins/Snapper.hpp
A mix-in that will make class T draggable and able to snap to a position when a drag operation has ended. The mix-in is able to perform callbacks when the snapper gets dragged and when the Snapper snaps to its snap position.
Template Parameters:
- T specifies the type to enable the Snap behavior to.
See: Draggable<T>
Inherits from: touchgfx::Draggable< T >, T
Public Functions
virtual void | handleClickEvent(const ClickEvent & event) |
Handles the click events when the Snapper is clicked. | |
virtual void | handleDragEvent(const DragEvent & event) |
Called when dragging the Draggable object. | |
void | setDragAction(GenericCallback< const DragEvent & > & callback) |
Associates an action to be performed when the Snapper is dragged. | |
void | setSnappedAction(GenericCallback<> & callback) |
Associates an action to be performed when the Snapper is snapped. | |
void | setSnapPosition(int16_t x, int16_t y) |
Sets the position the Snapper should snap to. | |
Snapper() | |
Additional inherited members
Public Functions inherited from touchgfx::Draggable< T >
Public Functions Documentation
handleClickEvent
virtual void handleClickEvent | ( | const ClickEvent & | event | ) | |
Handles the click events when the Snapper is clicked.
It saves its current position as the snap position if the Snapper is pressed. This happens when the drag operation starts.
The snapper will then move to the snap position when the click is released. This happens when the drag operation ends.
event | The click event. |
handleDragEvent
virtual void handleDragEvent | ( | const DragEvent & | event | ) | |
Called when dragging the Draggable object.
The object is moved according to the drag event.
event | The drag event. |
Reimplements: touchgfx::Draggable::handleDragEvent
setDragAction
void setDragAction | ( | GenericCallback< const DragEvent & > & | callback | ) | |
setSnappedAction
void setSnappedAction | ( | GenericCallback<> & | callback | ) | |
Associates an action to be performed when the Snapper is snapped.
callback | The callback to be executed on snap. |
setSnapPosition
void setSnapPosition | ( | int16_t | x , | ||
int16_t | y | ||||
) |
Snapper
Snapper | ( | ) |