-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathevents.h
55 lines (38 loc) · 910 Bytes
/
events.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
#ifndef _EVENTS_H_
#define _EVENTS_H_
// this file is shared between trackball C code and other C++ files.
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
MOUSE_BUTTON_LEFT,
MOUSE_BUTTON_RIGHT,
MOUSE_BUTTON_MIDDLE
} MouseButton;
typedef enum {
MOUSE_STATE_DOWN,
MOUSE_STATE_UP,
MOUSE_STATE_DOUBLE
} MouseState;
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
#include "observable.h"
#include <vector>
using namespace std;
namespace Renzoku {
class IMouseObserver {
public:
virtual void on_click(MouseButton button, MouseState state, int x, int y) = 0;
};
class MouseObservable : public Observable<IMouseObserver> {
public:
void notify_click(MouseButton button, MouseState state, int x, int y) {
for (int i = 0; i < observers.size(); ++i)
observers[i]->on_click(button, state, x, y);
}
};
} // end namespace
#endif
#endif