Currently, the PopupMenu class is smart enough not to actually add a separator if addSeparator() is called twice or when the menu is still empty.
But if the menu just contains a section header added with addSectionHeader(), the separator is added even if it can be argued that it’s not really necessary.
Below is a suggested improvement that allows skipping the addition of a separator when in happens after a section header.
There is no way to do this via client code because it’s not possible to get the last item in a popup menu.
/* argument added with default value that avoids breaking change */
void PopupMenu::addSeparator(const bool skipAfterSectionHeader = false)
{
if (items.size() > 0
&& ! items.getLast().isSeparator
&& (! skipAfterSectionHeader || ! items.getLast().isSectionHeader)) //< proposed change
{
Item i;
i.isSeparator = true;
addItem (std::move (i));
}
}