-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathButtonStep.pde
57 lines (45 loc) · 1.25 KB
/
ButtonStep.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
class ButtonStep extends Button {
int relativeValue;
int maxValue;
PShape shapeArrow;
ButtonStep(int x, int y, int w, int h, int relativeValue, int maxValue) {
super(x, y, w, h);
this.relativeValue = relativeValue;
this.maxValue = maxValue;
// Load left / right arrow
if (this.relativeValue <= 0) {
shapeArrow = loadShape("img/svg/arrow_left.svg");
} else {
shapeArrow = loadShape("img/svg/arrow_right.svg");
}
}
@Override
void onClick(boolean insideElement) {
if (insideElement) {
if (currStep + relativeValue >= 0 && currStep + relativeValue <= maxValue) {
currStep += relativeValue;
}
}
}
@Override
void draw() {
pushStyle();
if (this.isHovered) {
shapeArrow.disableStyle();
fill(color(colBright), 0.8);
}
if ((relativeValue < 0 && currStep == 0) || (relativeValue > 0 && currStep == maxValue)) {
shapeArrow.disableStyle();
fill(color(colBright), 0.2);
}
shapeMode(CENTER);
shape(shapeArrow, x + w/2, y + h/2);
if (this.isHovered) {
shapeArrow.enableStyle();
}
if ((relativeValue < 0 && currStep == 0) || (relativeValue > 0 && currStep == maxValue)) {
shapeArrow.enableStyle();
}
popStyle();
}
}