-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenu.pde
More file actions
63 lines (61 loc) · 1.25 KB
/
Menu.pde
File metadata and controls
63 lines (61 loc) · 1.25 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import java.util.LinkedList;
class Menu{
public Menu(int w, int h){
buttons = new LinkedList<Button>();
this.x= 0;
this.y = 0;
this.w = w;
this.h = h;
hide();
}
void hide(){
visible = false;
// unhighlight();
}
public void unhighlight(){
for(Button b : buttons)
b.setHighlight(false);
}
void open(){
visible = true;
}
boolean isOpen(){
return visible;
}
void setPosition(int x,int y){
this.x = x;
this.y = y;
int i = 0;
for(Button b : buttons){ //update button position
b.setX(x);
b.setY(y+(h*i++));
}
}
void addButton(String label, LabelInterface labelInterface){
int count = buttons.size();
Button b = new Button(x,y+(h*count),w,h, label, 18);
b.setInterface(labelInterface);
buttons.addLast(b);
buttons.getLast().setRGB(red,green,blue);
}
Button getIntersectingButton(float x, float y){
if(isOpen()){
for(Button b : buttons){
if(b.intersects(x,y)){
return b; //return vertex
}
}
}
return null;
}
void draw(){
if(isOpen()){
for(Button b : buttons){
b.draw();
}
}
}
int x,y, w,h;
LinkedList<Button> buttons;
boolean visible;
}