From a213ae8944e3d3af528f857f076f960451d95f3c Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Sat, 7 May 2022 10:55:50 -0700 Subject: [PATCH] nodeparamviewwidgetbridge: make disable property more versatile --- app/node/generator/matrix/matrix.cpp | 2 +- .../nodeparamviewwidgetbridge.cpp | 31 +++++++++++++------ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/app/node/generator/matrix/matrix.cpp b/app/node/generator/matrix/matrix.cpp index 30cbf6065..475aca566 100644 --- a/app/node/generator/matrix/matrix.cpp +++ b/app/node/generator/matrix/matrix.cpp @@ -183,7 +183,7 @@ void MatrixGenerator::InputValueChangedEvent(const QString &input, int element) Q_UNUSED(element) if (input == kUniformScaleInput) { - SetInputProperty(kScaleInput, QStringLiteral("disabley"), GetStandardValue(kUniformScaleInput).toBool()); + SetInputProperty(kScaleInput, QStringLiteral("disable1"), GetStandardValue(kUniformScaleInput).toBool()); } } diff --git a/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp b/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp index 0a5f091d8..b17335fff 100644 --- a/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp +++ b/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp @@ -553,17 +553,24 @@ void NodeParamViewWidgetBridge::SetProperty(const QString &key, const QVariant & } } - // Parameters for vectors only - if (NodeValue::type_is_vector(data_type)) { - if (key == QStringLiteral("disablex")) { - static_cast(widgets_.at(0))->setEnabled(!value.toBool()); - } else if (key == QStringLiteral("disabley")) { - static_cast(widgets_.at(1))->setEnabled(!value.toBool()); - } else if (widgets_.size() > 2 && key == QStringLiteral("disablez")) { - static_cast(widgets_.at(2))->setEnabled(!value.toBool()); - } else if (widgets_.size() > 3 && key == QStringLiteral("disablew")) { - static_cast(widgets_.at(3))->setEnabled(!value.toBool()); + if (key.startsWith(QStringLiteral("disable"))) { + + bool dis = value.toBool(); + + if (key.size() == 7) { + for (int i=0; isetEnabled(!dis); + } + } else { + bool ok; + int element = key.mid(7).toInt(&ok); + int tracks = NodeValue::get_number_of_keyframe_tracks(data_type); + + if (ok && element >= 0 && element < tracks) { + widgets_.at(element)->setEnabled(!dis); + } } + } // Parameters for integers, floats, and vectors @@ -645,6 +652,7 @@ void NodeParamViewWidgetBridge::SetProperty(const QString &key, const QVariant & break; } } else if (key == QStringLiteral("offset")) { + int tracks = NodeValue::get_number_of_keyframe_tracks(data_type); QVector offsets = NodeValue::split_normal_value_into_track_values(data_type, value); @@ -654,7 +662,9 @@ void NodeParamViewWidgetBridge::SetProperty(const QString &key, const QVariant & } UpdateWidgetValues(); + } else if (key.startsWith(QStringLiteral("color"))) { + QColor c(value.toString()); int tracks = NodeValue::get_number_of_keyframe_tracks(data_type); @@ -671,6 +681,7 @@ void NodeParamViewWidgetBridge::SetProperty(const QString &key, const QVariant & static_cast(widgets_.at(element))->SetColor(c); } } + } }