nodeeditor
nodeeditor copied to clipboard
Allow arbitrary ordering of nodes in the context menu
The ordering of nodes inside the DataModelRegistry is currently pretty arbitrary. When you open the context menu, the nodes are ordered by Category (sorted, as it uses std::set
), but within each category, there is no ordering. If I understand the code correctly, this is because RegisteredModelsCategoryMap
is a std::unordered_map
.
I think it's beneficial to allow this ordering to be fully specified by a user of this library, or at least the order of nodes within any given category.
My proposal is thus the following:
- Keep the models of a given category in the order that they were registered. This is backwards compatible, assuming the user doesn't rely on the iteration order of
unordered_map
- Keep the categories in the order that they are inserted in via
registerModel
. Basically, use astd::vector
instead of astd::set
. It might be a good idea to add asortCategories()
function. This is backwards incompatible, but I think it's valuable. If we want to stay backwards compatible, there should at least be a way to specify the order of the categories.