I can't seem to find a way to get a PropertyPanel to automatically scroll to a recently opened section. I have a feeling I already know the answer to this, but is there a way to do this? And if not, what would be the most unintrusive way?
How about the following for a solution?
void PropertyPanel::setSectionOpen (const int sectionIndex, const bool shouldBeOpen, const bool shouldScroll)
{
int index = 0;
for (int i = 0; i < propertyHolderComponent->getNumSections(); ++i)
{
SectionComponent* const section = propertyHolderComponent->getSection (i);
if (section->getName().isNotEmpty())
{
if (index == sectionIndex)
{
section->setOpen (shouldBeOpen);
if(shouldScroll)
{
viewport.setViewPosition(section->getX(), section->getY());
}
break;
}
++index;
}
}
}
