We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello my Friends, My application has to many buttons, It would be possible get a submenu for the lateral like as first code, with the content of the second code? for exemple... Thank very much. Santy
/**
* ControlP5 controlFont.
* this example shows how to create a button with controlP5 (1), how to
* load and use a PFont with controlP5 (2), apply a ControlFont to
* the caption label of a button (3), and adjust the location of a
* caption label using the style() property of a controller.
* by andreas schlegel, 2012
*/
import controlP5.*;
ControlP5 cp5;
controlP5.Button b;
int buttonValue = 1;
boolean isOpen;
int myColorBackground = color(0,0,0);
void setup() {
size(700,400);
smooth();
cp5 = new ControlP5(this);
// (1)
// create some controllers
cp5.addButton("button")
.setValue(10)
.setPosition(20,20)
.setSize(100,50)
.setId(1);
b = cp5.addButton("buttonValue")
.setValue(4)
.setPosition(100,190)
.setSize(200,200)
.setId(2);
PFont pfont = createFont("Arial",20,true); // use true/false for smooth/no-smooth
ControlFont font = new ControlFont(pfont,241);
cp5.getController("button")
.getCaptionLabel()
.setFont(font)
.toUpperCase(false)
.setSize(24)
;
b.getCaptionLabel()
.setFont(font)
.setSize(20)
.toUpperCase(false)
.setText("Controllers hear!")
;
b.getCaptionLabel().getStyle().marginLeft = 1;
b.getCaptionLabel().getStyle().marginTop = 20;
}
void draw() {
background(ControlP5.SILVER);
// animate button b
float x = b.x(b.getPosition());
x += ((isOpen==true ? 0:-200) - x) * 0.2;;
float y = b.y(b.getPosition());
b.setPosition(x,y);
}
public void controlEvent(ControlEvent theEvent) {
println(theEvent.getController().getId());
}
public void button(float theValue) {
println("a button event. "+theValue);
isOpen = !isOpen;
cp5.getController("button").setCaptionLabel((isOpen==true) ? "close":"open");
}
/**
* ControlP5 Mouseover
* this example demonstrates the use of the mouseover methods
* isMouseOver(), getMouseOverList()
* by Andreas Schlegel, 2012
* www.sojamo.de/libraries/controlp5
*/
import controlP5.*;
ControlP5 cp5;
public int Punt = 5;
public int Text = 12;
int p,t;
void setup() {
size(520, 250);
smooth();
cp5 = new ControlP5(this);
cp5.addSlider("Punt", 5, 14, 20, 100, 128, 20);
cp5.addSlider("Text", 12, 24, 20, 150, 128, 20);
cp5.addButton("Guardar_Save", 0, 420, 200, 80, 20);
}
color hover = color(0, 230, 150);
void draw() {
background(ControlP5.PURPLE);
textSize(16);fill(0);text("CONTROL DE TAMAÑO / SIZE CONTROL",20,20);
if(cp5.isMouseOver()) {fill(hover);
} else {fill(128);}
text("Deslize el Slider para cambiar el tamaño",25,70);
text("Slide the Slider to resize",25,85);
fill(255);
ellipse(230,110,Punt,Punt);
fill(cp5.isMouseOver(cp5.getController("slider2")) ? hover:color(Text));
textSize(Text);fill(255);text("Su nuevo tamaño/new size",200,150,350,100);
}
void Guardar_Save() {
p = (int)((Slider)cp5.getController("Punt")).getValue();
t = (int)((Slider)cp5.getController("Text")).getValue();
println(p+" "+t);
}
Answers
Please go back, edit your post
2 empty lines before and after the code
select / highlight entire code with mouse
click
ctrl-o
OR the small C in the command barOk now is ready, excúseme please.
i can't help you
@Santy -- When you say:
...what do you mean? Can you explain in more detail what you are trying to do with ControlP5?
get a submenu for the lateral like as first code, with the content of the second code
But what do you mean?
You posted two sketches but they look as one
Hello jeremydouglass I'n not English but I will try to explain it again... So, put a button in the main window that when pressed open a lateral menú with buttons, textfieds , sliders etc... but not a new window, like as the first code; when you push the button OPEN a new side window appears, so I would like this new side window with the button and sliders of the sencond code. I've tried but I do not understand the operation of ControlP5. If you could help me I would thank you.
Yes Chrisir, what I'm interested in putting the second sketch inside the CaptionLabel of the first sketch...Do you understand?
I made a menu without the library
Chrisir this is fantastic!!! thanks very much
@Santy Let's continue any other discussion in the new forum: https://discourse.processing.org
@Chrisir I agree... this is really neat. Wanna collab to get a lib together to capture all your good demos? PM in the new forum.
Kf