Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/blender/nodes/NOD_socket_declarations.hh26
-rw-r--r--source/blender/nodes/intern/node_socket_declarations.cc1
2 files changed, 26 insertions, 1 deletions
diff --git a/source/blender/nodes/NOD_socket_declarations.hh b/source/blender/nodes/NOD_socket_declarations.hh
index e22b96cd1ff..d4958f433d6 100644
--- a/source/blender/nodes/NOD_socket_declarations.hh
+++ b/source/blender/nodes/NOD_socket_declarations.hh
@@ -145,14 +145,26 @@ class ColorBuilder : public SocketDeclarationBuilder<Color> {
ColorBuilder &default_value(const ColorGeometry4f value);
};
+class StringBuilder;
+
class String : public SocketDeclaration {
+ private:
+ std::string default_value_;
+
+ friend StringBuilder;
+
public:
- using Builder = SocketDeclarationBuilder<String>;
+ using Builder = StringBuilder;
bNodeSocket &build(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_out) const override;
bool matches(const bNodeSocket &socket) const override;
};
+class StringBuilder : public SocketDeclarationBuilder<String> {
+ public:
+ StringBuilder &default_value(const std::string value);
+};
+
class IDSocketDeclaration : public SocketDeclaration {
private:
const char *idname_;
@@ -323,6 +335,18 @@ inline ColorBuilder &ColorBuilder::default_value(const ColorGeometry4f value)
/** \} */
/* -------------------------------------------------------------------- */
+/** \name #StringBuilder Inline Methods
+ * \{ */
+
+inline StringBuilder &StringBuilder::default_value(std::string value)
+{
+ decl_->default_value_ = std::move(value);
+ return *this;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name #IDSocketDeclaration and Children Inline Methods
* \{ */
diff --git a/source/blender/nodes/intern/node_socket_declarations.cc b/source/blender/nodes/intern/node_socket_declarations.cc
index f910679d492..e823476f9e4 100644
--- a/source/blender/nodes/intern/node_socket_declarations.cc
+++ b/source/blender/nodes/intern/node_socket_declarations.cc
@@ -254,6 +254,7 @@ bNodeSocket &String::build(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_ou
{
bNodeSocket &socket = *nodeAddStaticSocket(
&ntree, &node, in_out, SOCK_STRING, PROP_NONE, identifier_.c_str(), name_.c_str());
+ STRNCPY(((bNodeSocketValueString *)socket.default_value)->value, default_value_.c_str());
this->set_common_flags(socket);
return socket;
}