Skip to content

Commit

Permalink
Add data converters to flutter runtime
Browse files Browse the repository at this point in the history
It's the dart implementation of the first converters.
It's very similar to the c++ implementation.
Except some commented details of this PR, the rest is basically the same.

Diffs=
727e0ba8b Add data converters to flutter runtime (#8029)

Co-authored-by: hernan <[email protected]>
  • Loading branch information
bodymovin and bodymovin committed Sep 4, 2024
1 parent 5207dd8 commit 8f25e07
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f25ee97a05aaa30a58b13451c8020c4e1c095bed
727e0ba8b098d87dfa5d32ce3004c619659a81e0
1 change: 1 addition & 0 deletions include/rive/animation/state_machine_instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ class StateMachineInstance : public Scene, public NestedEventNotifier, public Ne
#ifdef WITH_RIVE_TOOLS
public:
void onInputChanged(InputChanged callback) { m_inputChangedCallback = callback; }
void onDataBindChanged(DataBindChanged callback);
InputChanged m_inputChangedCallback = nullptr;
#endif
};
Expand Down
6 changes: 5 additions & 1 deletion include/rive/data_bind/data_bind.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <stdio.h>
namespace rive
{

#ifdef WITH_RIVE_TOOLS
class DataBind;
typedef void (*DataBindChanged)();
Expand Down Expand Up @@ -38,6 +37,11 @@ class DataBind : public DataBindBase
std::unique_ptr<DataBindContextValue> m_ContextValue;
DataConverter* m_dataConverter;
DataType outputType();
#ifdef WITH_RIVE_TOOLS
public:
void onChanged(DataBindChanged callback) { m_changedCallback = callback; }
DataBindChanged m_changedCallback = nullptr;
#endif
};
} // namespace rive

Expand Down
10 changes: 10 additions & 0 deletions src/animation/state_machine_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,16 @@ StateMachineInstance::~StateMachineInstance()
m_bindablePropertyInstances.clear();
}

#ifdef WITH_RIVE_TOOLS
void StateMachineInstance::onDataBindChanged(DataBindChanged callback)
{
for (auto databind : m_dataBinds)
{
databind->onChanged(callback);
}
}
#endif

void StateMachineInstance::sortHitComponents()
{
Drawable* last = m_artboardInstance->firstDrawable();
Expand Down
6 changes: 6 additions & 0 deletions src/data_bind/data_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,5 +187,11 @@ bool DataBind::addDirt(ComponentDirt value, bool recurse)
}

m_Dirt |= value;
#ifdef WITH_RIVE_TOOLS
if (m_changedCallback != nullptr)
{
m_changedCallback();
}
#endif
return true;
}

0 comments on commit 8f25e07

Please sign in to comment.