[Bf-blender-cvs] [1415d3466b5] simulation-tree: first socket defined in C++
Jacques Lucke
noreply at git.blender.org
Mon Feb 17 18:16:20 CET 2020
Commit: 1415d3466b50ac250cf26c4799922e7eb1dc628f
Author: Jacques Lucke
Date: Mon Feb 17 15:17:33 2020 +0100
Branches: simulation-tree
https://developer.blender.org/rB1415d3466b50ac250cf26c4799922e7eb1dc628f
first socket defined in C++
===================================================================
M source/blender/simulations/nodes/my_test_node.cc
===================================================================
diff --git a/source/blender/simulations/nodes/my_test_node.cc b/source/blender/simulations/nodes/my_test_node.cc
index 789ea1f9fc0..3bb494c5efd 100644
--- a/source/blender/simulations/nodes/my_test_node.cc
+++ b/source/blender/simulations/nodes/my_test_node.cc
@@ -8,6 +8,8 @@
#include "BLI_set.h"
#include "BLI_linear_allocator.h"
+#include "UI_interface.h"
+
using BLI::LinearAllocator;
using BLI::Set;
using BLI::StringRef;
@@ -221,7 +223,31 @@ void register_node_type_my_test_node()
void init_socket_data_types()
{
- float_socket_type = new BaseSocketDataType("Float", nodeSocketTypeFind("NodeSocketFloat"));
+ {
+ bNodeSocketType *stype = (bNodeSocketType *)MEM_callocN(sizeof(bNodeSocketType), __func__);
+ strcpy(stype->idname, "TestSocket");
+ stype->draw = [](struct bContext *UNUSED(C),
+ struct uiLayout *layout,
+ struct PointerRNA *UNUSED(ptr),
+ struct PointerRNA *UNUSED(node_ptr),
+ const char *text) {
+ uiItemL(layout, text, 0);
+ std::cout << "->draw\n";
+ };
+ stype->draw_color = [](struct bContext *UNUSED(C),
+ struct PointerRNA *UNUSED(ptr),
+ struct PointerRNA *UNUSED(node_ptr),
+ float *r_color) {
+ r_color[0] = 1.0f;
+ r_color[1] = 0.5f;
+ r_color[2] = 0.5f;
+ r_color[3] = 1.0f;
+ std::cout << "->draw_color\n";
+ };
+ nodeRegisterSocketType(stype);
+ }
+
+ float_socket_type = new BaseSocketDataType("Float", nodeSocketTypeFind("TestSocket"));
int_socket_type = new BaseSocketDataType("Integer", nodeSocketTypeFind("NodeSocketInt"));
socket_data_types = new DataTypesInfo();
More information about the Bf-blender-cvs
mailing list