-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathButton.pde
46 lines (43 loc) · 1.43 KB
/
Button.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
class Button {
ArrayList<Shape> shapes = new ArrayList<Shape>();
String name, title;
PVector position, size;
PImage texture;
int anim_counter = 0;
ToolTip tool_tip;
Button(String _name, String _title, String[] ttt, PImage texture, PVector pos, PVector size) {
this.name = _name;
this.title = _title;
this.position = pos;
this.size = size;
this.texture = texture;
this.tool_tip = new ToolTip(ttt);
this.shapes.add(new Shape(new PVector[]{new PVector(0, 0), new PVector(40, 0), new PVector(40, 40), new PVector(0, 40)}));
}
void show() {
for (Shape shape : shapes) {
noFill();//fill(shape.fill);
noStroke();
beginShape();
for (PVector point : shape.points) {
vertex(this.position.x + point.x, this.position.y + point.y);
}
endShape(CLOSE);
updates[0] += 1;
updates[3] += 1;
}
image(this.texture, this.position.x, this.position.y, this.size.x, this.size.y);
fill(0);
textSize(14);
textAlign(CENTER, CENTER);
text(this.title, this.position.x+25, this.position.y+60);
updates[0] += 1;
updates[3] += 1;
if(mouseX > this.position.x && mouseX < this.position.x+this.size.x && mouseY > this.position.y && mouseY < this.position.y + this.size.y){
this.anim_counter--;
if(this.anim_counter < 0)this.tool_tip.show();
} else {
this.anim_counter = 40;
}
}
}