Skip to content
Snippets Groups Projects
Commit 2a869472 authored by Lukas Toenne's avatar Lukas Toenne
Browse files

svn merge ^/trunk/blender -c57073

parent 1e61184f
No related branches found
No related tags found
No related merge requests found
...@@ -36,13 +36,18 @@ class NodeCategory(): ...@@ -36,13 +36,18 @@ class NodeCategory():
elif callable(items): elif callable(items):
self.items = items self.items = items
else: else:
self.items = lambda context: items def items_gen(context):
for item in items:
if item.poll is None or item.poll(context):
yield item
self.items = items_gen
class NodeItem(): class NodeItem():
def __init__(self, nodetype, label=None, settings={}): def __init__(self, nodetype, label=None, settings={}, poll=None):
self.nodetype = nodetype self.nodetype = nodetype
self._label = label self._label = label
self.settings = settings self.settings = settings
self.poll = poll
@property @property
def label(self): def label(self):
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
# ##### END GPL LICENSE BLOCK ##### # ##### END GPL LICENSE BLOCK #####
# <pep8 compliant> # <pep8 compliant>
import bpy
import nodeitems_utils import nodeitems_utils
from nodeitems_utils import NodeCategory, NodeItem from nodeitems_utils import NodeCategory, NodeItem
...@@ -80,6 +81,13 @@ def node_group_items(context): ...@@ -80,6 +81,13 @@ def node_group_items(context):
yield NodeItem(node_tree_group_type[group.bl_idname], group.name, { "node_tree" : "bpy.data.node_groups[%r]" % group.name }) yield NodeItem(node_tree_group_type[group.bl_idname], group.name, { "node_tree" : "bpy.data.node_groups[%r]" % group.name })
# only show input/output nodes inside node groups
def group_input_output_item_poll(context):
space = context.space_data
if space.edit_tree in bpy.data.node_groups.values():
return True
return False
# All standard node categories currently used in nodes. # All standard node categories currently used in nodes.
...@@ -93,9 +101,11 @@ shader_node_categories = [ ...@@ -93,9 +101,11 @@ shader_node_categories = [
NodeItem("ShaderNodeTexture"), NodeItem("ShaderNodeTexture"),
NodeItem("ShaderNodeGeometry"), NodeItem("ShaderNodeGeometry"),
NodeItem("ShaderNodeExtendedMaterial"), NodeItem("ShaderNodeExtendedMaterial"),
NodeItem("NodeGroupInput", poll=group_input_output_item_poll),
]), ]),
ShaderOldNodeCategory("SH_OUTPUT", "Output", items=[ ShaderOldNodeCategory("SH_OUTPUT", "Output", items=[
NodeItem("ShaderNodeOutput"), NodeItem("ShaderNodeOutput"),
NodeItem("NodeGroupOutput", poll=group_input_output_item_poll),
]), ]),
ShaderOldNodeCategory("SH_OP_COLOR", "Color", items=[ ShaderOldNodeCategory("SH_OP_COLOR", "Color", items=[
NodeItem("ShaderNodeMixRGB"), NodeItem("ShaderNodeMixRGB"),
...@@ -139,11 +149,13 @@ shader_node_categories = [ ...@@ -139,11 +149,13 @@ shader_node_categories = [
NodeItem("ShaderNodeHairInfo"), NodeItem("ShaderNodeHairInfo"),
NodeItem("ShaderNodeParticleInfo"), NodeItem("ShaderNodeParticleInfo"),
NodeItem("ShaderNodeCameraData"), NodeItem("ShaderNodeCameraData"),
NodeItem("NodeGroupInput", poll=group_input_output_item_poll),
]), ]),
ShaderNewNodeCategory("SH_NEW_OUTPUT", "Output", items=[ ShaderNewNodeCategory("SH_NEW_OUTPUT", "Output", items=[
NodeItem("ShaderNodeOutputMaterial"), NodeItem("ShaderNodeOutputMaterial"),
NodeItem("ShaderNodeOutputLamp"), NodeItem("ShaderNodeOutputLamp"),
NodeItem("ShaderNodeOutputWorld"), NodeItem("ShaderNodeOutputWorld"),
NodeItem("NodeGroupOutput", poll=group_input_output_item_poll),
]), ]),
ShaderNewNodeCategory("SH_NEW_SHADER", "Shader", items=[ ShaderNewNodeCategory("SH_NEW_SHADER", "Shader", items=[
NodeItem("ShaderNodeMixShader"), NodeItem("ShaderNodeMixShader"),
...@@ -221,6 +233,7 @@ compositor_node_categories = [ ...@@ -221,6 +233,7 @@ compositor_node_categories = [
NodeItem("CompositorNodeBokehImage"), NodeItem("CompositorNodeBokehImage"),
NodeItem("CompositorNodeTime"), NodeItem("CompositorNodeTime"),
NodeItem("CompositorNodeTrackPos"), NodeItem("CompositorNodeTrackPos"),
NodeItem("NodeGroupInput", poll=group_input_output_item_poll),
]), ]),
CompositorNodeCategory("CMP_OUTPUT", "Output", items = [ CompositorNodeCategory("CMP_OUTPUT", "Output", items = [
NodeItem("CompositorNodeComposite"), NodeItem("CompositorNodeComposite"),
...@@ -228,6 +241,7 @@ compositor_node_categories = [ ...@@ -228,6 +241,7 @@ compositor_node_categories = [
NodeItem("CompositorNodeSplitViewer"), NodeItem("CompositorNodeSplitViewer"),
NodeItem("CompositorNodeOutputFile"), NodeItem("CompositorNodeOutputFile"),
NodeItem("CompositorNodeLevels"), NodeItem("CompositorNodeLevels"),
NodeItem("NodeGroupOutput", poll=group_input_output_item_poll),
]), ]),
CompositorNodeCategory("CMP_OP_COLOR", "Color", items = [ CompositorNodeCategory("CMP_OP_COLOR", "Color", items = [
NodeItem("CompositorNodeMixRGB"), NodeItem("CompositorNodeMixRGB"),
...@@ -321,10 +335,12 @@ texture_node_categories = [ ...@@ -321,10 +335,12 @@ texture_node_categories = [
NodeItem("TextureNodeCoordinates"), NodeItem("TextureNodeCoordinates"),
NodeItem("TextureNodeTexture"), NodeItem("TextureNodeTexture"),
NodeItem("TextureNodeImage"), NodeItem("TextureNodeImage"),
NodeItem("NodeGroupInput", poll=group_input_output_item_poll),
]), ]),
TextureNodeCategory("TEX_OUTPUT", "Output", items = [ TextureNodeCategory("TEX_OUTPUT", "Output", items = [
NodeItem("TextureNodeOutput"), NodeItem("TextureNodeOutput"),
NodeItem("TextureNodeViewer"), NodeItem("TextureNodeViewer"),
NodeItem("NodeGroupOutput", poll=group_input_output_item_poll),
]), ]),
TextureNodeCategory("TEX_OP_COLOR", "Color", items = [ TextureNodeCategory("TEX_OP_COLOR", "Color", items = [
NodeItem("TextureNodeMixRGB"), NodeItem("TextureNodeMixRGB"),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment