[Bf-blender-cvs] [eaa9feb9a05] temp-enum-socket: progress
Jacques Lucke
noreply at git.blender.org
Mon Nov 8 16:07:02 CET 2021
Commit: eaa9feb9a05d7554d195eaab50b6c5b62b2cee3f
Author: Jacques Lucke
Date: Sat Nov 6 18:25:11 2021 +0100
Branches: temp-enum-socket
https://developer.blender.org/rBeaa9feb9a05d7554d195eaab50b6c5b62b2cee3f
progress
===================================================================
M release/scripts/startup/bl_operators/node.py
M source/blender/makesrna/intern/rna_nodetree.c
M source/blender/nodes/function/nodes/node_fn_enum.cc
===================================================================
diff --git a/release/scripts/startup/bl_operators/node.py b/release/scripts/startup/bl_operators/node.py
index 2959232fa51..2eb1079a8db 100644
--- a/release/scripts/startup/bl_operators/node.py
+++ b/release/scripts/startup/bl_operators/node.py
@@ -306,6 +306,28 @@ class NODE_OT_tree_path_parent(Operator):
return {'FINISHED'}
+class NODE_OT_enum_item_add(Operator):
+ '''Add enum item'''
+ bl_idname = "node.enum_item_add"
+ bl_label = "Add Enum Item"
+ bl_options = {'UNDO'}
+
+ node_name: StringProperty()
+
+ @classmethod
+ def poll(cls, context):
+ space = context.space_data
+ return space is not None and space.type == 'NODE_EDITOR' and space.edit_tree is not None
+
+ def execute(self, context):
+ space = context.space_data
+ node = space.edit_tree.nodes.get(self.node_name)
+ if node is None:
+ return {'CANCELLED'}
+ node.enum_items.new()
+ return {'FINISHED'}
+
+
classes = (
NodeSetting,
@@ -314,4 +336,5 @@ classes = (
NODE_OT_add_search,
NODE_OT_collapse_hide_unused_toggle,
NODE_OT_tree_path_parent,
+ NODE_OT_enum_item_add,
)
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index f2558f30ffb..8a2df8638aa 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -4577,7 +4577,6 @@ static NodeFunctionEnumItem *rna_NodeFunctionEnumItems_items_new(bNode *node)
NodeFunctionEnumItem *item = MEM_callocN(sizeof(NodeFunctionEnumItem), __func__);
item->owner_node = node;
BLI_addtail(&storage->items, item);
- printf("%d\n", BLI_listbase_count(&storage->items));
return item;
}
diff --git a/source/blender/nodes/function/nodes/node_fn_enum.cc b/source/blender/nodes/function/nodes/node_fn_enum.cc
index 42c781c2404..fe21cc53baf 100644
--- a/source/blender/nodes/function/nodes/node_fn_enum.cc
+++ b/source/blender/nodes/function/nodes/node_fn_enum.cc
@@ -39,10 +39,10 @@ static void fn_node_enum_init(bNodeTree *UNUSED(tree), bNode *node)
node->storage = data;
}
-static void fn_node_enum_layout(uiLayout *UNUSED(layout),
- bContext *UNUSED(C),
- PointerRNA *UNUSED(ptr))
+static void fn_node_enum_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
+ bNode *node = (bNode *)ptr->data;
+ uiItemStringO(layout, "Add", ICON_PLUS, "node.enum_item_add", "node_name", node->name);
}
static const fn::MultiFunction *get_multi_function(bNode &UNUSED(bnode))
More information about the Bf-blender-cvs
mailing list