controlP5
Class MultiList

java.lang.Object
  extended by controlP5.Controller
      extended by controlP5.MultiList
All Implemented Interfaces:
CDrawable, ControllerInterface, ControlListener, ControlP5Constants, MultiListInterface

public class MultiList
extends Controller
implements MultiListInterface, ControlListener

multilist has the effect of a menu-tree. see the example for more information and usage.

+Example
/**
 * ControlP5 MultiList
 * by andreas schlegel, 2009
 */

import controlP5.*;

ControlP5 controlP5;
MultiList l;

void setup() {
  size(400,400);
  frameRate(30);
  controlP5 = new ControlP5(this);
  
  // add a multiList to controlP5.
  // elements of the list have default dimensions
  // here, a width of 100 and a height of 12
  l = controlP5.addMultiList("myList",0,10,100,12);
  
  // create a multiListButton which we will use to
  // add new buttons to the multilist
  MultiListButton b;
  b = l.add("level1",1);
  
  // add items to a sublist of button "level1"
  b.add("level11",11).setLabel("level1 item1");
  b.add("level12",12).setLabel("level1 item2");

  b = l.add("level2",2);
  
  int cnt = 100;
  
  // add some more sublists.
  for(int i=0;i<10;i++) {
    MultiListButton c = b.add("level2"+(i+1),20+i+1);
    c.setLabel("level2 item"+(i+1));
    c.setColorBackground(color(64 + 18*i,0,0));
    
    if(i==4) {
    // changing the width and the height of a button
    // will be inherited by its sublists.
    c.setWidth(100);
    c.setHeight(20);
    }
    cnt++;
    
    if(i==4) {
      for(int j=0;j<10;j++) {
        cnt++;
        MultiListButton d;
        d = c.add("level2"+i+""+j,250+j+1);
        d.setLabel("level2 item"+(i+1)+" "+"item"+(j+1));
        d.setColorBackground(color(64 + 18*j,(64 + 18*j)/2,0));
        d.setId(cnt);
        d.setWidth(200);
      }
    }
  }
  
  MultiListButton cc = (MultiListButton)controlP5.controller("level21");
  cc.setHeight(40);
}


void controlEvent(ControlEvent theEvent) {
  println(theEvent.controller().name()+" = "+theEvent.value());  
  // uncomment the line below to remove a multilist item when clicked.
  // theEvent.controller().remove();
}


void draw() {
  background(0);
}

void keyPressed() {
  if(controlP5.controller("level23")!=null) {
    println("removing multilist button level23.");
    controlP5.controller("level23").remove();
  }
}

Field Summary
 int closeDelay
           
 
Fields inherited from interface controlP5.ControlP5Constants
acceptClassList, ACTIVE, ALT, ARC, ARRAY, BACKSPACE, BOOLEAN, BOTTOM, CENTER, CONTROL, controlEventClass, CUSTOM, DECREASE, DEFAULT, DELETE, DOWN, ELLIPSE, ENTER, ESCAPE, EVENT, eventMethod, FIELD, FLOAT, HALF_PI, HIDE, HIGHLIGHT, HORIZONTAL, IMAGE, INCREASE, INTEGER, INVALID, KEYCONTROL, LEFT, LINE, LOAD, MENU, METHOD, MOVE, OVER, PI, PRESSED, PRINT, RELEASE, RESET, RIGHT, SAVE, SHIFT, SPRITE, STRING, SWITCH, SWITCH_BACK, SWITCH_FORE, TAB, TOP, TWO_PI, UP, VERBOSE, VERTICAL
 
Constructor Summary
MultiList(ControlP5 theControlP5, Tab theParent, java.lang.String theName, int theX, int theY, int theWidth, int theHeight)
           
 
Method Summary
 MultiListButton add(java.lang.String theName, int theValue)
          add multilist buttons to the multilist.
 void addToXMLElement(ControlP5XMLElement theElement)
           
 void close()
           
 void close(MultiListInterface theInterface)
           
 void controlEvent(ControlEvent theEvent)
          TODO experimental.
 void draw(processing.core.PApplet theApplet)
          the default draw function for each controller extending superclass Controller.
 int getDirection()
           
 void mouseReleased()
           
 boolean observe()
           
 void occupied(boolean theFlag)
           
 void open()
           
 void remove()
          remove a multilist.
 void setDirection(int theDirection)
           
 void setup()
           
 void setValue(float theValue)
          set the value of the controller.
 java.util.List<Controller> subelements()
           
 void update()
          updates the value of the controller without having to set the value explicitly.
 boolean update(processing.core.PApplet theApplet)
           
 void updateLocation(float theX, float theY)
           
 
Methods inherited from class controlP5.Controller
absolutePosition, add, addListener, arrayValue, behavior, captionLabel, changeValue, color, continuousUpdateEvents, controlWindow, defaultValue, disableSprite, enableSprite, getAsXML, getColor, getHeight, getPickingColor, getSprite, getTab, getWidth, getWindow, hide, id, init, isBroadcast, isInside, isLock, isMousePressed, isMoveable, isUpdate, isUserInteraction, isVisible, isXMLsavable, keyEvent, label, linebreak, listenerSize, lock, max, min, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, name, parent, plugTo, plugTo, position, remove, removeBehavior, removeListener, setArrayValue, setBehavior, setBroadcast, setCaptionLabel, setColor, setColorActive, setColorBackground, setColorCaptionLabel, setColorForeground, setColorLabel, setColorValue, setColorValueLabel, setDecimalPrecision, setDefaultValue, setDisplay, setDisplay, setGroup, setGroup, setHeight, setId, setImage, setImage, setImages, setImages, setLabel, setLabelVisible, setLock, setMax, setMin, setMousePressed, setMoveable, setParent, setPosition, setSize, setSize, setSprite, setTab, setTab, setUpdate, setUserInteraction, setValueLabel, setVisible, setWidth, setWindow, setWindow, show, stringValue, toString, trigger, unlock, unplugFrom, unplugFrom, updateAbsolutePosition, updateEvents, updateInternalEvents, updateSize, value, valueLabel
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface controlP5.MultiListInterface
name
 

Field Detail

closeDelay

public int closeDelay
Constructor Detail

MultiList

public MultiList(ControlP5 theControlP5,
                 Tab theParent,
                 java.lang.String theName,
                 int theX,
                 int theY,
                 int theWidth,
                 int theHeight)
Method Detail

setup

public void setup()

subelements

public java.util.List<Controller> subelements()
Specified by:
subelements in interface MultiListInterface

getDirection

public int getDirection()
Specified by:
getDirection in interface MultiListInterface

setDirection

public void setDirection(int theDirection)

updateLocation

public void updateLocation(float theX,
                           float theY)
Specified by:
updateLocation in interface MultiListInterface
Parameters:
theX - float
theY - float

remove

public void remove()
remove a multilist.

Specified by:
remove in interface ControllerInterface
Overrides:
remove in class Controller

add

public MultiListButton add(java.lang.String theName,
                           int theValue)
add multilist buttons to the multilist.

Parameters:
theName - String
theValue - int
Returns:
MultiListButton

controlEvent

public void controlEvent(ControlEvent theEvent)
TODO experimental. see scrollList. needs controllerPlug.

Specified by:
controlEvent in interface ControlListener
Parameters:
theEvent -

draw

public void draw(processing.core.PApplet theApplet)
Description copied from class: Controller
the default draw function for each controller extending superclass Controller. This draw function will take care of default matrix operations and will call the display function of the current ControllerDisplay object active for this particular controller.

Specified by:
draw in interface CDrawable
Specified by:
draw in interface ControllerInterface
Specified by:
draw in interface MultiListInterface
Overrides:
draw in class Controller
Parameters:
theApplet - PApplet
See Also:
ControllerDisplay

update

public boolean update(processing.core.PApplet theApplet)
Parameters:
theApplet - PApplet
Returns:
boolean

occupied

public void occupied(boolean theFlag)
Parameters:
theFlag - boolean

observe

public boolean observe()
Specified by:
observe in interface MultiListInterface
Returns:
boolean

close

public void close(MultiListInterface theInterface)
Specified by:
close in interface MultiListInterface
Parameters:
theInterface - MultiListInterface

close

public void close()
Specified by:
close in interface MultiListInterface

open

public void open()
Specified by:
open in interface MultiListInterface

setValue

public void setValue(float theValue)
Description copied from class: Controller
set the value of the controller.

Specified by:
setValue in class Controller
Parameters:
theValue - float

update

public void update()
Description copied from class: Controller
updates the value of the controller without having to set the value explicitly. update does not visually update the controller. the updating status can be set with setUpdate(true/false) and checked with isUpdate(). setUpdate ( )

Specified by:
update in interface ControllerInterface
Overrides:
update in class Controller

mouseReleased

public void mouseReleased()

addToXMLElement

public void addToXMLElement(ControlP5XMLElement theElement)
Specified by:
addToXMLElement in interface ControllerInterface
Specified by:
addToXMLElement in interface MultiListInterface
Parameters:
theElement - ControlP5XMLElement


processing library controlP5 by Andreas Schlegel. (c) 2010