Fixes #2505 : Style options and context menu items are now ordered by the "gravity" property. Some refactoring.