forked from sojamo/controlp5
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ControlP5tab.pde
236 lines (202 loc) · 8.35 KB
/
ControlP5tab.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
/**
* ControlP5 Tab
*
*
* find a list of public methods available for the Tab Controller
* at the bottom of this sketch.
*
* by Andreas Schlegel, 2012
* www.sojamo.de/libraries/controlp5
*
*/
import controlP5.*;
ControlP5 cp5;
int myColorBackground = color(128);
int sliderValue = 100;
void setup() {
size(700,400);
noStroke();
cp5 = new ControlP5(this);
// By default all controllers are stored inside Tab 'default'
// add a second tab with name 'extra'
cp5.addTab("extra")
.setColorBackground(color(0, 160, 100))
.setColorLabel(color(255))
.setColorActive(color(255,128,0))
;
// if you want to receive a controlEvent when
// a tab is clicked, use activeEvent(true)
cp5.getTab("default")
.activateEvent(true)
.setLabel("my default tab")
.setId(1)
;
cp5.getTab("extra")
.activateEvent(true)
.setId(2)
;
// create a few controllers
cp5.addButton("button")
.setBroadcast(false)
.setPosition(100,100)
.setSize(80,40)
.setValue(1)
.setBroadcast(true)
.getCaptionLabel().align(CENTER,CENTER)
;
cp5.addButton("buttonValue")
.setBroadcast(false)
.setPosition(220,100)
.setSize(80,40)
.setValue(2)
.setBroadcast(true)
.getCaptionLabel().align(CENTER,CENTER)
;
cp5.addSlider("slider")
.setBroadcast(false)
.setRange(100,200)
.setValue(128)
.setPosition(100,160)
.setSize(200,20)
.setBroadcast(true)
;
cp5.addSlider("sliderValue")
.setBroadcast(false)
.setRange(0,255)
.setValue(128)
.setPosition(100,200)
.setSize(200,20)
.setBroadcast(true)
;
// arrange controller in separate tabs
cp5.getController("sliderValue").moveTo("extra");
cp5.getController("slider").moveTo("global");
// Tab 'global' is a tab that lies on top of any
// other tab and is always visible
}
void draw() {
background(myColorBackground);
fill(sliderValue);
rect(0,0,width,100);
}
void controlEvent(ControlEvent theControlEvent) {
if (theControlEvent.isTab()) {
println("got an event from tab : "+theControlEvent.getTab().getName()+" with id "+theControlEvent.getTab().getId());
}
}
void slider(int theColor) {
myColorBackground = color(theColor);
println("a slider event. setting background to "+theColor);
}
void keyPressed() {
if(keyCode==TAB) {
cp5.getTab("extra").bringToFront();
}
}
/*
a list of all methods available for the Tab Controller
use ControlP5.printPublicMethodsFor(Tab.class);
to print the following list into the console.
You can find further details about class Tab in the javadoc.
Format:
ClassName : returnType methodName(parameter type)
main.java.controlp5.ControllerGroup : CColor getColor()
main.java.controlp5.ControllerGroup : Canvas addCanvas(Canvas)
main.java.controlp5.ControllerGroup : ControlWindow getWindow()
main.java.controlp5.ControllerGroup : Controller getController(String)
main.java.controlp5.ControllerGroup : ControllerProperty getProperty(String)
main.java.controlp5.ControllerGroup : ControllerProperty getProperty(String, String)
main.java.controlp5.ControllerGroup : Label getCaptionLabel()
main.java.controlp5.ControllerGroup : Label getValueLabel()
main.java.controlp5.ControllerGroup : String getAddress()
main.java.controlp5.ControllerGroup : String getInfo()
main.java.controlp5.ControllerGroup : String getName()
main.java.controlp5.ControllerGroup : String getStringValue()
main.java.controlp5.ControllerGroup : String toString()
main.java.controlp5.ControllerGroup : Tab add(ControllerInterface)
main.java.controlp5.ControllerGroup : Tab addListener(ControlListener)
main.java.controlp5.ControllerGroup : Tab bringToFront()
main.java.controlp5.ControllerGroup : Tab bringToFront(ControllerInterface)
main.java.controlp5.ControllerGroup : Tab close()
main.java.controlp5.ControllerGroup : Tab disableCollapse()
main.java.controlp5.ControllerGroup : Tab enableCollapse()
main.java.controlp5.ControllerGroup : Tab getTab()
main.java.controlp5.ControllerGroup : Tab hide()
main.java.controlp5.ControllerGroup : Tab hideArrow()
main.java.controlp5.ControllerGroup : Tab hideBar()
main.java.controlp5.ControllerGroup : Tab moveTo(ControlWindow)
main.java.controlp5.ControllerGroup : Tab moveTo(PApplet)
main.java.controlp5.ControllerGroup : Tab open()
main.java.controlp5.ControllerGroup : Tab registerProperty(String)
main.java.controlp5.ControllerGroup : Tab registerProperty(String, String)
main.java.controlp5.ControllerGroup : Tab remove(CDrawable)
main.java.controlp5.ControllerGroup : Tab remove(ControllerInterface)
main.java.controlp5.ControllerGroup : Tab removeCanvas(Canvas)
main.java.controlp5.ControllerGroup : Tab removeListener(ControlListener)
main.java.controlp5.ControllerGroup : Tab removeProperty(String)
main.java.controlp5.ControllerGroup : Tab removeProperty(String, String)
main.java.controlp5.ControllerGroup : Tab setAddress(String)
main.java.controlp5.ControllerGroup : Tab setArrayValue(float[])
main.java.controlp5.ControllerGroup : Tab setArrayValue(int, float)
main.java.controlp5.ControllerGroup : Tab setCaptionLabel(String)
main.java.controlp5.ControllerGroup : Tab setColor(CColor)
main.java.controlp5.ControllerGroup : Tab setColorActive(int)
main.java.controlp5.ControllerGroup : Tab setColorBackground(int)
main.java.controlp5.ControllerGroup : Tab setColorForeground(int)
main.java.controlp5.ControllerGroup : Tab setColorLabel(int)
main.java.controlp5.ControllerGroup : Tab setColorValue(int)
main.java.controlp5.ControllerGroup : Tab setHeight(int)
main.java.controlp5.ControllerGroup : Tab setId(int)
main.java.controlp5.ControllerGroup : Tab setLabel(String)
main.java.controlp5.ControllerGroup : Tab setMouseOver(boolean)
main.java.controlp5.ControllerGroup : Tab setMoveable(boolean)
main.java.controlp5.ControllerGroup : Tab setOpen(boolean)
main.java.controlp5.ControllerGroup : Tab setPosition(float, float)
main.java.controlp5.ControllerGroup : Tab setPosition(float[])
main.java.controlp5.ControllerGroup : Tab setSize(int, int)
main.java.controlp5.ControllerGroup : Tab setStringValue(String)
main.java.controlp5.ControllerGroup : Tab setTitle(String)
main.java.controlp5.ControllerGroup : Tab setUpdate(boolean)
main.java.controlp5.ControllerGroup : Tab setValue(float)
main.java.controlp5.ControllerGroup : Tab setVisible(boolean)
main.java.controlp5.ControllerGroup : Tab setWidth(int)
main.java.controlp5.ControllerGroup : Tab show()
main.java.controlp5.ControllerGroup : Tab showArrow()
main.java.controlp5.ControllerGroup : Tab showBar()
main.java.controlp5.ControllerGroup : Tab update()
main.java.controlp5.ControllerGroup : Tab updateAbsolutePosition()
main.java.controlp5.ControllerGroup : boolean isBarVisible()
main.java.controlp5.ControllerGroup : boolean isCollapse()
main.java.controlp5.ControllerGroup : boolean isMouseOver()
main.java.controlp5.ControllerGroup : boolean isMoveable()
main.java.controlp5.ControllerGroup : boolean isOpen()
main.java.controlp5.ControllerGroup : boolean isUpdate()
main.java.controlp5.ControllerGroup : boolean isVisible()
main.java.controlp5.ControllerGroup : boolean setMousePressed(boolean)
main.java.controlp5.ControllerGroup : float getArrayValue(int)
main.java.controlp5.ControllerGroup : float getValue()
main.java.controlp5.ControllerGroup : float[] getArrayValue()
main.java.controlp5.ControllerGroup : float[] getPosition()
main.java.controlp5.ControllerGroup : int getHeight()
main.java.controlp5.ControllerGroup : int getId()
main.java.controlp5.ControllerGroup : int getWidth()
main.java.controlp5.ControllerGroup : int listenerSize()
main.java.controlp5.ControllerGroup : void controlEvent(ControlEvent)
main.java.controlp5.ControllerGroup : void remove()
main.java.controlp5.Tab : String getStringValue()
main.java.controlp5.Tab : Tab activateEvent(boolean)
main.java.controlp5.Tab : Tab bringToFront()
main.java.controlp5.Tab : Tab moveTo(ControlWindow)
main.java.controlp5.Tab : Tab setActive(boolean)
main.java.controlp5.Tab : Tab setAlwaysActive(boolean)
main.java.controlp5.Tab : Tab setHeight(int)
main.java.controlp5.Tab : Tab setLabel(String)
main.java.controlp5.Tab : Tab setValue(float)
main.java.controlp5.Tab : Tab setWidth(int)
main.java.controlp5.Tab : boolean isActive()
main.java.controlp5.Tab : boolean isAlwaysActive()
main.java.controlp5.Tab : float getValue()
java.lang.Object : String toString()
java.lang.Object : boolean equals(Object)
created: 2015/03/24 12:25:49
*/