Last active
August 22, 2020 16:55
-
-
Save moebiussurfing/ce8f8ddcfb5e78c7d9074e10a5644eb8 to your computer and use it in GitHub Desktop.
openFrameworks / get a widget/parameter from and ofxGuiGroup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://forum.openframeworks.cc/t/can-iterate-though-all-ofxgui-elements/35047/11 | |
//https://forum.openframeworks.cc/t/its-posible-to-avoid-ofxgui-float-ofxslider-label-style-2-8e-15-to-0-000028/35953/2 | |
gui.setup(parameters); | |
//iterate through all elements of this gui | |
for (int i = 0; i < gui.getNumControls(); i++) { | |
auto control = gui.getControl(i); | |
//check if one of the elements might be a parameterGroup; i.e. parameter contains multiple items | |
string paramString = ofToString(control->getParameter()); | |
if (ofIsStringInString(paramString, ":")) { | |
//it's a group, so iterate through each group element | |
ofxGuiGroup aGroup = gui.getGroup(control->getName()); | |
for (int n = 0; n < aGroup.getNumControls(); n++) { | |
auto g_control = aGroup.getControl(n); | |
cout << ofToString(i) << " " << ofToString(control->getName()) << " : " << ofToString(g_control->getName()) << endl; | |
//customize widget | |
if (g_control->getName() == renderer1.size.getName()) { | |
auto w = g_control->getWidth(); | |
g_control->setSize(w, 40); | |
g_control->setFillColor(ofColor::red); | |
} | |
} | |
} | |
else { | |
//it's a parameter | |
cout << ofToString(i) << " " << ofToString(control->getName()) << endl; | |
//customize widget | |
if (control->getName() == f.getName()) { | |
auto w = control->getWidth(); | |
control->setSize(w, 40); | |
control->setFillColor(ofColor::red); | |
} | |
} | |
} | |
Author
moebiussurfing
commented
Aug 22, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment