forked from sojamo/controlp5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ControlP5radioButton.pde
238 lines (213 loc) · 9.71 KB
/
ControlP5radioButton.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
235
236
/**
* ControlP5 RadioButton
*
*
* find a list of public methods available for the RadioButton Controller
* at the bottom of this sketch.
*
* by Andreas Schlegel, 2012
* www.sojamo.de/libraries/controlp5
*
*/
import controlP5.*;
ControlP5 cp5;
int myColorBackground = color(0,0,0);
RadioButton r1, r2;
void setup() {
size(700,400);
cp5 = new ControlP5(this);
r1 = cp5.addRadioButton("radioButton")
.setPosition(100,180)
.setSize(40,20)
.setColorForeground(color(120))
.setColorActive(color(255))
.setColorLabel(color(255))
.setItemsPerRow(5)
.setSpacingColumn(50)
.addItem("50",1)
.addItem("100",2)
.addItem("150",3)
.addItem("200",4)
.addItem("250",5)
;
for(Toggle t:r1.getItems()) {
t.getCaptionLabel().setColorBackground(color(255,80));
t.getCaptionLabel().getStyle().moveMargin(-7,0,0,-3);
t.getCaptionLabel().getStyle().movePadding(7,0,0,3);
t.getCaptionLabel().getStyle().backgroundWidth = 45;
t.getCaptionLabel().getStyle().backgroundHeight = 13;
}
}
void draw() {
background(myColorBackground);
}
void keyPressed() {
switch(key) {
case('0'): r1.deactivateAll(); break;
case('1'): r1.activate(0); break;
case('2'): r1.activate(1); break;
case('3'): r1.activate(2); break;
case('4'): r1.activate(3); break;
case('5'): r1.activate(4); break;
}
}
void controlEvent(ControlEvent theEvent) {
if(theEvent.isFrom(r1)) {
print("got an event from "+theEvent.getName()+"\t");
for(int i=0;i<theEvent.getGroup().getArrayValue().length;i++) {
print(int(theEvent.getGroup().getArrayValue()[i]));
}
println("\t "+theEvent.getValue());
myColorBackground = color(int(theEvent.getGroup().getValue()*50),0,0);
}
}
void radioButton(int a) {
println("a radio Button event: "+a);
}
/*
a list of all methods available for the RadioButton Controller
use ControlP5.printPublicMethodsFor(RadioButton.class);
to print the following list into the console.
You can find further details about class RadioButton in the javadoc.
Format:
ClassName : returnType methodName(parameter type)
controlP5.ControlGroup : RadioButton activateEvent(boolean)
controlP5.ControlGroup : RadioButton addListener(ControlListener)
controlP5.ControlGroup : RadioButton removeListener(ControlListener)
controlP5.ControlGroup : RadioButton setBackgroundColor(int)
controlP5.ControlGroup : RadioButton setBackgroundHeight(int)
controlP5.ControlGroup : RadioButton setBarHeight(int)
controlP5.ControlGroup : RadioButton setSize(int, int)
controlP5.ControlGroup : RadioButton updateInternalEvents(PApplet)
controlP5.ControlGroup : String getInfo()
controlP5.ControlGroup : String toString()
controlP5.ControlGroup : int getBackgroundHeight()
controlP5.ControlGroup : int getBarHeight()
controlP5.ControlGroup : int listenerSize()
controlP5.ControllerGroup : CColor getColor()
controlP5.ControllerGroup : Canvas addCanvas(Canvas)
controlP5.ControllerGroup : ControlWindow getWindow()
controlP5.ControllerGroup : Controller getController(String)
controlP5.ControllerGroup : ControllerProperty getProperty(String)
controlP5.ControllerGroup : ControllerProperty getProperty(String, String)
controlP5.ControllerGroup : Label getCaptionLabel()
controlP5.ControllerGroup : Label getValueLabel()
controlP5.ControllerGroup : RadioButton add(ControllerInterface)
controlP5.ControllerGroup : RadioButton addListener(ControlListener)
controlP5.ControllerGroup : RadioButton bringToFront()
controlP5.ControllerGroup : RadioButton bringToFront(ControllerInterface)
controlP5.ControllerGroup : RadioButton close()
controlP5.ControllerGroup : RadioButton disableCollapse()
controlP5.ControllerGroup : RadioButton enableCollapse()
controlP5.ControllerGroup : RadioButton hide()
controlP5.ControllerGroup : RadioButton hideArrow()
controlP5.ControllerGroup : RadioButton hideBar()
controlP5.ControllerGroup : RadioButton moveTo(ControlWindow)
controlP5.ControllerGroup : RadioButton moveTo(PApplet)
controlP5.ControllerGroup : RadioButton open()
controlP5.ControllerGroup : RadioButton registerProperty(String)
controlP5.ControllerGroup : RadioButton registerProperty(String, String)
controlP5.ControllerGroup : RadioButton remove(CDrawable)
controlP5.ControllerGroup : RadioButton remove(ControllerInterface)
controlP5.ControllerGroup : RadioButton removeCanvas(Canvas)
controlP5.ControllerGroup : RadioButton removeListener(ControlListener)
controlP5.ControllerGroup : RadioButton removeProperty(String)
controlP5.ControllerGroup : RadioButton removeProperty(String, String)
controlP5.ControllerGroup : RadioButton setAddress(String)
controlP5.ControllerGroup : RadioButton setArrayValue(float[])
controlP5.ControllerGroup : RadioButton setArrayValue(int, float)
controlP5.ControllerGroup : RadioButton setCaptionLabel(String)
controlP5.ControllerGroup : RadioButton setColor(CColor)
controlP5.ControllerGroup : RadioButton setColorActive(int)
controlP5.ControllerGroup : RadioButton setColorBackground(int)
controlP5.ControllerGroup : RadioButton setColorForeground(int)
controlP5.ControllerGroup : RadioButton setColorLabel(int)
controlP5.ControllerGroup : RadioButton setColorValue(int)
controlP5.ControllerGroup : RadioButton setHeight(int)
controlP5.ControllerGroup : RadioButton setId(int)
controlP5.ControllerGroup : RadioButton setLabel(String)
controlP5.ControllerGroup : RadioButton setMouseOver(boolean)
controlP5.ControllerGroup : RadioButton setMoveable(boolean)
controlP5.ControllerGroup : RadioButton setOpen(boolean)
controlP5.ControllerGroup : RadioButton setPosition(float, float)
controlP5.ControllerGroup : RadioButton setPosition(float[])
controlP5.ControllerGroup : RadioButton setSize(int, int)
controlP5.ControllerGroup : RadioButton setStringValue(String)
controlP5.ControllerGroup : RadioButton setTitle(String)
controlP5.ControllerGroup : RadioButton setUpdate(boolean)
controlP5.ControllerGroup : RadioButton setValue(float)
controlP5.ControllerGroup : RadioButton setVisible(boolean)
controlP5.ControllerGroup : RadioButton setWidth(int)
controlP5.ControllerGroup : RadioButton show()
controlP5.ControllerGroup : RadioButton showArrow()
controlP5.ControllerGroup : RadioButton showBar()
controlP5.ControllerGroup : RadioButton update()
controlP5.ControllerGroup : RadioButton updateAbsolutePosition()
controlP5.ControllerGroup : String getAddress()
controlP5.ControllerGroup : String getInfo()
controlP5.ControllerGroup : String getName()
controlP5.ControllerGroup : String getStringValue()
controlP5.ControllerGroup : String toString()
controlP5.ControllerGroup : Tab getTab()
controlP5.ControllerGroup : boolean isBarVisible()
controlP5.ControllerGroup : boolean isCollapse()
controlP5.ControllerGroup : boolean isMouseOver()
controlP5.ControllerGroup : boolean isMoveable()
controlP5.ControllerGroup : boolean isOpen()
controlP5.ControllerGroup : boolean isUpdate()
controlP5.ControllerGroup : boolean isVisible()
controlP5.ControllerGroup : boolean setMousePressed(boolean)
controlP5.ControllerGroup : float getArrayValue(int)
controlP5.ControllerGroup : float getValue()
controlP5.ControllerGroup : float[] getArrayValue()
controlP5.ControllerGroup : float[] getPosition()
controlP5.ControllerGroup : int getHeight()
controlP5.ControllerGroup : int getId()
controlP5.ControllerGroup : int getWidth()
controlP5.ControllerGroup : int listenerSize()
controlP5.ControllerGroup : void controlEvent(ControlEvent)
controlP5.ControllerGroup : void remove()
controlP5.RadioButton : List getItems()
controlP5.RadioButton : RadioButton activate(String)
controlP5.RadioButton : RadioButton activate(int)
controlP5.RadioButton : RadioButton addItem(String, float)
controlP5.RadioButton : RadioButton addItem(Toggle, float)
controlP5.RadioButton : RadioButton align(int, int)
controlP5.RadioButton : RadioButton align(int[])
controlP5.RadioButton : RadioButton alignX(int)
controlP5.RadioButton : RadioButton alignY(int)
controlP5.RadioButton : RadioButton deactivate(String)
controlP5.RadioButton : RadioButton deactivate(int)
controlP5.RadioButton : RadioButton deactivateAll()
controlP5.RadioButton : RadioButton hideLabels()
controlP5.RadioButton : RadioButton plugTo(Object)
controlP5.RadioButton : RadioButton plugTo(Object, String)
controlP5.RadioButton : RadioButton removeItem(String)
controlP5.RadioButton : RadioButton setArrayValue(float[])
controlP5.RadioButton : RadioButton setColorLabels(int)
controlP5.RadioButton : RadioButton setImage(PImage)
controlP5.RadioButton : RadioButton setImage(PImage, int)
controlP5.RadioButton : RadioButton setImages(PImage, PImage, PImage)
controlP5.RadioButton : RadioButton setItemHeight(int)
controlP5.RadioButton : RadioButton setItemWidth(int)
controlP5.RadioButton : RadioButton setItemsPerRow(int)
controlP5.RadioButton : RadioButton setLabelPadding(int, int)
controlP5.RadioButton : RadioButton setNoneSelectedAllowed(boolean)
controlP5.RadioButton : RadioButton setSize(PImage)
controlP5.RadioButton : RadioButton setSize(int, int)
controlP5.RadioButton : RadioButton setSpacingColumn(int)
controlP5.RadioButton : RadioButton setSpacingRow(int)
controlP5.RadioButton : RadioButton showLabels()
controlP5.RadioButton : RadioButton toUpperCase(boolean)
controlP5.RadioButton : RadioButton toggle(int)
controlP5.RadioButton : String getInfo()
controlP5.RadioButton : Toggle getItem(String)
controlP5.RadioButton : Toggle getItem(int)
controlP5.RadioButton : boolean getState(String)
controlP5.RadioButton : boolean getState(int)
controlP5.RadioButton : int[] getAlign()
controlP5.RadioButton : void updateLayout()
java.lang.Object : String toString()
java.lang.Object : boolean equals(Object)
created: 2015/03/24 12:21:19
*/