-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWidget.pde
More file actions
45 lines (41 loc) · 1.03 KB
/
Copy pathWidget.pde
File metadata and controls
45 lines (41 loc) · 1.03 KB
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
class Widget {
int x, y, width, height;
String label;
int event;
color widgetColor, hoverColor, labelColor;
PFont widgetFont;
boolean isHovering = false;
Widget(int x, int y, int width, int height, String label, color widgetColor, color hoverColor, PFont widgetFont, int event) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.label = label;
this.event = event;
this.widgetColor = widgetColor;
this.hoverColor = hoverColor;
this.widgetFont = widgetFont;
labelColor = color(0);
}
void draw() {
stroke(0);
if (isHovering) {
stroke(hoverColor) ;
}
fill(widgetColor);
rect(x, y, width, height);
textAlign(CENTER);
textSize(20);
fill(0);
text(label, x+250, y+height-10);
}
int getEvent(int mX, int mY) {
if (mX>x && mX < x+width && mY >y && mY <y+height) {
return event;
}
return EVENT_NULL;
}
void setColor(int newColor) {
widgetColor = newColor;
}
}