setCaptionLabel on top of setImage in controlP5

edited March 2014 in Library Questions

Hi all,

I am using controlp5 for buttons in an interface. In previous versions, I've been loading in my own images for the buttons, including a title - text added in photoshop. Since I have a lot of buttons that are similar in shape and colour, I am now trying to load in a few general button-images, and repeat the use of this image, while adding a seperate label on top of it. However, I can't get the label to be displayed.

The buttons on the right is what how the title should be placed (but this is done in photoshop), and for the dark blue buttons on the left I've been trying to reach the same with a title/label set in processing.

Screenshot 2014-03-07 11.20.15

The construction of my code may be a bit weird, because I lock the buttons at certain points, and then change the image according to whether they're looked or not. In this piece, meshToggle is the name of the upperleft button, short_inactive, short_tr_active, short_tr_hover, and short_tr_static are the PImages representing the button in different states, and font1 is a Pfont that I use as well in a different part of the code, where it is working.

This happens in void setup():

    createControls();
    autoDraw(false);

This happens in void draw():

    if(meshToggle.isLock())  {   
        meshToggle.setImage(short_inactive);
        meshToggle.getCaptionLabel().align(ControlP5.LEFT, ControlP5.CENTER).setPaddingX(20).setFont(font1);
    } else { 
        meshToggle.setImages(short_tr_active,short_tr_hover,short_tr_static);       
        meshToggle.getCaptionLabel().align(ControlP5.LEFT, ControlP5.CENTER).setPaddingX(20).setFont(font1).setColor(255);
    }

    gui();

This happens in void gui():

void gui() {
    hint(DISABLE_DEPTH_TEST);
    cam.beginHUD();
    cp5.draw();
    cam.endHUD();
    hint(ENABLE_DEPTH_TEST);
}

This happens in void createControls():

void createControls() {
    cp5 = new ControlP5(this);

    meshToggle =  cp5.addButton("mesh_toggle")
      .setPosition(20, 20)
      .setSize(150,30)
      .setCaptionLabel("mesh setup")
      .setLock(false)
      .setSwitch(true);

     }

Hope that is enough information, and that someone can help me!

Answers

  • hey there! Im dealing with the same issue right now... did you happen to solve that particular problem(using textures for buttons and still having a caption label) ?! please let me know if you could work around that issue!

    Best, Sven.

Sign In or Register to comment.