Aurore
A Switch-like interface for your app, on every screen
Loading...
Searching...
No Matches
pan_gesture.hpp
Go to the documentation of this file.
1/*
2 Copyright 2021 XITRIX
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17#pragma once
18
19#include <aurore/core/event.hpp>
21
22namespace aurore
23{
24
25// Contains info about acceleration on pan ends
27{
28 // distances in pixels
30
31 // times to cover the distance
33};
34
35// Current status of gesture
37{
38 GestureState state; // Gesture state
39 Point position; // Current position
40 Point startPosition; // Start X position
41 Point delta; // Difference between current and previous positions by X
42 bool deltaOnly = false; // If true, current state will contain delta values ONLY
43
44 // Acceleration info, NOT NULL ONLY from
45 // gesture callback and when current state is END
47};
48
50
51// Axis of pan recognition start conditions
52enum class PanAxis
53{
54 HORIZONTAL, // Triggers only on horizontal coordinate changes
55 VERTICAL, // Triggers only on vertical coordinate changes
56 ANY, // Any movement allowed
57};
58
59// Pan recognizer
60// UNSURE: while touch not moved enough to recognize it as pan
61// START: gesture has been recognized
62// MOVE: gesture in process
63// END: finger released, acceleration will be calculated
64// FAILED: unsupported
66{
67 public:
69 GestureState recognitionLoop(TouchState touch, MouseState mouse, View* view, Sound* soundToPlay) override;
70
71 // Get pan gesture axis
72 PanAxis getAxis() const { return this->axis; }
73
74 // Get current state of recognizer
76
77 // Get pan gesture event
78 PanGestureEvent getPanGestureEvent() const { return panEvent; }
79
80 static inline float panFactor { 1.0f };
81
82 private:
83 int lastFingerId = 0;
84 PanGestureEvent panEvent;
85 Point position;
86 Point startPosition;
87 Point delta;
88 PanAxis axis;
89 std::vector<Point> posHistory;
91};
92
93} // namespace aurore
Definition event.hpp:41
std::function< void(Ts...)> Callback
Definition event.hpp:43
Definition gesture.hpp:68
Definition pan_gesture.hpp:66
PanGestureEvent getPanGestureEvent() const
Definition pan_gesture.hpp:78
PanGestureRecognizer(PanGestureEvent::Callback respond, PanAxis axis)
static float panFactor
Definition pan_gesture.hpp:80
PanAxis getAxis() const
Definition pan_gesture.hpp:72
GestureState recognitionLoop(TouchState touch, MouseState mouse, View *view, Sound *soundToPlay) override
PanGestureStatus getCurrentStatus()
Definition view.hpp:232
Definition actions.hpp:25
PanAxis
Definition pan_gesture.hpp:53
Event< PanGestureStatus, Sound * > PanGestureEvent
Definition pan_gesture.hpp:49
Sound
Definition audio.hpp:23
GestureState
Definition gesture.hpp:30
Definition input.hpp:321
Definition pan_gesture.hpp:27
Point time
Definition pan_gesture.hpp:32
Point distance
Definition pan_gesture.hpp:29
Definition pan_gesture.hpp:37
Point position
Definition pan_gesture.hpp:39
bool deltaOnly
Definition pan_gesture.hpp:42
PanAcceleration acceleration
Definition pan_gesture.hpp:46
Point delta
Definition pan_gesture.hpp:41
Point startPosition
Definition pan_gesture.hpp:40
GestureState state
Definition pan_gesture.hpp:38
Definition geometry.hpp:26
Definition input.hpp:277