Minor code simplification in previous commit.
This commit is contained in:
@@ -24,45 +24,35 @@ from nodeitems_utils import NodeCategory, NodeItem, NodeItemCustom
|
|||||||
|
|
||||||
# Subclasses for standard node types
|
# Subclasses for standard node types
|
||||||
|
|
||||||
def alphabetical(items):
|
class SortedNodeCategory(NodeCategory):
|
||||||
|
def __init__(self, identifier, name, description="", items=None):
|
||||||
# for builtin nodes the convention is to sort by name
|
# for builtin nodes the convention is to sort by name
|
||||||
if isinstance(items, list):
|
if isinstance(items, list):
|
||||||
return sorted(items, key=lambda item: item.label().lower)
|
items = sorted(items, key=lambda item: item.label.lower())
|
||||||
return items
|
|
||||||
|
|
||||||
class CompositorNodeCategory(NodeCategory):
|
super().__init__(identifier, name, description, items)
|
||||||
def __init__(self, identifier, name, description="", items=None):
|
|
||||||
super().__init__(identifier, name, description, alphabetical(items))
|
|
||||||
|
|
||||||
|
class CompositorNodeCategory(SortedNodeCategory):
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
return (context.space_data.tree_type == 'CompositorNodeTree')
|
return (context.space_data.tree_type == 'CompositorNodeTree')
|
||||||
|
|
||||||
|
|
||||||
class ShaderNewNodeCategory(NodeCategory):
|
class ShaderNewNodeCategory(SortedNodeCategory):
|
||||||
def __init__(self, identifier, name, description="", items=None):
|
|
||||||
super().__init__(identifier, name, description, alphabetical(items))
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
return (context.space_data.tree_type == 'ShaderNodeTree' and
|
return (context.space_data.tree_type == 'ShaderNodeTree' and
|
||||||
context.scene.render.use_shading_nodes)
|
context.scene.render.use_shading_nodes)
|
||||||
|
|
||||||
|
|
||||||
class ShaderOldNodeCategory(NodeCategory):
|
class ShaderOldNodeCategory(SortedNodeCategory):
|
||||||
def __init__(self, identifier, name, description="", items=None):
|
|
||||||
super().__init__(identifier, name, description, alphabetical(items))
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
return (context.space_data.tree_type == 'ShaderNodeTree' and
|
return (context.space_data.tree_type == 'ShaderNodeTree' and
|
||||||
not context.scene.render.use_shading_nodes)
|
not context.scene.render.use_shading_nodes)
|
||||||
|
|
||||||
|
|
||||||
class TextureNodeCategory(NodeCategory):
|
class TextureNodeCategory(SortedNodeCategory):
|
||||||
def __init__(self, identifier, name, description="", items=None):
|
|
||||||
super().__init__(identifier, name, description, alphabetical(items))
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
return context.space_data.tree_type == 'TextureNodeTree'
|
return context.space_data.tree_type == 'TextureNodeTree'
|
||||||
|
Reference in New Issue
Block a user