[controlP5] Properties Sets for my group?

edited October 2014 in Library Questions

hello,

this is very nice: http://www.sojamo.de/libraries/controlP5/examples/extra/ControlP5propertiesSets/ControlP5propertiesSets.pde

but my Group has many Controllers, and i don't want to say it to each Controller (like in the example).

can i make it for my Controllers which are in my groupA in a short step?

Answers

  • edited October 2014

    i want this(line39), but it doesn't work: :|

    import controlP5.*;
    
    ControlP5 cp5;
    Group g1; //...
    
    void setup() {
      size(400, 600);
    
      cp5 = new ControlP5(this);
      g1 = cp5.addGroup("groupA"); 
    
      cp5.addSlider("slider1", 0, 255, 20, 100, 128, 20).setGroup(g1);
      cp5.addToggle("toggle1", 20, 200, 20, 20).setGroup(g1);
      cp5.addSlider("slider2", 0, 255, 20, 150, 128, 20).setGroup(g1);
      cp5.addRadioButton("radio")
        .setPosition(0, 0)
          .setSpacingColumn(70)
            .setItemsPerRow(2)
              .addItem("a", 0) 
                .addItem("b", 1)
                  .addItem("c", 2)
                    .addItem("d", 3)
                      .addItem("e", 4)
                        .addItem("f", 5)
                          .addItem("g", 6)
                            .activate(1)
                              .setGroup(g1) 
                                ;
      //....
    
      cp5.addSlider("slider3", 0, 255, 20, 450, 128, 20);
      //....
    
      cp5.addButton("b1", 0, 20, 300, 80, 12).setCaptionLabel("save setA");
      cp5.addButton("b2", 0, 101, 300, 80, 12).setCaptionLabel("load setA").setColorBackground(color(0, 100, 50));
    
      cp5.getProperties().addSet("setA");
     //cp5.getProperties().move(cp5.getController("slider1"), "default", "setA");
      cp5.getProperties().move(cp5.getController(cp5.getGroup("groupA")), "default", "setA"); //doesn't work
    }
    
    void draw() {
      background(0);
    }
    
    void b1(float v) {
      cp5.saveProperties("setA.ser", "setA");
    }
    void b2(float v) {
      cp5.loadProperties(("setA.ser"));
    }
    
  • somebody an idea? :-S

  • edited October 2014

    i solved it: :D

    [...]
    //cp5.getProperties().move(cp5.getController("slider1"), "default", "setA");
    for (ControllerInterface t : cp5.getAll ()) {
      if (t.getParent()==g1)
        cp5.getProperties().copy(t, "default", "setA");
    }
    }
    [...]
    
Sign In or Register to comment.