Nodes: add default value to string socket declaration
Differential Revision: https://developer.blender.org/D12758
This commit is contained in:
parent
eb0d216dc1
commit
f9fe755dba
|
@ -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_;
|
||||
|
@ -322,6 +334,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
|
||||
* \{ */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue