feature: pass view model instance to bindable artboard (#10815) 3734dc3ab9

Co-authored-by: hernan <hernan@rive.app>
This commit is contained in:
bodymovin
2026-01-09 17:32:02 +00:00
parent 3a5b5058ac
commit 35eb312314
6 changed files with 24 additions and 2 deletions

View File

@@ -1 +1 @@
ba94f03ad0d0cbcea241f14f72689a2184ed7dcd
3734dc3ab996c24c024129cb5f88d257f241074d

View File

@@ -19,6 +19,7 @@ public:
ViewModelInstanceValueRuntime(viewModelInstance)
{}
void value(rcp<BindableArtboard> bindableArtboard);
void viewModelInstance(rcp<ViewModelInstance> viewModelInstance);
const DataType dataType() override { return DataType::artboard; }
#ifdef TESTING

View File

@@ -18,11 +18,14 @@ protected:
public:
void asset(rcp<BindableArtboard> value);
void viewModelInstance(rcp<ViewModelInstance> value);
rcp<BindableArtboard> asset() { return m_bindableArtboard; }
void applyValue(DataValueInteger*);
rcp<ViewModelInstance> viewModelInstance() { return m_viewModelInstance; }
private:
rcp<BindableArtboard> m_bindableArtboard = nullptr;
rcp<ViewModelInstance> m_viewModelInstance = nullptr;
#ifdef WITH_RIVE_TOOLS
public:
void onChanged(ViewModelArtboardChanged callback)

View File

@@ -137,7 +137,13 @@ void NestedArtboard::updateArtboard(
nestedStateMachine)); // take ownership
}
nest(artboardInstance.release());
if (m_dataContext != nullptr && m_viewModelInstance == nullptr)
if (viewModelInstanceArtboard->viewModelInstance())
{
bindViewModelInstance(
viewModelInstanceArtboard->viewModelInstance(),
m_dataContext);
}
else if (m_dataContext != nullptr && m_viewModelInstance == nullptr)
{
internalDataContext(m_dataContext);
}

View File

@@ -11,6 +11,13 @@ void ViewModelInstanceArtboardRuntime::value(
bindableArtboard);
}
void ViewModelInstanceArtboardRuntime::viewModelInstance(
rcp<ViewModelInstance> viewModelInstance)
{
m_viewModelInstanceValue->as<ViewModelInstanceArtboard>()
->viewModelInstance(viewModelInstance);
}
#ifdef TESTING
rcp<BindableArtboard> ViewModelInstanceArtboardRuntime::testing_value()
{

View File

@@ -31,4 +31,9 @@ void ViewModelInstanceArtboard::asset(rcp<BindableArtboard> value)
void ViewModelInstanceArtboard::applyValue(DataValueInteger* dataValue)
{
propertyValue(dataValue->value());
}
void ViewModelInstanceArtboard::viewModelInstance(rcp<ViewModelInstance> value)
{
m_viewModelInstance = value;
}