Aurore
A Switch-like interface for your app, on every screen
Loading...
Searching...
No Matches
tap_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
20
21namespace aurore
22{
23
40
42{
43 GestureState state; // Gesture state
44 Point position; // Current position
45};
47
48// Tap recognizer
49// UNSURE: while touch moves inside of View bounds
50// START: unsupported
51// MOVE: unsupported
52// END: touch released inside View's bounds
53// FAILED: touch moved outside View's bounds
55{
56 public:
57 // Simple ctor which uses View's primary action as response which will be called only on recognizer state END.
59
60 // Simple ctor with custom response which will be called only on recognizer state END.
61 TapGestureRecognizer(View* view, std::function<void()> respond, TapGestureConfig config = TapGestureConfig());
62
63 // Complex ctor with fully controllable response.
65
66 GestureState recognitionLoop(TouchState touch, MouseState mouse, View* view, Sound* soundToPlay) override;
67
68 // Get current state of recognizer
70
71 // Get tap gesture event
72 TapGestureEvent getTapGestureEvent() const { return tapEvent; }
73
74 void setForceRecognision(bool forceRecognision)
75 {
76 this->forceRecognision = forceRecognision;
77 }
78
79 private:
80 TapGestureEvent tapEvent;
81 Point position {};
82 GestureState lastState {};
83 bool forceRecognision {};
84};
85
86} // namespace aurore
Definition event.hpp:41
std::function< void(Ts...)> Callback
Definition event.hpp:43
Definition gesture.hpp:68
Definition tap_gesture.hpp:55
void setForceRecognision(bool forceRecognision)
Definition tap_gesture.hpp:74
GestureState recognitionLoop(TouchState touch, MouseState mouse, View *view, Sound *soundToPlay) override
TapGestureRecognizer(View *view, TapGestureConfig config=TapGestureConfig())
TapGestureEvent getTapGestureEvent() const
Definition tap_gesture.hpp:72
TapGestureRecognizer(View *view, std::function< void()> respond, TapGestureConfig config=TapGestureConfig())
TapGestureRecognizer(TapGestureEvent::Callback respond)
TapGestureStatus getCurrentStatus()
Definition view.hpp:232
Definition actions.hpp:25
Event< TapGestureStatus, Sound * > TapGestureEvent
Definition tap_gesture.hpp:46
Sound
Definition audio.hpp:23
@ SOUND_CLICK
Definition audio.hpp:28
@ SOUND_FOCUS_CHANGE
Definition audio.hpp:26
@ SOUND_TOUCH_UNFOCUS
Definition audio.hpp:34
GestureState
Definition gesture.hpp:30
Definition input.hpp:321
Definition geometry.hpp:26
Definition tap_gesture.hpp:25
Sound failedSound
Definition tap_gesture.hpp:28
Sound unsureSound
Definition tap_gesture.hpp:27
TapGestureConfig(bool highlightOnSelect, Sound unsureSound, Sound failedSound, Sound endSound)
Definition tap_gesture.hpp:32
Sound endSound
Definition tap_gesture.hpp:29
TapGestureConfig()
Definition tap_gesture.hpp:31
bool highlightOnSelect
Definition tap_gesture.hpp:26
Definition tap_gesture.hpp:42
Point position
Definition tap_gesture.hpp:44
GestureState state
Definition tap_gesture.hpp:43
Definition input.hpp:277