Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sort button for the scene menu, remove CategoriesSet #348

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zmoth
Copy link
Contributor

@zmoth zmoth commented Dec 16, 2022

  • 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.

@paceholder
Copy link
Owner

paceholder commented Dec 16, 2022

Your changes totally make sense.

What do you think about this one ? #147
And the corresponding PR #163

thanks

@zmoth
Copy link
Contributor Author

zmoth commented Dec 17, 2022

  • 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
Copy link
Contributor Author

zmoth commented Dec 17, 2022

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 zmoth changed the title Optimising the scene menu creation process, remove CategoriesSet Add sort button for the scene menu, remove CategoriesSet Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants