forked from yangsu/Synaptic-Wall
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Interactive.pde
52 lines (39 loc) · 1.03 KB
/
Interactive.pde
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
public abstract class Interactive extends Drawable {
protected boolean fSelected;
protected boolean fHover;
public Interactive() {
super();
}
public Interactive(float x, float y) {
super(x, y);
}
public Interactive(float x, float y, color cc) {
super(x, y, cc);
}
protected abstract boolean isInBounds(float x, float y);
public boolean onMouseDown(float x, float y) {
return fVisible && (fSelected = isInBounds(x, y));
}
public boolean onMouseMoved(float x, float y) {
return fVisible && (fHover = isInBounds(x,y));
}
public boolean onMouseDragged(float x, float y) {
return fVisible && isInBounds(x,y);
}
public boolean onMouseUp(float x, float y) {
return false;
}
public boolean onDblClick(float x, float y) {
return false;
}
public boolean onSmoothToggle(boolean smooth) {
return false;
}
public boolean select(float x, float y) {
return (fSelected = isInBounds(x, y));
}
public void deselect() {
fSelected = false;
}
public void remove() {}
}