We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Heyy! I am using ControlP5 for project! Anybody know how to keep the value label placement steady at a certain place for a vertical slider? Default it is set to follow the bar within the slider as you can see in my code, but I would like it to just stay at its starting position and not follow the bars movement.
import controlP5.*;
ControlP5 cp5;
int front = color(90); int back = color(190); int LabelColor = 100;
void setup() {
size(600, 450);
PFont font = createFont("arial", 20);
cp5 = new ControlP5(this);
cp5.addSlider("LodretFlyendeKnap")
.setPosition(210, 200)
.setSize(20, 200)
.setRange(0, 100)
.setDecimalPrecision(0)
.setValue(50)
.setFont(font)
.setColorActive(front)
.setColorBackground(back)
.setColorValueLabel(100)
.setColorForeground(front)
.setCaptionLabel(" ")
.setSliderMode(Slider.FLEXIBLE)
;
// reposition the Label for controller 'slider' cp5.getController("LodretFlyendeKnap").getValueLabel().align(ControlP5.LEFT, ControlP5.BOTTOM_OUTSIDE).setPaddingX(25); cp5.getController("LodretFlyendeKnap").getValueLabel().align(ControlP5.LEFT, ControlP5.BOTTOM_OUTSIDE).setPaddingY(-200); cp5.getController("LodretFlyendeKnap").getCaptionLabel().align(ControlP5.RIGHT, ControlP5.BOTTOM_OUTSIDE).setPaddingX(0); }
void draw() { background(255); }
Answers
Please format your code. Edit your post (gear on top right side of any of your posts), select your code and hit ctrl+o. Leave an empty line above and below your block of code.
I tried fixing the label but I couldn't go too far. One idea is to remove the label and draw a text() by the controller. You can hide the label using:
cp5.getController("LodretFlyendeKnap").setLabelVisible(false);
It is not elegant but it works. Or you could just dig into its source code and implement your own variant.
Kf