mirror of
https://github.com/rive-app/rive-cpp.git
synced 2026-01-18 21:21:17 +01:00
featue: add artboard data bind support (#9996) be0b691d9b
* add artboard data bind support Co-authored-by: hernan <hernan@rive.app>
This commit is contained in:
@@ -1 +1 @@
|
||||
9af17212ca6acc19b7f55ba6128d1f375425242f
|
||||
be0b691d9ba25faada8131d7ad2289460de7972f
|
||||
|
||||
8
dev/defs/data_bind/bindable_property_artboard.json
Normal file
8
dev/defs/data_bind/bindable_property_artboard.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "BindablePropertyArtboard",
|
||||
"key": {
|
||||
"int": 597,
|
||||
"string": "bindablepropertyartboard"
|
||||
},
|
||||
"extends": "data_bind/bindable_property_id.json"
|
||||
}
|
||||
@@ -4,19 +4,5 @@
|
||||
"int": 588,
|
||||
"string": "bindablepropertyasset"
|
||||
},
|
||||
"extends": "data_bind/bindable_property.json",
|
||||
"properties": {
|
||||
"propertyValue": {
|
||||
"type": "Id",
|
||||
"typeRuntime": "uint",
|
||||
"initialValue": "Core.missingId",
|
||||
"initialValueRuntime": "-1",
|
||||
"key": {
|
||||
"int": 823,
|
||||
"string": "propertyvalue"
|
||||
},
|
||||
"description": "The id of the asset used for dta binding",
|
||||
"bindable": true
|
||||
}
|
||||
}
|
||||
"extends": "data_bind/bindable_property_id.json"
|
||||
}
|
||||
23
dev/defs/data_bind/bindable_property_id.json
Normal file
23
dev/defs/data_bind/bindable_property_id.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "BindablePropertyId",
|
||||
"key": {
|
||||
"int": 596,
|
||||
"string": "bindablepropertyid"
|
||||
},
|
||||
"abstract": true,
|
||||
"extends": "data_bind/bindable_property.json",
|
||||
"properties": {
|
||||
"propertyValue": {
|
||||
"type": "Id",
|
||||
"typeRuntime": "uint",
|
||||
"initialValue": "Core.missingId",
|
||||
"initialValueRuntime": "-1",
|
||||
"key": {
|
||||
"int": 823,
|
||||
"string": "propertyvalue"
|
||||
},
|
||||
"description": "The id of the asset used for dta binding",
|
||||
"bindable": true
|
||||
}
|
||||
}
|
||||
}
|
||||
31
dev/defs/viewmodel/viewmodel_instance_artboard.json
Normal file
31
dev/defs/viewmodel/viewmodel_instance_artboard.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "ViewModelInstanceArtboard",
|
||||
"key": {
|
||||
"int": 599,
|
||||
"string": "viewmodelinstanceartboard"
|
||||
},
|
||||
"extends": "viewmodel/viewmodel_instance_value.json",
|
||||
"properties": {
|
||||
"propertyValue": {
|
||||
"type": "Id",
|
||||
"typeRuntime": "uint",
|
||||
"initialValue": "Core.missingId",
|
||||
"initialValueRuntime": "0",
|
||||
"key": {
|
||||
"int": 846,
|
||||
"string": "propertyvalue"
|
||||
},
|
||||
"description": "The id of the artboard."
|
||||
},
|
||||
"playbackValue": {
|
||||
"type": "Id",
|
||||
"initialValue": "Core.missingId",
|
||||
"key": {
|
||||
"int": 847,
|
||||
"string": "playbackvalue"
|
||||
},
|
||||
"description": "The id of the artboard.",
|
||||
"runtime": false
|
||||
}
|
||||
}
|
||||
}
|
||||
8
dev/defs/viewmodel/viewmodel_property_artboard.json
Normal file
8
dev/defs/viewmodel/viewmodel_property_artboard.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "ViewModelPropertyArtboard",
|
||||
"key": {
|
||||
"int": 598,
|
||||
"string": "viewmodelpropertyartboard"
|
||||
},
|
||||
"extends": "viewmodel/viewmodel_property.json"
|
||||
}
|
||||
@@ -37,6 +37,7 @@ public:
|
||||
NestedInput* input(std::string name);
|
||||
void bindViewModelInstance(rcp<ViewModelInstance> viewModelInstance);
|
||||
void dataContext(DataContext* dataContext);
|
||||
void clearDataContext();
|
||||
};
|
||||
} // namespace rive
|
||||
|
||||
|
||||
@@ -86,8 +86,8 @@ public:
|
||||
bool isLayoutProvider() override { return true; }
|
||||
size_t numLayoutNodes() override { return m_listItems.size(); }
|
||||
void reset();
|
||||
void file(File*);
|
||||
File* file() const;
|
||||
void file(File*) override;
|
||||
File* file() const override;
|
||||
Core* clone() const override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -8,6 +8,7 @@ class ArtboardInstance;
|
||||
class DataBind;
|
||||
class DataContext;
|
||||
class ViewModelInstance;
|
||||
class File;
|
||||
|
||||
class ArtboardHost
|
||||
{
|
||||
@@ -26,6 +27,8 @@ public:
|
||||
virtual Artboard* parentArtboard() = 0;
|
||||
virtual void markHostTransformDirty() = 0;
|
||||
virtual bool isLayoutProvider() { return false; }
|
||||
virtual void file(File* value) = 0;
|
||||
virtual File* file() const = 0;
|
||||
};
|
||||
} // namespace rive
|
||||
|
||||
|
||||
13
include/rive/data_bind/bindable_property_artboard.hpp
Normal file
13
include/rive/data_bind/bindable_property_artboard.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef _RIVE_BINDABLE_PROPERTY_ARTBOARD_HPP_
|
||||
#define _RIVE_BINDABLE_PROPERTY_ARTBOARD_HPP_
|
||||
#include "rive/generated/data_bind/bindable_property_artboard_base.hpp"
|
||||
#include <stdio.h>
|
||||
namespace rive
|
||||
{
|
||||
class BindablePropertyArtboard : public BindablePropertyArtboardBase
|
||||
{
|
||||
public:
|
||||
};
|
||||
} // namespace rive
|
||||
|
||||
#endif
|
||||
13
include/rive/data_bind/bindable_property_id.hpp
Normal file
13
include/rive/data_bind/bindable_property_id.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef _RIVE_BINDABLE_PROPERTY_ID_HPP_
|
||||
#define _RIVE_BINDABLE_PROPERTY_ID_HPP_
|
||||
#include "rive/generated/data_bind/bindable_property_id_base.hpp"
|
||||
#include <stdio.h>
|
||||
namespace rive
|
||||
{
|
||||
class BindablePropertyId : public BindablePropertyIdBase
|
||||
{
|
||||
public:
|
||||
};
|
||||
} // namespace rive
|
||||
|
||||
#endif
|
||||
27
include/rive/data_bind/context/context_value_artboard.hpp
Normal file
27
include/rive/data_bind/context/context_value_artboard.hpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef _RIVE_DATA_BIND_CONTEXT_VALUE_ARTBOARD_HPP_
|
||||
#define _RIVE_DATA_BIND_CONTEXT_VALUE_ARTBOARD_HPP_
|
||||
#include "rive/data_bind/context/context_value.hpp"
|
||||
#include "rive/data_bind/data_values/data_value_artboard.hpp"
|
||||
namespace rive
|
||||
{
|
||||
class Artboard;
|
||||
class DataBindContextValueArtboard : public DataBindContextValue
|
||||
{
|
||||
|
||||
public:
|
||||
DataBindContextValueArtboard(DataBind* m_dataBind);
|
||||
void apply(Core* component,
|
||||
uint32_t propertyKey,
|
||||
bool isMainDirection) override;
|
||||
bool syncTargetValue(Core* target, uint32_t propertyKey) override;
|
||||
|
||||
protected:
|
||||
DataValue* targetValue() override { return &m_targetDataValue; }
|
||||
|
||||
private:
|
||||
uint32_t m_previousValue = -1;
|
||||
DataValueArtboard m_targetDataValue;
|
||||
};
|
||||
} // namespace rive
|
||||
|
||||
#endif
|
||||
@@ -39,7 +39,10 @@ enum class DataType : unsigned int
|
||||
symbolListIndex = 10,
|
||||
|
||||
/// Asset Image.
|
||||
assetImage = 11
|
||||
assetImage = 11,
|
||||
|
||||
/// Artboard.
|
||||
artboard = 12
|
||||
};
|
||||
} // namespace rive
|
||||
#endif
|
||||
26
include/rive/data_bind/data_values/data_value_artboard.hpp
Normal file
26
include/rive/data_bind/data_values/data_value_artboard.hpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef _RIVE_DATA_VALUE_ARTBOARD_HPP_
|
||||
#define _RIVE_DATA_VALUE_ARTBOARD_HPP_
|
||||
#include "rive/data_bind/data_values/data_value.hpp"
|
||||
|
||||
#include <iostream>
|
||||
namespace rive
|
||||
{
|
||||
class DataValueArtboard : public DataValue
|
||||
{
|
||||
private:
|
||||
uint32_t m_value = -1;
|
||||
|
||||
public:
|
||||
DataValueArtboard(uint32_t value) : m_value(value){};
|
||||
DataValueArtboard(){};
|
||||
static const DataType typeKey = DataType::artboard;
|
||||
bool isTypeOf(DataType typeKey) const override
|
||||
{
|
||||
return typeKey == DataType::artboard;
|
||||
};
|
||||
uint32_t value() { return m_value; };
|
||||
void value(uint32_t value) { m_value = value; };
|
||||
constexpr static uint32_t defaultValue = -1;
|
||||
};
|
||||
} // namespace rive
|
||||
#endif
|
||||
@@ -128,10 +128,12 @@
|
||||
#include "rive/custom_property_number.hpp"
|
||||
#include "rive/custom_property_string.hpp"
|
||||
#include "rive/data_bind/bindable_property.hpp"
|
||||
#include "rive/data_bind/bindable_property_artboard.hpp"
|
||||
#include "rive/data_bind/bindable_property_asset.hpp"
|
||||
#include "rive/data_bind/bindable_property_boolean.hpp"
|
||||
#include "rive/data_bind/bindable_property_color.hpp"
|
||||
#include "rive/data_bind/bindable_property_enum.hpp"
|
||||
#include "rive/data_bind/bindable_property_id.hpp"
|
||||
#include "rive/data_bind/bindable_property_integer.hpp"
|
||||
#include "rive/data_bind/bindable_property_list.hpp"
|
||||
#include "rive/data_bind/bindable_property_number.hpp"
|
||||
@@ -248,6 +250,7 @@
|
||||
#include "rive/viewmodel/viewmodel.hpp"
|
||||
#include "rive/viewmodel/viewmodel_component.hpp"
|
||||
#include "rive/viewmodel/viewmodel_instance.hpp"
|
||||
#include "rive/viewmodel/viewmodel_instance_artboard.hpp"
|
||||
#include "rive/viewmodel/viewmodel_instance_asset.hpp"
|
||||
#include "rive/viewmodel/viewmodel_instance_asset_image.hpp"
|
||||
#include "rive/viewmodel/viewmodel_instance_boolean.hpp"
|
||||
@@ -263,6 +266,7 @@
|
||||
#include "rive/viewmodel/viewmodel_instance_value.hpp"
|
||||
#include "rive/viewmodel/viewmodel_instance_viewmodel.hpp"
|
||||
#include "rive/viewmodel/viewmodel_property.hpp"
|
||||
#include "rive/viewmodel/viewmodel_property_artboard.hpp"
|
||||
#include "rive/viewmodel/viewmodel_property_asset.hpp"
|
||||
#include "rive/viewmodel/viewmodel_property_asset_image.hpp"
|
||||
#include "rive/viewmodel/viewmodel_property_boolean.hpp"
|
||||
@@ -289,12 +293,14 @@ public:
|
||||
{
|
||||
case ViewModelInstanceListItemBase::typeKey:
|
||||
return new ViewModelInstanceListItem();
|
||||
case ViewModelInstanceColorBase::typeKey:
|
||||
return new ViewModelInstanceColor();
|
||||
case ViewModelComponentBase::typeKey:
|
||||
return new ViewModelComponent();
|
||||
case ViewModelPropertyBase::typeKey:
|
||||
return new ViewModelProperty();
|
||||
case ViewModelPropertyArtboardBase::typeKey:
|
||||
return new ViewModelPropertyArtboard();
|
||||
case ViewModelInstanceColorBase::typeKey:
|
||||
return new ViewModelInstanceColor();
|
||||
case ViewModelPropertyEnumBase::typeKey:
|
||||
return new ViewModelPropertyEnum();
|
||||
case ViewModelPropertyEnumCustomBase::typeKey:
|
||||
@@ -309,6 +315,8 @@ public:
|
||||
return new ViewModelInstanceEnum();
|
||||
case ViewModelPropertySymbolListIndexBase::typeKey:
|
||||
return new ViewModelPropertySymbolListIndex();
|
||||
case ViewModelInstanceArtboardBase::typeKey:
|
||||
return new ViewModelInstanceArtboard();
|
||||
case ViewModelInstanceStringBase::typeKey:
|
||||
return new ViewModelInstanceString();
|
||||
case ViewModelPropertyListBase::typeKey:
|
||||
@@ -593,6 +601,8 @@ public:
|
||||
return new Backboard();
|
||||
case OpenUrlEventBase::typeKey:
|
||||
return new OpenUrlEvent();
|
||||
case BindablePropertyArtboardBase::typeKey:
|
||||
return new BindablePropertyArtboard();
|
||||
case BindablePropertyIntegerBase::typeKey:
|
||||
return new BindablePropertyInteger();
|
||||
case BindablePropertyTriggerBase::typeKey:
|
||||
@@ -753,6 +763,10 @@ public:
|
||||
case ViewModelInstanceEnumBase::propertyValuePropertyKey:
|
||||
object->as<ViewModelInstanceEnumBase>()->propertyValue(value);
|
||||
break;
|
||||
case ViewModelInstanceArtboardBase::propertyValuePropertyKey:
|
||||
object->as<ViewModelInstanceArtboardBase>()->propertyValue(
|
||||
value);
|
||||
break;
|
||||
case ViewModelPropertyEnumSystemBase::enumTypePropertyKey:
|
||||
object->as<ViewModelPropertyEnumSystemBase>()->enumType(value);
|
||||
break;
|
||||
@@ -1221,6 +1235,9 @@ public:
|
||||
case OpenUrlEventBase::targetValuePropertyKey:
|
||||
object->as<OpenUrlEventBase>()->targetValue(value);
|
||||
break;
|
||||
case BindablePropertyIdBase::propertyValuePropertyKey:
|
||||
object->as<BindablePropertyIdBase>()->propertyValue(value);
|
||||
break;
|
||||
case BindablePropertyIntegerBase::propertyValuePropertyKey:
|
||||
object->as<BindablePropertyIntegerBase>()->propertyValue(value);
|
||||
break;
|
||||
@@ -1233,9 +1250,6 @@ public:
|
||||
case DataBindBase::converterIdPropertyKey:
|
||||
object->as<DataBindBase>()->converterId(value);
|
||||
break;
|
||||
case BindablePropertyAssetBase::propertyValuePropertyKey:
|
||||
object->as<BindablePropertyAssetBase>()->propertyValue(value);
|
||||
break;
|
||||
case DataConverterNumberToListBase::viewModelIdPropertyKey:
|
||||
object->as<DataConverterNumberToListBase>()->viewModelId(value);
|
||||
break;
|
||||
@@ -1380,33 +1394,6 @@ public:
|
||||
break;
|
||||
}
|
||||
}
|
||||
static void setColor(Core* object, int propertyKey, int value)
|
||||
{
|
||||
switch (propertyKey)
|
||||
{
|
||||
case ViewModelInstanceColorBase::propertyValuePropertyKey:
|
||||
object->as<ViewModelInstanceColorBase>()->propertyValue(value);
|
||||
break;
|
||||
case CustomPropertyColorBase::propertyValuePropertyKey:
|
||||
object->as<CustomPropertyColorBase>()->propertyValue(value);
|
||||
break;
|
||||
case KeyFrameColorBase::valuePropertyKey:
|
||||
object->as<KeyFrameColorBase>()->value(value);
|
||||
break;
|
||||
case TransitionValueColorComparatorBase::valuePropertyKey:
|
||||
object->as<TransitionValueColorComparatorBase>()->value(value);
|
||||
break;
|
||||
case SolidColorBase::colorValuePropertyKey:
|
||||
object->as<SolidColorBase>()->colorValue(value);
|
||||
break;
|
||||
case GradientStopBase::colorValuePropertyKey:
|
||||
object->as<GradientStopBase>()->colorValue(value);
|
||||
break;
|
||||
case BindablePropertyColorBase::propertyValuePropertyKey:
|
||||
object->as<BindablePropertyColorBase>()->propertyValue(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
static void setString(Core* object, int propertyKey, std::string value)
|
||||
{
|
||||
switch (propertyKey)
|
||||
@@ -1473,6 +1460,33 @@ public:
|
||||
break;
|
||||
}
|
||||
}
|
||||
static void setColor(Core* object, int propertyKey, int value)
|
||||
{
|
||||
switch (propertyKey)
|
||||
{
|
||||
case ViewModelInstanceColorBase::propertyValuePropertyKey:
|
||||
object->as<ViewModelInstanceColorBase>()->propertyValue(value);
|
||||
break;
|
||||
case CustomPropertyColorBase::propertyValuePropertyKey:
|
||||
object->as<CustomPropertyColorBase>()->propertyValue(value);
|
||||
break;
|
||||
case KeyFrameColorBase::valuePropertyKey:
|
||||
object->as<KeyFrameColorBase>()->value(value);
|
||||
break;
|
||||
case TransitionValueColorComparatorBase::valuePropertyKey:
|
||||
object->as<TransitionValueColorComparatorBase>()->value(value);
|
||||
break;
|
||||
case SolidColorBase::colorValuePropertyKey:
|
||||
object->as<SolidColorBase>()->colorValue(value);
|
||||
break;
|
||||
case GradientStopBase::colorValuePropertyKey:
|
||||
object->as<GradientStopBase>()->colorValue(value);
|
||||
break;
|
||||
case BindablePropertyColorBase::propertyValuePropertyKey:
|
||||
object->as<BindablePropertyColorBase>()->propertyValue(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
static void setBool(Core* object, int propertyKey, bool value)
|
||||
{
|
||||
switch (propertyKey)
|
||||
@@ -2270,6 +2284,9 @@ public:
|
||||
return object->as<ViewModelPropertyEnumCustomBase>()->enumId();
|
||||
case ViewModelInstanceEnumBase::propertyValuePropertyKey:
|
||||
return object->as<ViewModelInstanceEnumBase>()->propertyValue();
|
||||
case ViewModelInstanceArtboardBase::propertyValuePropertyKey:
|
||||
return object->as<ViewModelInstanceArtboardBase>()
|
||||
->propertyValue();
|
||||
case ViewModelPropertyEnumSystemBase::enumTypePropertyKey:
|
||||
return object->as<ViewModelPropertyEnumSystemBase>()
|
||||
->enumType();
|
||||
@@ -2606,6 +2623,8 @@ public:
|
||||
return object->as<JoystickBase>()->handleSourceId();
|
||||
case OpenUrlEventBase::targetValuePropertyKey:
|
||||
return object->as<OpenUrlEventBase>()->targetValue();
|
||||
case BindablePropertyIdBase::propertyValuePropertyKey:
|
||||
return object->as<BindablePropertyIdBase>()->propertyValue();
|
||||
case BindablePropertyIntegerBase::propertyValuePropertyKey:
|
||||
return object->as<BindablePropertyIntegerBase>()
|
||||
->propertyValue();
|
||||
@@ -2615,8 +2634,6 @@ public:
|
||||
return object->as<DataBindBase>()->flags();
|
||||
case DataBindBase::converterIdPropertyKey:
|
||||
return object->as<DataBindBase>()->converterId();
|
||||
case BindablePropertyAssetBase::propertyValuePropertyKey:
|
||||
return object->as<BindablePropertyAssetBase>()->propertyValue();
|
||||
case DataConverterNumberToListBase::viewModelIdPropertyKey:
|
||||
return object->as<DataConverterNumberToListBase>()
|
||||
->viewModelId();
|
||||
@@ -2718,29 +2735,6 @@ public:
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
static int getColor(Core* object, int propertyKey)
|
||||
{
|
||||
switch (propertyKey)
|
||||
{
|
||||
case ViewModelInstanceColorBase::propertyValuePropertyKey:
|
||||
return object->as<ViewModelInstanceColorBase>()
|
||||
->propertyValue();
|
||||
case CustomPropertyColorBase::propertyValuePropertyKey:
|
||||
return object->as<CustomPropertyColorBase>()->propertyValue();
|
||||
case KeyFrameColorBase::valuePropertyKey:
|
||||
return object->as<KeyFrameColorBase>()->value();
|
||||
case TransitionValueColorComparatorBase::valuePropertyKey:
|
||||
return object->as<TransitionValueColorComparatorBase>()
|
||||
->value();
|
||||
case SolidColorBase::colorValuePropertyKey:
|
||||
return object->as<SolidColorBase>()->colorValue();
|
||||
case GradientStopBase::colorValuePropertyKey:
|
||||
return object->as<GradientStopBase>()->colorValue();
|
||||
case BindablePropertyColorBase::propertyValuePropertyKey:
|
||||
return object->as<BindablePropertyColorBase>()->propertyValue();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
static std::string getString(Core* object, int propertyKey)
|
||||
{
|
||||
switch (propertyKey)
|
||||
@@ -2791,6 +2785,29 @@ public:
|
||||
}
|
||||
return "";
|
||||
}
|
||||
static int getColor(Core* object, int propertyKey)
|
||||
{
|
||||
switch (propertyKey)
|
||||
{
|
||||
case ViewModelInstanceColorBase::propertyValuePropertyKey:
|
||||
return object->as<ViewModelInstanceColorBase>()
|
||||
->propertyValue();
|
||||
case CustomPropertyColorBase::propertyValuePropertyKey:
|
||||
return object->as<CustomPropertyColorBase>()->propertyValue();
|
||||
case KeyFrameColorBase::valuePropertyKey:
|
||||
return object->as<KeyFrameColorBase>()->value();
|
||||
case TransitionValueColorComparatorBase::valuePropertyKey:
|
||||
return object->as<TransitionValueColorComparatorBase>()
|
||||
->value();
|
||||
case SolidColorBase::colorValuePropertyKey:
|
||||
return object->as<SolidColorBase>()->colorValue();
|
||||
case GradientStopBase::colorValuePropertyKey:
|
||||
return object->as<GradientStopBase>()->colorValue();
|
||||
case BindablePropertyColorBase::propertyValuePropertyKey:
|
||||
return object->as<BindablePropertyColorBase>()->propertyValue();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
static bool getBool(Core* object, int propertyKey)
|
||||
{
|
||||
switch (propertyKey)
|
||||
@@ -3331,6 +3348,7 @@ public:
|
||||
case ViewModelInstanceValueBase::viewModelPropertyIdPropertyKey:
|
||||
case ViewModelPropertyEnumCustomBase::enumIdPropertyKey:
|
||||
case ViewModelInstanceEnumBase::propertyValuePropertyKey:
|
||||
case ViewModelInstanceArtboardBase::propertyValuePropertyKey:
|
||||
case ViewModelPropertyEnumSystemBase::enumTypePropertyKey:
|
||||
case DataEnumSystemBase::enumTypePropertyKey:
|
||||
case ViewModelPropertyViewModelBase::
|
||||
@@ -3472,11 +3490,11 @@ public:
|
||||
case JoystickBase::joystickFlagsPropertyKey:
|
||||
case JoystickBase::handleSourceIdPropertyKey:
|
||||
case OpenUrlEventBase::targetValuePropertyKey:
|
||||
case BindablePropertyIdBase::propertyValuePropertyKey:
|
||||
case BindablePropertyIntegerBase::propertyValuePropertyKey:
|
||||
case DataBindBase::propertyKeyPropertyKey:
|
||||
case DataBindBase::flagsPropertyKey:
|
||||
case DataBindBase::converterIdPropertyKey:
|
||||
case BindablePropertyAssetBase::propertyValuePropertyKey:
|
||||
case DataConverterNumberToListBase::viewModelIdPropertyKey:
|
||||
case DataConverterOperationBase::operationTypePropertyKey:
|
||||
case DataConverterRangeMapperBase::interpolationTypePropertyKey:
|
||||
@@ -3524,14 +3542,6 @@ public:
|
||||
case FileAssetBase::assetIdPropertyKey:
|
||||
case AudioEventBase::assetIdPropertyKey:
|
||||
return CoreUintType::id;
|
||||
case ViewModelInstanceColorBase::propertyValuePropertyKey:
|
||||
case CustomPropertyColorBase::propertyValuePropertyKey:
|
||||
case KeyFrameColorBase::valuePropertyKey:
|
||||
case TransitionValueColorComparatorBase::valuePropertyKey:
|
||||
case SolidColorBase::colorValuePropertyKey:
|
||||
case GradientStopBase::colorValuePropertyKey:
|
||||
case BindablePropertyColorBase::propertyValuePropertyKey:
|
||||
return CoreColorType::id;
|
||||
case ViewModelComponentBase::namePropertyKey:
|
||||
case DataEnumCustomBase::namePropertyKey:
|
||||
case ViewModelInstanceStringBase::propertyValuePropertyKey:
|
||||
@@ -3553,6 +3563,14 @@ public:
|
||||
case AssetBase::namePropertyKey:
|
||||
case FileAssetBase::cdnBaseUrlPropertyKey:
|
||||
return CoreStringType::id;
|
||||
case ViewModelInstanceColorBase::propertyValuePropertyKey:
|
||||
case CustomPropertyColorBase::propertyValuePropertyKey:
|
||||
case KeyFrameColorBase::valuePropertyKey:
|
||||
case TransitionValueColorComparatorBase::valuePropertyKey:
|
||||
case SolidColorBase::colorValuePropertyKey:
|
||||
case GradientStopBase::colorValuePropertyKey:
|
||||
case BindablePropertyColorBase::propertyValuePropertyKey:
|
||||
return CoreColorType::id;
|
||||
case ViewModelInstanceBooleanBase::propertyValuePropertyKey:
|
||||
case TransformComponentConstraintBase::offsetPropertyKey:
|
||||
case TransformComponentConstraintBase::doesCopyPropertyKey:
|
||||
@@ -3841,6 +3859,8 @@ public:
|
||||
return object->is<ViewModelPropertyEnumCustomBase>();
|
||||
case ViewModelInstanceEnumBase::propertyValuePropertyKey:
|
||||
return object->is<ViewModelInstanceEnumBase>();
|
||||
case ViewModelInstanceArtboardBase::propertyValuePropertyKey:
|
||||
return object->is<ViewModelInstanceArtboardBase>();
|
||||
case ViewModelPropertyEnumSystemBase::enumTypePropertyKey:
|
||||
return object->is<ViewModelPropertyEnumSystemBase>();
|
||||
case DataEnumSystemBase::enumTypePropertyKey:
|
||||
@@ -4121,6 +4141,8 @@ public:
|
||||
return object->is<JoystickBase>();
|
||||
case OpenUrlEventBase::targetValuePropertyKey:
|
||||
return object->is<OpenUrlEventBase>();
|
||||
case BindablePropertyIdBase::propertyValuePropertyKey:
|
||||
return object->is<BindablePropertyIdBase>();
|
||||
case BindablePropertyIntegerBase::propertyValuePropertyKey:
|
||||
return object->is<BindablePropertyIntegerBase>();
|
||||
case DataBindBase::propertyKeyPropertyKey:
|
||||
@@ -4129,8 +4151,6 @@ public:
|
||||
return object->is<DataBindBase>();
|
||||
case DataBindBase::converterIdPropertyKey:
|
||||
return object->is<DataBindBase>();
|
||||
case BindablePropertyAssetBase::propertyValuePropertyKey:
|
||||
return object->is<BindablePropertyAssetBase>();
|
||||
case DataConverterNumberToListBase::viewModelIdPropertyKey:
|
||||
return object->is<DataConverterNumberToListBase>();
|
||||
case DataConverterOperationBase::operationTypePropertyKey:
|
||||
@@ -4223,20 +4243,6 @@ public:
|
||||
return object->is<FileAssetBase>();
|
||||
case AudioEventBase::assetIdPropertyKey:
|
||||
return object->is<AudioEventBase>();
|
||||
case ViewModelInstanceColorBase::propertyValuePropertyKey:
|
||||
return object->is<ViewModelInstanceColorBase>();
|
||||
case CustomPropertyColorBase::propertyValuePropertyKey:
|
||||
return object->is<CustomPropertyColorBase>();
|
||||
case KeyFrameColorBase::valuePropertyKey:
|
||||
return object->is<KeyFrameColorBase>();
|
||||
case TransitionValueColorComparatorBase::valuePropertyKey:
|
||||
return object->is<TransitionValueColorComparatorBase>();
|
||||
case SolidColorBase::colorValuePropertyKey:
|
||||
return object->is<SolidColorBase>();
|
||||
case GradientStopBase::colorValuePropertyKey:
|
||||
return object->is<GradientStopBase>();
|
||||
case BindablePropertyColorBase::propertyValuePropertyKey:
|
||||
return object->is<BindablePropertyColorBase>();
|
||||
case ViewModelComponentBase::namePropertyKey:
|
||||
return object->is<ViewModelComponentBase>();
|
||||
case DataEnumCustomBase::namePropertyKey:
|
||||
@@ -4277,6 +4283,20 @@ public:
|
||||
return object->is<AssetBase>();
|
||||
case FileAssetBase::cdnBaseUrlPropertyKey:
|
||||
return object->is<FileAssetBase>();
|
||||
case ViewModelInstanceColorBase::propertyValuePropertyKey:
|
||||
return object->is<ViewModelInstanceColorBase>();
|
||||
case CustomPropertyColorBase::propertyValuePropertyKey:
|
||||
return object->is<CustomPropertyColorBase>();
|
||||
case KeyFrameColorBase::valuePropertyKey:
|
||||
return object->is<KeyFrameColorBase>();
|
||||
case TransitionValueColorComparatorBase::valuePropertyKey:
|
||||
return object->is<TransitionValueColorComparatorBase>();
|
||||
case SolidColorBase::colorValuePropertyKey:
|
||||
return object->is<SolidColorBase>();
|
||||
case GradientStopBase::colorValuePropertyKey:
|
||||
return object->is<GradientStopBase>();
|
||||
case BindablePropertyColorBase::propertyValuePropertyKey:
|
||||
return object->is<BindablePropertyColorBase>();
|
||||
case ViewModelInstanceBooleanBase::propertyValuePropertyKey:
|
||||
return object->is<ViewModelInstanceBooleanBase>();
|
||||
case TransformComponentConstraintBase::offsetPropertyKey:
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
#ifndef _RIVE_BINDABLE_PROPERTY_ARTBOARD_BASE_HPP_
|
||||
#define _RIVE_BINDABLE_PROPERTY_ARTBOARD_BASE_HPP_
|
||||
#include "rive/data_bind/bindable_property_id.hpp"
|
||||
namespace rive
|
||||
{
|
||||
class BindablePropertyArtboardBase : public BindablePropertyId
|
||||
{
|
||||
protected:
|
||||
typedef BindablePropertyId Super;
|
||||
|
||||
public:
|
||||
static const uint16_t typeKey = 597;
|
||||
|
||||
/// Helper to quickly determine if a core object extends another without
|
||||
/// RTTI at runtime.
|
||||
bool isTypeOf(uint16_t typeKey) const override
|
||||
{
|
||||
switch (typeKey)
|
||||
{
|
||||
case BindablePropertyArtboardBase::typeKey:
|
||||
case BindablePropertyIdBase::typeKey:
|
||||
case BindablePropertyBase::typeKey:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t coreType() const override { return typeKey; }
|
||||
|
||||
Core* clone() const override;
|
||||
|
||||
protected:
|
||||
};
|
||||
} // namespace rive
|
||||
|
||||
#endif
|
||||
@@ -1,13 +1,12 @@
|
||||
#ifndef _RIVE_BINDABLE_PROPERTY_ASSET_BASE_HPP_
|
||||
#define _RIVE_BINDABLE_PROPERTY_ASSET_BASE_HPP_
|
||||
#include "rive/core/field_types/core_uint_type.hpp"
|
||||
#include "rive/data_bind/bindable_property.hpp"
|
||||
#include "rive/data_bind/bindable_property_id.hpp"
|
||||
namespace rive
|
||||
{
|
||||
class BindablePropertyAssetBase : public BindableProperty
|
||||
class BindablePropertyAssetBase : public BindablePropertyId
|
||||
{
|
||||
protected:
|
||||
typedef BindableProperty Super;
|
||||
typedef BindablePropertyId Super;
|
||||
|
||||
public:
|
||||
static const uint16_t typeKey = 588;
|
||||
@@ -19,6 +18,7 @@ public:
|
||||
switch (typeKey)
|
||||
{
|
||||
case BindablePropertyAssetBase::typeKey:
|
||||
case BindablePropertyIdBase::typeKey:
|
||||
case BindablePropertyBase::typeKey:
|
||||
return true;
|
||||
default:
|
||||
@@ -28,43 +28,9 @@ public:
|
||||
|
||||
uint16_t coreType() const override { return typeKey; }
|
||||
|
||||
static const uint16_t propertyValuePropertyKey = 823;
|
||||
|
||||
protected:
|
||||
uint32_t m_PropertyValue = -1;
|
||||
|
||||
public:
|
||||
inline uint32_t propertyValue() const { return m_PropertyValue; }
|
||||
void propertyValue(uint32_t value)
|
||||
{
|
||||
if (m_PropertyValue == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_PropertyValue = value;
|
||||
propertyValueChanged();
|
||||
}
|
||||
|
||||
Core* clone() const override;
|
||||
void copy(const BindablePropertyAssetBase& object)
|
||||
{
|
||||
m_PropertyValue = object.m_PropertyValue;
|
||||
BindableProperty::copy(object);
|
||||
}
|
||||
|
||||
bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
|
||||
{
|
||||
switch (propertyKey)
|
||||
{
|
||||
case propertyValuePropertyKey:
|
||||
m_PropertyValue = CoreUintType::deserialize(reader);
|
||||
return true;
|
||||
}
|
||||
return BindableProperty::deserialize(propertyKey, reader);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void propertyValueChanged() {}
|
||||
};
|
||||
} // namespace rive
|
||||
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
#ifndef _RIVE_BINDABLE_PROPERTY_ID_BASE_HPP_
|
||||
#define _RIVE_BINDABLE_PROPERTY_ID_BASE_HPP_
|
||||
#include "rive/core/field_types/core_uint_type.hpp"
|
||||
#include "rive/data_bind/bindable_property.hpp"
|
||||
namespace rive
|
||||
{
|
||||
class BindablePropertyIdBase : public BindableProperty
|
||||
{
|
||||
protected:
|
||||
typedef BindableProperty Super;
|
||||
|
||||
public:
|
||||
static const uint16_t typeKey = 596;
|
||||
|
||||
/// Helper to quickly determine if a core object extends another without
|
||||
/// RTTI at runtime.
|
||||
bool isTypeOf(uint16_t typeKey) const override
|
||||
{
|
||||
switch (typeKey)
|
||||
{
|
||||
case BindablePropertyIdBase::typeKey:
|
||||
case BindablePropertyBase::typeKey:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t coreType() const override { return typeKey; }
|
||||
|
||||
static const uint16_t propertyValuePropertyKey = 823;
|
||||
|
||||
protected:
|
||||
uint32_t m_PropertyValue = -1;
|
||||
|
||||
public:
|
||||
inline uint32_t propertyValue() const { return m_PropertyValue; }
|
||||
void propertyValue(uint32_t value)
|
||||
{
|
||||
if (m_PropertyValue == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_PropertyValue = value;
|
||||
propertyValueChanged();
|
||||
}
|
||||
|
||||
void copy(const BindablePropertyIdBase& object)
|
||||
{
|
||||
m_PropertyValue = object.m_PropertyValue;
|
||||
BindableProperty::copy(object);
|
||||
}
|
||||
|
||||
bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
|
||||
{
|
||||
switch (propertyKey)
|
||||
{
|
||||
case propertyValuePropertyKey:
|
||||
m_PropertyValue = CoreUintType::deserialize(reader);
|
||||
return true;
|
||||
}
|
||||
return BindableProperty::deserialize(propertyKey, reader);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void propertyValueChanged() {}
|
||||
};
|
||||
} // namespace rive
|
||||
|
||||
#endif
|
||||
@@ -1,8 +1,6 @@
|
||||
#ifndef _RIVE_TEXT_STYLE_PAINT_BASE_HPP_
|
||||
#define _RIVE_TEXT_STYLE_PAINT_BASE_HPP_
|
||||
|
||||
#include "rive/text/text_style.hpp"
|
||||
|
||||
namespace rive
|
||||
{
|
||||
class TextStylePaintBase : public TextStyle
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
#ifndef _RIVE_VIEW_MODEL_INSTANCE_ARTBOARD_BASE_HPP_
|
||||
#define _RIVE_VIEW_MODEL_INSTANCE_ARTBOARD_BASE_HPP_
|
||||
#include "rive/core/field_types/core_uint_type.hpp"
|
||||
#include "rive/viewmodel/viewmodel_instance_value.hpp"
|
||||
namespace rive
|
||||
{
|
||||
class ViewModelInstanceArtboardBase : public ViewModelInstanceValue
|
||||
{
|
||||
protected:
|
||||
typedef ViewModelInstanceValue Super;
|
||||
|
||||
public:
|
||||
static const uint16_t typeKey = 599;
|
||||
|
||||
/// Helper to quickly determine if a core object extends another without
|
||||
/// RTTI at runtime.
|
||||
bool isTypeOf(uint16_t typeKey) const override
|
||||
{
|
||||
switch (typeKey)
|
||||
{
|
||||
case ViewModelInstanceArtboardBase::typeKey:
|
||||
case ViewModelInstanceValueBase::typeKey:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t coreType() const override { return typeKey; }
|
||||
|
||||
static const uint16_t propertyValuePropertyKey = 846;
|
||||
|
||||
protected:
|
||||
uint32_t m_PropertyValue = 0;
|
||||
|
||||
public:
|
||||
inline uint32_t propertyValue() const { return m_PropertyValue; }
|
||||
void propertyValue(uint32_t value)
|
||||
{
|
||||
if (m_PropertyValue == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_PropertyValue = value;
|
||||
propertyValueChanged();
|
||||
}
|
||||
|
||||
Core* clone() const override;
|
||||
void copy(const ViewModelInstanceArtboardBase& object)
|
||||
{
|
||||
m_PropertyValue = object.m_PropertyValue;
|
||||
ViewModelInstanceValue::copy(object);
|
||||
}
|
||||
|
||||
bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
|
||||
{
|
||||
switch (propertyKey)
|
||||
{
|
||||
case propertyValuePropertyKey:
|
||||
m_PropertyValue = CoreUintType::deserialize(reader);
|
||||
return true;
|
||||
}
|
||||
return ViewModelInstanceValue::deserialize(propertyKey, reader);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void propertyValueChanged() {}
|
||||
};
|
||||
} // namespace rive
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,37 @@
|
||||
#ifndef _RIVE_VIEW_MODEL_PROPERTY_ARTBOARD_BASE_HPP_
|
||||
#define _RIVE_VIEW_MODEL_PROPERTY_ARTBOARD_BASE_HPP_
|
||||
#include "rive/viewmodel/viewmodel_property.hpp"
|
||||
namespace rive
|
||||
{
|
||||
class ViewModelPropertyArtboardBase : public ViewModelProperty
|
||||
{
|
||||
protected:
|
||||
typedef ViewModelProperty Super;
|
||||
|
||||
public:
|
||||
static const uint16_t typeKey = 598;
|
||||
|
||||
/// Helper to quickly determine if a core object extends another without
|
||||
/// RTTI at runtime.
|
||||
bool isTypeOf(uint16_t typeKey) const override
|
||||
{
|
||||
switch (typeKey)
|
||||
{
|
||||
case ViewModelPropertyArtboardBase::typeKey:
|
||||
case ViewModelPropertyBase::typeKey:
|
||||
case ViewModelComponentBase::typeKey:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t coreType() const override { return typeKey; }
|
||||
|
||||
Core* clone() const override;
|
||||
|
||||
protected:
|
||||
};
|
||||
} // namespace rive
|
||||
|
||||
#endif
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "rive/hit_info.hpp"
|
||||
#include "rive/span.hpp"
|
||||
#include "rive/advancing_component.hpp"
|
||||
#include "rive/viewmodel/viewmodel_instance_artboard.hpp"
|
||||
#include <stdio.h>
|
||||
|
||||
namespace rive
|
||||
@@ -18,6 +19,7 @@ class NestedAnimation;
|
||||
class NestedInput;
|
||||
class NestedStateMachine;
|
||||
class StateMachineInstance;
|
||||
class File;
|
||||
class NestedArtboard : public NestedArtboardBase,
|
||||
public AdvancingComponent,
|
||||
public ArtboardHost
|
||||
@@ -26,10 +28,17 @@ protected:
|
||||
Artboard* m_Artboard = nullptr; // might point to m_Instance, and might not
|
||||
std::unique_ptr<ArtboardInstance> m_Instance; // may be null
|
||||
std::vector<NestedAnimation*> m_NestedAnimations;
|
||||
File* m_file = nullptr;
|
||||
rcp<ViewModelInstance> m_viewModelInstance = nullptr;
|
||||
DataContext* m_dataContext = nullptr;
|
||||
|
||||
protected:
|
||||
std::vector<uint32_t> m_DataBindPathIdsBuffer;
|
||||
|
||||
private:
|
||||
Artboard* findArtboard(
|
||||
ViewModelInstanceArtboard* viewModelInstanceArtboard);
|
||||
|
||||
public:
|
||||
NestedArtboard();
|
||||
~NestedArtboard() override;
|
||||
@@ -39,6 +48,8 @@ public:
|
||||
void addNestedAnimation(NestedAnimation* nestedAnimation);
|
||||
|
||||
void nest(Artboard* artboard);
|
||||
virtual void updateArtboard(
|
||||
ViewModelInstanceArtboard* viewModelInstanceArtboard);
|
||||
size_t artboardCount() override { return 1; }
|
||||
ArtboardInstance* artboardInstance(int index = 0) override
|
||||
{
|
||||
@@ -89,6 +100,8 @@ public:
|
||||
AdvanceFlags::NewFrame) override;
|
||||
Artboard* parentArtboard() override { return artboard(); }
|
||||
void markHostTransformDirty() override { markTransformDirty(); }
|
||||
void file(File*) override;
|
||||
File* file() const override;
|
||||
};
|
||||
} // namespace rive
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "rive/generated/nested_artboard_layout_base.hpp"
|
||||
#include "rive/constraints/layout_constraint.hpp"
|
||||
#include "rive/layout/layout_node_provider.hpp"
|
||||
#include "rive/viewmodel/viewmodel_instance_artboard.hpp"
|
||||
|
||||
namespace rive
|
||||
{
|
||||
@@ -29,6 +30,8 @@ public:
|
||||
AABB layoutBounds() override;
|
||||
size_t numLayoutNodes() override { return 1; }
|
||||
bool isLayoutProvider() override { return true; }
|
||||
void updateArtboard(
|
||||
ViewModelInstanceArtboard* viewModelInstanceArtboard) override;
|
||||
|
||||
TransformComponent* transformComponent() override
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "rive/assets/file_asset.hpp"
|
||||
#include "rive/assets/font_asset.hpp"
|
||||
#include "rive/text/text_interface.hpp"
|
||||
#include "rive/text/text_variation_helper.hpp"
|
||||
|
||||
namespace rive
|
||||
{
|
||||
|
||||
34
include/rive/viewmodel/viewmodel_instance_artboard.hpp
Normal file
34
include/rive/viewmodel/viewmodel_instance_artboard.hpp
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef _RIVE_VIEW_MODEL_INSTANCE_ARTBOARD_HPP_
|
||||
#define _RIVE_VIEW_MODEL_INSTANCE_ARTBOARD_HPP_
|
||||
#include "rive/generated/viewmodel/viewmodel_instance_artboard_base.hpp"
|
||||
#include <stdio.h>
|
||||
namespace rive
|
||||
{
|
||||
#ifdef WITH_RIVE_TOOLS
|
||||
class ViewModelInstanceArtboard;
|
||||
typedef void (*ViewModelArtboardChanged)(ViewModelInstanceArtboard* vmi,
|
||||
uint32_t value);
|
||||
#endif
|
||||
class ViewModelInstanceArtboard : public ViewModelInstanceArtboardBase
|
||||
{
|
||||
protected:
|
||||
void propertyValueChanged() override;
|
||||
|
||||
public:
|
||||
void asset(Artboard* value) { m_artboard = value; }
|
||||
Artboard* asset() { return m_artboard; }
|
||||
|
||||
private:
|
||||
Artboard* m_artboard = nullptr;
|
||||
#ifdef WITH_RIVE_TOOLS
|
||||
public:
|
||||
void onChanged(ViewModelArtboardChanged callback)
|
||||
{
|
||||
m_changedCallback = callback;
|
||||
}
|
||||
ViewModelArtboardChanged m_changedCallback = nullptr;
|
||||
#endif
|
||||
};
|
||||
} // namespace rive
|
||||
|
||||
#endif
|
||||
13
include/rive/viewmodel/viewmodel_property_artboard.hpp
Normal file
13
include/rive/viewmodel/viewmodel_property_artboard.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef _RIVE_VIEW_MODEL_PROPERTY_ARTBOARD_HPP_
|
||||
#define _RIVE_VIEW_MODEL_PROPERTY_ARTBOARD_HPP_
|
||||
#include "rive/generated/viewmodel/viewmodel_property_artboard_base.hpp"
|
||||
#include <stdio.h>
|
||||
namespace rive
|
||||
{
|
||||
class ViewModelPropertyArtboard : public ViewModelPropertyArtboardBase
|
||||
{
|
||||
public:
|
||||
};
|
||||
} // namespace rive
|
||||
|
||||
#endif
|
||||
@@ -127,6 +127,14 @@ void NestedStateMachine::dataContext(DataContext* dataContext)
|
||||
}
|
||||
}
|
||||
|
||||
void NestedStateMachine::clearDataContext()
|
||||
{
|
||||
if (m_StateMachineInstance != nullptr)
|
||||
{
|
||||
m_StateMachineInstance->clearDataContext();
|
||||
}
|
||||
}
|
||||
|
||||
bool NestedStateMachine::tryChangeState()
|
||||
{
|
||||
if (m_StateMachineInstance != nullptr)
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "rive/data_bind/data_values/data_value_list.hpp"
|
||||
#include "rive/data_bind/data_values/data_value_symbol_list_index.hpp"
|
||||
#include "rive/data_bind/data_values/data_value_asset_image.hpp"
|
||||
#include "rive/data_bind/data_values/data_value_artboard.hpp"
|
||||
#include "rive/generated/core_registry.hpp"
|
||||
|
||||
using namespace rive;
|
||||
@@ -65,6 +66,10 @@ DataBindContextValue::DataBindContextValue(DataBind* dataBind) :
|
||||
m_dataValue = new DataValueAssetImage(
|
||||
source->as<ViewModelInstanceAssetImage>()->propertyValue());
|
||||
break;
|
||||
case ViewModelInstanceArtboardBase::typeKey:
|
||||
m_dataValue = new DataValueArtboard(
|
||||
source->as<ViewModelInstanceArtboard>()->propertyValue());
|
||||
break;
|
||||
default:
|
||||
m_dataValue = new DataValue();
|
||||
}
|
||||
@@ -122,6 +127,10 @@ void DataBindContextValue::syncSourceValue()
|
||||
m_dataValue->as<DataValueAssetImage>()->value(
|
||||
source->as<ViewModelInstanceAssetImage>()->propertyValue());
|
||||
break;
|
||||
case ViewModelInstanceArtboardBase::typeKey:
|
||||
m_dataValue->as<DataValueArtboard>()->value(
|
||||
source->as<ViewModelInstanceArtboard>()->propertyValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -222,5 +231,16 @@ void DataBindContextValue::applyToSource(Core* component,
|
||||
propertyKey);
|
||||
}
|
||||
break;
|
||||
case ViewModelInstanceArtboardBase::typeKey:
|
||||
{
|
||||
calculateValueAndApply<DataValueArtboard,
|
||||
uint32_t,
|
||||
ViewModelInstanceArtboard>(targetValue(),
|
||||
isMainDirection,
|
||||
m_dataBind,
|
||||
component,
|
||||
propertyKey);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
38
src/data_bind/context/context_value_artboard.cpp
Normal file
38
src/data_bind/context/context_value_artboard.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "rive/data_bind/context/context_value_artboard.hpp"
|
||||
#include "rive/data_bind/data_values/data_value_artboard.hpp"
|
||||
#include "rive/viewmodel/viewmodel_instance_artboard.hpp"
|
||||
#include "rive/generated/core_registry.hpp"
|
||||
#include "rive/file.hpp"
|
||||
|
||||
using namespace rive;
|
||||
|
||||
DataBindContextValueArtboard::DataBindContextValueArtboard(DataBind* dataBind) :
|
||||
DataBindContextValue(dataBind)
|
||||
{}
|
||||
|
||||
void DataBindContextValueArtboard::apply(Core* target,
|
||||
uint32_t propertyKey,
|
||||
bool isMainDirection)
|
||||
{
|
||||
auto source = m_dataBind->source();
|
||||
if (target->is<NestedArtboard>() && source != nullptr &&
|
||||
source->is<ViewModelInstanceArtboard>())
|
||||
{
|
||||
target->as<NestedArtboard>()->updateArtboard(
|
||||
source->as<ViewModelInstanceArtboard>());
|
||||
}
|
||||
}
|
||||
|
||||
bool DataBindContextValueArtboard::syncTargetValue(Core* target,
|
||||
uint32_t propertyKey)
|
||||
{
|
||||
auto value = CoreRegistry::getUint(target, propertyKey);
|
||||
|
||||
if (m_previousValue != value)
|
||||
{
|
||||
m_previousValue = value;
|
||||
m_targetDataValue.value(value);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "rive/artboard.hpp"
|
||||
#include "rive/data_bind_flags.hpp"
|
||||
#include "rive/generated/core_registry.hpp"
|
||||
#include "rive/data_bind/bindable_property_artboard.hpp"
|
||||
#include "rive/data_bind/bindable_property_asset.hpp"
|
||||
#include "rive/data_bind/bindable_property_number.hpp"
|
||||
#include "rive/data_bind/bindable_property_string.hpp"
|
||||
@@ -13,6 +14,7 @@
|
||||
#include "rive/data_bind/bindable_property_integer.hpp"
|
||||
#include "rive/data_bind/context/context_value.hpp"
|
||||
#include "rive/data_bind/context/context_value_asset_image.hpp"
|
||||
#include "rive/data_bind/context/context_value_artboard.hpp"
|
||||
#include "rive/data_bind/context/context_value_boolean.hpp"
|
||||
#include "rive/data_bind/context/context_value_number.hpp"
|
||||
#include "rive/data_bind/context/context_value_string.hpp"
|
||||
@@ -71,6 +73,7 @@ StatusCode DataBind::import(ImportStack& importStack)
|
||||
case BindablePropertyStringBase::typeKey:
|
||||
case BindablePropertyBooleanBase::typeKey:
|
||||
case BindablePropertyEnumBase::typeKey:
|
||||
case BindablePropertyArtboardBase::typeKey:
|
||||
case BindablePropertyColorBase::typeKey:
|
||||
case BindablePropertyTriggerBase::typeKey:
|
||||
case BindablePropertyIntegerBase::typeKey:
|
||||
@@ -135,6 +138,8 @@ DataType DataBind::outputType()
|
||||
return DataType::symbolListIndex;
|
||||
case ViewModelInstanceAssetImageBase::typeKey:
|
||||
return DataType::assetImage;
|
||||
case ViewModelInstanceArtboardBase::typeKey:
|
||||
return DataType::artboard;
|
||||
}
|
||||
return DataType::none;
|
||||
}
|
||||
@@ -205,6 +210,9 @@ void DataBind::bind()
|
||||
case DataType::assetImage:
|
||||
m_ContextValue = new DataBindContextValueAssetImage(this);
|
||||
break;
|
||||
case DataType::artboard:
|
||||
m_ContextValue = new DataBindContextValueArtboard(this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "rive/animation/transition_property_viewmodel_comparator.hpp"
|
||||
#include "rive/constraints/scrolling/scroll_physics.hpp"
|
||||
#include "rive/data_bind/bindable_property.hpp"
|
||||
#include "rive/data_bind/bindable_property_artboard.hpp"
|
||||
#include "rive/data_bind/bindable_property_asset.hpp"
|
||||
#include "rive/data_bind/bindable_property_number.hpp"
|
||||
#include "rive/data_bind/bindable_property_string.hpp"
|
||||
@@ -451,6 +452,7 @@ ImportResult File::read(BinaryReader& reader, const RuntimeHeader& header)
|
||||
case BindablePropertyEnum::typeKey:
|
||||
case BindablePropertyBoolean::typeKey:
|
||||
case BindablePropertyAsset::typeKey:
|
||||
case BindablePropertyArtboard::typeKey:
|
||||
case BindablePropertyTrigger::typeKey:
|
||||
case BindablePropertyInteger::typeKey:
|
||||
case BindablePropertyList::typeKey:
|
||||
@@ -475,6 +477,11 @@ ImportResult File::read(BinaryReader& reader, const RuntimeHeader& header)
|
||||
case ArtboardComponentList::typeKey:
|
||||
object->as<ArtboardComponentList>()->file(this);
|
||||
break;
|
||||
case NestedArtboard::typeKey:
|
||||
case NestedArtboardLayout::typeKey:
|
||||
case NestedArtboardLeaf::typeKey:
|
||||
object->as<NestedArtboard>()->file(this);
|
||||
break;
|
||||
}
|
||||
if (importStack.makeLatest(stackType, std::move(stackObject)) !=
|
||||
StatusCode::Ok)
|
||||
|
||||
11
src/generated/data_bind/bindable_property_artboard_base.cpp
Normal file
11
src/generated/data_bind/bindable_property_artboard_base.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include "rive/generated/data_bind/bindable_property_artboard_base.hpp"
|
||||
#include "rive/data_bind/bindable_property_artboard.hpp"
|
||||
|
||||
using namespace rive;
|
||||
|
||||
Core* BindablePropertyArtboardBase::clone() const
|
||||
{
|
||||
auto cloned = new BindablePropertyArtboard();
|
||||
cloned->copy(*this);
|
||||
return cloned;
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "rive/generated/text/text_style_paint_base.hpp"
|
||||
#include "rive/text/text_style_paint.hpp"
|
||||
#include "rive/text/text_variation_helper.hpp"
|
||||
|
||||
using namespace rive;
|
||||
|
||||
|
||||
11
src/generated/viewmodel/viewmodel_instance_artboard_base.cpp
Normal file
11
src/generated/viewmodel/viewmodel_instance_artboard_base.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include "rive/generated/viewmodel/viewmodel_instance_artboard_base.hpp"
|
||||
#include "rive/viewmodel/viewmodel_instance_artboard.hpp"
|
||||
|
||||
using namespace rive;
|
||||
|
||||
Core* ViewModelInstanceArtboardBase::clone() const
|
||||
{
|
||||
auto cloned = new ViewModelInstanceArtboard();
|
||||
cloned->copy(*this);
|
||||
return cloned;
|
||||
}
|
||||
11
src/generated/viewmodel/viewmodel_property_artboard_base.cpp
Normal file
11
src/generated/viewmodel/viewmodel_property_artboard_base.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include "rive/generated/viewmodel/viewmodel_property_artboard_base.hpp"
|
||||
#include "rive/viewmodel/viewmodel_property_artboard.hpp"
|
||||
|
||||
using namespace rive;
|
||||
|
||||
Core* ViewModelPropertyArtboardBase::clone() const
|
||||
{
|
||||
auto cloned = new ViewModelPropertyArtboard();
|
||||
cloned->copy(*this);
|
||||
return cloned;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "rive/nested_artboard.hpp"
|
||||
#include "rive/artboard.hpp"
|
||||
#include "rive/backboard.hpp"
|
||||
#include "rive/file.hpp"
|
||||
#include "rive/importers/import_stack.hpp"
|
||||
#include "rive/importers/backboard_importer.hpp"
|
||||
#include "rive/nested_animation.hpp"
|
||||
@@ -18,6 +19,7 @@ Core* NestedArtboard::clone() const
|
||||
{
|
||||
NestedArtboard* nestedArtboard =
|
||||
static_cast<NestedArtboard*>(NestedArtboardBase::clone());
|
||||
nestedArtboard->file(file());
|
||||
if (m_Artboard == nullptr)
|
||||
{
|
||||
return nestedArtboard;
|
||||
@@ -53,6 +55,56 @@ void NestedArtboard::nest(Artboard* artboard)
|
||||
m_Artboard->host(this);
|
||||
}
|
||||
|
||||
Artboard* NestedArtboard::findArtboard(
|
||||
ViewModelInstanceArtboard* viewModelInstanceArtboard)
|
||||
{
|
||||
if (viewModelInstanceArtboard->asset() != nullptr)
|
||||
{
|
||||
return viewModelInstanceArtboard->asset();
|
||||
}
|
||||
else if (m_file != nullptr)
|
||||
{
|
||||
if (m_file != nullptr && viewModelInstanceArtboard != nullptr &&
|
||||
viewModelInstanceArtboard->is<ViewModelInstanceArtboard>())
|
||||
{
|
||||
auto asset = m_file->artboard(
|
||||
viewModelInstanceArtboard->as<ViewModelInstanceArtboard>()
|
||||
->propertyValue());
|
||||
if (asset != nullptr)
|
||||
{
|
||||
return asset->as<Artboard>();
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void NestedArtboard::updateArtboard(
|
||||
ViewModelInstanceArtboard* viewModelInstanceArtboard)
|
||||
{
|
||||
clearDataContext();
|
||||
m_NestedAnimations.clear();
|
||||
Artboard* artboard = findArtboard(viewModelInstanceArtboard);
|
||||
if (artboard != nullptr)
|
||||
{
|
||||
auto artboardInstance = artboard->instance();
|
||||
// TODO: @hernan create state machine with nested state machine wrapper
|
||||
// stateMachine->initializeAnimation(artboardInstance);
|
||||
// m_NestedAnimations.push_back(stateMachine);
|
||||
nest(artboardInstance.release());
|
||||
if (m_dataContext != nullptr && m_viewModelInstance == nullptr)
|
||||
{
|
||||
internalDataContext(m_dataContext);
|
||||
}
|
||||
else if (m_viewModelInstance != nullptr)
|
||||
{
|
||||
bindViewModelInstance(m_viewModelInstance, m_dataContext);
|
||||
}
|
||||
// TODO: @hernan review what dirt to add
|
||||
addDirt(ComponentDirt::Filthy);
|
||||
}
|
||||
}
|
||||
|
||||
static Mat2D makeTranslate(const Artboard* artboard)
|
||||
{
|
||||
return Mat2D::fromTranslate(-artboard->originX() * artboard->width(),
|
||||
@@ -283,6 +335,8 @@ void NestedArtboard::copyDataBindPathIds(const NestedArtboardBase& object)
|
||||
|
||||
void NestedArtboard::internalDataContext(DataContext* value)
|
||||
{
|
||||
m_dataContext = value;
|
||||
m_viewModelInstance = nullptr;
|
||||
if (artboardInstance() != nullptr)
|
||||
{
|
||||
artboardInstance()->internalDataContext(value);
|
||||
@@ -301,6 +355,13 @@ void NestedArtboard::clearDataContext()
|
||||
if (artboardInstance() != nullptr)
|
||||
{
|
||||
artboardInstance()->clearDataContext();
|
||||
for (auto& animation : m_NestedAnimations)
|
||||
{
|
||||
if (animation->is<NestedStateMachine>())
|
||||
{
|
||||
animation->as<NestedStateMachine>()->clearDataContext();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,6 +385,8 @@ void NestedArtboard::bindViewModelInstance(
|
||||
rcp<ViewModelInstance> viewModelInstance,
|
||||
DataContext* parent)
|
||||
{
|
||||
m_dataContext = parent;
|
||||
m_viewModelInstance = viewModelInstance;
|
||||
if (artboardInstance() != nullptr)
|
||||
{
|
||||
artboardInstance()->bindViewModelInstance(viewModelInstance, parent);
|
||||
@@ -395,3 +458,7 @@ bool NestedArtboard::advanceComponent(float elapsedSeconds, AdvanceFlags flags)
|
||||
|
||||
return keepGoing;
|
||||
}
|
||||
|
||||
void NestedArtboard::file(File* value) { m_file = value; }
|
||||
|
||||
File* NestedArtboard::file() const { return m_file; }
|
||||
|
||||
@@ -9,6 +9,7 @@ Core* NestedArtboardLayout::clone() const
|
||||
{
|
||||
NestedArtboardLayout* nestedArtboard =
|
||||
static_cast<NestedArtboardLayout*>(NestedArtboardLayoutBase::clone());
|
||||
nestedArtboard->file(file());
|
||||
if (m_Artboard == nullptr)
|
||||
{
|
||||
return nestedArtboard;
|
||||
@@ -221,4 +222,22 @@ bool NestedArtboardLayout::syncStyleChanges()
|
||||
return false;
|
||||
}
|
||||
return m_Artboard->syncStyleChanges();
|
||||
}
|
||||
|
||||
void NestedArtboardLayout::updateArtboard(
|
||||
ViewModelInstanceArtboard* viewModelInstanceArtboard)
|
||||
{
|
||||
#ifdef WITH_RIVE_LAYOUT
|
||||
if (parent()->is<LayoutComponent>())
|
||||
{
|
||||
parent()->as<LayoutComponent>()->clearLayoutChildren();
|
||||
}
|
||||
#endif
|
||||
NestedArtboard::updateArtboard(viewModelInstanceArtboard);
|
||||
#ifdef WITH_RIVE_LAYOUT
|
||||
if (parent()->is<LayoutComponent>())
|
||||
{
|
||||
parent()->as<LayoutComponent>()->syncLayoutChildren();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -9,6 +9,7 @@ Core* NestedArtboardLeaf::clone() const
|
||||
{
|
||||
NestedArtboardLeaf* nestedArtboard =
|
||||
static_cast<NestedArtboardLeaf*>(NestedArtboardLeafBase::clone());
|
||||
nestedArtboard->file(file());
|
||||
if (m_Artboard == nullptr)
|
||||
{
|
||||
return nestedArtboard;
|
||||
|
||||
20
src/viewmodel/viewmodel_instance_artboard.cpp
Normal file
20
src/viewmodel/viewmodel_instance_artboard.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <array>
|
||||
|
||||
#include "rive/viewmodel/viewmodel_instance_artboard.hpp"
|
||||
#include "rive/component_dirt.hpp"
|
||||
#include "rive/refcnt.hpp"
|
||||
|
||||
using namespace rive;
|
||||
|
||||
void ViewModelInstanceArtboard::propertyValueChanged()
|
||||
{
|
||||
addDirt(ComponentDirt::Bindings);
|
||||
#ifdef WITH_RIVE_TOOLS
|
||||
if (m_changedCallback != nullptr)
|
||||
{
|
||||
m_changedCallback(this, propertyValue());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user