ControlP5 controlFont problem
in
Contributed Library Questions
•
1 year ago
Hi, I have a problem with the position of the fonts. Whatever I do, they get stuck at certain places on the screen, exept the place, where the font belongs.
Here's my code:
- void setSliders(){
- // when creating a PFont:
- PFont pfont = createFont("Times",10,true); // use true/false for smooth/no-smooth
- font = new ControlFont(pfont);
- // (1)
- // create some controllers
- controlP5.addButton("button",10,0,0,80,20).setId(1);
- controlP5.setAutoDraw(false);
- range = controlP5.addRange("images", 0, imagePhone.length, 0,imagePhone.length, 100,50,200,12);
- range.setNumberOfTickMarks(imagePhone.length);
- range.setSliderMode(Slider.FLEXIBLE);
- // Slider s1 = (Slider)controlP5.controller("eind");
- controlP5.addSlider("setBrightness", 0, 255, 200, 50, 80, 300, 10);
- s1 = (Slider)controlP5.controller("setBrightness");
- s1.setNumberOfTickMarks(25);
- // t.captionLabel().setControlFont(f); // f is of type PFont and can be instantiated under setu
- s2 = controlP5.addSlider("setDistance", 0, 255, 200, 50, 120, 300, 10);
- s2.setNumberOfTickMarks(25);
- // (3)
- // change the font and content of the captionlabels
- // for both buttons create earlier.
- controlP5.controller("button").captionLabel().setControlFont(font);
- controlP5.controller("button").captionLabel().setControlFontSize(10);
- range.captionLabel().setControlFont(font);
- range.captionLabel().setControlFontSize(10);
- range.captionLabel().toUpperCase(false);
- range.captionLabel().set("hello");
- }
- void controlEvent(ControlEvent theControlEvent) {
- if(theControlEvent.controller().name().equals("rangeController")) {
- // min and max values are stored in an array.
- // access this array with controller().arrayValue().
- // min is at index 0, max is at index 1.
- colorMin = int(theControlEvent.controller().arrayValue()[0]);
- colorMax = int(theControlEvent.controller().arrayValue()[1]);
- }
- }
- public void button(float theValue) {
- println("a button event. "+theValue);
- isOpen = !isOpen;
- controlP5.controller("button").setCaptionLabel((isOpen==true) ? "close":"open");
- }
- void gui() {
- currCameraMatrix = new PMatrix3D(g3.camera);
- camera();
- controlP5.draw();
- g3.camera = currCameraMatrix;
- }
- void setCam(){
- PeasyDragHandler PanDragHandler;
- PeasyDragHandler ZoomDragHandler;
- PanDragHandler = cam.getPanDragHandler();
- ZoomDragHandler = cam.getZoomDragHandler();//then you can just map this to the left mouse handlercam.setLeftDragHandler(PanDragHandler);
- }
1