diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2016-04-27 01:58:25 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2016-04-27 22:37:14 +0300 |
commit | dd8a7342bcc46aa567c86737ab583db6aa05803a (patch) | |
tree | d573aa16b4650db1e45c0b3e1defa2cc064cf570 /release | |
parent | c0ae38f65642da42909420e444ef464686773e49 (diff) |
Nodes: sort builtin compositor/shader/texture nodes alphabetically in menus
Reviewed By: lukastoenne, dingto, Severin, carter2422
Differential Revision: https://developer.blender.org/D1957
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/startup/nodeitems_builtins.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py index 9dca55ede00..b93cb857e0a 100644 --- a/release/scripts/startup/nodeitems_builtins.py +++ b/release/scripts/startup/nodeitems_builtins.py @@ -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' |