mirror of
https://github.com/processing/processing4.git
synced 2026-02-11 01:29:17 +01:00
49 lines
719 B
Plaintext
49 lines
719 B
Plaintext
|
|
class Control {
|
|
int x,y,w,h;
|
|
boolean over = false;
|
|
String label;
|
|
|
|
Control(int x, int y, int w, int h, String label) {
|
|
this.x = x;
|
|
this.y = y;
|
|
this.w = w;
|
|
this.h = h;
|
|
this.label = label;
|
|
}
|
|
|
|
boolean mouseIn() {
|
|
return over = mouseX>x&&mouseX<x+w&&mouseY>y&&mouseY<y+h;
|
|
}
|
|
|
|
boolean mousePressed() {
|
|
return mouseIn();
|
|
}
|
|
|
|
void mouseDragged() {
|
|
mouseIn();
|
|
}
|
|
|
|
boolean mouseReleased() {
|
|
return mouseIn();
|
|
}
|
|
|
|
void display() {
|
|
stroke(0x00,0x99,0xFF);
|
|
if (over)
|
|
fill(0xDD,0xDD,0xDD);
|
|
else
|
|
fill(0xFF,0xFF,0xFF);
|
|
rect(x,y,w,h);
|
|
drawContents();
|
|
stroke(0);
|
|
fill(0);
|
|
text(label, x+2, (y+h)-3);
|
|
}
|
|
|
|
void drawContents() {
|
|
|
|
}
|
|
}
|
|
|