How to add a new feature to someone's addon? Exponential scale ofxGuiExtended sliders

Hello people:
I wanted to have sliders with exponential scale for frequencies, for instance. Instead of rebuilding the wheel I tried to use the ofxGuiExtended addon written by @frauzufall. I downloaded her repository and wrote a class named tableMap, which I included in the utils subfolder and I managed to modify the class ofxGuiSlider to map/unmap the values to/from the slider position.
I read somewhere in this forum that there is a bot that frequently scans github searching for the ofx prefix, so if I make a branch (or a clone?) of it under my username, two almost identical addons would appear in the addons.braitsch.io list. (Is it down now Dec 28th 20:14 UTC-3 btw?)
I just want to put it under test by all of you because I don’t know if the way I achieved what I wanted is the most optimal.
Here is an image with some graphs applied onto it to show the options that are already working. I am having trouble with updating the mapping table after creating the widget. The links to the files are below. Just replacing the current files with these ones should work.

To create one of these modified sliders one can write:

sliders->add(slider1Val.set("y=a*10^bx", 0.5, 0.05, 1.0), ofJson({{"width", 150}, {"height", 25}, {"mappingTableType", 2}, {"margin", "1 1 1 1"}}));

The mappingTableType key should be 1 to 4. I am reserving the value 0 for custom (externally) made table.

Happy new year, and happy anything that you like to commemorate these days.

Gus

Files:
in ofxGuiExtended/src/util:
tableMap.h:


tableMap.cpp:

in ofxGuiExtended/src/controls:
ofxGuiSlider.h:


ofxGuiSlider.cpp:

Hi @GusCarr,

I really like the idea so I added a ofxGuiFunctionSlider to ofxGuiExtended - maybe this helps you.

It works a bit differently than what you did, it lets you basically assign any mapping function to a slider. You also have to provide the reverse function, since this is needed if the value of the slider is set programmatically (e.g. on initialization).

ofParameter<float> exponentialValue;
ofxGuiFloatFunctionSlider* functionSlider = group->add<ofxGuiFloatFunctionSlider>(exponentialValue.set("exponential", 2, 1, 10000));
functionSlider->setFunctions(exponentialFunction, reversedExponentialFunction);

… and here are example functions:

float exponentialFunction(float x) {
	return pow(10, x);
}

float reversedExponentialFunction(float y) {
	return log10(y);
}

I also added this to the exampleAdvancedGui example. In case you decide to try it, let me know if anything behaves unexpectedly.

1 Like

Thank you very much @frauzufall, I’m checking on it right away. :slight_smile:

1 Like