We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › ControlP5 ControllerStyle() class
Page Index Toggle Pages: 1
ControlP5 ControllerStyle() class (Read 558 times)
ControlP5 ControllerStyle() class
Nov 30th, 2008, 7:44am
 
I'm using ControlP5 for the UI elements in a current project, and wanted to style some of them to appear differently than the standard ControlP5 look.  After searching the ControlP5 documentation, I found the ControllerStyle class (http://www.sojamo.de/libraries/controlP5/reference/controllerstyle_class_controllerstyle.htm).  It has margin() and padding() methods, which are exactly what I need.

However, I can't figure out how to use it.  there isn't any real documentation of it in the ControlP5 reference, and my Google searches haven't turned up anything.  I've tried:

controlStyle = new ControllerStyle();
ControllerStyle controlStyle = new ControllerStyle();
controlStyle = new ControllerStyle(this);
controlStyle = ControlP5.ControllerStyle();

...and a range of other variations.  Either I'm missing something obvious or I just haven't hit on the right way to use this class.  Does anyone have any insight?

I've emailed Sojamo (Andreas Schlegel) about this.  If I hear back from him I will post the response here.
Re: ControlP5 ControllerStyle() class
Reply #1 - Nov 30th, 2008, 10:19am
 
hi johnny,
the ControllerStyle is not documented but only a hidden feature yet. it only works for labels, but the idea is to make each controller have it's own style.

to style a label see example below:

Code:

import controlP5.*;

ControlP5 controlP5;
Textarea myTextarea;

void setup() {
size(400,400);
frameRate(30);
controlP5 = new ControlP5(this);


Slider s = controlP5.addSlider("changeWidth",0,200,100,100,20,100,20);
// use style().padding and style().margin to make changes
// to the position and the background color of a label.
// style values for padding and margin can be positive and negative.
s.captionLabel().style().padding(7,0,3,2);
s.captionLabel().style().marginTop = -7;
s.captionLabel().setColorBackground(0x66ff0000);

controlP5.addSlider("changeHeight",0,200,100,100,60,100,9);
}

void draw() {
background(0);
}
Re: ControlP5 ControllerStyle() class
Reply #2 - Nov 30th, 2008, 6:22pm
 
Thanks a lot for the info!  It's not often the authors of this kind of thing get back so quickly.

I tried your example, and it works fine for sliders.  However, I'm trying to modify a ScrollList.  Since they do not have external labels, is this not going to work?  I get the error: "The function captionLabel() does not exist"

Code:

gameSelect = controlP5.addScrollList("gameIndex", 127, 110, 300, 250);
gameSelect.setLabel("SELECT GAME");
gameSelect.captionLabel().style().padding(10,10,10,10);


Are there different methods for accessing the labels/value labels of a ScrollList?  Thanks again.

Also, a note for others, the example given by Sojamo only works with the latest release of ControlP5 (v.0.3.4)
Re: ControlP5 ControllerStyle() class
Reply #3 - Jan 14th, 2009, 11:14pm
 
bug with ControllerStyle and captionLabel:

if you load settings (Alt-l) all the style and label settings are reset.


Re: ControlP5 ControllerStyle() class
Reply #4 - Jan 17th, 2009, 8:33am
 
no bug, but no feature yet. i put it on the list.
Page Index Toggle Pages: 1