math: use operation by default for name

This commit is contained in:
itsmattkc
2022-10-23 19:52:08 -07:00
parent 6ce80f4469
commit 93f88042d1
3 changed files with 28 additions and 5 deletions
+13 -5
View File
@@ -44,6 +44,14 @@ MathNode::MathNode()
QString MathNode::Name() const
{
// Default to naming after the operation
if (parent()) {
QString op_name = GetOperationName(GetOperation());
if (!op_name.isEmpty()) {
return op_name;
}
}
return tr("Math");
}
@@ -70,12 +78,12 @@ void MathNode::Retranslate()
SetInputName(kParamAIn, tr("Value"));
SetInputName(kParamBIn, tr("Value"));
QStringList operations = {tr("Add"),
tr("Subtract"),
tr("Multiply"),
tr("Divide"),
QStringList operations = {GetOperationName(kOpAdd),
GetOperationName(kOpSubtract),
GetOperationName(kOpMultiply),
GetOperationName(kOpDivide),
QString(),
tr("Power")};
GetOperationName(kOpPower)};
SetComboBoxStrings(kMethodIn, operations);
}
+13
View File
@@ -167,6 +167,19 @@ void MathNodeBase::PushVector(NodeValueTable *output, olive::NodeValue::Type typ
}
}
QString MathNodeBase::GetOperationName(Operation o)
{
switch (o) {
case kOpAdd: return tr("Add");
case kOpSubtract: return tr("Subtract");
case kOpMultiply: return tr("Multiply");
case kOpDivide: return tr("Divide");
case kOpPower: return tr("Power");
}
return QString();
}
void MathNodeBase::PerformAllOnFloatBuffer(Operation operation, float *a, float b, int start, int end)
{
for (int j=start;j<end;j++) {
+2
View File
@@ -38,6 +38,8 @@ public:
kOpPower
};
static QString GetOperationName(Operation o);
protected:
enum Pairing {
kPairNone = -1,