forked from SynapticWall/SynapticWall
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathControllableShape.pde
77 lines (67 loc) · 1.68 KB
/
ControllableShape.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
public abstract class ControllableShape extends Shape implements Controllable {
protected ArrayList<Control> fControls;
public ControllableShape() {
fControls = new ArrayList<Control>();
}
public ControllableShape(float x, float y, float size, color cc) {
super(x, y, size, cc);
fControls = new ArrayList<Control>();
}
public void showControls() {
for (Control c : fControls) {
c.setVisible(true);
}
}
public void hideControls() {
for (Control c : fControls) {
c.setVisible(false);
}
}
public void drawControls() {
for (Control c : fControls)
c.draw();
}
@Override
public boolean select(float x, float y) {
if (super.select(x, y)) {
this.showControls();
return true;
}
return false;
}
@Override
public void deselect() {
super.deselect();
this.hideControls();
}
public boolean onMouseDown(float x, float y) {
for (Control c : fControls) {
if (c.fVisible && c.onMouseDown(x, y))
return (fSelected = true);
}
return super.onMouseDown(x, y);
}
public boolean onMouseDragged(float x, float y) {
if (fSelected) {
for (Control c : fControls) {
if (c.fVisible && c.onMouseDragged(x, y))
return true;
}
}
return super.onMouseDragged(x, y);
}
public boolean onMouseMoved(float x, float y) {
for (Control c : fControls) {
if (c.fVisible && c.onMouseMoved(x, y))
return true;
}
return super.onMouseMoved(x, y);
}
public boolean onMouseUp(float x, float y) {
for (Control c : fControls) {
if (c.fVisible && c.onMouseUp(x, y))
return true;
}
return super.onMouseUp(x, y);
}
}