-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButtonContainer.pde
More file actions
39 lines (34 loc) · 907 Bytes
/
ButtonContainer.pde
File metadata and controls
39 lines (34 loc) · 907 Bytes
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
class ButtonContainer {
int x;
int y;
ArrayList<Button> buttons;
ButtonContainer(ArrayList<Button> buttons,int x, int y) {
this.x = x;
this.y = y;
this.buttons = new ArrayList<Button>();
for (int i = 0; i < buttons.size(); i++) {
Button button = buttons.get(i);
float buttonX = (i == 0 ? x : buttons.get(i - 1).getMaxX());
button.move(buttonX, y);
this.buttons.add(button);
}
}
ButtonContainer(int x, int y) {
this.x = x;
this.y = y;
this.buttons = new ArrayList<Button>();
}
void add(Button button) {
int size = buttons.size();
float buttonX = (size == 0 ? x : buttons.get(size - 1).getMaxX());
button.move(buttonX, y);
this.buttons.add(button);
}
void show() {
this.buttons.forEach((button) -> button.show());
}
void click() {
for (Button button : this.buttons)
button.onClick();
}
}