Skip to content

Commit

Permalink
Nnnn fix invalid viewmodel properties
Browse files Browse the repository at this point in the history
some fixes for data binding by commit:
- fix double callback when properties are synced between dart and cpp
- fix range mapper missing interpolator
- fix validating group converters
- fix duplication of view model properties and added validations

extra comments in PR

Diffs=
6e30b9bb43 Nnnn fix invalid viewmodel properties (#8922)

Co-authored-by: hernan <[email protected]>
  • Loading branch information
bodymovin and bodymovin committed Jan 27, 2025
1 parent 3ae65f7 commit 2a9ba98
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6d8854ec047020794d0d4babbcad8343d216256a
6e30b9bb430926b63f0ed662b89250b033993c87
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ class DataConverterRangeMapper : public DataConverterRangeMapperBase

public:
void interpolator(KeyFrameInterpolator* interpolator);
KeyFrameInterpolator* interpolator() const { return m_interpolator; };
DataType outputType() override { return DataType::number; };
DataValue* convert(DataValue* value, DataBind* dataBind) override;
DataValue* reverseConvert(DataValue* value, DataBind* dataBind) override;
void copy(const DataConverterRangeMapperBase& object);

private:
DataValueNumber m_output;
Expand Down
6 changes: 6 additions & 0 deletions src/data_bind/converters/data_converter_range_mapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@

using namespace rive;

void DataConverterRangeMapper::copy(const DataConverterRangeMapperBase& object)
{
interpolator(object.as<DataConverterRangeMapper>()->interpolator());
DataConverterRangeMapperBase::copy(object);
}

DataValueNumber* DataConverterRangeMapper::calculateRange(DataValue* input,
float minInput,
float maxInput,
Expand Down
27 changes: 14 additions & 13 deletions src/importers/backboard_importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,20 @@ StatusCode BackboardImporter::resolve()
auto asset = m_FileAssets[index];
referencer->setAsset(asset);
}

for (auto converter : m_DataConverters)
{
if (converter->is<DataConverterRangeMapper>())
{
size_t converterId =
converter->as<DataConverterRangeMapper>()->interpolatorId();
if (converterId != -1 && converterId < m_interpolators.size())
{
converter->as<DataConverterRangeMapper>()->interpolator(
m_interpolators[converterId]);
}
}
}
for (auto referencer : m_DataConverterGroupItemReferencers)
{
auto index = (size_t)referencer->converterId();
Expand All @@ -109,19 +123,6 @@ StatusCode BackboardImporter::resolve()
referencer->converter(
m_DataConverters[index]->clone()->as<DataConverter>());
}
for (auto converter : m_DataConverters)
{
if (converter->is<DataConverterRangeMapper>())
{
size_t converterId =
converter->as<DataConverterRangeMapper>()->interpolatorId();
if (converterId != -1 && converterId < m_interpolators.size())
{
converter->as<DataConverterRangeMapper>()->interpolator(
m_interpolators[converterId]);
}
}
}
return StatusCode::Ok;
}

Expand Down

0 comments on commit 2a9ba98

Please sign in to comment.