| #include "rive/data_bind/context/context_value_viewmodel.hpp" |
| #include "rive/data_bind/data_bind_viewmodel_consumer.hpp" |
| #include "rive/generated/core_registry.hpp" |
| #include "rive/viewmodel/viewmodel_instance_list_item.hpp" |
| |
| using namespace rive; |
| |
| DataBindContextValueViewModel::DataBindContextValueViewModel( |
| DataBind* dataBind) : |
| DataBindContextValue(dataBind) |
| {} |
| |
| void DataBindContextValueViewModel::apply(Core* target, |
| uint32_t propertyKey, |
| bool isMainDirection) |
| { |
| syncSourceValue(); |
| auto value = |
| calculateValue<DataValueViewModel, ViewModelInstance*>(m_dataValue, |
| isMainDirection, |
| m_dataBind); |
| if (target != nullptr) |
| { |
| auto consumer = DataBindViewModelConsumer::from(target); |
| if (consumer != nullptr) |
| { |
| consumer->updateViewModel(value); |
| } |
| } |
| } |
| |
| void DataBindContextValueViewModel::applyToSource(Core* target, |
| uint32_t propertyKey, |
| bool isMainDirection) |
| { |
| // TODO: @hernan does applyToSource make sense? Should we block it somehow? |
| } |