'submodule/include/generated/shapes/ellipse_base.hpp',
'submodule/include/generated/shapes/parametric_path_base.hpp',
'submodule/include/generated/shapes/path_base.hpp',
- 'submodule/include/generated/shapes/path_composer_base.hpp',
'submodule/include/generated/shapes/path_vertex_base.hpp',
'submodule/include/generated/shapes/points_path_base.hpp',
'submodule/include/generated/shapes/polygon_base.hpp',
'submodule/include/shapes/metrics_path.hpp',
'submodule/include/shapes/parametric_path.hpp',
'submodule/include/shapes/path.hpp',
- 'submodule/include/shapes/path_composer.hpp',
'submodule/include/shapes/path_space.hpp',
'submodule/include/shapes/path_vertex.hpp',
'submodule/include/shapes/points_path.hpp',
code.writeln('protected:');
code.writeln('typedef $superTypeName Super;');
code.writeln('public:');
- code.writeln('static const int typeKey = ${_key.intValue};\n');
+ code.writeln('static const uint16_t typeKey = ${_key.intValue};\n');
code.write(comment(
'Helper to quickly determine if a core object extends another '
'without RTTI at runtime.',
indent: 1));
- code.writeln('bool isTypeOf(int typeKey) const override {');
+ code.writeln('bool isTypeOf(uint16_t typeKey) const override {');
code.writeln('switch(typeKey) {');
code.writeln('case ${_name}Base::typeKey:');
code.writeln('}\n');
- code.writeln('int coreType() const override { return typeKey; }\n');
+ code.writeln('uint16_t coreType() const override { return typeKey; }\n');
if (properties.isNotEmpty) {
for (final property in properties) {
- code.writeln('static const int ${property.name}PropertyKey = '
+ code.writeln('static const uint16_t ${property.name}PropertyKey = '
'${property.key.intValue};');
}
code.writeln('private:');
for (final property in properties) {
code.writeln('${property.type.cppName} m_${property.capitalizedName}');
- var initialize = property.initialValue ?? property.type.defaultValue;
+ var initialize = property.initialValueRuntime ??
+ property.initialValue ??
+ property.type.defaultValue;
if (initialize != null) {
- code.write(' = $initialize');
+ code.write(' = ${property.type.convertCpp(initialize)}');
}
code.write(';');
}
}
if (properties.isNotEmpty || _extensionOf == null) {
- code.writeln('bool deserialize(int propertyKey, '
+ code.writeln('bool deserialize(uint16_t propertyKey, '
'BinaryReader& reader) override {');
code.writeln('switch (propertyKey){');
String get snakeRuntimeCoreName => _runtimeCoreType
.replaceAllMapped(RegExp('(.+?)([A-Z])'), (Match m) => '${m[1]}_${m[2]}')
.toLowerCase();
+
+ String convertCpp(String value) => value;
}
import '../field_type.dart';
class DoubleFieldType extends FieldType {
- DoubleFieldType()
- : super(
- 'double',
- 'CoreDoubleType',
- cppName: 'float'
- );
+ DoubleFieldType() : super('double', 'CoreDoubleType', cppName: 'float');
@override
String get defaultValue => '0.0f';
+
+ @override
+ String convertCpp(String value) {
+ var result = value;
+ if (result.isNotEmpty) {
+ if (result[result.length - 1] != 'f') {
+ if (!result.contains('.')) {
+ result += '.0';
+ }
+ result += 'f';
+ }
+ }
+ return result;
+ }
}
cppName: 'std::string', include: '<string>');
@override
String get defaultValue => '""';
+
+ @override
+ String convertCpp(String value) {
+ var result = value;
+ if (result.length > 1) {
+ if (result[0] == '\'') {
+ result = '"' + result.substring(1);
+ }
+ if (result[result.length - 1] == '\'') {
+ result = result.substring(0, result.length - 1) + '"';
+ }
+ }
+ return result;
+ }
}
@override
String get defaultValue => '0';
+
+ // We do this to fix up CoreContext.invalidProperyKey
+ @override
+ String convertCpp(String value) => value.replaceAll('CoreContext.', 'Core::');
}
final FieldType type;
final Definition definition;
String initialValue;
+ String initialValueRuntime;
bool animates = false;
String group;
Key key;
if (init is String) {
initialValue = init;
}
+ dynamic initRuntime = data['initialValueRuntime'];
+ if (initRuntime is String) {
+ initialValueRuntime = initRuntime;
+ }
dynamic overrideSet = data['overrideSet'];
if (overrideSet is bool && overrideSet) {
isSetOverride = true;
var code = StringBuffer(' /// ${'-' * 74}\n');
code.write(comment('${capitalize(name)} field with key ${key.intValue}.',
indent: 1));
- if (initialValue != null) {
- code.writeln('${exportType.cppName} _$name = $initialValue;');
+ if (initialValueRuntime != null || initialValue != null) {
+ code.writeln(
+ '${exportType.cppName} _$name = ${initialValueRuntime ?? initialValue};');
} else {
code.writeln('${exportType.cppName} _$name;');
}
if (initialValue != null) {
data['initialValue'] = initialValue;
}
+ if (initialValueRuntime != null) {
+ data['initialValueRuntime'] = initialValueRuntime;
+ }
if (isGetOverride) {
data['overrideGet'] = true;
}
"properties": {
"artboardId": {
"type": "Id",
+ "initialValue": "Core.missingId",
"key": {
"int": 54,
"string": "artboardid"
},
"name": {
"type": "String",
+ "initialValue": "''",
"key": {
"int": 55,
"string": "name"
},
"order": {
"type": "FractionalIndex",
+ "initialValue": "FractionalIndex.invalid",
"key": {
"int": 73,
"string": "order"
--- /dev/null
+{
+ "name": "AnimationState",
+ "key": {
+ "int": 61,
+ "string": "animationstate"
+ },
+ "extends": "animation/layer_state.json",
+ "properties": {
+ "animationId": {
+ "type": "Id",
+ "typeRuntime": "uint",
+ "initialValue": "Core.missingId",
+ "initialValueRuntime": "-1",
+ "key": {
+ "int": 149,
+ "string": "animationid"
+ },
+ "description": "Id of the animation this layer state refers to."
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+{
+ "name": "AnyState",
+ "key": {
+ "int": 62,
+ "string": "anystate"
+ },
+ "extends": "animation/layer_state.json"
+}
\ No newline at end of file
--- /dev/null
+{
+ "name": "EntryState",
+ "key": {
+ "int": 63,
+ "string": "entrystate"
+ },
+ "extends": "animation/layer_state.json"
+}
\ No newline at end of file
--- /dev/null
+{
+ "name": "ExitState",
+ "key": {
+ "int": 64,
+ "string": "exitstate"
+ },
+ "extends": "animation/layer_state.json"
+}
\ No newline at end of file
"objectId": {
"type": "Id",
"typeRuntime": "uint",
+ "initialValue": "Core.missingId",
+ "initialValueRuntime": "0",
"key": {
"int": 51,
"string": "objectid"
},
"animationId": {
"type": "Id",
+ "initialValue": "Core.missingId",
+ "initialValueRuntime": "-1",
"key": {
"int": 52,
"string": "animationid"
"properties": {
"keyedObjectId": {
"type": "Id",
+ "initialValue": "Core.missingId",
"key": {
"int": 71,
"string": "keyedobjectid"
},
"propertyKey": {
"type": "uint",
+ "initialValue": "CoreContext.invalidPropertyKey",
"key": {
"int": 53,
"string": "propertykey"
"properties": {
"keyedPropertyId": {
"type": "Id",
+ "initialValue": "Core.missingId",
+ "initialValueRuntime": "-1",
"key": {
"int": 72,
"string": "keyedpropertyid"
},
"frame": {
"type": "uint",
+ "initialValue": "0",
"key": {
"int": 67,
"string": "frame"
},
"interpolationType": {
"type": "uint",
+ "initialValue": "0",
"key": {
"int": 68,
"string": "interpolation"
"interpolatorId": {
"type": "Id",
"typeRuntime": "uint",
+ "initialValue": "Core.missingId",
+ "initialValueRuntime": "-1",
"key": {
"int": 69,
"string": "interpolatorid"
},
- "description": "The id of the custom interpolator used when interpolation is Cubic.",
- "nullable": true
+ "description": "The id of the custom interpolator used when interpolation is Cubic."
}
}
}
\ No newline at end of file
"properties": {
"value": {
"type": "Color",
+ "initialValue": "0",
"key": {
"int": 88,
"string": "value"
"properties": {
"value": {
"type": "double",
+ "initialValue": "0",
"key": {
"int": 70,
"string": "value"
"value": {
"type": "Id",
"typeRuntime": "uint",
+ "initialValue": "Core.missingId",
+ "initialValueRuntime": "-1",
"key": {
"int": 122,
"string": "value"
--- /dev/null
+{
+ "name": "LayerState",
+ "key": {
+ "int": 60,
+ "string": "layerstate"
+ },
+ "abstract": true,
+ "extends": "animation/state_machine_layer_component.json",
+ "properties": {
+ "layerId": {
+ "type": "Id",
+ "initialValue": "Core.missingId",
+ "key": {
+ "int": 146,
+ "string": "layerid"
+ },
+ "description": "Id of the state machine layer this state belongs to.",
+ "runtime": false
+ },
+ "x": {
+ "type": "double",
+ "initialValue": "0",
+ "key": {
+ "int": 147,
+ "string": "x"
+ },
+ "runtime": false
+ },
+ "y": {
+ "type": "double",
+ "initialValue": "0",
+ "key": {
+ "int": 148,
+ "string": "y"
+ },
+ "runtime": false
+ }
+ }
+}
\ No newline at end of file
},
"workStart": {
"type": "uint",
+ "initialValue": "-1",
"key": {
"int": 60,
"string": "workstart"
},
"workEnd": {
"type": "uint",
+ "initialValue": "-1",
"key": {
"int": 61,
"string": "workend"
"string": "enableworkarea"
},
"description": "Whether or not the work area is enabled."
+ },
+ "playhead": {
+ "type": "uint",
+ "initialValue": "0",
+ "key": {
+ "int": 132,
+ "string": "playhead"
+ },
+ "description": "Playhead position in frames.",
+ "runtime": false,
+ "coop": false
+ },
+ "viewStart": {
+ "type": "uint",
+ "initialValue": "0",
+ "key": {
+ "int": 133,
+ "string": "viewstart"
+ },
+ "description": "Viewport start in frames.",
+ "runtime": false,
+ "coop": false
+ },
+ "viewEnd": {
+ "type": "uint",
+ "initialValue": "2147483648",
+ "key": {
+ "int": 134,
+ "string": "viewend"
+ },
+ "description": "Viewport end in frames.",
+ "runtime": false,
+ "coop": false
}
}
}
\ No newline at end of file
--- /dev/null
+{
+ "name": "StateMachine",
+ "key": {
+ "int": 53,
+ "string": "statemachine"
+ },
+ "extends": "animation/animation.json",
+ "properties": {
+ "editingListValue": {
+ "type": "uint",
+ "initialValue": "0",
+ "key": {
+ "int": 136,
+ "string": "editinglistvalue"
+ },
+ "description": "Backing value for enum representing which list being edited.",
+ "runtime": false,
+ "coop": false
+ },
+ "editingLayerId": {
+ "type": "Id",
+ "initialValue": "Core.missingId",
+ "key": {
+ "int": 142,
+ "string": "editinglayer"
+ },
+ "description": "Id of the currently editing layer.",
+ "runtime": false,
+ "coop": false
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+{
+ "name": "StateMachineBool",
+ "key": {
+ "int": 59,
+ "string": "statemachinebool"
+ },
+ "extends": "animation/state_machine_input.json",
+ "properties": {
+ "value": {
+ "type": "bool",
+ "initialValue": "false",
+ "key": {
+ "int": 141,
+ "string": "value"
+ }
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+{
+ "name": "StateMachineComponent",
+ "key": {
+ "int": 54,
+ "string": "statemachinecomponent"
+ },
+ "abstract": true,
+ "properties": {
+ "machineId": {
+ "type": "Id",
+ "initialValue": "Core.missingId",
+ "key": {
+ "int": 137,
+ "string": "machineid"
+ },
+ "description": "Id of the state machine this component belongs to.",
+ "runtime": false
+ },
+ "name": {
+ "type": "String",
+ "initialValue": "''",
+ "key": {
+ "int": 138,
+ "string": "name"
+ },
+ "description": "Non-unique identifier, used to give friendly names to state machine components (like layers or inputs)."
+ },
+ "machineOrder": {
+ "type": "FractionalIndex",
+ "initialValue": "FractionalIndex.invalid",
+ "key": {
+ "int": 139,
+ "string": "machineorder"
+ },
+ "description": "Order of this component in the state machine. Exported in order for runtime",
+ "runtime": false
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+{
+ "name": "StateMachineDouble",
+ "key": {
+ "int": 56,
+ "string": "statemachinedouble"
+ },
+ "extends": "animation/state_machine_input.json",
+ "properties": {
+ "value": {
+ "type": "double",
+ "initialValue": "0",
+ "key": {
+ "int": 140,
+ "string": "value"
+ }
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+{
+ "name": "StateMachineInput",
+ "key": {
+ "int": 55,
+ "string": "statemachineinput"
+ },
+ "abstract": true,
+ "extends": "animation/state_machine_component.json"
+}
\ No newline at end of file
--- /dev/null
+{
+ "name": "StateMachineLayer",
+ "key": {
+ "int": 57,
+ "string": "statemachinelayer"
+ },
+ "extends": "animation/state_machine_component.json",
+ "properties": {
+ "stageZoom": {
+ "type": "double",
+ "initialValue": "0",
+ "key": {
+ "int": 143,
+ "string": "stagezoom"
+ },
+ "description": "Zoom value of the stage in the editor. Initial value is 0 to indicate it is not set.",
+ "runtime": false,
+ "coop": false
+ },
+ "stageX": {
+ "type": "double",
+ "initialValue": "0",
+ "key": {
+ "int": 144,
+ "string": "stagex"
+ },
+ "description": "X translation value of the stage in the editor.",
+ "runtime": false,
+ "coop": false
+ },
+ "stageY": {
+ "type": "double",
+ "initialValue": "0",
+ "key": {
+ "int": 145,
+ "string": "stagey"
+ },
+ "description": "Y translation value of the stage in the editor.",
+ "runtime": false,
+ "coop": false
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+{
+ "name": "StateMachineLayerComponent",
+ "key": {
+ "int": 66,
+ "string": "statemachinelayercomponent"
+ },
+ "abstract": true
+}
\ No newline at end of file
--- /dev/null
+{
+ "name": "StateMachineTrigger",
+ "key": {
+ "int": 58,
+ "string": "statemachinetrigger"
+ },
+ "extends": "animation/state_machine_input.json"
+}
\ No newline at end of file
--- /dev/null
+{
+ "name": "StateTransition",
+ "key": {
+ "int": 65,
+ "string": "statetransition"
+ },
+ "extends": "animation/state_machine_layer_component.json",
+ "properties": {
+ "stateFromId": {
+ "type": "Id",
+ "initialValue": "Core.missingId",
+ "key": {
+ "int": 150,
+ "string": "statefromid"
+ },
+ "description": "Id of the state this transition originates from.",
+ "runtime": false
+ },
+ "stateToId": {
+ "type": "Id",
+ "typeRuntime": "uint",
+ "initialValue": "Core.missingId",
+ "initialValueRuntime": "-1",
+ "key": {
+ "int": 151,
+ "string": "statetoid"
+ },
+ "description": "Id of the state this transition originates from."
+ },
+ "flags": {
+ "type": "uint",
+ "initialValue": "0",
+ "key": {
+ "int": 152,
+ "string": "flags"
+ }
+ },
+ "duration": {
+ "type": "uint",
+ "initialValue": "0",
+ "key": {
+ "int": 158,
+ "string": "duration"
+ },
+ "description": "Duration of the trasition (mix time) in milliseconds."
+ },
+ "transitionOrder": {
+ "type": "FractionalIndex",
+ "initialValue": "FractionalIndex.invalid",
+ "key": {
+ "int": 159,
+ "string": "transitionorder"
+ },
+ "description": "Order value for sorting transitions in states.",
+ "runtime": false
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+{
+ "name": "TransitionBoolCondition",
+ "key": {
+ "int": 71,
+ "string": "transitionboolcondition"
+ },
+ "extends": "animation/transition_value_condition.json"
+}
\ No newline at end of file
--- /dev/null
+{
+ "name": "TransitionCondition",
+ "key": {
+ "int": 67,
+ "string": "transitioncondition"
+ },
+ "abstract": true,
+ "properties": {
+ "transitionId": {
+ "type": "Id",
+ "typeRuntime": "uint",
+ "initialValue": "Core.missingId",
+ "initialValueRuntime": "-1",
+ "key": {
+ "int": 153,
+ "string": "transitionid"
+ },
+ "description": "Id of the transition this condition belongs to.",
+ "runtime": false
+ },
+ "conditionOrder": {
+ "type": "FractionalIndex",
+ "initialValue": "FractionalIndex.invalid",
+ "initialValueRuntime": "0",
+ "key": {
+ "int": 154,
+ "string": "conditionorder"
+ },
+ "description": "Order value for condition in a transition.",
+ "runtime": false
+ },
+ "inputId": {
+ "type": "Id",
+ "typeRuntime": "uint",
+ "initialValue": "Core.missingId",
+ "initialValueRuntime": "-1",
+ "key": {
+ "int": 155,
+ "string": "inputid"
+ },
+ "description": "Id of the StateMachineInput referenced."
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+{
+ "name": "TransitionDoubleCondition",
+ "key": {
+ "int": 70,
+ "string": "transitiondoublecondition"
+ },
+ "extends": "animation/transition_value_condition.json",
+ "properties": {
+ "value": {
+ "type": "double",
+ "initialValue": "0",
+ "key": {
+ "int": 157,
+ "string": "value"
+ }
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+{
+ "name": "TransitionTriggerCondition",
+ "key": {
+ "int": 68,
+ "string": "transitiontriggercondition"
+ },
+ "extends": "animation/transition_condition.json"
+}
\ No newline at end of file
--- /dev/null
+{
+ "name": "TransitionValueCondition",
+ "key": {
+ "int": 69,
+ "string": "transitionvaluecondition"
+ },
+ "abstract": true,
+ "extends": "animation/transition_condition.json",
+ "properties": {
+ "opValue": {
+ "type": "uint",
+ "initialValue": "0",
+ "key": {
+ "int": 156,
+ "string": "opvalue"
+ },
+ "description": "Integer representation of the StateMachineOp enum."
+ }
+ }
+}
\ No newline at end of file
"properties": {
"width": {
"type": "double",
+ "initialValue": "0",
"key": {
"int": 7,
"string": "w"
},
"height": {
"type": "double",
+ "initialValue": "0",
"key": {
"int": 8,
"string": "h"
},
"x": {
"type": "double",
+ "initialValue": "0",
"key": {
"int": 9,
"string": "x"
},
"y": {
"type": "double",
+ "initialValue": "0",
"key": {
"int": 10,
"string": "y"
},
"originX": {
"type": "double",
+ "initialValue": "0",
"key": {
"int": 11,
"string": "ox"
},
"originY": {
"type": "double",
+ "initialValue": "0",
"key": {
"int": 12,
"string": "oy"
},
"description": "Origin y in normalized coordinates (0.5 = center, 0 = top, 1 = bottom)."
+ },
+ "editingAnimation": {
+ "type": "Id",
+ "initialValue": "Core.missingId",
+ "key": {
+ "int": 131,
+ "string": "editinganimation"
+ },
+ "description": "Id of the last open animation.",
+ "runtime": false,
+ "coop": false
}
}
}
\ No newline at end of file
"properties": {
"activeArtboardId": {
"type": "Id",
+ "initialValue": "Core.missingId",
"key": {
"int": 43,
"string": "activeArtboardId"
},
"mainArtboardId": {
"type": "Id",
+ "initialValue": "Core.missingId",
"key": {
"int": 44,
"string": "mainArtboardId"
},
"description": "The background color.",
"runtime": false
+ },
+ "editorMode": {
+ "type": "uint",
+ "initialValue": "0",
+ "key": {
+ "int": 135,
+ "string": "editormode"
+ },
+ "description": "Edit time mode.",
+ "runtime": false,
+ "coop": false
}
}
}
\ No newline at end of file
"boneId": {
"type": "Id",
"typeRuntime": "uint",
+ "initialValue": "Core.missingId",
+ "initialValueRuntime": "-1",
"key": {
"int": 95,
"string": "boneid"
"properties": {
"dependentIds": {
"type": "List<Id>",
+ "initialValue": "[]",
"key": {
"int": 3,
"string": "dependentIds"
},
"name": {
"type": "String",
+ "initialValue": "''",
"key": {
"int": 4,
"string": "name"
},
- "description": "Non-unique identifier, used to give friendly names to elements in the hierarchy. Runtimes provide an API for finding components by this [name].",
- "nullable": true
+ "description": "Non-unique identifier, used to give friendly names to elements in the hierarchy. Runtimes provide an API for finding components by this [name]."
},
"parentId": {
"type": "Id",
"typeRuntime": "uint",
+ "initialValue": "Core.missingId",
+ "initialValueRuntime": "0",
"key": {
"int": 5,
"string": "parentId"
},
"childOrder": {
"type": "FractionalIndex",
+ "initialValue": "FractionalIndex.invalid",
+ "initialValueRuntime": "0",
"key": {
"int": 6,
"string": "childOrder"
},
"description": "Order value for sorting child elements in ContainerComponent parent.",
"runtime": false
+ },
+ "flags": {
+ "type": "uint",
+ "initialValue": "0",
+ "key": {
+ "int": 130,
+ "string": "flags"
+ },
+ "runtime": false
}
}
}
\ No newline at end of file
"drawTargetId": {
"type": "Id",
"typeRuntime": "uint",
+ "initialValue": "Core.missingId",
+ "initialValueRuntime": "-1",
"animates": true,
"key": {
"int": 121,
"drawableId": {
"type": "Id",
"typeRuntime": "uint",
+ "initialValue": "Core.missingId",
+ "initialValueRuntime": "-1",
"key": {
"int": 119,
"string": "drawableid"
"int": 23,
"string": "blendModeValue"
}
+ },
+ "drawableFlags": {
+ "type": "uint",
+ "initialValue": "0",
+ "key": {
+ "int": 129,
+ "string": "drawableflags"
+ },
+ "coop": false
}
}
}
\ No newline at end of file
"sourceId": {
"type": "Id",
"typeRuntime": "uint",
+ "initialValue": "Core.missingId",
+ "initialValueRuntime": "-1",
"key": {
"int": 92,
"string": "sourceid"
"string": "path"
},
"abstract": true,
- "extends": "node.json"
+ "extends": "node.json",
+ "properties": {
+ "pathFlags": {
+ "type": "uint",
+ "initialValue": "0",
+ "key": {
+ "int": 128,
+ "string": "pathflags"
+ },
+ "coop": false
+ }
+ }
}
\ No newline at end of file
+++ /dev/null
-{
- "name": "PathComposer",
- "key": {
- "int": 9,
- "string": "pathcomposer"
- },
- "extends": "component.json"
-}
\ No newline at end of file
"properties": {
"x": {
"type": "double",
+ "initialValue": "0",
"animates": true,
"group": "position",
"key": {
},
"y": {
"type": "double",
+ "initialValue": "0",
"animates": true,
"group": "position",
"key": {
"properties": {
"isClosed": {
"type": "bool",
+ "initialValue": "false",
"key": {
"int": 32,
"string": "isclosed"
{
- "name": "Polygon",
- "key": {
- "int": 51,
- "string": "polygon"
+ "name": "Polygon",
+ "key": {
+ "int": 51,
+ "string": "polygon"
+ },
+ "extends": "shapes/parametric_path.json",
+ "properties": {
+ "points": {
+ "type": "uint",
+ "initialValue": "5",
+ "key": {
+ "int": 125,
+ "string": "points"
+ },
+ "description": "The number of points for the polygon."
},
- "extends": "shapes/parametric_path.json",
- "properties": {
- "points": {
- "type": "uint",
- "initialValue": "5",
- "key": {
- "int": 125,
- "string": "points"
- },
- "description": "The number of points for the polygon."
+ "cornerRadius": {
+ "type": "double",
+ "initialValue": "0",
+ "key": {
+ "int": 126,
+ "string": "cornerradius"
},
- "cornerRadius": {
- "type": "double",
- "initialValue": "0",
- "key": {
- "int": 126,
- "string": "cornerradius"
- },
- "description": "The corner radius."
- }
+ "description": "The corner radius."
}
- }
\ No newline at end of file
+ }
+}
\ No newline at end of file
{
- "name": "Star",
- "key": {
- "int": 52,
- "string": "star"
- },
- "extends": "shapes/polygon.json",
- "properties": {
- "innerRadius": {
- "type": "double",
- "initialValue": "0.5",
- "animates": true,
- "key": {
- "int": 127,
- "string": "inner_radius"
- },
- "description": "Percentage of width/height to project inner points of the star."
- }
+ "name": "Star",
+ "key": {
+ "int": 52,
+ "string": "star"
+ },
+ "extends": "shapes/polygon.json",
+ "properties": {
+ "innerRadius": {
+ "type": "double",
+ "initialValue": "0.5",
+ "animates": true,
+ "key": {
+ "int": 127,
+ "string": "inner_radius"
+ },
+ "description": "Percentage of width/height to project inner points of the star."
}
- }
\ No newline at end of file
+ }
+}
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_ANIMATION_STATE_HPP_
+#define _RIVE_ANIMATION_STATE_HPP_
+#include "generated/animation/animation_state_base.hpp"
+#include <stdio.h>
+namespace rive
+{
+ class AnimationState : public AnimationStateBase
+ {
+ public:
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_ANY_STATE_HPP_
+#define _RIVE_ANY_STATE_HPP_
+#include "generated/animation/any_state_base.hpp"
+#include <stdio.h>
+namespace rive
+{
+ class AnyState : public AnyStateBase
+ {
+ public:
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
/// Convert a linear interpolation factor to an eased one.
float transform(float value) const;
+
+ StatusCode import(ImportStack& importStack) override;
};
} // namespace rive
--- /dev/null
+#ifndef _RIVE_ENTRY_STATE_HPP_
+#define _RIVE_ENTRY_STATE_HPP_
+#include "generated/animation/entry_state_base.hpp"
+#include <stdio.h>
+namespace rive
+{
+ class EntryState : public EntryStateBase
+ {
+ public:
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_EXIT_STATE_HPP_
+#define _RIVE_EXIT_STATE_HPP_
+#include "generated/animation/exit_state_base.hpp"
+#include <stdio.h>
+namespace rive
+{
+ class ExitState : public ExitStateBase
+ {
+ public:
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
StatusCode onAddedDirty(CoreContext* context) override;
StatusCode onAddedClean(CoreContext* context) override;
void apply(Artboard* coreContext, float time, float mix);
+
+ StatusCode import(ImportStack& importStack) override;
};
} // namespace rive
StatusCode onAddedDirty(CoreContext* context) override;
void apply(Core* object, float time, float mix);
+
+ StatusCode import(ImportStack& importStack) override;
};
} // namespace rive
public:
inline float seconds() const { return m_Seconds; }
- inline CubicInterpolator* interpolator() const { return m_Interpolator; }
+ inline CubicInterpolator* interpolator() const
+ {
+ return m_Interpolator;
+ }
void computeSeconds(int fps);
StatusCode onAddedDirty(CoreContext* context) override;
- StatusCode onAddedClean(CoreContext* context) override { return StatusCode::Ok; }
+ StatusCode onAddedClean(CoreContext* context) override
+ {
+ return StatusCode::Ok;
+ }
virtual void apply(Core* object, int propertyKey, float mix) = 0;
virtual void applyInterpolation(Core* object,
float seconds,
const KeyFrame* nextFrame,
float mix) = 0;
+
+ StatusCode import(ImportStack& importStack) override;
};
} // namespace rive
--- /dev/null
+#ifndef _RIVE_LAYER_STATE_HPP_
+#define _RIVE_LAYER_STATE_HPP_
+#include "generated/animation/layer_state_base.hpp"
+#include <stdio.h>
+namespace rive
+{
+ class LayerState : public LayerStateBase
+ {
+ public:
+ StatusCode onAddedDirty(CoreContext* context) override;
+ StatusCode onAddedClean(CoreContext* context) override;
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
void apply(Artboard* artboard, float time, float mix = 1.0f);
Loop loop() const { return (Loop)loopValue(); }
+
+ StatusCode import(ImportStack& importStack) override;
+
+#ifdef TESTING
+ size_t numKeyedObjects() { return m_KeyedObjects.size(); }
+#endif
};
} // namespace rive
--- /dev/null
+#ifndef _RIVE_STATE_MACHINE_HPP_
+#define _RIVE_STATE_MACHINE_HPP_
+#include "generated/animation/state_machine_base.hpp"
+#include <stdio.h>
+namespace rive
+{
+ class StateMachine : public StateMachineBase
+ {
+ public:
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_STATE_MACHINE_BOOL_HPP_
+#define _RIVE_STATE_MACHINE_BOOL_HPP_
+#include "generated/animation/state_machine_bool_base.hpp"
+#include <stdio.h>
+namespace rive
+{
+ class StateMachineBool : public StateMachineBoolBase
+ {
+ public:
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_STATE_MACHINE_COMPONENT_HPP_
+#define _RIVE_STATE_MACHINE_COMPONENT_HPP_
+#include "generated/animation/state_machine_component_base.hpp"
+#include <stdio.h>
+namespace rive
+{
+ class StateMachineComponent : public StateMachineComponentBase
+ {
+ public:
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_STATE_MACHINE_DOUBLE_HPP_
+#define _RIVE_STATE_MACHINE_DOUBLE_HPP_
+#include "generated/animation/state_machine_double_base.hpp"
+#include <stdio.h>
+namespace rive
+{
+ class StateMachineDouble : public StateMachineDoubleBase
+ {
+ public:
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_STATE_MACHINE_INPUT_HPP_
+#define _RIVE_STATE_MACHINE_INPUT_HPP_
+#include "generated/animation/state_machine_input_base.hpp"
+#include <stdio.h>
+namespace rive
+{
+ class StateMachineInput : public StateMachineInputBase
+ {
+ public:
+ StatusCode onAddedDirty(CoreContext* context) override;
+ StatusCode onAddedClean(CoreContext* context) override;
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_STATE_MACHINE_LAYER_HPP_
+#define _RIVE_STATE_MACHINE_LAYER_HPP_
+#include "generated/animation/state_machine_layer_base.hpp"
+#include <stdio.h>
+namespace rive
+{
+ class StateMachineLayer : public StateMachineLayerBase
+ {
+ public:
+ StatusCode onAddedDirty(CoreContext* context) override;
+ StatusCode onAddedClean(CoreContext* context) override;
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_STATE_MACHINE_LAYER_COMPONENT_HPP_
+#define _RIVE_STATE_MACHINE_LAYER_COMPONENT_HPP_
+#include "generated/animation/state_machine_layer_component_base.hpp"
+#include <stdio.h>
+namespace rive
+{
+ class StateMachineLayerComponent : public StateMachineLayerComponentBase
+ {
+ public:
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_STATE_MACHINE_TRIGGER_HPP_
+#define _RIVE_STATE_MACHINE_TRIGGER_HPP_
+#include "generated/animation/state_machine_trigger_base.hpp"
+#include <stdio.h>
+namespace rive
+{
+ class StateMachineTrigger : public StateMachineTriggerBase
+ {
+ private:
+ bool m_Fired = false;
+ void reset();
+
+ public:
+ void fire();
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_STATE_TRANSITION_HPP_
+#define _RIVE_STATE_TRANSITION_HPP_
+#include "generated/animation/state_transition_base.hpp"
+#include <stdio.h>
+namespace rive
+{
+ class StateTransition : public StateTransitionBase
+ {
+ public:
+ StatusCode onAddedDirty(CoreContext* context) override;
+ StatusCode onAddedClean(CoreContext* context) override;
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_TRANSITION_BOOL_CONDITION_HPP_
+#define _RIVE_TRANSITION_BOOL_CONDITION_HPP_
+#include "generated/animation/transition_bool_condition_base.hpp"
+#include <stdio.h>
+namespace rive
+{
+ class TransitionBoolCondition : public TransitionBoolConditionBase
+ {
+ public:
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_TRANSITION_CONDITION_HPP_
+#define _RIVE_TRANSITION_CONDITION_HPP_
+#include "generated/animation/transition_condition_base.hpp"
+#include <stdio.h>
+namespace rive
+{
+ class TransitionCondition : public TransitionConditionBase
+ {
+ public:
+ StatusCode onAddedDirty(CoreContext* context) override;
+ StatusCode onAddedClean(CoreContext* context) override;
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_TRANSITION_DOUBLE_CONDITION_HPP_
+#define _RIVE_TRANSITION_DOUBLE_CONDITION_HPP_
+#include "generated/animation/transition_double_condition_base.hpp"
+#include <stdio.h>
+namespace rive
+{
+ class TransitionDoubleCondition : public TransitionDoubleConditionBase
+ {
+ public:
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_TRANSITION_TRIGGER_CONDITION_HPP_
+#define _RIVE_TRANSITION_TRIGGER_CONDITION_HPP_
+#include "generated/animation/transition_trigger_condition_base.hpp"
+#include <stdio.h>
+namespace rive
+{
+ class TransitionTriggerCondition : public TransitionTriggerConditionBase
+ {
+ public:
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_TRANSITION_VALUE_CONDITION_HPP_
+#define _RIVE_TRANSITION_VALUE_CONDITION_HPP_
+#include "generated/animation/transition_value_condition_base.hpp"
+#include <stdio.h>
+namespace rive
+{
+ class TransitionValueCondition : public TransitionValueConditionBase
+ {
+ public:
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
#ifndef _RIVE_ARTBOARD_HPP_
#define _RIVE_ARTBOARD_HPP_
-#include "animation/animation.hpp"
+#include "animation/linear_animation.hpp"
+#include "animation/state_machine.hpp"
#include "core_context.hpp"
#include "generated/artboard_base.hpp"
#include "math/aabb.hpp"
private:
std::vector<Core*> m_Objects;
- std::vector<Animation*> m_Animations;
+ std::vector<LinearAnimation*> m_Animations;
+ std::vector<StateMachine*> m_StateMachines;
std::vector<Component*> m_DependencyOrder;
std::vector<Drawable*> m_Drawables;
std::vector<DrawTarget*> m_DrawTargets;
~Artboard();
StatusCode initialize();
void addObject(Core* object);
- void addAnimation(Animation* object);
+ void addAnimation(LinearAnimation* object);
+ void addStateMachine(StateMachine* object);
Core* resolve(int id) const override;
{
for (auto object : m_Objects)
{
- if (object->is<T>() && object->as<T>()->name() == name)
+ if (object != nullptr && object->is<T>() &&
+ object->as<T>()->name() == name)
{
return reinterpret_cast<T*>(object);
}
return nullptr;
}
- template <typename T = Animation> T* firstAnimation()
- {
- for (auto animation : m_Animations)
- {
- if (animation->is<T>())
- {
- return reinterpret_cast<T*>(animation);
- }
- }
- return nullptr;
- }
-
- template <typename T = Animation> T* animation(std::string name)
- {
- for (auto animation : m_Animations)
- {
- if (animation->is<T>() && animation->as<T>()->name() == name)
- {
- return reinterpret_cast<T*>(animation);
- }
- }
- return nullptr;
- }
-
- template <typename T = Animation> T* animation(size_t index)
- {
- if (index >= 0 && index >= m_Animations.size())
- {
- return nullptr;
- }
- return m_Animations[index]->as<T>();
- }
-
+ LinearAnimation* firstAnimation();
+ LinearAnimation* animation(std::string name);
+ LinearAnimation* animation(size_t index);
size_t animationCount() { return m_Animations.size(); }
+
+ StateMachine* firstStateMachine();
+ StateMachine* stateMachine(std::string name);
+ StateMachine* stateMachine(size_t index);
+ size_t stateMachineCount() { return m_StateMachines.size(); }
};
} // namespace rive
{
return (value & flag) != ComponentDirt::None;
}
+
+ StatusCode import(ImportStack& importStack) override;
};
} // namespace rive
namespace rive
{
class CoreContext;
+ class ImportStack;
class Core
{
public:
+ static const int invalidPropertyKey = 0;
virtual ~Core() {}
- virtual int coreType() const = 0;
- virtual bool isTypeOf(int typeKey) const = 0;
- virtual bool deserialize(int propertyKey, BinaryReader& reader) = 0;
+ virtual uint16_t coreType() const = 0;
+ virtual bool isTypeOf(uint16_t typeKey) const = 0;
+ virtual bool deserialize(uint16_t propertyKey,
+ BinaryReader& reader) = 0;
template <typename T> bool is() const { return isTypeOf(T::typeKey); }
template <typename T> T* as()
/// dependencies. (A path should be able to find a Shape somewhere in
/// its hierarchy, which may be multiple levels up).
virtual StatusCode onAddedClean(CoreContext* context) = 0;
+
+ virtual StatusCode import(ImportStack& importStack)
+ {
+ return StatusCode::Ok;
+ }
};
} // namespace rive
#endif
\ No newline at end of file
public:
BinaryReader(uint8_t* bytes, size_t length);
bool didOverflow() const;
+ bool reachedEnd() const;
size_t lengthInBytes() const;
{
public:
/// Major version number supported by the runtime.
- static const int majorVersion = 6;
+ static const int majorVersion = 7;
/// Minor version number supported by the runtime.
- static const int minorVersion = 3;
+ static const int minorVersion = 0;
private:
/// The file's backboard. All Rive files have a single backboard
typedef Core Super;
public:
- static const int typeKey = 27;
+ static const uint16_t typeKey = 27;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int namePropertyKey = 55;
+ static const uint16_t namePropertyKey = 55;
private:
std::string m_Name = "";
nameChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
--- /dev/null
+#ifndef _RIVE_ANIMATION_STATE_BASE_HPP_
+#define _RIVE_ANIMATION_STATE_BASE_HPP_
+#include "animation/layer_state.hpp"
+#include "core/field_types/core_uint_type.hpp"
+namespace rive
+{
+ class AnimationStateBase : public LayerState
+ {
+ protected:
+ typedef LayerState Super;
+
+ public:
+ static const uint16_t typeKey = 61;
+
+ /// Helper to quickly determine if a core object extends another without
+ /// RTTI at runtime.
+ bool isTypeOf(uint16_t typeKey) const override
+ {
+ switch (typeKey)
+ {
+ case AnimationStateBase::typeKey:
+ case LayerStateBase::typeKey:
+ case StateMachineLayerComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ uint16_t coreType() const override { return typeKey; }
+
+ static const uint16_t animationIdPropertyKey = 149;
+
+ private:
+ int m_AnimationId = -1;
+ public:
+ inline int animationId() const { return m_AnimationId; }
+ void animationId(int value)
+ {
+ if (m_AnimationId == value)
+ {
+ return;
+ }
+ m_AnimationId = value;
+ animationIdChanged();
+ }
+
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
+ {
+ switch (propertyKey)
+ {
+ case animationIdPropertyKey:
+ m_AnimationId = CoreUintType::deserialize(reader);
+ return true;
+ }
+ return LayerState::deserialize(propertyKey, reader);
+ }
+
+ protected:
+ virtual void animationIdChanged() {}
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_ANY_STATE_BASE_HPP_
+#define _RIVE_ANY_STATE_BASE_HPP_
+#include "animation/layer_state.hpp"
+namespace rive
+{
+ class AnyStateBase : public LayerState
+ {
+ protected:
+ typedef LayerState Super;
+
+ public:
+ static const uint16_t typeKey = 62;
+
+ /// Helper to quickly determine if a core object extends another without
+ /// RTTI at runtime.
+ bool isTypeOf(uint16_t typeKey) const override
+ {
+ switch (typeKey)
+ {
+ case AnyStateBase::typeKey:
+ case LayerStateBase::typeKey:
+ case StateMachineLayerComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ uint16_t coreType() const override { return typeKey; }
+
+ protected:
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
typedef Core Super;
public:
- static const int typeKey = 28;
+ static const uint16_t typeKey = 28;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int x1PropertyKey = 63;
- static const int y1PropertyKey = 64;
- static const int x2PropertyKey = 65;
- static const int y2PropertyKey = 66;
+ static const uint16_t x1PropertyKey = 63;
+ static const uint16_t y1PropertyKey = 64;
+ static const uint16_t x2PropertyKey = 65;
+ static const uint16_t y2PropertyKey = 66;
private:
- float m_X1 = 0.42;
- float m_Y1 = 0;
- float m_X2 = 0.58;
- float m_Y2 = 1;
+ float m_X1 = 0.42f;
+ float m_Y1 = 0.0f;
+ float m_X2 = 0.58f;
+ float m_Y2 = 1.0f;
public:
inline float x1() const { return m_X1; }
void x1(float value)
y2Changed();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
--- /dev/null
+#ifndef _RIVE_ENTRY_STATE_BASE_HPP_
+#define _RIVE_ENTRY_STATE_BASE_HPP_
+#include "animation/layer_state.hpp"
+namespace rive
+{
+ class EntryStateBase : public LayerState
+ {
+ protected:
+ typedef LayerState Super;
+
+ public:
+ static const uint16_t typeKey = 63;
+
+ /// Helper to quickly determine if a core object extends another without
+ /// RTTI at runtime.
+ bool isTypeOf(uint16_t typeKey) const override
+ {
+ switch (typeKey)
+ {
+ case EntryStateBase::typeKey:
+ case LayerStateBase::typeKey:
+ case StateMachineLayerComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ uint16_t coreType() const override { return typeKey; }
+
+ protected:
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_EXIT_STATE_BASE_HPP_
+#define _RIVE_EXIT_STATE_BASE_HPP_
+#include "animation/layer_state.hpp"
+namespace rive
+{
+ class ExitStateBase : public LayerState
+ {
+ protected:
+ typedef LayerState Super;
+
+ public:
+ static const uint16_t typeKey = 64;
+
+ /// Helper to quickly determine if a core object extends another without
+ /// RTTI at runtime.
+ bool isTypeOf(uint16_t typeKey) const override
+ {
+ switch (typeKey)
+ {
+ case ExitStateBase::typeKey:
+ case LayerStateBase::typeKey:
+ case StateMachineLayerComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ uint16_t coreType() const override { return typeKey; }
+
+ protected:
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
typedef Core Super;
public:
- static const int typeKey = 25;
+ static const uint16_t typeKey = 25;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int objectIdPropertyKey = 51;
+ static const uint16_t objectIdPropertyKey = 51;
private:
int m_ObjectId = 0;
objectIdChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef Core Super;
public:
- static const int typeKey = 26;
+ static const uint16_t typeKey = 26;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int propertyKeyPropertyKey = 53;
+ static const uint16_t propertyKeyPropertyKey = 53;
private:
- int m_PropertyKey = 0;
+ int m_PropertyKey = Core::invalidPropertyKey;
public:
inline int propertyKey() const { return m_PropertyKey; }
void propertyKey(int value)
propertyKeyChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef Core Super;
public:
- static const int typeKey = 29;
+ static const uint16_t typeKey = 29;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int framePropertyKey = 67;
- static const int interpolationTypePropertyKey = 68;
- static const int interpolatorIdPropertyKey = 69;
+ static const uint16_t framePropertyKey = 67;
+ static const uint16_t interpolationTypePropertyKey = 68;
+ static const uint16_t interpolatorIdPropertyKey = 69;
private:
int m_Frame = 0;
int m_InterpolationType = 0;
- int m_InterpolatorId = 0;
+ int m_InterpolatorId = -1;
public:
inline int frame() const { return m_Frame; }
void frame(int value)
interpolatorIdChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef KeyFrame Super;
public:
- static const int typeKey = 37;
+ static const uint16_t typeKey = 37;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int valuePropertyKey = 88;
+ static const uint16_t valuePropertyKey = 88;
private:
int m_Value = 0;
valueChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef KeyFrame Super;
public:
- static const int typeKey = 30;
+ static const uint16_t typeKey = 30;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int valuePropertyKey = 70;
+ static const uint16_t valuePropertyKey = 70;
private:
float m_Value = 0.0f;
valueChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef KeyFrame Super;
public:
- static const int typeKey = 50;
+ static const uint16_t typeKey = 50;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int valuePropertyKey = 122;
+ static const uint16_t valuePropertyKey = 122;
private:
- int m_Value = 0;
+ int m_Value = -1;
public:
inline int value() const { return m_Value; }
void value(int value)
valueChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
--- /dev/null
+#ifndef _RIVE_LAYER_STATE_BASE_HPP_
+#define _RIVE_LAYER_STATE_BASE_HPP_
+#include "animation/state_machine_layer_component.hpp"
+namespace rive
+{
+ class LayerStateBase : public StateMachineLayerComponent
+ {
+ protected:
+ typedef StateMachineLayerComponent Super;
+
+ public:
+ static const uint16_t typeKey = 60;
+
+ /// Helper to quickly determine if a core object extends another without
+ /// RTTI at runtime.
+ bool isTypeOf(uint16_t typeKey) const override
+ {
+ switch (typeKey)
+ {
+ case LayerStateBase::typeKey:
+ case StateMachineLayerComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ uint16_t coreType() const override { return typeKey; }
+
+ protected:
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
typedef Animation Super;
public:
- static const int typeKey = 31;
+ static const uint16_t typeKey = 31;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int fpsPropertyKey = 56;
- static const int durationPropertyKey = 57;
- static const int speedPropertyKey = 58;
- static const int loopValuePropertyKey = 59;
- static const int workStartPropertyKey = 60;
- static const int workEndPropertyKey = 61;
- static const int enableWorkAreaPropertyKey = 62;
+ static const uint16_t fpsPropertyKey = 56;
+ static const uint16_t durationPropertyKey = 57;
+ static const uint16_t speedPropertyKey = 58;
+ static const uint16_t loopValuePropertyKey = 59;
+ static const uint16_t workStartPropertyKey = 60;
+ static const uint16_t workEndPropertyKey = 61;
+ static const uint16_t enableWorkAreaPropertyKey = 62;
private:
int m_Fps = 60;
int m_Duration = 60;
- float m_Speed = 1;
+ float m_Speed = 1.0f;
int m_LoopValue = 0;
- int m_WorkStart = 0;
- int m_WorkEnd = 0;
+ int m_WorkStart = -1;
+ int m_WorkEnd = -1;
bool m_EnableWorkArea = false;
public:
inline int fps() const { return m_Fps; }
enableWorkAreaChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
--- /dev/null
+#ifndef _RIVE_STATE_MACHINE_BASE_HPP_
+#define _RIVE_STATE_MACHINE_BASE_HPP_
+#include "animation/animation.hpp"
+namespace rive
+{
+ class StateMachineBase : public Animation
+ {
+ protected:
+ typedef Animation Super;
+
+ public:
+ static const uint16_t typeKey = 53;
+
+ /// Helper to quickly determine if a core object extends another without
+ /// RTTI at runtime.
+ bool isTypeOf(uint16_t typeKey) const override
+ {
+ switch (typeKey)
+ {
+ case StateMachineBase::typeKey:
+ case AnimationBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ uint16_t coreType() const override { return typeKey; }
+
+ protected:
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_STATE_MACHINE_BOOL_BASE_HPP_
+#define _RIVE_STATE_MACHINE_BOOL_BASE_HPP_
+#include "animation/state_machine_input.hpp"
+#include "core/field_types/core_bool_type.hpp"
+namespace rive
+{
+ class StateMachineBoolBase : public StateMachineInput
+ {
+ protected:
+ typedef StateMachineInput Super;
+
+ public:
+ static const uint16_t typeKey = 59;
+
+ /// Helper to quickly determine if a core object extends another without
+ /// RTTI at runtime.
+ bool isTypeOf(uint16_t typeKey) const override
+ {
+ switch (typeKey)
+ {
+ case StateMachineBoolBase::typeKey:
+ case StateMachineInputBase::typeKey:
+ case StateMachineComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ uint16_t coreType() const override { return typeKey; }
+
+ static const uint16_t valuePropertyKey = 141;
+
+ private:
+ bool m_Value = false;
+ public:
+ inline bool value() const { return m_Value; }
+ void value(bool value)
+ {
+ if (m_Value == value)
+ {
+ return;
+ }
+ m_Value = value;
+ valueChanged();
+ }
+
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
+ {
+ switch (propertyKey)
+ {
+ case valuePropertyKey:
+ m_Value = CoreBoolType::deserialize(reader);
+ return true;
+ }
+ return StateMachineInput::deserialize(propertyKey, reader);
+ }
+
+ protected:
+ virtual void valueChanged() {}
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_STATE_MACHINE_COMPONENT_BASE_HPP_
+#define _RIVE_STATE_MACHINE_COMPONENT_BASE_HPP_
+#include "core.hpp"
+#include "core/field_types/core_string_type.hpp"
+#include <string>
+namespace rive
+{
+ class StateMachineComponentBase : public Core
+ {
+ protected:
+ typedef Core Super;
+
+ public:
+ static const uint16_t typeKey = 54;
+
+ /// Helper to quickly determine if a core object extends another without
+ /// RTTI at runtime.
+ bool isTypeOf(uint16_t typeKey) const override
+ {
+ switch (typeKey)
+ {
+ case StateMachineComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ uint16_t coreType() const override { return typeKey; }
+
+ static const uint16_t namePropertyKey = 138;
+
+ private:
+ std::string m_Name = "";
+ public:
+ inline std::string name() const { return m_Name; }
+ void name(std::string value)
+ {
+ if (m_Name == value)
+ {
+ return;
+ }
+ m_Name = value;
+ nameChanged();
+ }
+
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
+ {
+ switch (propertyKey)
+ {
+ case namePropertyKey:
+ m_Name = CoreStringType::deserialize(reader);
+ return true;
+ }
+ return false;
+ }
+
+ protected:
+ virtual void nameChanged() {}
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_STATE_MACHINE_DOUBLE_BASE_HPP_
+#define _RIVE_STATE_MACHINE_DOUBLE_BASE_HPP_
+#include "animation/state_machine_input.hpp"
+#include "core/field_types/core_double_type.hpp"
+namespace rive
+{
+ class StateMachineDoubleBase : public StateMachineInput
+ {
+ protected:
+ typedef StateMachineInput Super;
+
+ public:
+ static const uint16_t typeKey = 56;
+
+ /// Helper to quickly determine if a core object extends another without
+ /// RTTI at runtime.
+ bool isTypeOf(uint16_t typeKey) const override
+ {
+ switch (typeKey)
+ {
+ case StateMachineDoubleBase::typeKey:
+ case StateMachineInputBase::typeKey:
+ case StateMachineComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ uint16_t coreType() const override { return typeKey; }
+
+ static const uint16_t valuePropertyKey = 140;
+
+ private:
+ float m_Value = 0.0f;
+ public:
+ inline float value() const { return m_Value; }
+ void value(float value)
+ {
+ if (m_Value == value)
+ {
+ return;
+ }
+ m_Value = value;
+ valueChanged();
+ }
+
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
+ {
+ switch (propertyKey)
+ {
+ case valuePropertyKey:
+ m_Value = CoreDoubleType::deserialize(reader);
+ return true;
+ }
+ return StateMachineInput::deserialize(propertyKey, reader);
+ }
+
+ protected:
+ virtual void valueChanged() {}
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_STATE_MACHINE_INPUT_BASE_HPP_
+#define _RIVE_STATE_MACHINE_INPUT_BASE_HPP_
+#include "animation/state_machine_component.hpp"
+namespace rive
+{
+ class StateMachineInputBase : public StateMachineComponent
+ {
+ protected:
+ typedef StateMachineComponent Super;
+
+ public:
+ static const uint16_t typeKey = 55;
+
+ /// Helper to quickly determine if a core object extends another without
+ /// RTTI at runtime.
+ bool isTypeOf(uint16_t typeKey) const override
+ {
+ switch (typeKey)
+ {
+ case StateMachineInputBase::typeKey:
+ case StateMachineComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ uint16_t coreType() const override { return typeKey; }
+
+ protected:
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_STATE_MACHINE_LAYER_BASE_HPP_
+#define _RIVE_STATE_MACHINE_LAYER_BASE_HPP_
+#include "animation/state_machine_component.hpp"
+namespace rive
+{
+ class StateMachineLayerBase : public StateMachineComponent
+ {
+ protected:
+ typedef StateMachineComponent Super;
+
+ public:
+ static const uint16_t typeKey = 57;
+
+ /// Helper to quickly determine if a core object extends another without
+ /// RTTI at runtime.
+ bool isTypeOf(uint16_t typeKey) const override
+ {
+ switch (typeKey)
+ {
+ case StateMachineLayerBase::typeKey:
+ case StateMachineComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ uint16_t coreType() const override { return typeKey; }
+
+ protected:
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_STATE_MACHINE_LAYER_COMPONENT_BASE_HPP_
+#define _RIVE_STATE_MACHINE_LAYER_COMPONENT_BASE_HPP_
+#include "core.hpp"
+namespace rive
+{
+ class StateMachineLayerComponentBase : public Core
+ {
+ protected:
+ typedef Core Super;
+
+ public:
+ static const uint16_t typeKey = 66;
+
+ /// Helper to quickly determine if a core object extends another without
+ /// RTTI at runtime.
+ bool isTypeOf(uint16_t typeKey) const override
+ {
+ switch (typeKey)
+ {
+ case StateMachineLayerComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ uint16_t coreType() const override { return typeKey; }
+
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
+ {
+ switch (propertyKey)
+ {
+ }
+ return false;
+ }
+
+ protected:
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_STATE_MACHINE_TRIGGER_BASE_HPP_
+#define _RIVE_STATE_MACHINE_TRIGGER_BASE_HPP_
+#include "animation/state_machine_input.hpp"
+namespace rive
+{
+ class StateMachineTriggerBase : public StateMachineInput
+ {
+ protected:
+ typedef StateMachineInput Super;
+
+ public:
+ static const uint16_t typeKey = 58;
+
+ /// Helper to quickly determine if a core object extends another without
+ /// RTTI at runtime.
+ bool isTypeOf(uint16_t typeKey) const override
+ {
+ switch (typeKey)
+ {
+ case StateMachineTriggerBase::typeKey:
+ case StateMachineInputBase::typeKey:
+ case StateMachineComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ uint16_t coreType() const override { return typeKey; }
+
+ protected:
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_STATE_TRANSITION_BASE_HPP_
+#define _RIVE_STATE_TRANSITION_BASE_HPP_
+#include "animation/state_machine_layer_component.hpp"
+#include "core/field_types/core_uint_type.hpp"
+namespace rive
+{
+ class StateTransitionBase : public StateMachineLayerComponent
+ {
+ protected:
+ typedef StateMachineLayerComponent Super;
+
+ public:
+ static const uint16_t typeKey = 65;
+
+ /// Helper to quickly determine if a core object extends another without
+ /// RTTI at runtime.
+ bool isTypeOf(uint16_t typeKey) const override
+ {
+ switch (typeKey)
+ {
+ case StateTransitionBase::typeKey:
+ case StateMachineLayerComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ uint16_t coreType() const override { return typeKey; }
+
+ static const uint16_t stateToIdPropertyKey = 151;
+ static const uint16_t flagsPropertyKey = 152;
+ static const uint16_t durationPropertyKey = 158;
+
+ private:
+ int m_StateToId = -1;
+ int m_Flags = 0;
+ int m_Duration = 0;
+ public:
+ inline int stateToId() const { return m_StateToId; }
+ void stateToId(int value)
+ {
+ if (m_StateToId == value)
+ {
+ return;
+ }
+ m_StateToId = value;
+ stateToIdChanged();
+ }
+
+ inline int flags() const { return m_Flags; }
+ void flags(int value)
+ {
+ if (m_Flags == value)
+ {
+ return;
+ }
+ m_Flags = value;
+ flagsChanged();
+ }
+
+ inline int duration() const { return m_Duration; }
+ void duration(int value)
+ {
+ if (m_Duration == value)
+ {
+ return;
+ }
+ m_Duration = value;
+ durationChanged();
+ }
+
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
+ {
+ switch (propertyKey)
+ {
+ case stateToIdPropertyKey:
+ m_StateToId = CoreUintType::deserialize(reader);
+ return true;
+ case flagsPropertyKey:
+ m_Flags = CoreUintType::deserialize(reader);
+ return true;
+ case durationPropertyKey:
+ m_Duration = CoreUintType::deserialize(reader);
+ return true;
+ }
+ return StateMachineLayerComponent::deserialize(propertyKey, reader);
+ }
+
+ protected:
+ virtual void stateToIdChanged() {}
+ virtual void flagsChanged() {}
+ virtual void durationChanged() {}
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_TRANSITION_BOOL_CONDITION_BASE_HPP_
+#define _RIVE_TRANSITION_BOOL_CONDITION_BASE_HPP_
+#include "animation/transition_value_condition.hpp"
+namespace rive
+{
+ class TransitionBoolConditionBase : public TransitionValueCondition
+ {
+ protected:
+ typedef TransitionValueCondition Super;
+
+ public:
+ static const uint16_t typeKey = 71;
+
+ /// Helper to quickly determine if a core object extends another without
+ /// RTTI at runtime.
+ bool isTypeOf(uint16_t typeKey) const override
+ {
+ switch (typeKey)
+ {
+ case TransitionBoolConditionBase::typeKey:
+ case TransitionValueConditionBase::typeKey:
+ case TransitionConditionBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ uint16_t coreType() const override { return typeKey; }
+
+ protected:
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_TRANSITION_CONDITION_BASE_HPP_
+#define _RIVE_TRANSITION_CONDITION_BASE_HPP_
+#include "core.hpp"
+#include "core/field_types/core_uint_type.hpp"
+namespace rive
+{
+ class TransitionConditionBase : public Core
+ {
+ protected:
+ typedef Core Super;
+
+ public:
+ static const uint16_t typeKey = 67;
+
+ /// Helper to quickly determine if a core object extends another without
+ /// RTTI at runtime.
+ bool isTypeOf(uint16_t typeKey) const override
+ {
+ switch (typeKey)
+ {
+ case TransitionConditionBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ uint16_t coreType() const override { return typeKey; }
+
+ static const uint16_t inputIdPropertyKey = 155;
+
+ private:
+ int m_InputId = -1;
+ public:
+ inline int inputId() const { return m_InputId; }
+ void inputId(int value)
+ {
+ if (m_InputId == value)
+ {
+ return;
+ }
+ m_InputId = value;
+ inputIdChanged();
+ }
+
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
+ {
+ switch (propertyKey)
+ {
+ case inputIdPropertyKey:
+ m_InputId = CoreUintType::deserialize(reader);
+ return true;
+ }
+ return false;
+ }
+
+ protected:
+ virtual void inputIdChanged() {}
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_TRANSITION_DOUBLE_CONDITION_BASE_HPP_
+#define _RIVE_TRANSITION_DOUBLE_CONDITION_BASE_HPP_
+#include "animation/transition_value_condition.hpp"
+#include "core/field_types/core_double_type.hpp"
+namespace rive
+{
+ class TransitionDoubleConditionBase : public TransitionValueCondition
+ {
+ protected:
+ typedef TransitionValueCondition Super;
+
+ public:
+ static const uint16_t typeKey = 70;
+
+ /// Helper to quickly determine if a core object extends another without
+ /// RTTI at runtime.
+ bool isTypeOf(uint16_t typeKey) const override
+ {
+ switch (typeKey)
+ {
+ case TransitionDoubleConditionBase::typeKey:
+ case TransitionValueConditionBase::typeKey:
+ case TransitionConditionBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ uint16_t coreType() const override { return typeKey; }
+
+ static const uint16_t valuePropertyKey = 157;
+
+ private:
+ float m_Value = 0.0f;
+ public:
+ inline float value() const { return m_Value; }
+ void value(float value)
+ {
+ if (m_Value == value)
+ {
+ return;
+ }
+ m_Value = value;
+ valueChanged();
+ }
+
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
+ {
+ switch (propertyKey)
+ {
+ case valuePropertyKey:
+ m_Value = CoreDoubleType::deserialize(reader);
+ return true;
+ }
+ return TransitionValueCondition::deserialize(propertyKey, reader);
+ }
+
+ protected:
+ virtual void valueChanged() {}
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_TRANSITION_TRIGGER_CONDITION_BASE_HPP_
+#define _RIVE_TRANSITION_TRIGGER_CONDITION_BASE_HPP_
+#include "animation/transition_condition.hpp"
+namespace rive
+{
+ class TransitionTriggerConditionBase : public TransitionCondition
+ {
+ protected:
+ typedef TransitionCondition Super;
+
+ public:
+ static const uint16_t typeKey = 68;
+
+ /// Helper to quickly determine if a core object extends another without
+ /// RTTI at runtime.
+ bool isTypeOf(uint16_t typeKey) const override
+ {
+ switch (typeKey)
+ {
+ case TransitionTriggerConditionBase::typeKey:
+ case TransitionConditionBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ uint16_t coreType() const override { return typeKey; }
+
+ protected:
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_TRANSITION_VALUE_CONDITION_BASE_HPP_
+#define _RIVE_TRANSITION_VALUE_CONDITION_BASE_HPP_
+#include "animation/transition_condition.hpp"
+#include "core/field_types/core_uint_type.hpp"
+namespace rive
+{
+ class TransitionValueConditionBase : public TransitionCondition
+ {
+ protected:
+ typedef TransitionCondition Super;
+
+ public:
+ static const uint16_t typeKey = 69;
+
+ /// Helper to quickly determine if a core object extends another without
+ /// RTTI at runtime.
+ bool isTypeOf(uint16_t typeKey) const override
+ {
+ switch (typeKey)
+ {
+ case TransitionValueConditionBase::typeKey:
+ case TransitionConditionBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ uint16_t coreType() const override { return typeKey; }
+
+ static const uint16_t opValuePropertyKey = 156;
+
+ private:
+ int m_OpValue = 0;
+ public:
+ inline int opValue() const { return m_OpValue; }
+ void opValue(int value)
+ {
+ if (m_OpValue == value)
+ {
+ return;
+ }
+ m_OpValue = value;
+ opValueChanged();
+ }
+
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
+ {
+ switch (propertyKey)
+ {
+ case opValuePropertyKey:
+ m_OpValue = CoreUintType::deserialize(reader);
+ return true;
+ }
+ return TransitionCondition::deserialize(propertyKey, reader);
+ }
+
+ protected:
+ virtual void opValueChanged() {}
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
typedef ContainerComponent Super;
public:
- static const int typeKey = 1;
+ static const uint16_t typeKey = 1;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int widthPropertyKey = 7;
- static const int heightPropertyKey = 8;
- static const int xPropertyKey = 9;
- static const int yPropertyKey = 10;
- static const int originXPropertyKey = 11;
- static const int originYPropertyKey = 12;
+ static const uint16_t widthPropertyKey = 7;
+ static const uint16_t heightPropertyKey = 8;
+ static const uint16_t xPropertyKey = 9;
+ static const uint16_t yPropertyKey = 10;
+ static const uint16_t originXPropertyKey = 11;
+ static const uint16_t originYPropertyKey = 12;
private:
float m_Width = 0.0f;
originYChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef Core Super;
public:
- static const int typeKey = 23;
+ static const uint16_t typeKey = 23;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef SkeletalComponent Super;
public:
- static const int typeKey = 40;
+ static const uint16_t typeKey = 40;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int lengthPropertyKey = 89;
+ static const uint16_t lengthPropertyKey = 89;
private:
- float m_Length = 0;
+ float m_Length = 0.0f;
public:
inline float length() const { return m_Length; }
void length(float value)
lengthChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef Weight Super;
public:
- static const int typeKey = 46;
+ static const uint16_t typeKey = 46;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int inValuesPropertyKey = 110;
- static const int inIndicesPropertyKey = 111;
- static const int outValuesPropertyKey = 112;
- static const int outIndicesPropertyKey = 113;
+ static const uint16_t inValuesPropertyKey = 110;
+ static const uint16_t inIndicesPropertyKey = 111;
+ static const uint16_t outValuesPropertyKey = 112;
+ static const uint16_t outIndicesPropertyKey = 113;
private:
int m_InValues = 255;
outIndicesChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef Bone Super;
public:
- static const int typeKey = 41;
+ static const uint16_t typeKey = 41;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int xPropertyKey = 90;
- static const int yPropertyKey = 91;
+ static const uint16_t xPropertyKey = 90;
+ static const uint16_t yPropertyKey = 91;
private:
- float m_X = 0;
- float m_Y = 0;
+ float m_X = 0.0f;
+ float m_Y = 0.0f;
public:
inline float x() const override { return m_X; }
void x(float value)
yChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef TransformComponent Super;
public:
- static const int typeKey = 39;
+ static const uint16_t typeKey = 39;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
protected:
};
typedef ContainerComponent Super;
public:
- static const int typeKey = 43;
+ static const uint16_t typeKey = 43;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int xxPropertyKey = 104;
- static const int yxPropertyKey = 105;
- static const int xyPropertyKey = 106;
- static const int yyPropertyKey = 107;
- static const int txPropertyKey = 108;
- static const int tyPropertyKey = 109;
+ static const uint16_t xxPropertyKey = 104;
+ static const uint16_t yxPropertyKey = 105;
+ static const uint16_t xyPropertyKey = 106;
+ static const uint16_t yyPropertyKey = 107;
+ static const uint16_t txPropertyKey = 108;
+ static const uint16_t tyPropertyKey = 109;
private:
- float m_Xx = 1;
- float m_Yx = 0;
- float m_Xy = 0;
- float m_Yy = 1;
- float m_Tx = 0;
- float m_Ty = 0;
+ float m_Xx = 1.0f;
+ float m_Yx = 0.0f;
+ float m_Xy = 0.0f;
+ float m_Yy = 1.0f;
+ float m_Tx = 0.0f;
+ float m_Ty = 0.0f;
public:
inline float xx() const { return m_Xx; }
void xx(float value)
tyChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef Component Super;
public:
- static const int typeKey = 44;
+ static const uint16_t typeKey = 44;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int boneIdPropertyKey = 95;
- static const int xxPropertyKey = 96;
- static const int yxPropertyKey = 97;
- static const int xyPropertyKey = 98;
- static const int yyPropertyKey = 99;
- static const int txPropertyKey = 100;
- static const int tyPropertyKey = 101;
+ static const uint16_t boneIdPropertyKey = 95;
+ static const uint16_t xxPropertyKey = 96;
+ static const uint16_t yxPropertyKey = 97;
+ static const uint16_t xyPropertyKey = 98;
+ static const uint16_t yyPropertyKey = 99;
+ static const uint16_t txPropertyKey = 100;
+ static const uint16_t tyPropertyKey = 101;
private:
- int m_BoneId = 0;
- float m_Xx = 1;
- float m_Yx = 0;
- float m_Xy = 0;
- float m_Yy = 1;
- float m_Tx = 0;
- float m_Ty = 0;
+ int m_BoneId = -1;
+ float m_Xx = 1.0f;
+ float m_Yx = 0.0f;
+ float m_Xy = 0.0f;
+ float m_Yy = 1.0f;
+ float m_Tx = 0.0f;
+ float m_Ty = 0.0f;
public:
inline int boneId() const { return m_BoneId; }
void boneId(int value)
tyChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef Component Super;
public:
- static const int typeKey = 45;
+ static const uint16_t typeKey = 45;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int valuesPropertyKey = 102;
- static const int indicesPropertyKey = 103;
+ static const uint16_t valuesPropertyKey = 102;
+ static const uint16_t indicesPropertyKey = 103;
private:
int m_Values = 255;
indicesChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef Core Super;
public:
- static const int typeKey = 10;
+ static const uint16_t typeKey = 10;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int namePropertyKey = 4;
- static const int parentIdPropertyKey = 5;
+ static const uint16_t namePropertyKey = 4;
+ static const uint16_t parentIdPropertyKey = 5;
private:
std::string m_Name = "";
parentIdChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef Component Super;
public:
- static const int typeKey = 11;
+ static const uint16_t typeKey = 11;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
protected:
};
#ifndef _RIVE_CORE_REGISTRY_HPP_
#define _RIVE_CORE_REGISTRY_HPP_
#include "animation/animation.hpp"
+#include "animation/animation_state.hpp"
+#include "animation/any_state.hpp"
#include "animation/cubic_interpolator.hpp"
+#include "animation/entry_state.hpp"
+#include "animation/exit_state.hpp"
#include "animation/keyed_object.hpp"
#include "animation/keyed_property.hpp"
#include "animation/keyframe.hpp"
#include "animation/keyframe_color.hpp"
#include "animation/keyframe_double.hpp"
#include "animation/keyframe_id.hpp"
+#include "animation/layer_state.hpp"
#include "animation/linear_animation.hpp"
+#include "animation/state_machine.hpp"
+#include "animation/state_machine_bool.hpp"
+#include "animation/state_machine_component.hpp"
+#include "animation/state_machine_double.hpp"
+#include "animation/state_machine_input.hpp"
+#include "animation/state_machine_layer.hpp"
+#include "animation/state_machine_layer_component.hpp"
+#include "animation/state_machine_trigger.hpp"
+#include "animation/state_transition.hpp"
+#include "animation/transition_bool_condition.hpp"
+#include "animation/transition_condition.hpp"
+#include "animation/transition_double_condition.hpp"
+#include "animation/transition_trigger_condition.hpp"
+#include "animation/transition_value_condition.hpp"
#include "artboard.hpp"
#include "backboard.hpp"
#include "bones/bone.hpp"
#include "shapes/paint/trim_path.hpp"
#include "shapes/parametric_path.hpp"
#include "shapes/path.hpp"
-#include "shapes/path_composer.hpp"
#include "shapes/path_vertex.hpp"
#include "shapes/points_path.hpp"
#include "shapes/polygon.hpp"
{
case DrawTargetBase::typeKey:
return new DrawTarget();
+ case AnimationStateBase::typeKey:
+ return new AnimationState();
case KeyedObjectBase::typeKey:
return new KeyedObject();
+ case TransitionTriggerConditionBase::typeKey:
+ return new TransitionTriggerCondition();
case KeyedPropertyBase::typeKey:
return new KeyedProperty();
+ case StateMachineDoubleBase::typeKey:
+ return new StateMachineDouble();
case KeyFrameIdBase::typeKey:
return new KeyFrameId();
+ case AnyStateBase::typeKey:
+ return new AnyState();
+ case StateMachineLayerBase::typeKey:
+ return new StateMachineLayer();
case AnimationBase::typeKey:
return new Animation();
case CubicInterpolatorBase::typeKey:
return new CubicInterpolator();
+ case TransitionDoubleConditionBase::typeKey:
+ return new TransitionDoubleCondition();
+ case StateTransitionBase::typeKey:
+ return new StateTransition();
case KeyFrameDoubleBase::typeKey:
return new KeyFrameDouble();
case KeyFrameColorBase::typeKey:
return new KeyFrameColor();
+ case StateMachineBase::typeKey:
+ return new StateMachine();
+ case EntryStateBase::typeKey:
+ return new EntryState();
case LinearAnimationBase::typeKey:
return new LinearAnimation();
+ case StateMachineTriggerBase::typeKey:
+ return new StateMachineTrigger();
+ case ExitStateBase::typeKey:
+ return new ExitState();
+ case TransitionBoolConditionBase::typeKey:
+ return new TransitionBoolCondition();
+ case StateMachineBoolBase::typeKey:
+ return new StateMachineBool();
case LinearGradientBase::typeKey:
return new LinearGradient();
case RadialGradientBase::typeKey:
return new Polygon();
case StarBase::typeKey:
return new Star();
- case PathComposerBase::typeKey:
- return new PathComposer();
case CubicDetachedVertexBase::typeKey:
return new CubicDetachedVertex();
case DrawRulesBase::typeKey:
case ComponentBase::namePropertyKey:
object->as<ComponentBase>()->name(value);
break;
+ case StateMachineComponentBase::namePropertyKey:
+ object->as<StateMachineComponentBase>()->name(value);
+ break;
case AnimationBase::namePropertyKey:
object->as<AnimationBase>()->name(value);
break;
case DrawTargetBase::placementValuePropertyKey:
object->as<DrawTargetBase>()->placementValue(value);
break;
+ case AnimationStateBase::animationIdPropertyKey:
+ object->as<AnimationStateBase>()->animationId(value);
+ break;
case KeyedObjectBase::objectIdPropertyKey:
object->as<KeyedObjectBase>()->objectId(value);
break;
+ case TransitionConditionBase::inputIdPropertyKey:
+ object->as<TransitionConditionBase>()->inputId(value);
+ break;
case KeyedPropertyBase::propertyKeyPropertyKey:
object->as<KeyedPropertyBase>()->propertyKey(value);
break;
case KeyFrameIdBase::valuePropertyKey:
object->as<KeyFrameIdBase>()->value(value);
break;
+ case TransitionValueConditionBase::opValuePropertyKey:
+ object->as<TransitionValueConditionBase>()->opValue(value);
+ break;
+ case StateTransitionBase::stateToIdPropertyKey:
+ object->as<StateTransitionBase>()->stateToId(value);
+ break;
+ case StateTransitionBase::flagsPropertyKey:
+ object->as<StateTransitionBase>()->flags(value);
+ break;
+ case StateTransitionBase::durationPropertyKey:
+ object->as<StateTransitionBase>()->duration(value);
+ break;
case LinearAnimationBase::fpsPropertyKey:
object->as<LinearAnimationBase>()->fps(value);
break;
case FillBase::fillRulePropertyKey:
object->as<FillBase>()->fillRule(value);
break;
+ case PathBase::pathFlagsPropertyKey:
+ object->as<PathBase>()->pathFlags(value);
+ break;
case DrawableBase::blendModeValuePropertyKey:
object->as<DrawableBase>()->blendModeValue(value);
break;
+ case DrawableBase::drawableFlagsPropertyKey:
+ object->as<DrawableBase>()->drawableFlags(value);
+ break;
case ClippingShapeBase::sourceIdPropertyKey:
object->as<ClippingShapeBase>()->sourceId(value);
break;
{
switch (propertyKey)
{
+ case StateMachineDoubleBase::valuePropertyKey:
+ object->as<StateMachineDoubleBase>()->value(value);
+ break;
case CubicInterpolatorBase::x1PropertyKey:
object->as<CubicInterpolatorBase>()->x1(value);
break;
case CubicInterpolatorBase::y2PropertyKey:
object->as<CubicInterpolatorBase>()->y2(value);
break;
+ case TransitionDoubleConditionBase::valuePropertyKey:
+ object->as<TransitionDoubleConditionBase>()->value(value);
+ break;
case KeyFrameDoubleBase::valuePropertyKey:
object->as<KeyFrameDoubleBase>()->value(value);
break;
case LinearAnimationBase::enableWorkAreaPropertyKey:
object->as<LinearAnimationBase>()->enableWorkArea(value);
break;
+ case StateMachineBoolBase::valuePropertyKey:
+ object->as<StateMachineBoolBase>()->value(value);
+ break;
case ShapePaintBase::isVisiblePropertyKey:
object->as<ShapePaintBase>()->isVisible(value);
break;
{
case ComponentBase::namePropertyKey:
return object->as<ComponentBase>()->name();
+ case StateMachineComponentBase::namePropertyKey:
+ return object->as<StateMachineComponentBase>()->name();
case AnimationBase::namePropertyKey:
return object->as<AnimationBase>()->name();
}
return object->as<DrawTargetBase>()->drawableId();
case DrawTargetBase::placementValuePropertyKey:
return object->as<DrawTargetBase>()->placementValue();
+ case AnimationStateBase::animationIdPropertyKey:
+ return object->as<AnimationStateBase>()->animationId();
case KeyedObjectBase::objectIdPropertyKey:
return object->as<KeyedObjectBase>()->objectId();
+ case TransitionConditionBase::inputIdPropertyKey:
+ return object->as<TransitionConditionBase>()->inputId();
case KeyedPropertyBase::propertyKeyPropertyKey:
return object->as<KeyedPropertyBase>()->propertyKey();
case KeyFrameBase::framePropertyKey:
return object->as<KeyFrameBase>()->interpolatorId();
case KeyFrameIdBase::valuePropertyKey:
return object->as<KeyFrameIdBase>()->value();
+ case TransitionValueConditionBase::opValuePropertyKey:
+ return object->as<TransitionValueConditionBase>()
+ ->opValue();
+ case StateTransitionBase::stateToIdPropertyKey:
+ return object->as<StateTransitionBase>()->stateToId();
+ case StateTransitionBase::flagsPropertyKey:
+ return object->as<StateTransitionBase>()->flags();
+ case StateTransitionBase::durationPropertyKey:
+ return object->as<StateTransitionBase>()->duration();
case LinearAnimationBase::fpsPropertyKey:
return object->as<LinearAnimationBase>()->fps();
case LinearAnimationBase::durationPropertyKey:
return object->as<TrimPathBase>()->modeValue();
case FillBase::fillRulePropertyKey:
return object->as<FillBase>()->fillRule();
+ case PathBase::pathFlagsPropertyKey:
+ return object->as<PathBase>()->pathFlags();
case DrawableBase::blendModeValuePropertyKey:
return object->as<DrawableBase>()->blendModeValue();
+ case DrawableBase::drawableFlagsPropertyKey:
+ return object->as<DrawableBase>()->drawableFlags();
case ClippingShapeBase::sourceIdPropertyKey:
return object->as<ClippingShapeBase>()->sourceId();
case ClippingShapeBase::fillRulePropertyKey:
{
switch (propertyKey)
{
+ case StateMachineDoubleBase::valuePropertyKey:
+ return object->as<StateMachineDoubleBase>()->value();
case CubicInterpolatorBase::x1PropertyKey:
return object->as<CubicInterpolatorBase>()->x1();
case CubicInterpolatorBase::y1PropertyKey:
return object->as<CubicInterpolatorBase>()->x2();
case CubicInterpolatorBase::y2PropertyKey:
return object->as<CubicInterpolatorBase>()->y2();
+ case TransitionDoubleConditionBase::valuePropertyKey:
+ return object->as<TransitionDoubleConditionBase>()->value();
case KeyFrameDoubleBase::valuePropertyKey:
return object->as<KeyFrameDoubleBase>()->value();
case LinearAnimationBase::speedPropertyKey:
{
case LinearAnimationBase::enableWorkAreaPropertyKey:
return object->as<LinearAnimationBase>()->enableWorkArea();
+ case StateMachineBoolBase::valuePropertyKey:
+ return object->as<StateMachineBoolBase>()->value();
case ShapePaintBase::isVisiblePropertyKey:
return object->as<ShapePaintBase>()->isVisible();
case StrokeBase::transformAffectsStrokePropertyKey:
switch (propertyKey)
{
case ComponentBase::namePropertyKey:
+ case StateMachineComponentBase::namePropertyKey:
case AnimationBase::namePropertyKey:
return CoreStringType::id;
case ComponentBase::parentIdPropertyKey:
case DrawTargetBase::drawableIdPropertyKey:
case DrawTargetBase::placementValuePropertyKey:
+ case AnimationStateBase::animationIdPropertyKey:
case KeyedObjectBase::objectIdPropertyKey:
+ case TransitionConditionBase::inputIdPropertyKey:
case KeyedPropertyBase::propertyKeyPropertyKey:
case KeyFrameBase::framePropertyKey:
case KeyFrameBase::interpolationTypePropertyKey:
case KeyFrameBase::interpolatorIdPropertyKey:
case KeyFrameIdBase::valuePropertyKey:
+ case TransitionValueConditionBase::opValuePropertyKey:
+ case StateTransitionBase::stateToIdPropertyKey:
+ case StateTransitionBase::flagsPropertyKey:
+ case StateTransitionBase::durationPropertyKey:
case LinearAnimationBase::fpsPropertyKey:
case LinearAnimationBase::durationPropertyKey:
case LinearAnimationBase::loopValuePropertyKey:
case StrokeBase::joinPropertyKey:
case TrimPathBase::modeValuePropertyKey:
case FillBase::fillRulePropertyKey:
+ case PathBase::pathFlagsPropertyKey:
case DrawableBase::blendModeValuePropertyKey:
+ case DrawableBase::drawableFlagsPropertyKey:
case ClippingShapeBase::sourceIdPropertyKey:
case ClippingShapeBase::fillRulePropertyKey:
+ case PolygonBase::pointsPropertyKey:
case DrawRulesBase::drawTargetIdPropertyKey:
case WeightBase::valuesPropertyKey:
case WeightBase::indicesPropertyKey:
case CubicWeightBase::outValuesPropertyKey:
case CubicWeightBase::outIndicesPropertyKey:
return CoreUintType::id;
+ case StateMachineDoubleBase::valuePropertyKey:
case CubicInterpolatorBase::x1PropertyKey:
case CubicInterpolatorBase::y1PropertyKey:
case CubicInterpolatorBase::x2PropertyKey:
case CubicInterpolatorBase::y2PropertyKey:
+ case TransitionDoubleConditionBase::valuePropertyKey:
case KeyFrameDoubleBase::valuePropertyKey:
case LinearAnimationBase::speedPropertyKey:
case LinearGradientBase::startXPropertyKey:
case RectangleBase::cornerRadiusPropertyKey:
case CubicMirroredVertexBase::rotationPropertyKey:
case CubicMirroredVertexBase::distancePropertyKey:
+ case PolygonBase::cornerRadiusPropertyKey:
+ case StarBase::innerRadiusPropertyKey:
case CubicDetachedVertexBase::inRotationPropertyKey:
case CubicDetachedVertexBase::inDistancePropertyKey:
case CubicDetachedVertexBase::outRotationPropertyKey:
case GradientStopBase::colorValuePropertyKey:
return CoreColorType::id;
case LinearAnimationBase::enableWorkAreaPropertyKey:
+ case StateMachineBoolBase::valuePropertyKey:
case ShapePaintBase::isVisiblePropertyKey:
case StrokeBase::transformAffectsStrokePropertyKey:
case PointsPathBase::isClosedPropertyKey:
typedef ContainerComponent Super;
public:
- static const int typeKey = 49;
+ static const uint16_t typeKey = 49;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int drawTargetIdPropertyKey = 121;
+ static const uint16_t drawTargetIdPropertyKey = 121;
private:
- int m_DrawTargetId = 0;
+ int m_DrawTargetId = -1;
public:
inline int drawTargetId() const { return m_DrawTargetId; }
void drawTargetId(int value)
drawTargetIdChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef Component Super;
public:
- static const int typeKey = 48;
+ static const uint16_t typeKey = 48;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int drawableIdPropertyKey = 119;
- static const int placementValuePropertyKey = 120;
+ static const uint16_t drawableIdPropertyKey = 119;
+ static const uint16_t placementValuePropertyKey = 120;
private:
- int m_DrawableId = 0;
+ int m_DrawableId = -1;
int m_PlacementValue = 0;
public:
inline int drawableId() const { return m_DrawableId; }
placementValueChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef Node Super;
public:
- static const int typeKey = 13;
+ static const uint16_t typeKey = 13;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int blendModeValuePropertyKey = 23;
+ static const uint16_t blendModeValuePropertyKey = 23;
+ static const uint16_t drawableFlagsPropertyKey = 129;
private:
int m_BlendModeValue = 3;
+ int m_DrawableFlags = 0;
public:
inline int blendModeValue() const { return m_BlendModeValue; }
void blendModeValue(int value)
blendModeValueChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ inline int drawableFlags() const { return m_DrawableFlags; }
+ void drawableFlags(int value)
+ {
+ if (m_DrawableFlags == value)
+ {
+ return;
+ }
+ m_DrawableFlags = value;
+ drawableFlagsChanged();
+ }
+
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
case blendModeValuePropertyKey:
m_BlendModeValue = CoreUintType::deserialize(reader);
return true;
+ case drawableFlagsPropertyKey:
+ m_DrawableFlags = CoreUintType::deserialize(reader);
+ return true;
}
return Node::deserialize(propertyKey, reader);
}
protected:
virtual void blendModeValueChanged() {}
+ virtual void drawableFlagsChanged() {}
};
} // namespace rive
typedef TransformComponent Super;
public:
- static const int typeKey = 2;
+ static const uint16_t typeKey = 2;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int xPropertyKey = 13;
- static const int yPropertyKey = 14;
+ static const uint16_t xPropertyKey = 13;
+ static const uint16_t yPropertyKey = 14;
private:
- float m_X = 0;
- float m_Y = 0;
+ float m_X = 0.0f;
+ float m_Y = 0.0f;
public:
inline float x() const override { return m_X; }
void x(float value)
yChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef Component Super;
public:
- static const int typeKey = 42;
+ static const uint16_t typeKey = 42;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int sourceIdPropertyKey = 92;
- static const int fillRulePropertyKey = 93;
- static const int isVisiblePropertyKey = 94;
+ static const uint16_t sourceIdPropertyKey = 92;
+ static const uint16_t fillRulePropertyKey = 93;
+ static const uint16_t isVisiblePropertyKey = 94;
private:
- int m_SourceId = 0;
+ int m_SourceId = -1;
int m_FillRule = 0;
bool m_IsVisible = true;
public:
isVisibleChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef CubicVertex Super;
public:
- static const int typeKey = 34;
+ static const uint16_t typeKey = 34;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int rotationPropertyKey = 79;
- static const int inDistancePropertyKey = 80;
- static const int outDistancePropertyKey = 81;
+ static const uint16_t rotationPropertyKey = 79;
+ static const uint16_t inDistancePropertyKey = 80;
+ static const uint16_t outDistancePropertyKey = 81;
private:
- float m_Rotation = 0;
- float m_InDistance = 0;
- float m_OutDistance = 0;
+ float m_Rotation = 0.0f;
+ float m_InDistance = 0.0f;
+ float m_OutDistance = 0.0f;
public:
inline float rotation() const { return m_Rotation; }
void rotation(float value)
outDistanceChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef CubicVertex Super;
public:
- static const int typeKey = 6;
+ static const uint16_t typeKey = 6;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int inRotationPropertyKey = 84;
- static const int inDistancePropertyKey = 85;
- static const int outRotationPropertyKey = 86;
- static const int outDistancePropertyKey = 87;
+ static const uint16_t inRotationPropertyKey = 84;
+ static const uint16_t inDistancePropertyKey = 85;
+ static const uint16_t outRotationPropertyKey = 86;
+ static const uint16_t outDistancePropertyKey = 87;
private:
- float m_InRotation = 0;
- float m_InDistance = 0;
- float m_OutRotation = 0;
- float m_OutDistance = 0;
+ float m_InRotation = 0.0f;
+ float m_InDistance = 0.0f;
+ float m_OutRotation = 0.0f;
+ float m_OutDistance = 0.0f;
public:
inline float inRotation() const { return m_InRotation; }
void inRotation(float value)
outDistanceChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef CubicVertex Super;
public:
- static const int typeKey = 35;
+ static const uint16_t typeKey = 35;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int rotationPropertyKey = 82;
- static const int distancePropertyKey = 83;
+ static const uint16_t rotationPropertyKey = 82;
+ static const uint16_t distancePropertyKey = 83;
private:
- float m_Rotation = 0;
- float m_Distance = 0;
+ float m_Rotation = 0.0f;
+ float m_Distance = 0.0f;
public:
inline float rotation() const { return m_Rotation; }
void rotation(float value)
distanceChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef PathVertex Super;
public:
- static const int typeKey = 36;
+ static const uint16_t typeKey = 36;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
protected:
};
typedef ParametricPath Super;
public:
- static const int typeKey = 4;
+ static const uint16_t typeKey = 4;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
protected:
};
typedef ShapePaint Super;
public:
- static const int typeKey = 20;
+ static const uint16_t typeKey = 20;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int fillRulePropertyKey = 40;
+ static const uint16_t fillRulePropertyKey = 40;
private:
int m_FillRule = 0;
fillRuleChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef Component Super;
public:
- static const int typeKey = 19;
+ static const uint16_t typeKey = 19;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int colorValuePropertyKey = 38;
- static const int positionPropertyKey = 39;
+ static const uint16_t colorValuePropertyKey = 38;
+ static const uint16_t positionPropertyKey = 39;
private:
int m_ColorValue = 0xFFFFFFFF;
- float m_Position = 0;
+ float m_Position = 0.0f;
public:
inline int colorValue() const { return m_ColorValue; }
void colorValue(int value)
positionChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef ContainerComponent Super;
public:
- static const int typeKey = 22;
+ static const uint16_t typeKey = 22;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int startXPropertyKey = 42;
- static const int startYPropertyKey = 33;
- static const int endXPropertyKey = 34;
- static const int endYPropertyKey = 35;
- static const int opacityPropertyKey = 46;
+ static const uint16_t startXPropertyKey = 42;
+ static const uint16_t startYPropertyKey = 33;
+ static const uint16_t endXPropertyKey = 34;
+ static const uint16_t endYPropertyKey = 35;
+ static const uint16_t opacityPropertyKey = 46;
private:
- float m_StartX = 0;
- float m_StartY = 0;
- float m_EndX = 0;
- float m_EndY = 0;
- float m_Opacity = 1;
+ float m_StartX = 0.0f;
+ float m_StartY = 0.0f;
+ float m_EndX = 0.0f;
+ float m_EndY = 0.0f;
+ float m_Opacity = 1.0f;
public:
inline float startX() const { return m_StartX; }
void startX(float value)
opacityChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef LinearGradient Super;
public:
- static const int typeKey = 17;
+ static const uint16_t typeKey = 17;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
protected:
};
typedef ContainerComponent Super;
public:
- static const int typeKey = 21;
+ static const uint16_t typeKey = 21;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int isVisiblePropertyKey = 41;
+ static const uint16_t isVisiblePropertyKey = 41;
private:
bool m_IsVisible = true;
isVisibleChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef Component Super;
public:
- static const int typeKey = 18;
+ static const uint16_t typeKey = 18;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int colorValuePropertyKey = 37;
+ static const uint16_t colorValuePropertyKey = 37;
private:
int m_ColorValue = 0xFF747474;
colorValueChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef ShapePaint Super;
public:
- static const int typeKey = 24;
+ static const uint16_t typeKey = 24;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int thicknessPropertyKey = 47;
- static const int capPropertyKey = 48;
- static const int joinPropertyKey = 49;
- static const int transformAffectsStrokePropertyKey = 50;
+ static const uint16_t thicknessPropertyKey = 47;
+ static const uint16_t capPropertyKey = 48;
+ static const uint16_t joinPropertyKey = 49;
+ static const uint16_t transformAffectsStrokePropertyKey = 50;
private:
- float m_Thickness = 1;
+ float m_Thickness = 1.0f;
int m_Cap = 0;
int m_Join = 0;
bool m_TransformAffectsStroke = true;
transformAffectsStrokeChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef Component Super;
public:
- static const int typeKey = 47;
+ static const uint16_t typeKey = 47;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int startPropertyKey = 114;
- static const int endPropertyKey = 115;
- static const int offsetPropertyKey = 116;
- static const int modeValuePropertyKey = 117;
+ static const uint16_t startPropertyKey = 114;
+ static const uint16_t endPropertyKey = 115;
+ static const uint16_t offsetPropertyKey = 116;
+ static const uint16_t modeValuePropertyKey = 117;
private:
- float m_Start = 0;
- float m_End = 0;
- float m_Offset = 0;
+ float m_Start = 0.0f;
+ float m_End = 0.0f;
+ float m_Offset = 0.0f;
int m_ModeValue = 0;
public:
inline float start() const { return m_Start; }
modeValueChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef Path Super;
public:
- static const int typeKey = 15;
+ static const uint16_t typeKey = 15;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int widthPropertyKey = 20;
- static const int heightPropertyKey = 21;
- static const int originXPropertyKey = 123;
- static const int originYPropertyKey = 124;
+ static const uint16_t widthPropertyKey = 20;
+ static const uint16_t heightPropertyKey = 21;
+ static const uint16_t originXPropertyKey = 123;
+ static const uint16_t originYPropertyKey = 124;
private:
- float m_Width = 0;
- float m_Height = 0;
- float m_OriginX = 0.5;
- float m_OriginY = 0.5;
+ float m_Width = 0.0f;
+ float m_Height = 0.0f;
+ float m_OriginX = 0.5f;
+ float m_OriginY = 0.5f;
public:
inline float width() const { return m_Width; }
void width(float value)
originYChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
#ifndef _RIVE_PATH_BASE_HPP_
#define _RIVE_PATH_BASE_HPP_
+#include "core/field_types/core_uint_type.hpp"
#include "node.hpp"
namespace rive
{
typedef Node Super;
public:
- static const int typeKey = 12;
+ static const uint16_t typeKey = 12;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
+
+ static const uint16_t pathFlagsPropertyKey = 128;
+
+ private:
+ int m_PathFlags = 0;
+ public:
+ inline int pathFlags() const { return m_PathFlags; }
+ void pathFlags(int value)
+ {
+ if (m_PathFlags == value)
+ {
+ return;
+ }
+ m_PathFlags = value;
+ pathFlagsChanged();
+ }
+
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
+ {
+ switch (propertyKey)
+ {
+ case pathFlagsPropertyKey:
+ m_PathFlags = CoreUintType::deserialize(reader);
+ return true;
+ }
+ return Node::deserialize(propertyKey, reader);
+ }
protected:
+ virtual void pathFlagsChanged() {}
};
} // namespace rive
+++ /dev/null
-#ifndef _RIVE_PATH_COMPOSER_BASE_HPP_
-#define _RIVE_PATH_COMPOSER_BASE_HPP_
-#include "component.hpp"
-namespace rive
-{
- class PathComposerBase : public Component
- {
- protected:
- typedef Component Super;
-
- public:
- static const int typeKey = 9;
-
- /// Helper to quickly determine if a core object extends another without
- /// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
- {
- switch (typeKey)
- {
- case PathComposerBase::typeKey:
- case ComponentBase::typeKey:
- return true;
- default:
- return false;
- }
- }
-
- int coreType() const override { return typeKey; }
-
- protected:
- };
-} // namespace rive
-
-#endif
\ No newline at end of file
typedef ContainerComponent Super;
public:
- static const int typeKey = 14;
+ static const uint16_t typeKey = 14;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int xPropertyKey = 24;
- static const int yPropertyKey = 25;
+ static const uint16_t xPropertyKey = 24;
+ static const uint16_t yPropertyKey = 25;
private:
float m_X = 0.0f;
yChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef Path Super;
public:
- static const int typeKey = 16;
+ static const uint16_t typeKey = 16;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int isClosedPropertyKey = 32;
+ static const uint16_t isClosedPropertyKey = 32;
private:
bool m_IsClosed = false;
isClosedChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef ParametricPath Super;
public:
- static const int typeKey = 51;
+ static const uint16_t typeKey = 51;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int pointsPropertyKey = 125;
- static const int cornerRadiusPropertyKey = 126;
+ static const uint16_t pointsPropertyKey = 125;
+ static const uint16_t cornerRadiusPropertyKey = 126;
private:
int m_Points = 5;
- float m_CornerRadius = 0;
+ float m_CornerRadius = 0.0f;
public:
inline int points() const { return m_Points; }
void points(int value)
cornerRadiusChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef ParametricPath Super;
public:
- static const int typeKey = 7;
+ static const uint16_t typeKey = 7;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int cornerRadiusPropertyKey = 31;
+ static const uint16_t cornerRadiusPropertyKey = 31;
private:
- float m_CornerRadius = 0;
+ float m_CornerRadius = 0.0f;
public:
inline float cornerRadius() const { return m_CornerRadius; }
void cornerRadius(float value)
cornerRadiusChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef Drawable Super;
public:
- static const int typeKey = 3;
+ static const uint16_t typeKey = 3;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
protected:
};
typedef Polygon Super;
public:
- static const int typeKey = 52;
+ static const uint16_t typeKey = 52;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int innerRadiusPropertyKey = 127;
+ static const uint16_t innerRadiusPropertyKey = 127;
private:
- float m_InnerRadius = 0.5;
-
+ float m_InnerRadius = 0.5f;
public:
inline float innerRadius() const { return m_InnerRadius; }
void innerRadius(float value)
innerRadiusChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef PathVertex Super;
public:
- static const int typeKey = 5;
+ static const uint16_t typeKey = 5;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int radiusPropertyKey = 26;
+ static const uint16_t radiusPropertyKey = 26;
private:
- float m_Radius = 0;
+ float m_Radius = 0.0f;
public:
inline float radius() const { return m_Radius; }
void radius(float value)
radiusChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
typedef ParametricPath Super;
public:
- static const int typeKey = 8;
+ static const uint16_t typeKey = 8;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
protected:
};
typedef ContainerComponent Super;
public:
- static const int typeKey = 38;
+ static const uint16_t typeKey = 38;
/// Helper to quickly determine if a core object extends another without
/// RTTI at runtime.
- bool isTypeOf(int typeKey) const override
+ bool isTypeOf(uint16_t typeKey) const override
{
switch (typeKey)
{
}
}
- int coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const int rotationPropertyKey = 15;
- static const int scaleXPropertyKey = 16;
- static const int scaleYPropertyKey = 17;
- static const int opacityPropertyKey = 18;
+ static const uint16_t rotationPropertyKey = 15;
+ static const uint16_t scaleXPropertyKey = 16;
+ static const uint16_t scaleYPropertyKey = 17;
+ static const uint16_t opacityPropertyKey = 18;
private:
- float m_Rotation = 0;
- float m_ScaleX = 1;
- float m_ScaleY = 1;
- float m_Opacity = 1;
+ float m_Rotation = 0.0f;
+ float m_ScaleX = 1.0f;
+ float m_ScaleY = 1.0f;
+ float m_Opacity = 1.0f;
public:
inline float rotation() const { return m_Rotation; }
void rotation(float value)
opacityChanged();
}
- bool deserialize(int propertyKey, BinaryReader& reader) override
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
{
switch (propertyKey)
{
--- /dev/null
+#ifndef _RIVE_ARTBOARD_IMPORTER_HPP_
+#define _RIVE_ARTBOARD_IMPORTER_HPP_
+
+#include "importers/import_stack.hpp"
+
+namespace rive
+{
+ class Core;
+ class Artboard;
+ class LinearAnimation;
+ class StateMachine;
+ class ArtboardImporter : public ImportStackObject
+ {
+ private:
+ Artboard* m_Artboard;
+
+ public:
+ ArtboardImporter(Artboard* artboard);
+ void addComponent(Core* object);
+ void addAnimation(LinearAnimation* animation);
+ void addStateMachine(StateMachine* stateMachine);
+ StatusCode resolve() override;
+ };
+} // namespace rive
+#endif
--- /dev/null
+#ifndef _RIVE_IMPORT_STACK_HPP_
+#define _RIVE_IMPORT_STACK_HPP_
+#include "status_code.hpp"
+#include <unordered_map>
+
+namespace rive
+{
+ class ImportStackObject
+ {
+ public:
+ virtual ~ImportStackObject() {}
+ virtual StatusCode resolve() { return StatusCode::Ok; }
+ };
+
+ class ImportStack
+ {
+ private:
+ std::unordered_map<uint16_t, ImportStackObject*> m_Latests;
+
+ public:
+ template <typename T = ImportStackObject> T* latest(uint16_t coreType)
+ {
+ auto itr = m_Latests.find(coreType);
+ if (itr == m_Latests.end())
+ {
+ return nullptr;
+ }
+ return reinterpret_cast<T*>(itr->second);
+ }
+
+ StatusCode makeLatest(uint16_t coreType, ImportStackObject* object)
+ {
+ // Clean up the old object in the stack.
+ auto itr = m_Latests.find(coreType);
+ if (itr != m_Latests.end())
+ {
+ auto stackObject = itr->second;
+ StatusCode code = stackObject->resolve();
+ delete stackObject;
+ if (code != StatusCode::Ok)
+ {
+ m_Latests.erase(coreType);
+ return code;
+ }
+ }
+
+ // Set the new one.
+ if (object == nullptr)
+ {
+ m_Latests.erase(coreType);
+ }
+ else
+ {
+ m_Latests[coreType] = object;
+ }
+ return StatusCode::Ok;
+ }
+
+ StatusCode resolve()
+ {
+ for (auto& pair : m_Latests)
+ {
+ StatusCode code = pair.second->resolve();
+ if (code != StatusCode::Ok)
+ {
+ return code;
+ }
+ }
+ return StatusCode::Ok;
+ }
+
+ ~ImportStack()
+ {
+ for (auto& pair : m_Latests)
+ {
+ delete pair.second;
+ }
+ }
+ };
+} // namespace rive
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_KEYED_OBJECT_IMPORTER_HPP_
+#define _RIVE_KEYED_OBJECT_IMPORTER_HPP_
+
+#include "importers/import_stack.hpp"
+
+namespace rive
+{
+ class Core;
+ class KeyedObject;
+ class KeyedProperty;
+ class KeyedObjectImporter : public ImportStackObject
+ {
+ private:
+ KeyedObject* m_KeyedObject;
+
+ public:
+ KeyedObjectImporter(KeyedObject* keyedObject);
+ void addKeyedProperty(KeyedProperty* property);
+ };
+} // namespace rive
+#endif
--- /dev/null
+#ifndef _RIVE_KEYED_PROPERTY_IMPORTER_HPP_
+#define _RIVE_KEYED_PROPERTY_IMPORTER_HPP_
+
+#include "importers/import_stack.hpp"
+
+namespace rive
+{
+ class Core;
+ class KeyFrame;
+ class KeyedProperty;
+ class LinearAnimation;
+ class KeyedPropertyImporter : public ImportStackObject
+ {
+ private:
+ LinearAnimation* m_Animation;
+ KeyedProperty* m_KeyedProperty;
+
+ public:
+ KeyedPropertyImporter(LinearAnimation* animation,
+ KeyedProperty* keyedProperty);
+ void addKeyFrame(KeyFrame* keyFrame);
+ };
+} // namespace rive
+#endif
--- /dev/null
+#ifndef _RIVE_LINEAR_ANIMATION_IMPORTER_HPP_
+#define _RIVE_LINEAR_ANIMATION_IMPORTER_HPP_
+
+#include "importers/import_stack.hpp"
+
+namespace rive
+{
+ class Core;
+ class LinearAnimation;
+ class KeyedObject;
+ class LinearAnimationImporter : public ImportStackObject
+ {
+ private:
+ LinearAnimation* m_Animation;
+
+ public:
+ LinearAnimation* animation() const { return m_Animation; };
+ LinearAnimationImporter(LinearAnimation* animation);
+ void addKeyedObject(KeyedObject* object);
+ };
+} // namespace rive
+#endif
float buffer[4];
struct
{
- Vec2D min, max;
- };
- struct
- {
float minX, minY, maxX, maxY;
};
};
float perimeter() const;
};
} // namespace rive
-#endif
\ No newline at end of file
+#endif
int m_MajorVersion;
int m_MinorVersion;
- int m_OwnerId;
int m_FileId;
std::unordered_map<int, int> m_PropertyToFieldIndex;
int majorVersion() const { return m_MajorVersion; }
/// @returns the file's minor version
int minorVersion() const { return m_MinorVersion; }
- /// @returns the id of the file's owner; may be zero
- int ownerId() const { return m_OwnerId; }
/// @returns the file's id; may be zero
int fileId() const { return m_FileId; }
}
}
- header.m_MajorVersion = (int) reader.readVarUint();
+ header.m_MajorVersion = (int)reader.readVarUint();
if (reader.didOverflow())
{
return false;
}
- header.m_MinorVersion = (int) reader.readVarUint();
+ header.m_MinorVersion = (int)reader.readVarUint();
if (reader.didOverflow())
{
return false;
}
- header.m_OwnerId = (int) reader.readVarUint();
- header.m_FileId = (int) reader.readVarUint();
+ header.m_FileId = (int)reader.readVarUint();
+
+ if (reader.didOverflow())
+ {
+ return false;
+ }
std::vector<int> propertyKeys;
- for (int propertyKey = (int) reader.readVarUint(); propertyKey != 0;
- propertyKey = (int) reader.readVarUint())
+ for (int propertyKey = (int)reader.readVarUint(); propertyKey != 0;
+ propertyKey = (int)reader.readVarUint())
{
propertyKeys.push_back(propertyKey);
+ if (reader.didOverflow())
+ {
+ return false;
+ }
}
int currentInt = 0;
int fieldIndex = (currentInt >> currentBit) & 3;
header.m_PropertyToFieldIndex[propertyKey] = fieldIndex;
currentBit += 2;
+ if (reader.didOverflow())
+ {
+ return false;
+ }
}
return true;
#ifndef _RIVE_PATH_COMPOSER_HPP_
#define _RIVE_PATH_COMPOSER_HPP_
-#include "generated/shapes/path_composer_base.hpp"
+#include "component.hpp"
namespace rive
{
class Shape;
class CommandPath;
class RenderPath;
- class PathComposer : public PathComposerBase
+ class PathComposer : public Component
{
private:
- Shape* m_Shape = nullptr;
+ Shape* m_Shape;
CommandPath* m_LocalPath = nullptr;
CommandPath* m_WorldPath = nullptr;
public:
+ PathComposer(Shape* shape);
~PathComposer();
Shape* shape() const { return m_Shape; }
- StatusCode onAddedClean(CoreContext* context) override;
+ StatusCode onAddedClean(CoreContext* context) override
+ {
+ return StatusCode::Ok;
+ }
void buildDependencies() override;
void update(ComponentDirt value) override;
#ifndef _RIVE_SHAPE_HPP_
#define _RIVE_SHAPE_HPP_
#include "generated/shapes/shape_base.hpp"
+#include "shapes/path_composer.hpp"
#include "shapes/shape_paint_container.hpp"
#include <vector>
class Shape : public ShapeBase, public ShapePaintContainer
{
private:
- PathComposer* m_PathComposer = nullptr;
+ PathComposer m_PathComposer;
std::vector<Path*> m_Paths;
bool m_WantDifferencePath = false;
public:
+ Shape();
void buildDependencies() override;
void addPath(Path* path);
std::vector<Path*>& paths() { return m_Paths; }
void update(ComponentDirt value) override;
void draw(Renderer* renderer) override;
- void pathComposer(PathComposer* value);
- PathComposer* pathComposer() const { return m_PathComposer; }
+ PathComposer* pathComposer() const
+ {
+ return (PathComposer*)&m_PathComposer;
+ }
void pathChanged();
void addDefaultPathSpace(PathSpace space);
+ StatusCode onAddedDirty(CoreContext* context) override;
};
} // namespace rive
rive::LinearAnimation* animation;
if (animation_name != NULL && animation_name[0] != '\0')
{
- if ((animation = artboard->animation<rive::LinearAnimation>(
- animation_name)) == nullptr)
+ if ((animation = artboard->animation(animation_name)) == nullptr)
{
fprintf(stderr,
}
else
{
- animation = artboard->firstAnimation<rive::LinearAnimation>();
+ animation = artboard->firstAnimation();
if (animation == nullptr)
{
throw std::invalid_argument(
delete animationInstance;
delete currentFile;
- auto animation = artboard->firstAnimation<rive::LinearAnimation>();
+ auto animation = artboard->firstAnimation();
if (animation != nullptr)
{
animationInstance = new rive::LinearAnimationInstance(animation);
#include "animation/cubic_interpolator.hpp"
+#include "artboard.hpp"
+#include "importers/artboard_importer.hpp"
+#include "importers/import_stack.hpp"
#include <cmath>
using namespace rive;
float CubicInterpolator::transform(float mix) const
{
return calcBezier(getT(mix), y1(), y2());
+}
+
+StatusCode CubicInterpolator::import(ImportStack& importStack)
+{
+ auto artboardImporter =
+ importStack.latest<ArtboardImporter>(ArtboardBase::typeKey);
+ if (artboardImporter == nullptr)
+ {
+ return StatusCode::MissingObject;
+ }
+ artboardImporter->addComponent(this);
+ return Super::import(importStack);
}
\ No newline at end of file
#include "animation/keyed_object.hpp"
#include "animation/keyed_property.hpp"
+#include "animation/linear_animation.hpp"
#include "artboard.hpp"
+#include "importers/linear_animation_importer.hpp"
using namespace rive;
for (auto property : m_KeyedProperties)
{
- property->onAddedDirty(context);
+ StatusCode code;
+ if ((code = property->onAddedDirty(context)) != StatusCode::Ok)
+ {
+ return code;
+ }
}
return StatusCode::Ok;
}
{
property->apply(object, time, mix);
}
+}
+
+StatusCode KeyedObject::import(ImportStack& importStack)
+{
+ auto importer = importStack.latest<LinearAnimationImporter>(
+ LinearAnimationBase::typeKey);
+ if (importer == nullptr)
+ {
+ return StatusCode::MissingObject;
+ }
+ importer->addKeyedObject(this);
+ return Super::import(importStack);
}
\ No newline at end of file
#include "animation/keyed_property.hpp"
+#include "animation/keyed_object.hpp"
#include "animation/keyframe.hpp"
+#include "importers/import_stack.hpp"
+#include "importers/keyed_object_importer.hpp"
using namespace rive;
idx = start;
}
int pk = propertyKey();
+
if (idx == 0)
{
m_KeyFrames[0]->apply(object, pk, mix);
}
}
return StatusCode::Ok;
+}
+
+StatusCode KeyedProperty::import(ImportStack& importStack)
+{
+ auto importer =
+ importStack.latest<KeyedObjectImporter>(KeyedObjectBase::typeKey);
+ if (importer == nullptr)
+ {
+ return StatusCode::MissingObject;
+ }
+ importer->addKeyedProperty(this);
+ return Super::import(importStack);
}
\ No newline at end of file
#include "animation/keyframe.hpp"
#include "animation/cubic_interpolator.hpp"
+#include "animation/keyed_property.hpp"
#include "core_context.hpp"
+#include "importers/import_stack.hpp"
+#include "importers/keyed_property_importer.hpp"
using namespace rive;
StatusCode KeyFrame::onAddedDirty(CoreContext* context)
{
- if (interpolatorId() != 0)
+ if (interpolatorId() > 0)
{
auto coreObject = context->resolve(interpolatorId());
if (coreObject == nullptr || !coreObject->is<CubicInterpolator>())
{
return StatusCode::MissingObject;
}
-
m_Interpolator = coreObject->as<CubicInterpolator>();
}
return StatusCode::Ok;
}
-void KeyFrame::computeSeconds(int fps) { m_Seconds = frame() / (float)fps; }
\ No newline at end of file
+void KeyFrame::computeSeconds(int fps) { m_Seconds = frame() / (float)fps; }
+
+StatusCode KeyFrame::import(ImportStack& importStack)
+{
+ auto importer =
+ importStack.latest<KeyedPropertyImporter>(KeyedProperty::typeKey);
+ if (importer == nullptr)
+ {
+ return StatusCode::MissingObject;
+ }
+ importer->addKeyFrame(this);
+ return Super::import(importStack);
+}
\ No newline at end of file
--- /dev/null
+#include "animation/layer_state.hpp"
+using namespace rive;
+#include "animation/transition_bool_condition.hpp"
+
+using namespace rive;
+
+StatusCode LayerState::onAddedDirty(CoreContext* context)
+{
+ return StatusCode::Ok;
+}
+
+StatusCode LayerState::onAddedClean(CoreContext* context)
+{
+ return StatusCode::Ok;
+}
\ No newline at end of file
#include "animation/linear_animation.hpp"
#include "animation/keyed_object.hpp"
+#include "artboard.hpp"
+#include "importers/artboard_importer.hpp"
+#include "importers/import_stack.hpp"
using namespace rive;
}
return StatusCode::Ok;
}
+
StatusCode LinearAnimation::onAddedClean(CoreContext* context)
{
StatusCode code;
{
object->apply(artboard, time, mix);
}
+}
+
+StatusCode LinearAnimation::import(ImportStack& importStack)
+{
+ auto artboardImporter =
+ importStack.latest<ArtboardImporter>(ArtboardBase::typeKey);
+ if (artboardImporter == nullptr)
+ {
+ return StatusCode::MissingObject;
+ }
+ artboardImporter->addAnimation(this);
+ return Super::import(importStack);
}
\ No newline at end of file
--- /dev/null
+#include "animation/state_machine_input.hpp"
+
+using namespace rive;
+
+StatusCode StateMachineInput::onAddedDirty(CoreContext* context)
+{
+ return StatusCode::Ok;
+}
+
+StatusCode StateMachineInput::onAddedClean(CoreContext* context)
+{
+ return StatusCode::Ok;
+}
\ No newline at end of file
--- /dev/null
+#include "animation/state_machine_layer.hpp"
+
+using namespace rive;
+
+StatusCode StateMachineLayer::onAddedDirty(CoreContext* context)
+{
+ return StatusCode::Ok;
+}
+
+StatusCode StateMachineLayer::onAddedClean(CoreContext* context)
+{
+ return StatusCode::Ok;
+}
\ No newline at end of file
--- /dev/null
+#include "animation/state_machine_trigger.hpp"
+
+using namespace rive;
+
+void StateMachineTrigger::fire() { m_Fired = true; }
+
+void StateMachineTrigger::reset() { m_Fired = false; }
\ No newline at end of file
--- /dev/null
+#include "animation/state_transition.hpp"
+
+using namespace rive;
+
+StatusCode StateTransition::onAddedDirty(CoreContext* context)
+{
+ return StatusCode::Ok;
+}
+
+StatusCode StateTransition::onAddedClean(CoreContext* context)
+{
+ return StatusCode::Ok;
+}
\ No newline at end of file
--- /dev/null
+#include "animation/transition_bool_condition.hpp"
+
+using namespace rive;
+
+StatusCode TransitionCondition::onAddedDirty(CoreContext* context)
+{
+ return StatusCode::Ok;
+}
+
+StatusCode TransitionCondition::onAddedClean(CoreContext* context)
+{
+ return StatusCode::Ok;
+}
\ No newline at end of file
{
delete object;
}
+ for (auto object : m_StateMachines)
+ {
+ delete object;
+ }
delete m_ClipPath;
delete m_BackgroundPath;
}
-static bool canContinue(StatusCode code)
+static bool canContinue(StatusCode code)
{
// We currently only cease loading on invalid object.
return code != StatusCode::InvalidObject;
// can't assume that their parent's parent will have resolved yet.
for (auto object : m_Objects)
{
- if(object == nullptr)
+ if (object == nullptr)
{
// objects can be null if they were not understood by this runtime.
continue;
}
}
+ for (auto object : m_StateMachines)
+ {
+ if (!canContinue(code = object->onAddedDirty(this)))
+ {
+ return code;
+ }
+ }
+
// Store a map of the drawRules to make it easier to lookup the matching
// rule for a transform component.
std::unordered_map<Core*, DrawRules*> componentDrawRules;
// parent should be type X can be checked now).
for (auto object : m_Objects)
{
- if(object == nullptr)
+ if (object == nullptr)
{
continue;
}
{
componentDrawRules[component] = rules;
}
- else
+ else
{
- fprintf(stderr, "Artboard::initialize - Draw rule targets missing component width id %d\n", rules->parentId());
+ fprintf(stderr,
+ "Artboard::initialize - Draw rule targets missing "
+ "component width id %d\n",
+ rules->parentId());
}
}
}
+
for (auto object : m_Animations)
{
if (!canContinue(code = object->onAddedClean(this)))
return code;
}
}
+
+ for (auto object : m_StateMachines)
+ {
+ if (!canContinue(code = object->onAddedClean(this)))
+ {
+ return code;
+ }
+ }
+
// Multi-level references have been built up, now we can actually mark
// what's dependent on what.
for (auto object : m_Objects)
{
- if(object == nullptr)
+ if (object == nullptr)
{
continue;
}
// dependencies.
for (auto object : m_Objects)
{
- if(object == nullptr)
+ if (object == nullptr)
{
continue;
}
// targets that belong to this rule here.
for (auto object : m_Objects)
{
- if (object->is<DrawTarget>())
+ if (object != nullptr && object->is<DrawTarget>())
{
DrawTarget* dependentTarget = object->as<DrawTarget>();
if (dependentTarget->parent() == dependentRules)
}
}
}
-
DependencySorter sorter;
std::vector<Component*> drawTargetOrder;
sorter.sort(&root, drawTargetOrder);
void Artboard::addObject(Core* object) { m_Objects.push_back(object); }
-void Artboard::addAnimation(Animation* object)
+void Artboard::addAnimation(LinearAnimation* object)
{
m_Animations.push_back(object);
}
+void Artboard::addStateMachine(StateMachine* object)
+{
+ m_StateMachines.push_back(object);
+}
+
Core* Artboard::resolve(int id) const
{
if (id < 0 || id >= m_Objects.size())
{
m_ClipPath->reset();
m_ClipPath->addRect(0.0f, 0.0f, width(), height());
- m_BackgroundPath->addRect(-width() * originX(), -height() * originY(), width(), height());
+ m_BackgroundPath->addRect(
+ -width() * originX(), -height() * originY(), width(), height());
}
}
renderer->restore();
}
-AABB Artboard::bounds() const { return AABB(0.0f, 0.0f, width(), height()); }
\ No newline at end of file
+AABB Artboard::bounds() const { return AABB(0.0f, 0.0f, width(), height()); }
+
+LinearAnimation* Artboard::firstAnimation()
+{
+ if (m_Animations.empty())
+ {
+ return nullptr;
+ }
+ return m_Animations.front();
+}
+
+LinearAnimation* Artboard::animation(std::string name)
+{
+ for (auto animation : m_Animations)
+ {
+ if (animation->name() == name)
+ {
+ return animation;
+ }
+ }
+ return nullptr;
+}
+
+LinearAnimation* Artboard::animation(size_t index)
+{
+ if (index < 0 || index >= m_Animations.size())
+ {
+ return nullptr;
+ }
+ return m_Animations[index];
+}
+
+StateMachine* Artboard::firstStateMachine()
+{
+ if (m_StateMachines.empty())
+ {
+ return nullptr;
+ }
+ return m_StateMachines.front();
+}
+
+StateMachine* Artboard::stateMachine(std::string name)
+{
+ for (auto machine : m_StateMachines)
+ {
+ if (machine->name() == name)
+ {
+ return machine;
+ }
+ }
+ return nullptr;
+}
+
+StateMachine* Artboard::stateMachine(size_t index)
+{
+ if (index < 0 || index >= m_StateMachines.size())
+ {
+ return nullptr;
+ }
+ return m_StateMachines[index];
+}
\ No newline at end of file
#include "artboard.hpp"
#include "container_component.hpp"
#include "core_context.hpp"
+#include "importers/artboard_importer.hpp"
+#include "importers/import_stack.hpp"
#include <algorithm>
using namespace rive;
d->addDirt(value, true);
}
return true;
+}
+
+StatusCode Component::import(ImportStack& importStack)
+{
+ auto artboardImporter =
+ importStack.latest<ArtboardImporter>(ArtboardBase::typeKey);
+ if (artboardImporter == nullptr)
+ {
+ return StatusCode::MissingObject;
+ }
+ artboardImporter->addComponent(this);
+ return Super::import(importStack);
}
\ No newline at end of file
{
}
+bool BinaryReader::reachedEnd() const { return m_Position == m_End || didOverflow(); }
+
size_t BinaryReader::lengthInBytes() const { return m_Length; }
bool BinaryReader::didOverflow() const { return m_Overflowed; }
return std::string();
}
- char rawValue[length];
+ char rawValue[length + 1];
auto readBytes = decode_string(length, m_Position, m_End, &rawValue[0]);
if (readBytes != length)
{
return *m_Position++;
}
-uint32_t BinaryReader::readUint32()
+uint32_t BinaryReader::readUint32()
{
uint32_t value;
auto readBytes = decode_uint_32(m_Position, m_End, &value);
}
m_Position += readBytes;
return value;
-}
\ No newline at end of file
+}
#include "core/field_types/core_string_type.hpp"
#include "core/field_types/core_uint_type.hpp"
#include "generated/core_registry.hpp"
+#include "importers/artboard_importer.hpp"
+#include "importers/import_stack.hpp"
+#include "importers/keyed_object_importer.hpp"
+#include "importers/keyed_property_importer.hpp"
+#include "importers/linear_animation_importer.hpp"
// Default namespace for Rive Cpp code
using namespace rive;
// Import a single Rive runtime object.
// Used by the file importer.
-template <typename T = Core>
-static T* readRuntimeObject(BinaryReader& reader, const RuntimeHeader& header)
+static Core* readRuntimeObject(BinaryReader& reader,
+ const RuntimeHeader& header)
{
auto coreObjectKey = reader.readVarUint();
auto object = CoreRegistry::makeCoreInstance((int)coreObjectKey);
}
}
}
-
- // This is evaluated at compile time based on how the templated method
- // is called. This means that it'll get optimized out when calling with
- // type Core (which is the default). The type checking is skipped in
- // this case.
- if constexpr (!std::is_same<T, Core>::value)
- {
- // Concrete Core object couldn't be read.
- if (object == nullptr)
- {
- fprintf(stderr,
- "Expected object of type %d but found %llu, which this "
- "runtime doesn't understand.\n",
- T::typeKey,
- coreObjectKey);
- return nullptr;
- }
- // Ensure the object is of the provided type, if not, return null
- // and delete the object. Note that we read in the properties
- // regardless of whether or not this object is the expected one.
- // This ensures our reader has advanced past the object.
- if (!object->is<T>())
- {
- fprintf(stderr,
- "Expected object of type %d but found %d.\n",
- T::typeKey,
- object->coreType());
- delete object;
- return nullptr;
- }
- }
- // Core object couldn't be read.
- else if (object == nullptr)
+ if (object == nullptr)
{
fprintf(stderr,
- "Expected a Core object but found %llu, which this runtime "
- "doesn't understand.\n",
+ "File contains an unknown object with coreType %llu, which "
+ "this runtime doesn't understand.\n",
coreObjectKey);
return nullptr;
}
- return reinterpret_cast<T*>(object);
+ return object;
}
File::~File()
fprintf(stderr, "Bad header\n");
return ImportResult::malformed;
}
- if (header.majorVersion() > majorVersion)
+ if (header.majorVersion() != majorVersion)
{
fprintf(stderr,
"Unsupported version %u.%u expected %u.%u.\n",
ImportResult File::read(BinaryReader& reader, const RuntimeHeader& header)
{
- m_Backboard = readRuntimeObject<Backboard>(reader, header);
- if (m_Backboard == nullptr)
- {
- fprintf(stderr, "Expected first object to be the backboard.\n");
- return ImportResult::malformed;
- }
-
- auto numArtboards = reader.readVarUint();
- for (int i = 0; i < numArtboards; i++)
+ ImportStack importStack;
+ while (!reader.reachedEnd())
{
- auto numObjects = reader.readVarUint();
- if (numObjects == 0)
- {
- fprintf(stderr,
- "Artboards must contain at least one object "
- "(themselves).\n");
- return ImportResult::malformed;
- }
- auto artboard = readRuntimeObject<Artboard>(reader, header);
- if (artboard == nullptr)
- {
- fprintf(stderr, "Found non-artboard in artboard list.\n");
- return ImportResult::malformed;
- }
- m_Artboards.push_back(artboard);
-
- artboard->addObject(artboard);
-
- for (int i = 1; i < numObjects; i++)
+ auto object = readRuntimeObject(reader, header);
+ if (object == nullptr)
{
- auto object = readRuntimeObject(reader, header);
- // N.B. we add objects that don't load (null) too as we need to
- // look them up by index.
- artboard->addObject(object);
+ // See if there's an artboard on the stack, need to track the null
+ // object as it'll still hold an id.
+ auto importer =
+ importStack.latest<ArtboardImporter>(Artboard::typeKey);
+ if (importer == nullptr)
+ {
+ return ImportResult::malformed;
+ }
+ importer->addComponent(object);
+ continue;
}
+ ImportStackObject* stackObject = nullptr;
+ auto stackType = object->coreType();
- // Animations also need to reference objects, so make sure they get
- // read in before the hierarchy resolves (batch add completes).
- auto numAnimations = reader.readVarUint();
- for (int i = 0; i < numAnimations; i++)
+ switch (stackType)
{
- auto animation = readRuntimeObject<Animation>(reader, header);
- if (animation == nullptr)
+ case Artboard::typeKey:
+ stackObject = new ArtboardImporter(object->as<Artboard>());
+ break;
+ case LinearAnimation::typeKey:
+ stackObject =
+ new LinearAnimationImporter(object->as<LinearAnimation>());
+ break;
+ case KeyedObject::typeKey:
+ stackObject =
+ new KeyedObjectImporter(object->as<KeyedObject>());
+ break;
+ case KeyedProperty::typeKey:
{
- continue;
- }
- artboard->addAnimation(animation);
- if (animation->coreType() == LinearAnimationBase::typeKey)
- {
- auto linearAnimation =
- reinterpret_cast<LinearAnimation*>(animation);
- auto numKeyedObjects = reader.readVarUint();
- for (int j = 0; j < numKeyedObjects; j++)
+ auto importer = importStack.latest<LinearAnimationImporter>(
+ LinearAnimation::typeKey);
+ if (importer == nullptr)
{
- auto keyedObject =
- readRuntimeObject<KeyedObject>(reader, header);
- if (keyedObject == nullptr)
- {
- continue;
- }
- linearAnimation->addKeyedObject(keyedObject);
-
- int numKeyedProperties = (int)reader.readVarUint();
- for (int k = 0; k < numKeyedProperties; k++)
- {
- auto keyedProperty =
- readRuntimeObject<KeyedProperty>(reader, header);
- if (keyedProperty == nullptr)
- {
- continue;
- }
- keyedObject->addKeyedProperty(keyedProperty);
-
- auto numKeyframes = reader.readVarUint();
- for (int l = 0; l < numKeyframes; l++)
- {
- auto keyframe =
- readRuntimeObject<KeyFrame>(reader, header);
- if (keyframe == nullptr)
- {
- continue;
- }
- keyframe->computeSeconds(linearAnimation->fps());
- keyedProperty->addKeyFrame(keyframe);
- }
- }
+ return ImportResult::malformed;
}
+ stackObject = new KeyedPropertyImporter(
+ importer->animation(), object->as<KeyedProperty>());
+ break;
}
}
-
- // Artboard has been read in.
- if (artboard->initialize() != StatusCode::Ok)
+ if (importStack.makeLatest(stackType, stackObject) != StatusCode::Ok)
{
+ // Some previous stack item didn't resolve.
return ImportResult::malformed;
}
+ if (object->import(importStack) == StatusCode::Ok)
+ {
+ switch (object->coreType())
+ {
+ case Backboard::typeKey:
+ m_Backboard = object->as<Backboard>();
+ break;
+ case Artboard::typeKey:
+ m_Artboards.push_back(object->as<Artboard>());
+ break;
+ }
+ }
}
- return ImportResult::success;
+
+ return importStack.resolve() == StatusCode::Ok ? ImportResult::success
+ : ImportResult::malformed;
}
Backboard* File::backboard() const { return m_Backboard; }
--- /dev/null
+#include "artboard.hpp"
+#include "importers/artboard_importer.hpp"
+#include "animation/linear_animation.hpp"
+#include "animation/state_machine.hpp"
+#include "artboard.hpp"
+
+using namespace rive;
+
+ArtboardImporter::ArtboardImporter(Artboard* artboard) : m_Artboard(artboard) {}
+
+void ArtboardImporter::addComponent(Core* object)
+{
+ m_Artboard->addObject(object);
+}
+
+void ArtboardImporter::addAnimation(LinearAnimation* animation)
+{
+ m_Artboard->addAnimation(animation);
+}
+
+void ArtboardImporter::addStateMachine(StateMachine* stateMachine)
+{
+ m_Artboard->addStateMachine(stateMachine);
+}
+
+StatusCode ArtboardImporter::resolve() { return m_Artboard->initialize(); }
\ No newline at end of file
--- /dev/null
+#include "importers/keyed_object_importer.hpp"
+#include "animation/keyed_object.hpp"
+#include "animation/keyed_property.hpp"
+#include "artboard.hpp"
+
+using namespace rive;
+
+KeyedObjectImporter::KeyedObjectImporter(KeyedObject* keyedObject) :
+ m_KeyedObject(keyedObject)
+{
+}
+
+void KeyedObjectImporter::addKeyedProperty(KeyedProperty* property)
+{
+ m_KeyedObject->addKeyedProperty(property);
+}
\ No newline at end of file
--- /dev/null
+#include "importers/keyed_property_importer.hpp"
+#include "animation/keyed_property.hpp"
+#include "animation/keyframe.hpp"
+#include "animation/linear_animation.hpp"
+
+using namespace rive;
+
+KeyedPropertyImporter::KeyedPropertyImporter(LinearAnimation* animation,
+ KeyedProperty* keyedProperty) :
+ m_Animation(animation), m_KeyedProperty(keyedProperty)
+{
+}
+
+void KeyedPropertyImporter::addKeyFrame(KeyFrame* keyFrame)
+{
+ keyFrame->computeSeconds(m_Animation->fps());
+ m_KeyedProperty->addKeyFrame(keyFrame);
+}
\ No newline at end of file
--- /dev/null
+#include "importers/linear_animation_importer.hpp"
+#include "animation/keyed_object.hpp"
+#include "animation/linear_animation.hpp"
+#include "artboard.hpp"
+
+using namespace rive;
+
+LinearAnimationImporter::LinearAnimationImporter(LinearAnimation* animation) :
+ m_Animation(animation)
+{
+}
+
+void LinearAnimationImporter::addKeyedObject(KeyedObject* object)
+{
+ m_Animation->addKeyedObject(object);
+}
\ No newline at end of file
return a[0] == b[0] && a[1] == b[1] && a[2] == b[2] && a[3] == b[3];
}
-float AABB::width() const { return max[0] - min[0]; }
+float AABB::width() const { return buffer[2] - buffer[0]; }
-float AABB::height() const { return max[1] - min[1]; }
+float AABB::height() const { return buffer[3] - buffer[1]; }
float AABB::perimeter() const
{
out[1] = std::fmin(p1[1], std::fmin(p2[1], std::fmin(p3[1], p4[1])));
out[2] = std::fmax(p1[0], std::fmax(p2[0], std::fmax(p3[0], p4[0])));
out[3] = std::fmax(p1[1], std::fmax(p2[1], std::fmax(p3[1], p4[1])));
-}
\ No newline at end of file
+}
auto artboard = static_cast<Artboard*>(context);
for (auto core : artboard->objects())
{
+ if (core == nullptr)
+ {
+ continue;
+ }
// Iterate artboard to find drawables that are parented to this clipping
// shape, they need to know they'll be clipped by this shape.
if (core->is<Drawable>())
using namespace rive;
+float clamp(float v, float lo, float hi)
+{
+ if (v < lo)
+ {
+ return lo;
+ }
+ else if (v > hi)
+ {
+ return hi;
+ }
+ return v;
+}
+
void MetricsPath::reset()
{
m_ComputedLength = 0.0f;
length += partLength;
}
+ // Lets make sur we're between 0 & 1f on both start & end.
+ startT = clamp(startT, 0.0f, 1.0f);
+ endT = clamp(endT, 0.0f, 1.0f);
+
if (firstPartIndex == lastPartIndex)
{
extractSubPart(firstPartIndex, startT, endT, moveTo, result);
static Mat2D identity;
+PathComposer::PathComposer(Shape* shape) : m_Shape(shape) {}
PathComposer::~PathComposer()
{
delete m_LocalPath;
delete m_WorldPath;
}
-StatusCode PathComposer::onAddedClean(CoreContext* context)
-{
- // Find the shape.
- for (auto currentParent = parent(); currentParent != nullptr;
- currentParent = currentParent->parent())
- {
- if (currentParent->is<Shape>())
- {
- m_Shape = currentParent->as<Shape>();
- m_Shape->pathComposer(this);
- return StatusCode::Ok;
- }
- }
- return StatusCode::MissingObject;
-}
-
void PathComposer::buildDependencies()
{
assert(m_Shape != nullptr);
using namespace rive;
+Shape::Shape() : m_PathComposer(this) {}
+
void Shape::addPath(Path* path)
{
// Make sure the path is not already in the shape.
void Shape::pathChanged()
{
- m_PathComposer->addDirt(ComponentDirt::Path, true);
+ m_PathComposer.addDirt(ComponentDirt::Path, true);
invalidateStrokeEffects();
}
-void Shape::pathComposer(PathComposer* value) { m_PathComposer = value; }
void Shape::draw(Renderer* renderer)
{
auto shouldRestore = clip(renderer);
renderer->transform(transform);
}
shapePaint->draw(renderer,
- paintsInLocal ? m_PathComposer->localPath()
- : m_PathComposer->worldPath());
+ paintsInLocal ? m_PathComposer.localPath()
+ : m_PathComposer.worldPath());
renderer->restore();
}
void Shape::buildDependencies()
{
+ // Make sure to propagate the call to PathComposer as it's no longer part of
+ // Core and owned only by the Shape.
+ m_PathComposer.buildDependencies();
+
Super::buildDependencies();
// Set the blend mode on all the shape paints. If we ever animate this
void Shape::addDefaultPathSpace(PathSpace space)
{
m_DefaultPathSpace |= space;
+}
+
+StatusCode Shape::onAddedDirty(CoreContext* context)
+{
+ auto code = Super::onAddedDirty(context);
+ if (code != StatusCode::Ok)
+ {
+ return code;
+ }
+ // This ensures context propagates to path composer too.
+ return m_PathComposer.onAddedDirty(context);
}
\ No newline at end of file
+#include "bones/skin.hpp"
+#include "bones/tendon.hpp"
#include "catch.hpp"
#include "core/binary_reader.hpp"
#include "file.hpp"
#include "no_op_renderer.hpp"
#include "node.hpp"
#include "shapes/clipping_shape.hpp"
+#include "shapes/path_vertex.hpp"
+#include "shapes/points_path.hpp"
#include "shapes/rectangle.hpp"
#include "shapes/shape.hpp"
-#include "shapes/points_path.hpp"
-#include "bones/skin.hpp"
-#include "bones/tendon.hpp"
-#include "shapes/path_vertex.hpp"
#include <cstdio>
TEST_CASE("bound bones load correctly", "[bones]")
REQUIRE(fread(bytes, 1, length, fp) == length);
auto reader = rive::BinaryReader(bytes, length);
rive::File* file = nullptr;
+
auto result = rive::File::import(reader, &file);
REQUIRE(result == rive::ImportResult::success);
+
REQUIRE(file != nullptr);
REQUIRE(file->artboard() != nullptr);
auto node = file->artboard()->find("transmission_front_testing");
REQUIRE(node != nullptr);
REQUIRE(node->is<rive::Shape>());
- REQUIRE(node->as<rive::Shape>()->paths().size() == 1);
- auto path = node->as<rive::Shape>()->paths()[0];
- REQUIRE(path->is<rive::PointsPath>());
- auto pointsPath = path->as<rive::PointsPath>();
- REQUIRE(pointsPath->skin() != nullptr);
- REQUIRE(pointsPath->skin()->tendons().size() == 2);
- REQUIRE(pointsPath->skin()->tendons()[0]->bone() != nullptr);
- REQUIRE(pointsPath->skin()->tendons()[1]->bone() != nullptr);
-
- for(auto vertex : path->vertices()) {
- REQUIRE(vertex->weight() != nullptr);
- }
-
- // Ok seems like bones are set up ok.
-
+ REQUIRE(node->as<rive::Shape>()->paths().size() == 1);
+ auto path = node->as<rive::Shape>()->paths()[0];
+ REQUIRE(path->is<rive::PointsPath>());
+ auto pointsPath = path->as<rive::PointsPath>();
+ REQUIRE(pointsPath->skin() != nullptr);
+ REQUIRE(pointsPath->skin()->tendons().size() == 2);
+ REQUIRE(pointsPath->skin()->tendons()[0]->bone() != nullptr);
+ REQUIRE(pointsPath->skin()->tendons()[1]->bone() != nullptr);
+
+ for (auto vertex : path->vertices())
+ {
+ REQUIRE(vertex->weight() != nullptr);
+ }
+
+ // Ok seems like bones are set up ok.
delete file;
delete[] bytes;
REQUIRE(file != nullptr);
REQUIRE(file->artboard() != nullptr);
- // Default artboard should be named One.
- REQUIRE(file->artboard()->name() == "One");
+ // Default artboard should be named Two.
+ REQUIRE(file->artboard()->name() == "Two");
- // There should be a second artboard named Two.
- REQUIRE(file->artboard("Two") != nullptr);
+ // There should be a second artboard named One.
+ REQUIRE(file->artboard("One") != nullptr);
delete file;
delete[] bytes;
REQUIRE(shinNode->parent()->parent()->parent() != nullptr);
REQUIRE(shinNode->parent()->parent()->parent() == artboard);
+ auto walkAnimation = artboard->animation("walk");
+ REQUIRE(walkAnimation != nullptr);
+ REQUIRE(walkAnimation->numKeyedObjects() == 22);
+
+
delete file;
delete[] bytes;
}
{
rive::Artboard* artboard = new rive::Artboard();
rive::Shape* shape = new rive::Shape();
- rive::PathComposer* composer = new rive::PathComposer();
rive::Rectangle* rectangle = new rive::Rectangle();
rectangle->x(0.0f);
artboard->addObject(artboard);
artboard->addObject(shape);
- artboard->addObject(composer);
artboard->addObject(rectangle);
rectangle->parentId(1);
- composer->parentId(1);
REQUIRE(artboard->initialize() == rive::StatusCode::Ok);
{
rive::Artboard* artboard = new rive::Artboard();
rive::Shape* shape = new rive::Shape();
- rive::PathComposer* composer = new rive::PathComposer();
rive::Rectangle* rectangle = new rive::Rectangle();
rectangle->x(0.0f);
artboard->addObject(artboard);
artboard->addObject(shape);
- artboard->addObject(composer);
artboard->addObject(rectangle);
rectangle->parentId(1);
- composer->parentId(1);
artboard->initialize();
rive::Artboard* artboard = new rive::Artboard();
rive::Ellipse* ellipse = new rive::Ellipse();
rive::Shape* shape = new rive::Shape();
- rive::PathComposer* composer = new rive::PathComposer();
ellipse->x(0.0f);
ellipse->y(0.0f);
artboard->addObject(artboard);
artboard->addObject(shape);
- artboard->addObject(composer);
artboard->addObject(ellipse);
ellipse->parentId(1);
- composer->parentId(1);
artboard->initialize();