2015-04-26 13:13:35 +02:00
|
|
|
// the ControlFrame class extends PApplet, so we
|
|
|
|
// are creating a new processing applet inside a
|
|
|
|
// new frame with a controlP5 object loaded
|
|
|
|
public class ControlFrame extends PApplet {
|
|
|
|
public int w, h;
|
|
|
|
int abc = 100;
|
|
|
|
public ControlP5 cp5;
|
2015-08-16 13:19:19 +02:00
|
|
|
protected PApplet parent;
|
2015-04-26 13:13:35 +02:00
|
|
|
|
|
|
|
private ControlFrame() {
|
|
|
|
}
|
|
|
|
|
2015-08-16 13:19:19 +02:00
|
|
|
public ControlFrame(PApplet theParent, int theWidth, int theHeight) {
|
2015-04-26 13:13:35 +02:00
|
|
|
this.parent = theParent;
|
|
|
|
this.w = theWidth;
|
|
|
|
this.h = theHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ControlP5 cp5() {
|
2015-09-05 17:00:22 +02:00
|
|
|
if (this.cp5 == null) {
|
|
|
|
this.cp5 = this.setupControlP5();
|
|
|
|
}
|
|
|
|
return this.cp5;
|
2015-04-26 13:13:35 +02:00
|
|
|
}
|
2015-09-05 17:00:22 +02:00
|
|
|
|
|
|
|
public PApplet getParent() {
|
|
|
|
return this.parent;
|
|
|
|
}
|
|
|
|
|
2015-04-26 13:13:35 +02:00
|
|
|
public void setup() {
|
|
|
|
size(w, h);
|
|
|
|
frameRate(5);
|
|
|
|
}
|
2015-09-05 17:00:22 +02:00
|
|
|
|
2015-04-26 13:13:35 +02:00
|
|
|
public ControlP5 setupControlP5() {
|
2015-09-05 17:00:22 +02:00
|
|
|
println("About to create new ControlP5");
|
2015-04-26 13:13:35 +02:00
|
|
|
ControlP5 cp5 = new ControlP5(this);
|
2015-09-05 17:00:22 +02:00
|
|
|
println("Created: " + cp5);
|
|
|
|
while (cp5 == null) {
|
2015-04-26 13:13:35 +02:00
|
|
|
println("Was null: " + cp5);
|
2015-09-05 17:00:22 +02:00
|
|
|
}
|
|
|
|
println("Finally created: " + cp5);
|
|
|
|
return cp5;
|
2015-04-26 13:13:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void draw() {
|
2015-09-05 17:00:22 +02:00
|
|
|
background(abc);
|
2015-04-26 13:13:35 +02:00
|
|
|
}
|
2015-09-05 17:00:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|