forked from bartvdbraak/blender
Fix #35633, Cannot Add Group Node In Blender 2.67a. The menu entry for the "make group" operator was missing in the new categories system. Added an alternative NodeItemCustom to the standard NodeItem to
allow custom draw functions such as this operator. Used in the group items callback to generate the basic group_make operator call.
This commit is contained in:
parent
aa96f0290a
commit
32f35056af
@ -57,6 +57,27 @@ class NodeItem():
|
|||||||
# if no custom label is defined, fall back to the node type UI name
|
# if no custom label is defined, fall back to the node type UI name
|
||||||
return getattr(bpy.types, self.nodetype).bl_rna.name
|
return getattr(bpy.types, self.nodetype).bl_rna.name
|
||||||
|
|
||||||
|
# NB: is a staticmethod because called with an explicit self argument
|
||||||
|
# NodeItemCustom sets this as a variable attribute in __init__
|
||||||
|
@staticmethod
|
||||||
|
def draw(self, layout, context):
|
||||||
|
default_context = bpy.app.translations.contexts.default
|
||||||
|
|
||||||
|
props = layout.operator("node.add_node", text=self.label, text_ctxt=default_context)
|
||||||
|
props.type = self.nodetype
|
||||||
|
props.use_transform = True
|
||||||
|
|
||||||
|
for setting in self.settings.items():
|
||||||
|
ops = props.settings.add()
|
||||||
|
ops.name = setting[0]
|
||||||
|
ops.value = setting[1]
|
||||||
|
|
||||||
|
|
||||||
|
class NodeItemCustom():
|
||||||
|
def __init__(self, poll=None, draw=None):
|
||||||
|
self.poll = poll
|
||||||
|
self.draw = draw
|
||||||
|
|
||||||
|
|
||||||
_node_categories = {}
|
_node_categories = {}
|
||||||
|
|
||||||
@ -71,14 +92,7 @@ def register_node_categories(identifier, cat_list):
|
|||||||
col = layout.column()
|
col = layout.column()
|
||||||
default_context = bpy.app.translations.contexts.default
|
default_context = bpy.app.translations.contexts.default
|
||||||
for item in self.category.items(context):
|
for item in self.category.items(context):
|
||||||
props = col.operator("node.add_node", text=item.label, text_ctxt=default_context)
|
item.draw(item, col, context)
|
||||||
props.type = item.nodetype
|
|
||||||
props.use_transform = True
|
|
||||||
|
|
||||||
for setting in item.settings.items():
|
|
||||||
ops = props.settings.add()
|
|
||||||
ops.name = setting[0]
|
|
||||||
ops.value = setting[1]
|
|
||||||
|
|
||||||
menu_types = []
|
menu_types = []
|
||||||
panel_types = []
|
panel_types = []
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
# <pep8 compliant>
|
# <pep8 compliant>
|
||||||
import bpy
|
import bpy
|
||||||
import nodeitems_utils
|
import nodeitems_utils
|
||||||
from nodeitems_utils import NodeCategory, NodeItem
|
from nodeitems_utils import NodeCategory, NodeItem, NodeItemCustom
|
||||||
|
|
||||||
|
|
||||||
# Subclasses for standard node types
|
# Subclasses for standard node types
|
||||||
@ -47,6 +47,11 @@ class TextureNodeCategory(NodeCategory):
|
|||||||
return context.space_data.tree_type == 'TextureNodeTree'
|
return context.space_data.tree_type == 'TextureNodeTree'
|
||||||
|
|
||||||
|
|
||||||
|
# menu entry for making a new group from selected nodes
|
||||||
|
def group_make_draw(self, layout, context):
|
||||||
|
layout.operator("node.group_make")
|
||||||
|
layout.separator()
|
||||||
|
|
||||||
# maps node tree type to group node type
|
# maps node tree type to group node type
|
||||||
node_tree_group_type = {
|
node_tree_group_type = {
|
||||||
'CompositorNodeTree' : 'CompositorNodeGroup',
|
'CompositorNodeTree' : 'CompositorNodeGroup',
|
||||||
@ -62,6 +67,8 @@ def node_group_items(context):
|
|||||||
if not ntree:
|
if not ntree:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
yield NodeItemCustom(draw=group_make_draw)
|
||||||
|
|
||||||
def contains_group(nodetree, group):
|
def contains_group(nodetree, group):
|
||||||
if nodetree == group:
|
if nodetree == group:
|
||||||
return True
|
return True
|
||||||
|
Loading…
Reference in New Issue
Block a user