mirror of
https://github.com/rive-app/rive-cpp.git
synced 2026-01-18 13:11:19 +01:00
feature: pass view model instance to bindable artboard (#10815) 3734dc3ab9
Co-authored-by: hernan <hernan@rive.app>
This commit is contained in:
@@ -1 +1 @@
|
||||
ba94f03ad0d0cbcea241f14f72689a2184ed7dcd
|
||||
3734dc3ab996c24c024129cb5f88d257f241074d
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user