Hi Memo
in reference to http://forum.openframeworks.cc/t/ofxmsafluid-and-ofxsimpleguitoo-examples-fixed/2619/0 (“ofxMSAFluid and ofxSimpleGuiTooExamples fixed”), some small problems remain with simpleGui and am wondering how to best fix it.
I downloaded your latest from github’s memo/msalibs, and inside ofxSimpleGuiToo.cpp:
ofxSimpleGuiControl &ofxSimpleGuiToo::control(string name)
{
for(int i = 0; i < pages.size(); i++)
{
for(int j = 0; j < pages[i]->getControls().size(); j++)
{
if(name==pages[i]->getControls()[j]->name)
{
return *pages[i]->getControls()[j];
}
}
}
//return NULL;
}
You had commented out the "return NULL;"s (cuz one can’t return a NULL reference), but GCC complains about the lack of return value of course.
I could patch that by returning an exception when no match is found, but wouldn’t it make more sense that search functions such as this one – and page(string name) and page(int i) – should return pointers (potentially NULL) and not references? Something like:
ofxSimpleGuiControl* ofxSimpleGuiToo::findControl(string name)
{
for(int i = 0; i < pages.size(); i++)
{
for(int j = 0; j < pages[i]->getControls().size(); j++)
{
if(name==pages[i]->getControls()[j]->name)
{
return pages[i]->getControls()[j];
}
}
}
return NULL;
}
ofxSimpleGuiPage* ofxSimpleGuiToo::findPage(int i)
{
return pages.at(i);
}
ofxSimpleGuiPage* ofxSimpleGuiToo::findPage(string name)
{
if (!config) setup();
for (int i=1; i<pages.size(); i++)
{
if (name.compare(pages[i]->name) == 0)
{
return pages[i];
}
}
return NULL;
}
?
Cheers
Alex