groupMenuItems

Performs grouping of the provided list of menu items based on the available toolbar capacity, meaning the max number of items it can fit.

Return

A re-ordered (could be left the same) list of menu items capacity that will ultimately be set on the toolbar.

Parameters

flatItems

Menu items originally set to the toolbar (note: there should be no submenus here, just flat items).

capacity

Maximum number of items the toolbar can fit (without optional drag and close buttons).