rezaali/ofxUI

While AddSlider(...) works splendid sending floats, AddIntSlider does not work at all

iShapeNoise opened this issue · 3 comments

I want to get my sliders to send int, rather than float. Therefore, I tried to use AddIntSlider, which is implemented as standard. Unfortunately, it does not work.

gui->addSlider("SSPEED", 0, 200, sSpeed); works perfect!

gui->addIntSlider("SSPEED", 0, 200, sSpeed); not at all :-(

The GuiEvents code:

else if(name == "SSPEED")
{
ofxUISlider *rslider = (ofxUISlider *) e.widget;
sSpeed = rslider->getScaledValue();

    cout << "slider speed " << sSpeed << "\n";

@iShapeNoise is sSpeed an int or float? Also, not sure if you know, but you can use variable binding to automatically update the value for you:

int sSpeed = 0;
gui->addIntSlider("SSPEED", 0, 200, &sSpeed);

Let me know if that works for you.

Thank you very much for your reply.

I recognized, that values are integers. That might be through guiEvents.addIntArg(sSpeed);

However, the display on the widget still and remains float with .00 at the end. I have seen other conversations pointing at it. The display should change relatively to the type of widget. If we use
AddIntSlider..or in future...AddIntRotarySlider, the display could show the value in full.

Today, I copied over the latest release of your addon and now I am struggling with getting it compiled. ../../../addons/ofxUI/src/ofxUICanvas.cpp|511|error: ‘ofxUIFont’ has no member named ‘load’|

And there is one question I really would like to ask out of context:
Is there any way to get a grid matrix working, that makes it possible to position widget on a greater canvas easier? It could be a nested matrix of some sort, which sets a relative or absolute position to
its canvas width and height. The way I use it with e.g. OFX_UI_WIDGET_POSITION_DOWN does not do the trick for me.

Otherwise, it is a great addon, which I will use for all my upcoming projects in futures. Thanks Rez!

@iShapeNoise so the library is now officially deprecated, so I wouldn't recommend using it, try ofxGui now, its what comes with OF and has a lot more functionality (it will be maintained in the future).

To answer your question tho, all sliders have a function called: void setLabelPrecision(int _precision); you can set this value to 0 to just show the integer part.

Also, before deprecating the library I started updating it to work with OF 0.9.0, so I made changes that broke ofxUI's compatibility with any version of OF before 0.9.0, then realized the amount of work I would have to do to maintain ofxUI for both versions, and decided it was time to move on.

Regarding your second question, you can always use a widget's ofxUIRectangle* getRect(); method to get its underlying rect and place it doing something like this:

ofxUISlider *s = gui->addSlider(...);
ofxUIRectangle *r = s->getRect();
r->x = 100;
r->y = 100;

Let me know if that helps.