mirror of
https://projects.blender.org/blender/blender.git
synced 2025-01-22 07:22:12 -05:00
be0c9174aa
- Wrap the closing parenthesis onto it's own line which makes assignments to the return value read better. - Reduce right-shift with multi-line function calls.
56 lines
1.4 KiB
Python
56 lines
1.4 KiB
Python
# SPDX-FileCopyrightText: 2013-2023 Blender Authors
|
|
#
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
import bpy
|
|
from nodeitems_utils import (
|
|
NodeCategory,
|
|
NodeItem,
|
|
NodeItemCustom,
|
|
)
|
|
|
|
|
|
# Subclasses for standard node types
|
|
|
|
class SortedNodeCategory(NodeCategory):
|
|
def __init__(self, identifier, name, description="", items=None):
|
|
# for builtin nodes the convention is to sort by name
|
|
if isinstance(items, list):
|
|
items = sorted(items, key=lambda item: item.label.lower())
|
|
|
|
super().__init__(identifier, name, description=description, items=items)
|
|
|
|
|
|
class CompositorNodeCategory(SortedNodeCategory):
|
|
@classmethod
|
|
def poll(cls, context):
|
|
return (
|
|
context.space_data.type == 'NODE_EDITOR' and
|
|
context.space_data.tree_type == 'CompositorNodeTree'
|
|
)
|
|
|
|
|
|
class ShaderNodeCategory(SortedNodeCategory):
|
|
@classmethod
|
|
def poll(cls, context):
|
|
return (
|
|
context.space_data.type == 'NODE_EDITOR' and
|
|
context.space_data.tree_type == 'ShaderNodeTree'
|
|
)
|
|
|
|
|
|
# Maps node tree type to group node type.
|
|
node_tree_group_type = {
|
|
'CompositorNodeTree': 'CompositorNodeGroup',
|
|
'ShaderNodeTree': 'ShaderNodeGroup',
|
|
'TextureNodeTree': 'TextureNodeGroup',
|
|
'GeometryNodeTree': 'GeometryNodeGroup',
|
|
}
|
|
|
|
|
|
def register():
|
|
pass
|
|
|
|
|
|
def unregister():
|
|
pass
|