Aurore
A Switch-like interface for your app, on every screen
Loading...
Searching...
No Matches
long_press_gesture.hpp
Go to the documentation of this file.
1/*
2 Copyright 2026 JigSawFr
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 <functional>
21#include <aurore/core/time.hpp>
22
23namespace aurore
24{
25
26// Long press recognizer: a touch (or the mouse's left button) held still
27// on the view for `duration` ms. (The right button is B on desktop.)
28// UNSURE: while it is held, not long enough yet
29// START: held long enough: `respond` runs, and the other recognizers (the
30// tap under it, a scroll) are interrupted
31// END: released after START
32// FAILED: released too soon, or moved more than `slop` px away
34{
35 public:
36 LongPressGestureRecognizer(View* view, std::function<void()> respond, Time duration = 500, float slop = 16);
37
38 GestureState recognitionLoop(TouchState touch, MouseState mouse, View* view, Sound* soundToPlay) override;
39
40 private:
41 std::function<void()> respond;
42 Time duration;
43 float slop;
44
45 Time pressedAt = 0;
46 Point position;
47};
48
49} // namespace aurore
Definition gesture.hpp:68
Definition long_press_gesture.hpp:34
GestureState recognitionLoop(TouchState touch, MouseState mouse, View *view, Sound *soundToPlay) override
LongPressGestureRecognizer(View *view, std::function< void()> respond, Time duration=500, float slop=16)
Definition view.hpp:232
Definition actions.hpp:25
Sound
Definition audio.hpp:23
retro_time_t Time
Definition time.hpp:31
GestureState
Definition gesture.hpp:30
Definition input.hpp:321
Definition geometry.hpp:26
Definition input.hpp:277