-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUIComponent.pde
93 lines (69 loc) · 2.32 KB
/
UIComponent.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
* Copyright (c) 2010 The Jackson Laboratory
*
* This software was developed by Matt Hibbs' Lab at The Jackson
* Laboratory (see http://cbfg.jax.org/).
*
* This is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software. If not, see <http://www.gnu.org/licenses/>.
*/
abstract class UIComponent {
boolean active = true, focus = true;
float x = 0.0, y = 0.0, cWidth = 0.0, cHeight = 0.0;
UIComponent(float newX, float newY, float newWidth, float newHeight) {
x = newX;
y = newY;
cWidth = newWidth;
cHeight = newHeight;
}
UIComponent() { }
void mouseAction() { }
void update() { } // override this
void updateComponents() { }
void keyAction(char k, int code, int mods) { }
void addComponent(UIComponent c, int index, int index2) { }
void removeComponent(int index1, int index2) { }
abstract int size();
String toString() { return ""; }
void pan(PVector vec) { }
void panStart(int userId) { }
void panEnd(int userId) { }
void zoom(PVector vec) { }
}
abstract class UIComponentContainer extends UIComponent {
ArrayList<UIComponent> components;
UIComponentContainer() {
components = new ArrayList<UIComponent>();
}
int size() {
return components.size();
}
boolean add(UIComponent newComponent) {
return components.add(newComponent);
}
UIComponent remove(int index) {
return components.remove(index);
}
void add(int index, UIComponent newComponent) {
components.add(index, newComponent);
}
UIComponent get(int index) {
return components.get(index);
}
}
interface UIAction {
public void doAction();
}
interface UIListener {
public int eventHeard(int i, int j);
}