-
Notifications
You must be signed in to change notification settings - Fork 233
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
Allow extra_menu: tag for nested menus. #4830
Conversation
ui/nodeview_space_menu.py
Outdated
for cat in add_node_menu: | ||
if getattr(cat, 'extra_menu', '') == self.menu_name: | ||
cat.draw(_self.layout) | ||
elif isinstance(cat, Category): | ||
for item in cat: | ||
if getattr(item, 'extra_menu', '') == self.menu_name: | ||
item.draw(_self.layout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this method can be used instead
sverchok/ui/nodeview_space_menu.py
Line 272 in b7b06eb
def walk_categories(self) -> 'Category': |
for cat in add_node_menu: | |
if getattr(cat, 'extra_menu', '') == self.menu_name: | |
cat.draw(_self.layout) | |
elif isinstance(cat, Category): | |
for item in cat: | |
if getattr(item, 'extra_menu', '') == self.menu_name: | |
item.draw(_self.layout) | |
for cat in add_node_menu.walk_categories(): | |
if getattr(cat, 'extra_menu', '') == self.menu_name: | |
cat.draw(_self.layout) |
Probably I preferred the first variant for performance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, updated.
I had to add a parameter to walk_categories to include CustomMenu items in order to include Groups and Presets into 5 menu.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not realize that Custom Menus are also needed. Then using walk_categories it not best choice. The idea was that the method returns only categories. The annontation also show this. And there is recursive call which makes things a bit more complicated. I can suggest than:
sub_categories = [add_node_menu]
for _ in range(1000):
cat = sub_categories.pop()
for cat_item in cat:
if getattr(cat, 'extra_menu', '') == self.menu_name:
cat_item.draw(_self.layout)
if hasattr(cat, '__iter__'):
sub_categories.append(cat_item)
if not sub_categories:
break
else:
log('There is some problem')
This allows to process
extra_menu:
tags for nested menus inindex.yaml
.Preflight checklist
Put an x letter in each brackets when you're done this item: