ControlP5

description
controlP5 is a processing and java library for creating simple control GUIs.
+Example
/**
 * controlP5numberbox by andreas schlegel <br />
 * an example to show how to use a numberbox to control<br />
 * variables and events.<br />
 * click a numberbox and move mouse up and down while pressing <br />
 * the mousebutton to change values.<br />
 * for further information and questions about controlP5 first<br />
 * take a look at the documentation, the examples, or the <br />
 * website at http://www.sojamo.de/controlP5<br />
 */

import controlP5.*;

ControlP5 controlP5;

public int myColorRect = 200;

public int myColorBackground = 100;


void setup() {
  size(400,400);
  frameRate(25);
  controlP5 = new ControlP5(this);
  controlP5.addNumberbox("numberbox1",myColorRect,100,160,100,14).setId(1);
  controlP5.addNumberbox("numberbox2",myColorBackground,100,200,100,14).setId(2);
  controlP5.addSlider("slider1",100,200,100,100,250,100,14).setId(3);
  controlP5.addTextfield("text1",100,290,100,20).setId(4);
}

void draw() {
  background(myColorBackground);
  fill(myColorRect);
  rect(0,0,width,100);
}


void controlEvent(ControlEvent theEvent) {
  println("got a control event from controller with id "+theEvent.controller().id());
  switch(theEvent.controller().id()) {
    case(1):
    myColorRect = (int)(theEvent.controller().value());
    break;
    case(2):
    myColorBackground = (int)(theEvent.controller().value());
    break;  
  }
}
constructors
ControlP5(theParent);
parameters
theParentPApplet 
Methods
addBang ( )
add a bang to controlP5. by default it will be added to the default tab of the main window.
addButton ( )
a button to controlP5. by default it will be added to the default tab of the main window.
addControlWindow ( )
create a new ControlWindow.
addGroup ( )
add a group to controlP5. by default it will be added to the default tab of the main window.
addKnob ( )
add a knob to controlP5. by default it will be added to the default tab of the main window.
addNumberbox ( )
add a numberbox to controlP5. by default it will be added to the default tab of the main window.
addRadio ( )
add a radio list to controlP5. by default it will be added to the default tab of the main window.
addRange ( )
add a slider to controlP5. by default it will be added to the default tab of the main window.
addScrollList ( )
add a scroll list to controlP5. by default it will be added to the default tab of the main window.
addSlider ( )
add a slider to controlP5. by default it will be added to the default tab of the main window.
addTab ( )
add a tab to controlP5. by default the tab will be added to the main window.
addTextarea ( )
add a textlabel to controlP5. by default it will be added to the default tab of the main window.
addTextfield ( )
add a textfield to controlP5. by default it will be added to the default tab of the main window.
addToggle ( )
add a toggle to controlP5. by default it will be added to the default tab of the main window.
controller ( )
get a controller by name. you will have to cast the controller.
filePath ( )
get the current file path where your controlP5 setup will be save to on your local disk.
getGroup ( )
get a group by name.
getTab ( )
get a tab by name from a specific controlwindow.
group ( )
get a group by name
hide ( )
hide all controllers and tabs in your sketch.
isAutoDraw ( )
check if the autoDraw function for the main window is enabled(true) or disabled(false).
load ( )
load an xml file, containing a controlP5 setup
lock ( )
lock ControlP5 to disable moving Controllers around.
remove ( )
remove a controlP5 element such as a controller, group, or tab by name.
save ( )
save controlP5 settings to your local disk or to a remote server.
setAutoDraw ( )
by default controlP5 draws any controller on top of any drawing done in the draw() function (this doesnt apply to P3D where controlP5.draw() has to be called manually in the sketch's draw() function ). to turn off the auto drawing of controlP5, use controlP5.setAutoDraw(false). now you can call controlP5.draw() any time whenever controllers should be drawn into the sketch.
setAutoInitialization ( )
autoInitialization can be very handy when it comes to initializing values, e.g. you load a set of controllers from an xml file, then the values that are attached to the controllers will be reset to its state saved in the xml file. to turn of auto intialization, call setAutoInitialization(false) right after initializing controlP5 and before creating any controller.
setColorActive ( )
set the active state color of tabs and controllers.
setColorBackground ( )
set the backgorund color of tabs and controllers.
setColorForeground ( )
set the foreground color of tabs and controllers.
setColorLabel ( )
set the label color of tabs and controllers.
setColorValue ( )
set the value color of controllers.
setFilePath ( )
set the path / filename of the xml file your controlP5 setup will be saved to.
setUrlPath ( )
you can set an url e.g. an index.php file on a server where you want to save your controlP5 setup to.
show ( )
show all controllers and tabs in your sketch.
tab ( )
get a tab by name from a specific controlwindow.
trigger ( )
forces each available controller to broadcast its value. deprecated. use .update() instead.
unlock ( )
unlock ControlP5 to enable moving Controllers around.
urlPath ( )
get the current url path where your controlP5 setup will be save to a remote server e.g. a webserver.
version ( )
get the current version of controlP5
usage
Web & Application
related