nodeeditor icon indicating copy to clipboard operation
nodeeditor copied to clipboard

Add sort button for the scene menu, remove `CategoriesSet`

Open zmoth opened this issue 3 years ago • 3 comments

  • No longer use registry->categories() to create parent items
  • Automatic sorting
  • removed CategoriesSet

I looked up where CategoriesSet is used in v2 and v3 and found that it is only used when creating menus. RegisteredModelsCategoryMap is perfectly capable of doing the job of CategoriesSet.

So I think the CategoriesSet can now be removed.

Please contact me if I have any incomplete considerations. Thanks.

zmoth avatar Dec 16 '22 05:12 zmoth

Your changes totally make sense.

What do you think about this one ? #147 And the corresponding PR https://github.com/paceholder/nodeeditor/pull/163

thanks

paceholder avatar Dec 16 '22 17:12 paceholder

  • I use std::vector to store the RegisteredModelsCategory, and since the class seems to be used only to generate the Scene Menu, just traversing it without using lookups, using std::vector not only sorts the classes in the order they are registered, but also reduces the performance loss (though not by much)
  • I don't think it's a good idea to use ret->sortCategories() to sort at the end of the registration model. Because I won't know which model will be loaded last in my plugin_extensionbranch because of the plugin name change.
  • I have used a bool variable to flag whether or not the Menu needs to be sorted when it is generated, but I think the best way to do this would be to place a Button in the Menu to choose whether or not to sort it, and to be able to take effect the next time the Menu is generated.

Is there anything else you think we should recommend or improve? Thanks

zmoth avatar Dec 17 '22 08:12 zmoth

Sort button function

  auto ret = std::make_shared<NodeDelegateModelRegistry>();

  ret->registerModel<NumberSourceDataModel>("Sources");
  ret->registerModel<NumberDisplayDataModel>("Displays");
  ret->registerModel<AdditionModel>("Operators");
  ret->registerModel<SubtractionModel>("Operators");
  ret->registerModel<MultiplicationModel>("Operators");
  ret->registerModel<DivisionModel>("Operators");

imageimage

zmoth avatar Dec 17 '22 15:12 zmoth