Skip to content

Instantly share code, notes, and snippets.

@moebiussurfing
Last active August 22, 2020 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moebiussurfing/ce8f8ddcfb5e78c7d9074e10a5644eb8 to your computer and use it in GitHub Desktop.
Save moebiussurfing/ce8f8ddcfb5e78c7d9074e10a5644eb8 to your computer and use it in GitHub Desktop.
openFrameworks / get a widget/parameter from and ofxGuiGroup
//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);
}
}
}
@moebiussurfing
Copy link
Author

Capture2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment