nodeparam: allowed for dynamic nodeparam property change to affect UI widgets

immediately
This commit is contained in:
itsmattkc
2020-03-07 02:16:48 +11:00
parent c168bf1a80
commit 3f043496f3
9 changed files with 159 additions and 66 deletions
+7
View File
@@ -34,11 +34,13 @@ TransformDistort::TransformDistort()
scale_input_ = new NodeInput("scale_in", NodeParam::kVec2, QVector2D(1.0f, 1.0f));
scale_input_->set_property("min", QVector2D(0, 0));
scale_input_->set_property("view", "percent");
scale_input_->set_property("disabley", true);
AddInput(scale_input_);
uniform_scale_input_ = new NodeInput("uniform_scale_in", NodeParam::kBoolean, true);
uniform_scale_input_->set_is_keyframable(false);
uniform_scale_input_->SetConnectable(false);
connect(uniform_scale_input_, &NodeInput::ValueChanged, this, &TransformDistort::UniformScaleChanged);
AddInput(uniform_scale_input_);
anchor_input_ = new NodeInput("anchor_in", NodeParam::kVec2);
@@ -105,3 +107,8 @@ NodeValueTable TransformDistort::Value(const NodeValueDatabase &value) const
output.Push(NodeParam::kMatrix, mat);
return output;
}
void TransformDistort::UniformScaleChanged()
{
scale_input_->set_property("disabley", uniform_scale_input_->get_standard_value().toBool());
}
+3
View File
@@ -51,6 +51,9 @@ private:
NodeInput* anchor_input_;
private slots:
void UniformScaleChanged();
};
#endif // TRANSFORMDISTORT_H
+5
View File
@@ -917,6 +917,11 @@ bool NodeInput::has_property(const QString &key) const
return properties_.contains(key);
}
const QHash<QString, QVariant> &NodeInput::properties() const
{
return properties_;
}
QVector<QVariant> NodeInput::split_normal_value_into_track_values(const QVariant &value) const
{
QVector<QVariant> vals(get_number_of_keyframe_tracks());
+9
View File
@@ -232,6 +232,10 @@ public:
* - `min` - For any numeral type represented with a slider, prevents values going BELOW this number
* - `max` - For any numeral type represented with a slider, prevents values going ABOVE this number
* - `view` - For any numeral type represented with a slider, shows number either as `db`, `percent`, or `normal`
* - `disablex` - For kVec2, kVec3, kVec4 and kColor types, disables the first/X/R UI widget
* - `disabley` - For kVec2, kVec3, kVec4 and kColor types, disables the second/Y/G UI widget
* - `disablez` - For kVec3, kVec4 and kColor types, disables the third/Z/B UI widget
* - `disablew` - For kVec4 and kColor types, disables the fourth/W/A UI widget
*/
void set_property(const QString& key, const QVariant& value);
@@ -245,6 +249,11 @@ public:
*/
bool has_property(const QString& key) const;
/**
* @brief Get properties hashmap (useful for iterating)
*/
const QHash<QString, QVariant>& properties() const;
QVector<QVariant> split_normal_value_into_track_values(const QVariant &value) const;
QVariant combine_track_values_into_normal_value(const QVector<QVariant>& split) const;
-1
View File
@@ -206,7 +206,6 @@ QByteArray NodeParam::ValueToBytes(const NodeParam::DataType &type, const QVaria
case kTexture:
case kSamples:
case kDecimal:
case kWholeNumber:
case kNumber:
case kString:
case kBuffer:
+2 -9
View File
@@ -179,19 +179,12 @@ public:
*/
kDecimal = 0x6,
/**
* Identifier for type that contains a whole number
*
* Includes kInt and kBoolean.
*/
kWholeNumber = 0x9,
/**
* Identifier for type that contains a number of any kind (whole or decimal)
*
* Includes kInt, kFloat, kRational, and kBoolean.
* Includes kInt, kFloat, and kRational.
*/
kNumber = 0xF,
kNumber = 0x7,
/**
* Identifier for type that contains a text string of any kind.