-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathGestureAdapter.h
60 lines (46 loc) · 1.37 KB
/
GestureAdapter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#pragma once
#include <memory>
#include "MouseAdapter.h"
#include "PipedEventAdapter.h"
class GestureAdapter {
public:
enum class GestureEventType {
Move = 0,
Drag = 1,
Scroll = 2,
};
enum class GesturePointer {
Primary = 1,
Secondary = 2,
Tertiary = 4,
PrimaryDouble = 3,
};
class GestureEvent {
public:
GestureEvent() {}
GestureEvent(GestureEventType type): type(type) {}
GestureEventType getType() {return type;}
void setType(GestureEventType type) {this->type = type;}
GesturePointer pointer;
Core::Vector2i start;
Core::Vector2i end;
Core::Real scrollDistance;
private:
GestureEventType type;
};
GestureAdapter();
void setMouseAdapter(MouseAdapter& mouseAdapter);
bool setPipedEventAdapter(Core::WeakPointer<PipedEventAdapter<GestureEvent>> adapter);
private:
static const unsigned int MAX_POINTERS = 5;
class PointerState {
public:
bool active = false;
Core::Vector2i startPosition;
Core::Vector2i position;
};
void onMouseEvent(MouseAdapter::MouseEvent event);
std::shared_ptr<PipedEventAdapter<MouseAdapter::MouseEvent>> mouseEventAdapter;
PointerState pointerStates[MAX_POINTERS];
Core::WeakPointer<PipedEventAdapter<GestureEvent>> pipedEventAdapter;
};