Blender  V2.93
node_fn_input_string.cc
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
17 #include "node_function_util.hh"
18 
19 #include "UI_interface.h"
20 #include "UI_resources.h"
21 
23  {SOCK_STRING, N_("String")},
24  {-1, ""},
25 };
26 
28 {
29  uiItemR(layout, ptr, "string", 0, "", ICON_NONE);
30 }
31 
34 {
35  bNode &bnode = builder.bnode();
36  NodeInputString *node_storage = static_cast<NodeInputString *>(bnode.storage);
37  std::string string = std::string((node_storage->string) ? node_storage->string : "");
38 
40 }
41 
43 {
44  node->storage = MEM_callocN(sizeof(NodeInputString), __func__);
45 }
46 
48 {
49  NodeInputString *storage = (NodeInputString *)node->storage;
50  if (storage == nullptr) {
51  return;
52  }
53  if (storage->string != nullptr) {
54  MEM_freeN(storage->string);
55  }
56  MEM_freeN(storage);
57 }
58 
59 static void fn_node_string_copy(bNodeTree *UNUSED(dest_ntree),
60  bNode *dest_node,
61  const bNode *src_node)
62 {
63  NodeInputString *source_storage = (NodeInputString *)src_node->storage;
64  NodeInputString *destination_storage = (NodeInputString *)MEM_dupallocN(source_storage);
65 
66  if (source_storage->string) {
67  destination_storage->string = (char *)MEM_dupallocN(source_storage->string);
68  }
69 
70  dest_node->storage = destination_storage;
71 }
72 
74 {
75  static bNodeType ntype;
76 
83  nodeRegisterType(&ntype);
84 }
void node_type_socket_templates(struct bNodeType *ntype, struct bNodeSocketTemplate *inputs, struct bNodeSocketTemplate *outputs)
Definition: node.cc:4527
void node_type_init(struct bNodeType *ntype, void(*initfunc)(struct bNodeTree *ntree, struct bNode *node))
Definition: node.cc:4559
void node_type_storage(struct bNodeType *ntype, const char *storagename, void(*freefunc)(struct bNode *node), void(*copyfunc)(struct bNodeTree *dest_ntree, struct bNode *dest_node, const struct bNode *src_node))
Definition: node.cc:4599
#define NODE_CLASS_INPUT
Definition: BKE_node.h:334
void nodeRegisterType(struct bNodeType *ntype)
Definition: node.cc:1298
#define UNUSED(x)
#define N_(msgid)
@ SOCK_STRING
Group RGB to Bright Vector Camera Vector Combine Material Light Line Style Layer Add Ambient Diffuse Glossy Refraction Transparent Toon Principled Hair Volume Principled Light Particle Volume Image Sky Noise Wave Voronoi Brick Texture Vector Combine Vertex Separate Vector White RGB Map Separate Set Z Dilate Combine Combine Color Channel Split ID Combine Luminance Directional Alpha Distance Hue Movie Ellipse Bokeh View Corner Anti Mix RGB Hue Separate TEX_NODE_PROC TEX_NODE_PROC TEX_NODE_PROC TEX_NODE_PROC TEX_NODE_PROC Boolean Random FN_NODE_INPUT_STRING
#define C
Definition: RandGen.cpp:39
void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon)
OperationNode * node
bNodeTree * ntree
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_dupallocN)(const void *vmemh)
Definition: mallocn.c:42
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
static void fn_node_input_string_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
static void fn_node_input_string_free(bNode *node)
static void fn_node_input_string_expand_in_mf_network(blender::nodes::NodeMFNetworkBuilder &builder)
void register_node_type_fn_input_string()
static void fn_node_input_string_init(bNodeTree *UNUSED(ntree), bNode *node)
static bNodeSocketTemplate fn_node_input_string_out[]
static void fn_node_string_copy(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, const bNode *src_node)
void fn_node_type_base(bNodeType *ntype, int type, const char *name, short nclass, short flag)
Compact definition of a node socket.
Definition: BKE_node.h:95
Defines a node type.
Definition: BKE_node.h:221
NodeExpandInMFNetworkFunction expand_in_mf_network
Definition: BKE_node.h:324
void(* draw_buttons)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr)
Definition: BKE_node.h:253
void * storage
PointerRNA * ptr
Definition: wm_files.c:3157