Nodes: sort builtin compositor/shader/texture nodes alphabetically in menus
Reviewed By: lukastoenne, dingto, Severin, carter2422 Differential Revision: https://developer.blender.org/D1957
This commit is contained in:
@@ -24,13 +24,25 @@ from nodeitems_utils import NodeCategory, NodeItem, NodeItemCustom
|
||||
|
||||
# Subclasses for standard node types
|
||||
|
||||
def alphabetical(items):
|
||||
# for builtin nodes the convention is to sort by name
|
||||
if isinstance(items, list):
|
||||
return sorted(items, key=lambda item: item.label().lower)
|
||||
return items
|
||||
|
||||
class CompositorNodeCategory(NodeCategory):
|
||||
def __init__(self, identifier, name, description="", items=None):
|
||||
super().__init__(identifier, name, description, alphabetical(items))
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return (context.space_data.tree_type == 'CompositorNodeTree')
|
||||
|
||||
|
||||
class ShaderNewNodeCategory(NodeCategory):
|
||||
def __init__(self, identifier, name, description="", items=None):
|
||||
super().__init__(identifier, name, description, alphabetical(items))
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return (context.space_data.tree_type == 'ShaderNodeTree' and
|
||||
@@ -38,6 +50,9 @@ class ShaderNewNodeCategory(NodeCategory):
|
||||
|
||||
|
||||
class ShaderOldNodeCategory(NodeCategory):
|
||||
def __init__(self, identifier, name, description="", items=None):
|
||||
super().__init__(identifier, name, description, alphabetical(items))
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return (context.space_data.tree_type == 'ShaderNodeTree' and
|
||||
@@ -45,6 +60,9 @@ class ShaderOldNodeCategory(NodeCategory):
|
||||
|
||||
|
||||
class TextureNodeCategory(NodeCategory):
|
||||
def __init__(self, identifier, name, description="", items=None):
|
||||
super().__init__(identifier, name, description, alphabetical(items))
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return context.space_data.tree_type == 'TextureNodeTree'
|
||||
|
Reference in New Issue
Block a user