forked from bartvdbraak/blender
Fix for nodeitems module using the NODE_MT_add menu types from bl_ui.
This is basically a bad-level call: ui scripts are registered *after* the modules. It only works for addons because those are loaded even later. Now the nodeitems_utils module just defines a function which is then called by the UI script, rather than the other way around.
This commit is contained in:
parent
4052384be3
commit
9bcf1bb266
@ -85,7 +85,6 @@ class NodeItemCustom:
|
||||
|
||||
_node_categories = {}
|
||||
|
||||
|
||||
def register_node_categories(identifier, cat_list):
|
||||
if identifier in _node_categories:
|
||||
raise KeyError("Node categories list '%s' already registered" % identifier)
|
||||
@ -131,8 +130,6 @@ def register_node_categories(identifier, cat_list):
|
||||
if cat.poll(context):
|
||||
layout.menu("NODE_MT_category_%s" % cat.identifier)
|
||||
|
||||
bpy.types.NODE_MT_add.append(draw_add_menu)
|
||||
|
||||
# stores: (categories list, menu draw function, submenu types, panel types)
|
||||
_node_categories[identifier] = (cat_list, draw_add_menu, menu_types, panel_types)
|
||||
|
||||
@ -151,7 +148,6 @@ def node_items_iter(context):
|
||||
|
||||
|
||||
def unregister_node_cat_types(cats):
|
||||
bpy.types.NODE_MT_add.remove(cats[1])
|
||||
for mt in cats[2]:
|
||||
bpy.utils.unregister_class(mt)
|
||||
for pt in cats[3]:
|
||||
@ -170,3 +166,7 @@ def unregister_node_categories(identifier=None):
|
||||
for cat_types in _node_categories.values():
|
||||
unregister_node_cat_types(cat_types)
|
||||
_node_categories.clear()
|
||||
|
||||
def draw_node_categories_menu(self, context):
|
||||
for cats in _node_categories.values():
|
||||
cats[1](self, context)
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
# <pep8 compliant>
|
||||
import bpy
|
||||
import nodeitems_utils
|
||||
from bpy.types import Header, Menu, Panel
|
||||
from bpy.app.translations import pgettext_iface as iface_
|
||||
from bl_ui.properties_grease_pencil_common import (
|
||||
@ -154,7 +155,8 @@ class NODE_MT_add(bpy.types.Menu):
|
||||
props = layout.operator("node.add_search", text="Search ...")
|
||||
props.use_transform = True
|
||||
|
||||
# actual node submenus are added by draw functions from node categories
|
||||
# actual node submenus are defined by draw functions from node categories
|
||||
nodeitems_utils.draw_node_categories_menu(self, context)
|
||||
|
||||
|
||||
class NODE_MT_view(Menu):
|
||||
|
Loading…
Reference in New Issue
Block a user