Adding support for translation, rotation, and scale constraints.

This commit is contained in:
Luigi Rosso
2021-08-05 17:34:42 -07:00
parent 84f310134b
commit af5d88e90d
78 changed files with 1362 additions and 162 deletions

View File

@ -36,7 +36,7 @@ abstract class AnimationBase<T extends CoreContext> extends Core<T> {
void nameChanged(String from, String to); void nameChanged(String from, String to);
@override @override
void copy(AnimationBase source) { void copy(covariant AnimationBase source) {
_name = source._name; _name = source._name;
} }
} }

View File

@ -43,7 +43,7 @@ abstract class AnimationStateBase extends LayerState {
void animationIdChanged(int from, int to); void animationIdChanged(int from, int to);
@override @override
void copy(AnimationStateBase source) { void copy(covariant AnimationStateBase source) {
super.copy(source); super.copy(source);
_animationId = source._animationId; _animationId = source._animationId;
} }

View File

@ -36,7 +36,7 @@ abstract class BlendAnimation1DBase extends BlendAnimation {
void valueChanged(double from, double to); void valueChanged(double from, double to);
@override @override
void copy(BlendAnimation1DBase source) { void copy(covariant BlendAnimation1DBase source) {
super.copy(source); super.copy(source);
_value = source._value; _value = source._value;
} }

View File

@ -37,7 +37,7 @@ abstract class BlendAnimationBase<T extends CoreContext> extends Core<T> {
void animationIdChanged(int from, int to); void animationIdChanged(int from, int to);
@override @override
void copy(BlendAnimationBase source) { void copy(covariant BlendAnimationBase source) {
_animationId = source._animationId; _animationId = source._animationId;
} }
} }

View File

@ -38,7 +38,7 @@ abstract class BlendAnimationDirectBase extends BlendAnimation {
void inputIdChanged(int from, int to); void inputIdChanged(int from, int to);
@override @override
void copy(BlendAnimationDirectBase source) { void copy(covariant BlendAnimationDirectBase source) {
super.copy(source); super.copy(source);
_inputId = source._inputId; _inputId = source._inputId;
} }

View File

@ -45,7 +45,7 @@ abstract class BlendState1DBase extends BlendState<BlendAnimation1D> {
void inputIdChanged(int from, int to); void inputIdChanged(int from, int to);
@override @override
void copy(BlendState1DBase source) { void copy(covariant BlendState1DBase source) {
super.copy(source); super.copy(source);
_inputId = source._inputId; _inputId = source._inputId;
} }

View File

@ -43,7 +43,7 @@ abstract class BlendStateTransitionBase extends StateTransition {
void exitBlendAnimationIdChanged(int from, int to); void exitBlendAnimationIdChanged(int from, int to);
@override @override
void copy(BlendStateTransitionBase source) { void copy(covariant BlendStateTransitionBase source) {
super.copy(source); super.copy(source);
_exitBlendAnimationId = source._exitBlendAnimationId; _exitBlendAnimationId = source._exitBlendAnimationId;
} }

View File

@ -100,7 +100,7 @@ abstract class CubicInterpolatorBase<T extends CoreContext> extends Core<T> {
void y2Changed(double from, double to); void y2Changed(double from, double to);
@override @override
void copy(CubicInterpolatorBase source) { void copy(covariant CubicInterpolatorBase source) {
_x1 = source._x1; _x1 = source._x1;
_y1 = source._y1; _y1 = source._y1;
_x2 = source._x2; _x2 = source._x2;

View File

@ -36,7 +36,7 @@ abstract class KeyedObjectBase<T extends CoreContext> extends Core<T> {
void objectIdChanged(int from, int to); void objectIdChanged(int from, int to);
@override @override
void copy(KeyedObjectBase source) { void copy(covariant KeyedObjectBase source) {
_objectId = source._objectId; _objectId = source._objectId;
} }
} }

View File

@ -37,7 +37,7 @@ abstract class KeyedPropertyBase<T extends CoreContext> extends Core<T> {
void propertyKeyChanged(int from, int to); void propertyKeyChanged(int from, int to);
@override @override
void copy(KeyedPropertyBase source) { void copy(covariant KeyedPropertyBase source) {
_propertyKey = source._propertyKey; _propertyKey = source._propertyKey;
} }
} }

View File

@ -87,7 +87,7 @@ abstract class KeyFrameBase<T extends CoreContext> extends Core<T> {
void interpolatorIdChanged(int from, int to); void interpolatorIdChanged(int from, int to);
@override @override
void copy(KeyFrameBase source) { void copy(covariant KeyFrameBase source) {
_frame = source._frame; _frame = source._frame;
_interpolationType = source._interpolationType; _interpolationType = source._interpolationType;
_interpolatorId = source._interpolatorId; _interpolatorId = source._interpolatorId;

View File

@ -0,0 +1,42 @@
/// Core automatically generated
/// lib/src/generated/animation/keyframe_bool_base.dart.
/// Do not modify manually.
import 'package:rive/src/generated/animation/keyframe_base.dart';
import 'package:rive/src/rive_core/animation/keyframe.dart';
abstract class KeyFrameBoolBase extends KeyFrame {
static const int typeKey = 84;
@override
int get coreType => KeyFrameBoolBase.typeKey;
@override
Set<int> get coreTypes => {KeyFrameBoolBase.typeKey, KeyFrameBase.typeKey};
/// --------------------------------------------------------------------------
/// Value field with key 181.
static const bool valueInitialValue = false;
bool _value = valueInitialValue;
static const int valuePropertyKey = 181;
bool get value => _value;
/// Change the [_value] field value.
/// [valueChanged] will be invoked only if the field's value has changed.
set value(bool value) {
if (_value == value) {
return;
}
bool from = _value;
_value = value;
if (hasValidated) {
valueChanged(from, value);
}
}
void valueChanged(bool from, bool to);
@override
void copy(covariant KeyFrameBoolBase source) {
super.copy(source);
_value = source._value;
}
}

View File

@ -35,7 +35,7 @@ abstract class KeyFrameColorBase extends KeyFrame {
void valueChanged(int from, int to); void valueChanged(int from, int to);
@override @override
void copy(KeyFrameColorBase source) { void copy(covariant KeyFrameColorBase source) {
super.copy(source); super.copy(source);
_value = source._value; _value = source._value;
} }

View File

@ -35,7 +35,7 @@ abstract class KeyFrameDoubleBase extends KeyFrame {
void valueChanged(double from, double to); void valueChanged(double from, double to);
@override @override
void copy(KeyFrameDoubleBase source) { void copy(covariant KeyFrameDoubleBase source) {
super.copy(source); super.copy(source);
_value = source._value; _value = source._value;
} }

View File

@ -35,7 +35,7 @@ abstract class KeyFrameIdBase extends KeyFrame {
void valueChanged(int from, int to); void valueChanged(int from, int to);
@override @override
void copy(KeyFrameIdBase source) { void copy(covariant KeyFrameIdBase source) {
super.copy(source); super.copy(source);
_value = source._value; _value = source._value;
} }

View File

@ -184,7 +184,7 @@ abstract class LinearAnimationBase extends Animation {
void enableWorkAreaChanged(bool from, bool to); void enableWorkAreaChanged(bool from, bool to);
@override @override
void copy(LinearAnimationBase source) { void copy(covariant LinearAnimationBase source) {
super.copy(source); super.copy(source);
_fps = source._fps; _fps = source._fps;
_duration = source._duration; _duration = source._duration;

View File

@ -40,7 +40,7 @@ abstract class StateMachineBoolBase extends StateMachineInput {
void valueChanged(bool from, bool to); void valueChanged(bool from, bool to);
@override @override
void copy(StateMachineBoolBase source) { void copy(covariant StateMachineBoolBase source) {
super.copy(source); super.copy(source);
_value = source._value; _value = source._value;
} }

View File

@ -38,7 +38,7 @@ abstract class StateMachineComponentBase<T extends CoreContext>
void nameChanged(String from, String to); void nameChanged(String from, String to);
@override @override
void copy(StateMachineComponentBase source) { void copy(covariant StateMachineComponentBase source) {
_name = source._name; _name = source._name;
} }
} }

View File

@ -40,7 +40,7 @@ abstract class StateMachineNumberBase extends StateMachineInput {
void valueChanged(double from, double to); void valueChanged(double from, double to);
@override @override
void copy(StateMachineNumberBase source) { void copy(covariant StateMachineNumberBase source) {
super.copy(source); super.copy(source);
_value = source._value; _value = source._value;
} }

View File

@ -111,7 +111,7 @@ abstract class StateTransitionBase extends StateMachineLayerComponent {
void exitTimeChanged(int from, int to); void exitTimeChanged(int from, int to);
@override @override
void copy(StateTransitionBase source) { void copy(covariant StateTransitionBase source) {
super.copy(source); super.copy(source);
_stateToId = source._stateToId; _stateToId = source._stateToId;
_flags = source._flags; _flags = source._flags;

View File

@ -36,7 +36,7 @@ abstract class TransitionConditionBase<T extends CoreContext> extends Core<T> {
void inputIdChanged(int from, int to); void inputIdChanged(int from, int to);
@override @override
void copy(TransitionConditionBase source) { void copy(covariant TransitionConditionBase source) {
_inputId = source._inputId; _inputId = source._inputId;
} }
} }

View File

@ -40,7 +40,7 @@ abstract class TransitionNumberConditionBase extends TransitionValueCondition {
void valueChanged(double from, double to); void valueChanged(double from, double to);
@override @override
void copy(TransitionNumberConditionBase source) { void copy(covariant TransitionNumberConditionBase source) {
super.copy(source); super.copy(source);
_value = source._value; _value = source._value;
} }

View File

@ -38,7 +38,7 @@ abstract class TransitionValueConditionBase extends TransitionCondition {
void opValueChanged(int from, int to); void opValueChanged(int from, int to);
@override @override
void copy(TransitionValueConditionBase source) { void copy(covariant TransitionValueConditionBase source) {
super.copy(source); super.copy(source);
_opValue = source._opValue; _opValue = source._opValue;
} }

View File

@ -161,7 +161,7 @@ abstract class ArtboardBase extends ContainerComponent {
void originYChanged(double from, double to); void originYChanged(double from, double to);
@override @override
void copy(ArtboardBase source) { void copy(covariant ArtboardBase source) {
super.copy(source); super.copy(source);
_width = source._width; _width = source._width;
_height = source._height; _height = source._height;

View File

@ -43,7 +43,7 @@ abstract class BoneBase extends SkeletalComponent {
void lengthChanged(double from, double to); void lengthChanged(double from, double to);
@override @override
void copy(BoneBase source) { void copy(covariant BoneBase source) {
super.copy(source); super.copy(source);
_length = source._length; _length = source._length;
} }

View File

@ -102,7 +102,7 @@ abstract class CubicWeightBase extends Weight {
void outIndicesChanged(int from, int to); void outIndicesChanged(int from, int to);
@override @override
void copy(CubicWeightBase source) { void copy(covariant CubicWeightBase source) {
super.copy(source); super.copy(source);
_inValues = source._inValues; _inValues = source._inValues;
_inIndices = source._inIndices; _inIndices = source._inIndices;

View File

@ -71,7 +71,7 @@ abstract class RootBoneBase extends Bone {
void yChanged(double from, double to); void yChanged(double from, double to);
@override @override
void copy(RootBoneBase source) { void copy(covariant RootBoneBase source) {
super.copy(source); super.copy(source);
_x = source._x; _x = source._x;
_y = source._y; _y = source._y;

View File

@ -158,7 +158,7 @@ abstract class SkinBase extends ContainerComponent {
void tyChanged(double from, double to); void tyChanged(double from, double to);
@override @override
void copy(SkinBase source) { void copy(covariant SkinBase source) {
super.copy(source); super.copy(source);
_xx = source._xx; _xx = source._xx;
_yx = source._yx; _yx = source._yx;

View File

@ -180,7 +180,7 @@ abstract class TendonBase extends Component {
void tyChanged(double from, double to); void tyChanged(double from, double to);
@override @override
void copy(TendonBase source) { void copy(covariant TendonBase source) {
super.copy(source); super.copy(source);
_boneId = source._boneId; _boneId = source._boneId;
_xx = source._xx; _xx = source._xx;

View File

@ -56,7 +56,7 @@ abstract class WeightBase extends Component {
void indicesChanged(int from, int to); void indicesChanged(int from, int to);
@override @override
void copy(WeightBase source) { void copy(covariant WeightBase source) {
super.copy(source); super.copy(source);
_values = source._values; _values = source._values;
_indices = source._indices; _indices = source._indices;

View File

@ -60,7 +60,7 @@ abstract class ComponentBase<T extends CoreContext> extends Core<T> {
void parentIdChanged(int from, int to); void parentIdChanged(int from, int to);
@override @override
void copy(ComponentBase source) { void copy(covariant ComponentBase source) {
_name = source._name; _name = source._name;
_parentId = source._parentId; _parentId = source._parentId;
} }

View File

@ -37,7 +37,7 @@ abstract class ConstraintBase extends Component {
void strengthChanged(double from, double to); void strengthChanged(double from, double to);
@override @override
void copy(ConstraintBase source) { void copy(covariant ConstraintBase source) {
super.copy(source); super.copy(source);
_strength = source._strength; _strength = source._strength;
} }

View File

@ -69,7 +69,7 @@ abstract class DistanceConstraintBase extends TargetedConstraint {
void modeValueChanged(int from, int to); void modeValueChanged(int from, int to);
@override @override
void copy(DistanceConstraintBase source) { void copy(covariant DistanceConstraintBase source) {
super.copy(source); super.copy(source);
_distance = source._distance; _distance = source._distance;
_modeValue = source._modeValue; _modeValue = source._modeValue;

View File

@ -72,7 +72,7 @@ abstract class IKConstraintBase extends TargetedConstraint {
void parentBoneCountChanged(int from, int to); void parentBoneCountChanged(int from, int to);
@override @override
void copy(IKConstraintBase source) { void copy(covariant IKConstraintBase source) {
super.copy(source); super.copy(source);
_invertDirection = source._invertDirection; _invertDirection = source._invertDirection;
_parentBoneCount = source._parentBoneCount; _parentBoneCount = source._parentBoneCount;

View File

@ -0,0 +1,25 @@
/// Core automatically generated
/// lib/src/generated/constraints/rotation_constraint_base.dart.
/// Do not modify manually.
import 'package:rive/src/generated/component_base.dart';
import 'package:rive/src/generated/constraints/constraint_base.dart';
import 'package:rive/src/generated/constraints/targeted_constraint_base.dart';
import 'package:rive/src/generated/constraints/transform_component_constraint_base.dart';
import 'package:rive/src/generated/constraints/transform_space_constraint_base.dart';
import 'package:rive/src/rive_core/constraints/transform_component_constraint.dart';
abstract class RotationConstraintBase extends TransformComponentConstraint {
static const int typeKey = 89;
@override
int get coreType => RotationConstraintBase.typeKey;
@override
Set<int> get coreTypes => {
RotationConstraintBase.typeKey,
TransformComponentConstraintBase.typeKey,
TransformSpaceConstraintBase.typeKey,
TargetedConstraintBase.typeKey,
ConstraintBase.typeKey,
ComponentBase.typeKey
};
}

View File

@ -0,0 +1,27 @@
/// Core automatically generated
/// lib/src/generated/constraints/scale_constraint_base.dart.
/// Do not modify manually.
import 'package:rive/src/generated/component_base.dart';
import 'package:rive/src/generated/constraints/constraint_base.dart';
import 'package:rive/src/generated/constraints/targeted_constraint_base.dart';
import 'package:rive/src/generated/constraints/transform_component_constraint_base.dart';
import 'package:rive/src/generated/constraints/transform_component_constraint_y_base.dart';
import 'package:rive/src/generated/constraints/transform_space_constraint_base.dart';
import 'package:rive/src/rive_core/constraints/transform_component_constraint_y.dart';
abstract class ScaleConstraintBase extends TransformComponentConstraintY {
static const int typeKey = 88;
@override
int get coreType => ScaleConstraintBase.typeKey;
@override
Set<int> get coreTypes => {
ScaleConstraintBase.typeKey,
TransformComponentConstraintYBase.typeKey,
TransformComponentConstraintBase.typeKey,
TransformSpaceConstraintBase.typeKey,
TargetedConstraintBase.typeKey,
ConstraintBase.typeKey,
ComponentBase.typeKey
};
}

View File

@ -43,7 +43,7 @@ abstract class TargetedConstraintBase extends Constraint {
void targetIdChanged(int from, int to); void targetIdChanged(int from, int to);
@override @override
void copy(TargetedConstraintBase source) { void copy(covariant TargetedConstraintBase source) {
super.copy(source); super.copy(source);
_targetId = source._targetId; _targetId = source._targetId;
} }

View File

@ -0,0 +1,231 @@
/// Core automatically generated
/// lib/src/generated/constraints/transform_component_constraint_base.dart.
/// Do not modify manually.
import 'package:rive/src/generated/component_base.dart';
import 'package:rive/src/generated/constraints/constraint_base.dart';
import 'package:rive/src/generated/constraints/targeted_constraint_base.dart';
import 'package:rive/src/generated/constraints/transform_space_constraint_base.dart';
import 'package:rive/src/rive_core/constraints/transform_space_constraint.dart';
abstract class TransformComponentConstraintBase
extends TransformSpaceConstraint {
static const int typeKey = 85;
@override
int get coreType => TransformComponentConstraintBase.typeKey;
@override
Set<int> get coreTypes => {
TransformComponentConstraintBase.typeKey,
TransformSpaceConstraintBase.typeKey,
TargetedConstraintBase.typeKey,
ConstraintBase.typeKey,
ComponentBase.typeKey
};
/// --------------------------------------------------------------------------
/// MinMaxSpaceValue field with key 195.
static const int minMaxSpaceValueInitialValue = 0;
int _minMaxSpaceValue = minMaxSpaceValueInitialValue;
static const int minMaxSpaceValuePropertyKey = 195;
/// The min/max transform space.
int get minMaxSpaceValue => _minMaxSpaceValue;
/// Change the [_minMaxSpaceValue] field value.
/// [minMaxSpaceValueChanged] will be invoked only if the field's value has
/// changed.
set minMaxSpaceValue(int value) {
if (_minMaxSpaceValue == value) {
return;
}
int from = _minMaxSpaceValue;
_minMaxSpaceValue = value;
if (hasValidated) {
minMaxSpaceValueChanged(from, value);
}
}
void minMaxSpaceValueChanged(int from, int to);
/// --------------------------------------------------------------------------
/// CopyFactor field with key 182.
static const double copyFactorInitialValue = 1;
double _copyFactor = copyFactorInitialValue;
static const int copyFactorPropertyKey = 182;
/// Copy factor.
double get copyFactor => _copyFactor;
/// Change the [_copyFactor] field value.
/// [copyFactorChanged] will be invoked only if the field's value has changed.
set copyFactor(double value) {
if (_copyFactor == value) {
return;
}
double from = _copyFactor;
_copyFactor = value;
if (hasValidated) {
copyFactorChanged(from, value);
}
}
void copyFactorChanged(double from, double to);
/// --------------------------------------------------------------------------
/// MinValue field with key 183.
static const double minValueInitialValue = 0;
double _minValue = minValueInitialValue;
static const int minValuePropertyKey = 183;
/// Minimum value.
double get minValue => _minValue;
/// Change the [_minValue] field value.
/// [minValueChanged] will be invoked only if the field's value has changed.
set minValue(double value) {
if (_minValue == value) {
return;
}
double from = _minValue;
_minValue = value;
if (hasValidated) {
minValueChanged(from, value);
}
}
void minValueChanged(double from, double to);
/// --------------------------------------------------------------------------
/// MaxValue field with key 184.
static const double maxValueInitialValue = 0;
double _maxValue = maxValueInitialValue;
static const int maxValuePropertyKey = 184;
/// Maximum value.
double get maxValue => _maxValue;
/// Change the [_maxValue] field value.
/// [maxValueChanged] will be invoked only if the field's value has changed.
set maxValue(double value) {
if (_maxValue == value) {
return;
}
double from = _maxValue;
_maxValue = value;
if (hasValidated) {
maxValueChanged(from, value);
}
}
void maxValueChanged(double from, double to);
/// --------------------------------------------------------------------------
/// Offset field with key 188.
static const bool offsetInitialValue = false;
bool _offset = offsetInitialValue;
static const int offsetPropertyKey = 188;
/// True when the original component (rotation/scale/translation) is used to
/// offset the copied one.
bool get offset => _offset;
/// Change the [_offset] field value.
/// [offsetChanged] will be invoked only if the field's value has changed.
set offset(bool value) {
if (_offset == value) {
return;
}
bool from = _offset;
_offset = value;
if (hasValidated) {
offsetChanged(from, value);
}
}
void offsetChanged(bool from, bool to);
/// --------------------------------------------------------------------------
/// DoesCopy field with key 189.
static const bool doesCopyInitialValue = true;
bool _doesCopy = doesCopyInitialValue;
static const int doesCopyPropertyKey = 189;
/// Whether the component is copied.
bool get doesCopy => _doesCopy;
/// Change the [_doesCopy] field value.
/// [doesCopyChanged] will be invoked only if the field's value has changed.
set doesCopy(bool value) {
if (_doesCopy == value) {
return;
}
bool from = _doesCopy;
_doesCopy = value;
if (hasValidated) {
doesCopyChanged(from, value);
}
}
void doesCopyChanged(bool from, bool to);
/// --------------------------------------------------------------------------
/// Min field with key 190.
static const bool minInitialValue = false;
bool _min = minInitialValue;
static const int minPropertyKey = 190;
/// Whether min is used.
bool get min => _min;
/// Change the [_min] field value.
/// [minChanged] will be invoked only if the field's value has changed.
set min(bool value) {
if (_min == value) {
return;
}
bool from = _min;
_min = value;
if (hasValidated) {
minChanged(from, value);
}
}
void minChanged(bool from, bool to);
/// --------------------------------------------------------------------------
/// Max field with key 191.
static const bool maxInitialValue = false;
bool _max = maxInitialValue;
static const int maxPropertyKey = 191;
/// Whether max is used.
bool get max => _max;
/// Change the [_max] field value.
/// [maxChanged] will be invoked only if the field's value has changed.
set max(bool value) {
if (_max == value) {
return;
}
bool from = _max;
_max = value;
if (hasValidated) {
maxChanged(from, value);
}
}
void maxChanged(bool from, bool to);
@override
void copy(covariant TransformComponentConstraintBase source) {
super.copy(source);
_minMaxSpaceValue = source._minMaxSpaceValue;
_copyFactor = source._copyFactor;
_minValue = source._minValue;
_maxValue = source._maxValue;
_offset = source._offset;
_doesCopy = source._doesCopy;
_min = source._min;
_max = source._max;
}
}

View File

@ -0,0 +1,182 @@
/// Core automatically generated
/// lib/src/generated/constraints/transform_component_constraint_y_base.dart.
/// Do not modify manually.
import 'package:rive/src/generated/component_base.dart';
import 'package:rive/src/generated/constraints/constraint_base.dart';
import 'package:rive/src/generated/constraints/targeted_constraint_base.dart';
import 'package:rive/src/generated/constraints/transform_component_constraint_base.dart';
import 'package:rive/src/generated/constraints/transform_space_constraint_base.dart';
import 'package:rive/src/rive_core/constraints/transform_component_constraint.dart';
abstract class TransformComponentConstraintYBase
extends TransformComponentConstraint {
static const int typeKey = 86;
@override
int get coreType => TransformComponentConstraintYBase.typeKey;
@override
Set<int> get coreTypes => {
TransformComponentConstraintYBase.typeKey,
TransformComponentConstraintBase.typeKey,
TransformSpaceConstraintBase.typeKey,
TargetedConstraintBase.typeKey,
ConstraintBase.typeKey,
ComponentBase.typeKey
};
/// --------------------------------------------------------------------------
/// CopyFactorY field with key 185.
static const double copyFactorYInitialValue = 1;
double _copyFactorY = copyFactorYInitialValue;
static const int copyFactorYPropertyKey = 185;
/// Copy factor.
double get copyFactorY => _copyFactorY;
/// Change the [_copyFactorY] field value.
/// [copyFactorYChanged] will be invoked only if the field's value has
/// changed.
set copyFactorY(double value) {
if (_copyFactorY == value) {
return;
}
double from = _copyFactorY;
_copyFactorY = value;
if (hasValidated) {
copyFactorYChanged(from, value);
}
}
void copyFactorYChanged(double from, double to);
/// --------------------------------------------------------------------------
/// MinValueY field with key 186.
static const double minValueYInitialValue = 0;
double _minValueY = minValueYInitialValue;
static const int minValueYPropertyKey = 186;
/// Minimum value.
double get minValueY => _minValueY;
/// Change the [_minValueY] field value.
/// [minValueYChanged] will be invoked only if the field's value has changed.
set minValueY(double value) {
if (_minValueY == value) {
return;
}
double from = _minValueY;
_minValueY = value;
if (hasValidated) {
minValueYChanged(from, value);
}
}
void minValueYChanged(double from, double to);
/// --------------------------------------------------------------------------
/// MaxValueY field with key 187.
static const double maxValueYInitialValue = 0;
double _maxValueY = maxValueYInitialValue;
static const int maxValueYPropertyKey = 187;
/// Maximum value.
double get maxValueY => _maxValueY;
/// Change the [_maxValueY] field value.
/// [maxValueYChanged] will be invoked only if the field's value has changed.
set maxValueY(double value) {
if (_maxValueY == value) {
return;
}
double from = _maxValueY;
_maxValueY = value;
if (hasValidated) {
maxValueYChanged(from, value);
}
}
void maxValueYChanged(double from, double to);
/// --------------------------------------------------------------------------
/// DoesCopyY field with key 192.
static const bool doesCopyYInitialValue = true;
bool _doesCopyY = doesCopyYInitialValue;
static const int doesCopyYPropertyKey = 192;
/// Whether the Y component is copied.
bool get doesCopyY => _doesCopyY;
/// Change the [_doesCopyY] field value.
/// [doesCopyYChanged] will be invoked only if the field's value has changed.
set doesCopyY(bool value) {
if (_doesCopyY == value) {
return;
}
bool from = _doesCopyY;
_doesCopyY = value;
if (hasValidated) {
doesCopyYChanged(from, value);
}
}
void doesCopyYChanged(bool from, bool to);
/// --------------------------------------------------------------------------
/// MinY field with key 193.
static const bool minYInitialValue = false;
bool _minY = minYInitialValue;
static const int minYPropertyKey = 193;
/// Whether min Y is used.
bool get minY => _minY;
/// Change the [_minY] field value.
/// [minYChanged] will be invoked only if the field's value has changed.
set minY(bool value) {
if (_minY == value) {
return;
}
bool from = _minY;
_minY = value;
if (hasValidated) {
minYChanged(from, value);
}
}
void minYChanged(bool from, bool to);
/// --------------------------------------------------------------------------
/// MaxY field with key 194.
static const bool maxYInitialValue = false;
bool _maxY = maxYInitialValue;
static const int maxYPropertyKey = 194;
/// Whether max Y is used.
bool get maxY => _maxY;
/// Change the [_maxY] field value.
/// [maxYChanged] will be invoked only if the field's value has changed.
set maxY(bool value) {
if (_maxY == value) {
return;
}
bool from = _maxY;
_maxY = value;
if (hasValidated) {
maxYChanged(from, value);
}
}
void maxYChanged(bool from, bool to);
@override
void copy(covariant TransformComponentConstraintYBase source) {
super.copy(source);
_copyFactorY = source._copyFactorY;
_minValueY = source._minValueY;
_maxValueY = source._maxValueY;
_doesCopyY = source._doesCopyY;
_minY = source._minY;
_maxY = source._maxY;
}
}

View File

@ -5,74 +5,19 @@
import 'package:rive/src/generated/component_base.dart'; import 'package:rive/src/generated/component_base.dart';
import 'package:rive/src/generated/constraints/constraint_base.dart'; import 'package:rive/src/generated/constraints/constraint_base.dart';
import 'package:rive/src/generated/constraints/targeted_constraint_base.dart'; import 'package:rive/src/generated/constraints/targeted_constraint_base.dart';
import 'package:rive/src/rive_core/constraints/targeted_constraint.dart'; import 'package:rive/src/generated/constraints/transform_space_constraint_base.dart';
import 'package:rive/src/rive_core/constraints/transform_space_constraint.dart';
abstract class TransformConstraintBase extends TargetedConstraint { abstract class TransformConstraintBase extends TransformSpaceConstraint {
static const int typeKey = 83; static const int typeKey = 83;
@override @override
int get coreType => TransformConstraintBase.typeKey; int get coreType => TransformConstraintBase.typeKey;
@override @override
Set<int> get coreTypes => { Set<int> get coreTypes => {
TransformConstraintBase.typeKey, TransformConstraintBase.typeKey,
TransformSpaceConstraintBase.typeKey,
TargetedConstraintBase.typeKey, TargetedConstraintBase.typeKey,
ConstraintBase.typeKey, ConstraintBase.typeKey,
ComponentBase.typeKey ComponentBase.typeKey
}; };
/// --------------------------------------------------------------------------
/// SourceSpaceValue field with key 179.
static const int sourceSpaceValueInitialValue = 0;
int _sourceSpaceValue = sourceSpaceValueInitialValue;
static const int sourceSpaceValuePropertyKey = 179;
/// The source transform space.
int get sourceSpaceValue => _sourceSpaceValue;
/// Change the [_sourceSpaceValue] field value.
/// [sourceSpaceValueChanged] will be invoked only if the field's value has
/// changed.
set sourceSpaceValue(int value) {
if (_sourceSpaceValue == value) {
return;
}
int from = _sourceSpaceValue;
_sourceSpaceValue = value;
if (hasValidated) {
sourceSpaceValueChanged(from, value);
}
}
void sourceSpaceValueChanged(int from, int to);
/// --------------------------------------------------------------------------
/// DestSpaceValue field with key 180.
static const int destSpaceValueInitialValue = 0;
int _destSpaceValue = destSpaceValueInitialValue;
static const int destSpaceValuePropertyKey = 180;
/// The destination transform space.
int get destSpaceValue => _destSpaceValue;
/// Change the [_destSpaceValue] field value.
/// [destSpaceValueChanged] will be invoked only if the field's value has
/// changed.
set destSpaceValue(int value) {
if (_destSpaceValue == value) {
return;
}
int from = _destSpaceValue;
_destSpaceValue = value;
if (hasValidated) {
destSpaceValueChanged(from, value);
}
}
void destSpaceValueChanged(int from, int to);
@override
void copy(TransformConstraintBase source) {
super.copy(source);
_sourceSpaceValue = source._sourceSpaceValue;
_destSpaceValue = source._destSpaceValue;
}
} }

View File

@ -0,0 +1,78 @@
/// Core automatically generated
/// lib/src/generated/constraints/transform_space_constraint_base.dart.
/// Do not modify manually.
import 'package:rive/src/generated/component_base.dart';
import 'package:rive/src/generated/constraints/constraint_base.dart';
import 'package:rive/src/generated/constraints/targeted_constraint_base.dart';
import 'package:rive/src/rive_core/constraints/targeted_constraint.dart';
abstract class TransformSpaceConstraintBase extends TargetedConstraint {
static const int typeKey = 90;
@override
int get coreType => TransformSpaceConstraintBase.typeKey;
@override
Set<int> get coreTypes => {
TransformSpaceConstraintBase.typeKey,
TargetedConstraintBase.typeKey,
ConstraintBase.typeKey,
ComponentBase.typeKey
};
/// --------------------------------------------------------------------------
/// SourceSpaceValue field with key 179.
static const int sourceSpaceValueInitialValue = 0;
int _sourceSpaceValue = sourceSpaceValueInitialValue;
static const int sourceSpaceValuePropertyKey = 179;
/// The source transform space.
int get sourceSpaceValue => _sourceSpaceValue;
/// Change the [_sourceSpaceValue] field value.
/// [sourceSpaceValueChanged] will be invoked only if the field's value has
/// changed.
set sourceSpaceValue(int value) {
if (_sourceSpaceValue == value) {
return;
}
int from = _sourceSpaceValue;
_sourceSpaceValue = value;
if (hasValidated) {
sourceSpaceValueChanged(from, value);
}
}
void sourceSpaceValueChanged(int from, int to);
/// --------------------------------------------------------------------------
/// DestSpaceValue field with key 180.
static const int destSpaceValueInitialValue = 0;
int _destSpaceValue = destSpaceValueInitialValue;
static const int destSpaceValuePropertyKey = 180;
/// The destination transform space.
int get destSpaceValue => _destSpaceValue;
/// Change the [_destSpaceValue] field value.
/// [destSpaceValueChanged] will be invoked only if the field's value has
/// changed.
set destSpaceValue(int value) {
if (_destSpaceValue == value) {
return;
}
int from = _destSpaceValue;
_destSpaceValue = value;
if (hasValidated) {
destSpaceValueChanged(from, value);
}
}
void destSpaceValueChanged(int from, int to);
@override
void copy(covariant TransformSpaceConstraintBase source) {
super.copy(source);
_sourceSpaceValue = source._sourceSpaceValue;
_destSpaceValue = source._destSpaceValue;
}
}

View File

@ -0,0 +1,27 @@
/// Core automatically generated
/// lib/src/generated/constraints/translation_constraint_base.dart.
/// Do not modify manually.
import 'package:rive/src/generated/component_base.dart';
import 'package:rive/src/generated/constraints/constraint_base.dart';
import 'package:rive/src/generated/constraints/targeted_constraint_base.dart';
import 'package:rive/src/generated/constraints/transform_component_constraint_base.dart';
import 'package:rive/src/generated/constraints/transform_component_constraint_y_base.dart';
import 'package:rive/src/generated/constraints/transform_space_constraint_base.dart';
import 'package:rive/src/rive_core/constraints/transform_component_constraint_y.dart';
abstract class TranslationConstraintBase extends TransformComponentConstraintY {
static const int typeKey = 87;
@override
int get coreType => TranslationConstraintBase.typeKey;
@override
Set<int> get coreTypes => {
TranslationConstraintBase.typeKey,
TransformComponentConstraintYBase.typeKey,
TransformComponentConstraintBase.typeKey,
TransformSpaceConstraintBase.typeKey,
TargetedConstraintBase.typeKey,
ConstraintBase.typeKey,
ComponentBase.typeKey
};
}

View File

@ -42,7 +42,7 @@ abstract class DrawRulesBase extends ContainerComponent {
void drawTargetIdChanged(int from, int to); void drawTargetIdChanged(int from, int to);
@override @override
void copy(DrawRulesBase source) { void copy(covariant DrawRulesBase source) {
super.copy(source); super.copy(source);
_drawTargetId = source._drawTargetId; _drawTargetId = source._drawTargetId;
} }

View File

@ -61,7 +61,7 @@ abstract class DrawTargetBase extends Component {
void placementValueChanged(int from, int to); void placementValueChanged(int from, int to);
@override @override
void copy(DrawTargetBase source) { void copy(covariant DrawTargetBase source) {
super.copy(source); super.copy(source);
_drawableId = source._drawableId; _drawableId = source._drawableId;
_placementValue = source._placementValue; _placementValue = source._placementValue;

View File

@ -67,7 +67,7 @@ abstract class DrawableBase extends Node {
void drawableFlagsChanged(int from, int to); void drawableFlagsChanged(int from, int to);
@override @override
void copy(DrawableBase source) { void copy(covariant DrawableBase source) {
super.copy(source); super.copy(source);
_blendModeValue = source._blendModeValue; _blendModeValue = source._blendModeValue;
_drawableFlags = source._drawableFlags; _drawableFlags = source._drawableFlags;

View File

@ -67,7 +67,7 @@ abstract class NodeBase extends TransformComponent {
void yChanged(double from, double to); void yChanged(double from, double to);
@override @override
void copy(NodeBase source) { void copy(covariant NodeBase source) {
super.copy(source); super.copy(source);
_x = source._x; _x = source._x;
_y = source._y; _y = source._y;

View File

@ -20,6 +20,7 @@ import 'package:rive/src/generated/animation/exit_state_base.dart';
import 'package:rive/src/generated/animation/keyed_object_base.dart'; import 'package:rive/src/generated/animation/keyed_object_base.dart';
import 'package:rive/src/generated/animation/keyed_property_base.dart'; import 'package:rive/src/generated/animation/keyed_property_base.dart';
import 'package:rive/src/generated/animation/keyframe_base.dart'; import 'package:rive/src/generated/animation/keyframe_base.dart';
import 'package:rive/src/generated/animation/keyframe_bool_base.dart';
import 'package:rive/src/generated/animation/keyframe_color_base.dart'; import 'package:rive/src/generated/animation/keyframe_color_base.dart';
import 'package:rive/src/generated/animation/keyframe_double_base.dart'; import 'package:rive/src/generated/animation/keyframe_double_base.dart';
import 'package:rive/src/generated/animation/keyframe_id_base.dart'; import 'package:rive/src/generated/animation/keyframe_id_base.dart';
@ -48,8 +49,14 @@ import 'package:rive/src/generated/component_base.dart';
import 'package:rive/src/generated/constraints/constraint_base.dart'; import 'package:rive/src/generated/constraints/constraint_base.dart';
import 'package:rive/src/generated/constraints/distance_constraint_base.dart'; import 'package:rive/src/generated/constraints/distance_constraint_base.dart';
import 'package:rive/src/generated/constraints/ik_constraint_base.dart'; import 'package:rive/src/generated/constraints/ik_constraint_base.dart';
import 'package:rive/src/generated/constraints/rotation_constraint_base.dart';
import 'package:rive/src/generated/constraints/scale_constraint_base.dart';
import 'package:rive/src/generated/constraints/targeted_constraint_base.dart'; import 'package:rive/src/generated/constraints/targeted_constraint_base.dart';
import 'package:rive/src/generated/constraints/transform_component_constraint_base.dart';
import 'package:rive/src/generated/constraints/transform_component_constraint_y_base.dart';
import 'package:rive/src/generated/constraints/transform_constraint_base.dart'; import 'package:rive/src/generated/constraints/transform_constraint_base.dart';
import 'package:rive/src/generated/constraints/transform_space_constraint_base.dart';
import 'package:rive/src/generated/constraints/translation_constraint_base.dart';
import 'package:rive/src/generated/draw_rules_base.dart'; import 'package:rive/src/generated/draw_rules_base.dart';
import 'package:rive/src/generated/draw_target_base.dart'; import 'package:rive/src/generated/draw_target_base.dart';
import 'package:rive/src/generated/drawable_base.dart'; import 'package:rive/src/generated/drawable_base.dart';
@ -91,6 +98,7 @@ import 'package:rive/src/rive_core/animation/entry_state.dart';
import 'package:rive/src/rive_core/animation/exit_state.dart'; import 'package:rive/src/rive_core/animation/exit_state.dart';
import 'package:rive/src/rive_core/animation/keyed_object.dart'; import 'package:rive/src/rive_core/animation/keyed_object.dart';
import 'package:rive/src/rive_core/animation/keyed_property.dart'; import 'package:rive/src/rive_core/animation/keyed_property.dart';
import 'package:rive/src/rive_core/animation/keyframe_bool.dart';
import 'package:rive/src/rive_core/animation/keyframe_color.dart'; import 'package:rive/src/rive_core/animation/keyframe_color.dart';
import 'package:rive/src/rive_core/animation/keyframe_double.dart'; import 'package:rive/src/rive_core/animation/keyframe_double.dart';
import 'package:rive/src/rive_core/animation/keyframe_id.dart'; import 'package:rive/src/rive_core/animation/keyframe_id.dart';
@ -114,7 +122,10 @@ import 'package:rive/src/rive_core/bones/tendon.dart';
import 'package:rive/src/rive_core/bones/weight.dart'; import 'package:rive/src/rive_core/bones/weight.dart';
import 'package:rive/src/rive_core/constraints/distance_constraint.dart'; import 'package:rive/src/rive_core/constraints/distance_constraint.dart';
import 'package:rive/src/rive_core/constraints/ik_constraint.dart'; import 'package:rive/src/rive_core/constraints/ik_constraint.dart';
import 'package:rive/src/rive_core/constraints/rotation_constraint.dart';
import 'package:rive/src/rive_core/constraints/scale_constraint.dart';
import 'package:rive/src/rive_core/constraints/transform_constraint.dart'; import 'package:rive/src/rive_core/constraints/transform_constraint.dart';
import 'package:rive/src/rive_core/constraints/translation_constraint.dart';
import 'package:rive/src/rive_core/draw_rules.dart'; import 'package:rive/src/rive_core/draw_rules.dart';
import 'package:rive/src/rive_core/draw_target.dart'; import 'package:rive/src/rive_core/draw_target.dart';
import 'package:rive/src/rive_core/node.dart'; import 'package:rive/src/rive_core/node.dart';
@ -148,8 +159,14 @@ class RiveCoreContext {
return DistanceConstraint(); return DistanceConstraint();
case IKConstraintBase.typeKey: case IKConstraintBase.typeKey:
return IKConstraint(); return IKConstraint();
case TranslationConstraintBase.typeKey:
return TranslationConstraint();
case TransformConstraintBase.typeKey: case TransformConstraintBase.typeKey:
return TransformConstraint(); return TransformConstraint();
case ScaleConstraintBase.typeKey:
return ScaleConstraint();
case RotationConstraintBase.typeKey:
return RotationConstraint();
case AnimationStateBase.typeKey: case AnimationStateBase.typeKey:
return AnimationState(); return AnimationState();
case KeyedObjectBase.typeKey: case KeyedObjectBase.typeKey:
@ -164,6 +181,8 @@ class RiveCoreContext {
return KeyedProperty(); return KeyedProperty();
case KeyFrameIdBase.typeKey: case KeyFrameIdBase.typeKey:
return KeyFrameId(); return KeyFrameId();
case KeyFrameBoolBase.typeKey:
return KeyFrameBool();
case TransitionNumberConditionBase.typeKey: case TransitionNumberConditionBase.typeKey:
return TransitionNumberCondition(); return TransitionNumberCondition();
case AnyStateBase.typeKey: case AnyStateBase.typeKey:
@ -307,6 +326,86 @@ class RiveCoreContext {
object.modeValue = value; object.modeValue = value;
} }
break; break;
case TransformSpaceConstraintBase.sourceSpaceValuePropertyKey:
if (object is TransformSpaceConstraintBase && value is int) {
object.sourceSpaceValue = value;
}
break;
case TransformSpaceConstraintBase.destSpaceValuePropertyKey:
if (object is TransformSpaceConstraintBase && value is int) {
object.destSpaceValue = value;
}
break;
case TransformComponentConstraintBase.minMaxSpaceValuePropertyKey:
if (object is TransformComponentConstraintBase && value is int) {
object.minMaxSpaceValue = value;
}
break;
case TransformComponentConstraintBase.copyFactorPropertyKey:
if (object is TransformComponentConstraintBase && value is double) {
object.copyFactor = value;
}
break;
case TransformComponentConstraintBase.minValuePropertyKey:
if (object is TransformComponentConstraintBase && value is double) {
object.minValue = value;
}
break;
case TransformComponentConstraintBase.maxValuePropertyKey:
if (object is TransformComponentConstraintBase && value is double) {
object.maxValue = value;
}
break;
case TransformComponentConstraintBase.offsetPropertyKey:
if (object is TransformComponentConstraintBase && value is bool) {
object.offset = value;
}
break;
case TransformComponentConstraintBase.doesCopyPropertyKey:
if (object is TransformComponentConstraintBase && value is bool) {
object.doesCopy = value;
}
break;
case TransformComponentConstraintBase.minPropertyKey:
if (object is TransformComponentConstraintBase && value is bool) {
object.min = value;
}
break;
case TransformComponentConstraintBase.maxPropertyKey:
if (object is TransformComponentConstraintBase && value is bool) {
object.max = value;
}
break;
case TransformComponentConstraintYBase.copyFactorYPropertyKey:
if (object is TransformComponentConstraintYBase && value is double) {
object.copyFactorY = value;
}
break;
case TransformComponentConstraintYBase.minValueYPropertyKey:
if (object is TransformComponentConstraintYBase && value is double) {
object.minValueY = value;
}
break;
case TransformComponentConstraintYBase.maxValueYPropertyKey:
if (object is TransformComponentConstraintYBase && value is double) {
object.maxValueY = value;
}
break;
case TransformComponentConstraintYBase.doesCopyYPropertyKey:
if (object is TransformComponentConstraintYBase && value is bool) {
object.doesCopyY = value;
}
break;
case TransformComponentConstraintYBase.minYPropertyKey:
if (object is TransformComponentConstraintYBase && value is bool) {
object.minY = value;
}
break;
case TransformComponentConstraintYBase.maxYPropertyKey:
if (object is TransformComponentConstraintYBase && value is bool) {
object.maxY = value;
}
break;
case IKConstraintBase.invertDirectionPropertyKey: case IKConstraintBase.invertDirectionPropertyKey:
if (object is IKConstraintBase && value is bool) { if (object is IKConstraintBase && value is bool) {
object.invertDirection = value; object.invertDirection = value;
@ -317,16 +416,6 @@ class RiveCoreContext {
object.parentBoneCount = value; object.parentBoneCount = value;
} }
break; break;
case TransformConstraintBase.sourceSpaceValuePropertyKey:
if (object is TransformConstraintBase && value is int) {
object.sourceSpaceValue = value;
}
break;
case TransformConstraintBase.destSpaceValuePropertyKey:
if (object is TransformConstraintBase && value is int) {
object.destSpaceValue = value;
}
break;
case AnimationStateBase.animationIdPropertyKey: case AnimationStateBase.animationIdPropertyKey:
if (object is AnimationStateBase && value is int) { if (object is AnimationStateBase && value is int) {
object.animationId = value; object.animationId = value;
@ -387,6 +476,11 @@ class RiveCoreContext {
object.value = value; object.value = value;
} }
break; break;
case KeyFrameBoolBase.valuePropertyKey:
if (object is KeyFrameBoolBase && value is bool) {
object.value = value;
}
break;
case TransitionValueConditionBase.opValuePropertyKey: case TransitionValueConditionBase.opValuePropertyKey:
if (object is TransitionValueConditionBase && value is int) { if (object is TransitionValueConditionBase && value is int) {
object.opValue = value; object.opValue = value;
@ -946,9 +1040,10 @@ class RiveCoreContext {
case DrawTargetBase.placementValuePropertyKey: case DrawTargetBase.placementValuePropertyKey:
case TargetedConstraintBase.targetIdPropertyKey: case TargetedConstraintBase.targetIdPropertyKey:
case DistanceConstraintBase.modeValuePropertyKey: case DistanceConstraintBase.modeValuePropertyKey:
case TransformSpaceConstraintBase.sourceSpaceValuePropertyKey:
case TransformSpaceConstraintBase.destSpaceValuePropertyKey:
case TransformComponentConstraintBase.minMaxSpaceValuePropertyKey:
case IKConstraintBase.parentBoneCountPropertyKey: case IKConstraintBase.parentBoneCountPropertyKey:
case TransformConstraintBase.sourceSpaceValuePropertyKey:
case TransformConstraintBase.destSpaceValuePropertyKey:
case AnimationStateBase.animationIdPropertyKey: case AnimationStateBase.animationIdPropertyKey:
case KeyedObjectBase.objectIdPropertyKey: case KeyedObjectBase.objectIdPropertyKey:
case BlendAnimationBase.animationIdPropertyKey: case BlendAnimationBase.animationIdPropertyKey:
@ -992,6 +1087,12 @@ class RiveCoreContext {
return uintType; return uintType;
case ConstraintBase.strengthPropertyKey: case ConstraintBase.strengthPropertyKey:
case DistanceConstraintBase.distancePropertyKey: case DistanceConstraintBase.distancePropertyKey:
case TransformComponentConstraintBase.copyFactorPropertyKey:
case TransformComponentConstraintBase.minValuePropertyKey:
case TransformComponentConstraintBase.maxValuePropertyKey:
case TransformComponentConstraintYBase.copyFactorYPropertyKey:
case TransformComponentConstraintYBase.minValueYPropertyKey:
case TransformComponentConstraintYBase.maxValueYPropertyKey:
case StateMachineNumberBase.valuePropertyKey: case StateMachineNumberBase.valuePropertyKey:
case TransitionNumberConditionBase.valuePropertyKey: case TransitionNumberConditionBase.valuePropertyKey:
case CubicInterpolatorBase.x1PropertyKey: case CubicInterpolatorBase.x1PropertyKey:
@ -1061,7 +1162,15 @@ class RiveCoreContext {
case TendonBase.txPropertyKey: case TendonBase.txPropertyKey:
case TendonBase.tyPropertyKey: case TendonBase.tyPropertyKey:
return doubleType; return doubleType;
case TransformComponentConstraintBase.offsetPropertyKey:
case TransformComponentConstraintBase.doesCopyPropertyKey:
case TransformComponentConstraintBase.minPropertyKey:
case TransformComponentConstraintBase.maxPropertyKey:
case TransformComponentConstraintYBase.doesCopyYPropertyKey:
case TransformComponentConstraintYBase.minYPropertyKey:
case TransformComponentConstraintYBase.maxYPropertyKey:
case IKConstraintBase.invertDirectionPropertyKey: case IKConstraintBase.invertDirectionPropertyKey:
case KeyFrameBoolBase.valuePropertyKey:
case LinearAnimationBase.enableWorkAreaPropertyKey: case LinearAnimationBase.enableWorkAreaPropertyKey:
case StateMachineBoolBase.valuePropertyKey: case StateMachineBoolBase.valuePropertyKey:
case ShapePaintBase.isVisiblePropertyKey: case ShapePaintBase.isVisiblePropertyKey:
@ -1103,12 +1212,14 @@ class RiveCoreContext {
return (object as TargetedConstraintBase).targetId; return (object as TargetedConstraintBase).targetId;
case DistanceConstraintBase.modeValuePropertyKey: case DistanceConstraintBase.modeValuePropertyKey:
return (object as DistanceConstraintBase).modeValue; return (object as DistanceConstraintBase).modeValue;
case TransformSpaceConstraintBase.sourceSpaceValuePropertyKey:
return (object as TransformSpaceConstraintBase).sourceSpaceValue;
case TransformSpaceConstraintBase.destSpaceValuePropertyKey:
return (object as TransformSpaceConstraintBase).destSpaceValue;
case TransformComponentConstraintBase.minMaxSpaceValuePropertyKey:
return (object as TransformComponentConstraintBase).minMaxSpaceValue;
case IKConstraintBase.parentBoneCountPropertyKey: case IKConstraintBase.parentBoneCountPropertyKey:
return (object as IKConstraintBase).parentBoneCount; return (object as IKConstraintBase).parentBoneCount;
case TransformConstraintBase.sourceSpaceValuePropertyKey:
return (object as TransformConstraintBase).sourceSpaceValue;
case TransformConstraintBase.destSpaceValuePropertyKey:
return (object as TransformConstraintBase).destSpaceValue;
case AnimationStateBase.animationIdPropertyKey: case AnimationStateBase.animationIdPropertyKey:
return (object as AnimationStateBase).animationId; return (object as AnimationStateBase).animationId;
case KeyedObjectBase.objectIdPropertyKey: case KeyedObjectBase.objectIdPropertyKey:
@ -1199,6 +1310,18 @@ class RiveCoreContext {
return (object as ConstraintBase).strength; return (object as ConstraintBase).strength;
case DistanceConstraintBase.distancePropertyKey: case DistanceConstraintBase.distancePropertyKey:
return (object as DistanceConstraintBase).distance; return (object as DistanceConstraintBase).distance;
case TransformComponentConstraintBase.copyFactorPropertyKey:
return (object as TransformComponentConstraintBase).copyFactor;
case TransformComponentConstraintBase.minValuePropertyKey:
return (object as TransformComponentConstraintBase).minValue;
case TransformComponentConstraintBase.maxValuePropertyKey:
return (object as TransformComponentConstraintBase).maxValue;
case TransformComponentConstraintYBase.copyFactorYPropertyKey:
return (object as TransformComponentConstraintYBase).copyFactorY;
case TransformComponentConstraintYBase.minValueYPropertyKey:
return (object as TransformComponentConstraintYBase).minValueY;
case TransformComponentConstraintYBase.maxValueYPropertyKey:
return (object as TransformComponentConstraintYBase).maxValueY;
case StateMachineNumberBase.valuePropertyKey: case StateMachineNumberBase.valuePropertyKey:
return (object as StateMachineNumberBase).value; return (object as StateMachineNumberBase).value;
case TransitionNumberConditionBase.valuePropertyKey: case TransitionNumberConditionBase.valuePropertyKey:
@ -1341,8 +1464,24 @@ class RiveCoreContext {
static bool getBool(Core object, int propertyKey) { static bool getBool(Core object, int propertyKey) {
switch (propertyKey) { switch (propertyKey) {
case TransformComponentConstraintBase.offsetPropertyKey:
return (object as TransformComponentConstraintBase).offset;
case TransformComponentConstraintBase.doesCopyPropertyKey:
return (object as TransformComponentConstraintBase).doesCopy;
case TransformComponentConstraintBase.minPropertyKey:
return (object as TransformComponentConstraintBase).min;
case TransformComponentConstraintBase.maxPropertyKey:
return (object as TransformComponentConstraintBase).max;
case TransformComponentConstraintYBase.doesCopyYPropertyKey:
return (object as TransformComponentConstraintYBase).doesCopyY;
case TransformComponentConstraintYBase.minYPropertyKey:
return (object as TransformComponentConstraintYBase).minY;
case TransformComponentConstraintYBase.maxYPropertyKey:
return (object as TransformComponentConstraintYBase).maxY;
case IKConstraintBase.invertDirectionPropertyKey: case IKConstraintBase.invertDirectionPropertyKey:
return (object as IKConstraintBase).invertDirection; return (object as IKConstraintBase).invertDirection;
case KeyFrameBoolBase.valuePropertyKey:
return (object as KeyFrameBoolBase).value;
case LinearAnimationBase.enableWorkAreaPropertyKey: case LinearAnimationBase.enableWorkAreaPropertyKey:
return (object as LinearAnimationBase).enableWorkArea; return (object as LinearAnimationBase).enableWorkArea;
case StateMachineBoolBase.valuePropertyKey: case StateMachineBoolBase.valuePropertyKey:
@ -1420,21 +1559,26 @@ class RiveCoreContext {
object.modeValue = value; object.modeValue = value;
} }
break; break;
case IKConstraintBase.parentBoneCountPropertyKey: case TransformSpaceConstraintBase.sourceSpaceValuePropertyKey:
if (object is IKConstraintBase) { if (object is TransformSpaceConstraintBase) {
object.parentBoneCount = value;
}
break;
case TransformConstraintBase.sourceSpaceValuePropertyKey:
if (object is TransformConstraintBase) {
object.sourceSpaceValue = value; object.sourceSpaceValue = value;
} }
break; break;
case TransformConstraintBase.destSpaceValuePropertyKey: case TransformSpaceConstraintBase.destSpaceValuePropertyKey:
if (object is TransformConstraintBase) { if (object is TransformSpaceConstraintBase) {
object.destSpaceValue = value; object.destSpaceValue = value;
} }
break; break;
case TransformComponentConstraintBase.minMaxSpaceValuePropertyKey:
if (object is TransformComponentConstraintBase) {
object.minMaxSpaceValue = value;
}
break;
case IKConstraintBase.parentBoneCountPropertyKey:
if (object is IKConstraintBase) {
object.parentBoneCount = value;
}
break;
case AnimationStateBase.animationIdPropertyKey: case AnimationStateBase.animationIdPropertyKey:
if (object is AnimationStateBase) { if (object is AnimationStateBase) {
object.animationId = value; object.animationId = value;
@ -1650,6 +1794,36 @@ class RiveCoreContext {
object.distance = value; object.distance = value;
} }
break; break;
case TransformComponentConstraintBase.copyFactorPropertyKey:
if (object is TransformComponentConstraintBase) {
object.copyFactor = value;
}
break;
case TransformComponentConstraintBase.minValuePropertyKey:
if (object is TransformComponentConstraintBase) {
object.minValue = value;
}
break;
case TransformComponentConstraintBase.maxValuePropertyKey:
if (object is TransformComponentConstraintBase) {
object.maxValue = value;
}
break;
case TransformComponentConstraintYBase.copyFactorYPropertyKey:
if (object is TransformComponentConstraintYBase) {
object.copyFactorY = value;
}
break;
case TransformComponentConstraintYBase.minValueYPropertyKey:
if (object is TransformComponentConstraintYBase) {
object.minValueY = value;
}
break;
case TransformComponentConstraintYBase.maxValueYPropertyKey:
if (object is TransformComponentConstraintYBase) {
object.maxValueY = value;
}
break;
case StateMachineNumberBase.valuePropertyKey: case StateMachineNumberBase.valuePropertyKey:
if (object is StateMachineNumberBase) { if (object is StateMachineNumberBase) {
object.value = value; object.value = value;
@ -1995,11 +2169,51 @@ class RiveCoreContext {
static void setBool(Core object, int propertyKey, bool value) { static void setBool(Core object, int propertyKey, bool value) {
switch (propertyKey) { switch (propertyKey) {
case TransformComponentConstraintBase.offsetPropertyKey:
if (object is TransformComponentConstraintBase) {
object.offset = value;
}
break;
case TransformComponentConstraintBase.doesCopyPropertyKey:
if (object is TransformComponentConstraintBase) {
object.doesCopy = value;
}
break;
case TransformComponentConstraintBase.minPropertyKey:
if (object is TransformComponentConstraintBase) {
object.min = value;
}
break;
case TransformComponentConstraintBase.maxPropertyKey:
if (object is TransformComponentConstraintBase) {
object.max = value;
}
break;
case TransformComponentConstraintYBase.doesCopyYPropertyKey:
if (object is TransformComponentConstraintYBase) {
object.doesCopyY = value;
}
break;
case TransformComponentConstraintYBase.minYPropertyKey:
if (object is TransformComponentConstraintYBase) {
object.minY = value;
}
break;
case TransformComponentConstraintYBase.maxYPropertyKey:
if (object is TransformComponentConstraintYBase) {
object.maxY = value;
}
break;
case IKConstraintBase.invertDirectionPropertyKey: case IKConstraintBase.invertDirectionPropertyKey:
if (object is IKConstraintBase) { if (object is IKConstraintBase) {
object.invertDirection = value; object.invertDirection = value;
} }
break; break;
case KeyFrameBoolBase.valuePropertyKey:
if (object is KeyFrameBoolBase) {
object.value = value;
}
break;
case LinearAnimationBase.enableWorkAreaPropertyKey: case LinearAnimationBase.enableWorkAreaPropertyKey:
if (object is LinearAnimationBase) { if (object is LinearAnimationBase) {
object.enableWorkArea = value; object.enableWorkArea = value;

View File

@ -83,7 +83,7 @@ abstract class ClippingShapeBase extends Component {
void isVisibleChanged(bool from, bool to); void isVisibleChanged(bool from, bool to);
@override @override
void copy(ClippingShapeBase source) { void copy(covariant ClippingShapeBase source) {
super.copy(source); super.copy(source);
_sourceId = source._sourceId; _sourceId = source._sourceId;
_fillRule = source._fillRule; _fillRule = source._fillRule;

View File

@ -95,7 +95,7 @@ abstract class CubicAsymmetricVertexBase extends CubicVertex {
void outDistanceChanged(double from, double to); void outDistanceChanged(double from, double to);
@override @override
void copy(CubicAsymmetricVertexBase source) { void copy(covariant CubicAsymmetricVertexBase source) {
super.copy(source); super.copy(source);
_rotation = source._rotation; _rotation = source._rotation;
_inDistance = source._inDistance; _inDistance = source._inDistance;

View File

@ -120,7 +120,7 @@ abstract class CubicDetachedVertexBase extends CubicVertex {
void outDistanceChanged(double from, double to); void outDistanceChanged(double from, double to);
@override @override
void copy(CubicDetachedVertexBase source) { void copy(covariant CubicDetachedVertexBase source) {
super.copy(source); super.copy(source);
_inRotation = source._inRotation; _inRotation = source._inRotation;
_inDistance = source._inDistance; _inDistance = source._inDistance;

View File

@ -70,7 +70,7 @@ abstract class CubicMirroredVertexBase extends CubicVertex {
void distanceChanged(double from, double to); void distanceChanged(double from, double to);
@override @override
void copy(CubicMirroredVertexBase source) { void copy(covariant CubicMirroredVertexBase source) {
super.copy(source); super.copy(source);
_rotation = source._rotation; _rotation = source._rotation;
_distance = source._distance; _distance = source._distance;

View File

@ -41,7 +41,7 @@ abstract class FillBase extends ShapePaint {
void fillRuleChanged(int from, int to); void fillRuleChanged(int from, int to);
@override @override
void copy(FillBase source) { void copy(covariant FillBase source) {
super.copy(source); super.copy(source);
_fillRule = source._fillRule; _fillRule = source._fillRule;
} }

View File

@ -57,7 +57,7 @@ abstract class GradientStopBase extends Component {
void positionChanged(double from, double to); void positionChanged(double from, double to);
@override @override
void copy(GradientStopBase source) { void copy(covariant GradientStopBase source) {
super.copy(source); super.copy(source);
_colorValue = source._colorValue; _colorValue = source._colorValue;
_position = source._position; _position = source._position;

View File

@ -128,7 +128,7 @@ abstract class LinearGradientBase extends ContainerComponent {
void opacityChanged(double from, double to); void opacityChanged(double from, double to);
@override @override
void copy(LinearGradientBase source) { void copy(covariant LinearGradientBase source) {
super.copy(source); super.copy(source);
_startX = source._startX; _startX = source._startX;
_startY = source._startY; _startY = source._startY;

View File

@ -40,7 +40,7 @@ abstract class ShapePaintBase extends ContainerComponent {
void isVisibleChanged(bool from, bool to); void isVisibleChanged(bool from, bool to);
@override @override
void copy(ShapePaintBase source) { void copy(covariant ShapePaintBase source) {
super.copy(source); super.copy(source);
_isVisible = source._isVisible; _isVisible = source._isVisible;
} }

View File

@ -35,7 +35,7 @@ abstract class SolidColorBase extends Component {
void colorValueChanged(int from, int to); void colorValueChanged(int from, int to);
@override @override
void copy(SolidColorBase source) { void copy(covariant SolidColorBase source) {
super.copy(source); super.copy(source);
_colorValue = source._colorValue; _colorValue = source._colorValue;
} }

View File

@ -109,7 +109,7 @@ abstract class StrokeBase extends ShapePaint {
void transformAffectsStrokeChanged(bool from, bool to); void transformAffectsStrokeChanged(bool from, bool to);
@override @override
void copy(StrokeBase source) { void copy(covariant StrokeBase source) {
super.copy(source); super.copy(source);
_thickness = source._thickness; _thickness = source._thickness;
_cap = source._cap; _cap = source._cap;

View File

@ -101,7 +101,7 @@ abstract class TrimPathBase extends Component {
void modeValueChanged(int from, int to); void modeValueChanged(int from, int to);
@override @override
void copy(TrimPathBase source) { void copy(covariant TrimPathBase source) {
super.copy(source); super.copy(source);
_start = source._start; _start = source._start;
_end = source._end; _end = source._end;

View File

@ -120,7 +120,7 @@ abstract class ParametricPathBase extends Path {
void originYChanged(double from, double to); void originYChanged(double from, double to);
@override @override
void copy(ParametricPathBase source) { void copy(covariant ParametricPathBase source) {
super.copy(source); super.copy(source);
_width = source._width; _width = source._width;
_height = source._height; _height = source._height;

View File

@ -43,7 +43,7 @@ abstract class PathBase extends Node {
void pathFlagsChanged(int from, int to); void pathFlagsChanged(int from, int to);
@override @override
void copy(PathBase source) { void copy(covariant PathBase source) {
super.copy(source); super.copy(source);
_pathFlags = source._pathFlags; _pathFlags = source._pathFlags;
} }

View File

@ -65,7 +65,7 @@ abstract class PathVertexBase extends ContainerComponent {
void yChanged(double from, double to); void yChanged(double from, double to);
@override @override
void copy(PathVertexBase source) { void copy(covariant PathVertexBase source) {
super.copy(source); super.copy(source);
_x = source._x; _x = source._x;
_y = source._y; _y = source._y;

View File

@ -48,7 +48,7 @@ abstract class PointsPathBase extends Path {
void isClosedChanged(bool from, bool to); void isClosedChanged(bool from, bool to);
@override @override
void copy(PointsPathBase source) { void copy(covariant PointsPathBase source) {
super.copy(source); super.copy(source);
_isClosed = source._isClosed; _isClosed = source._isClosed;
} }

View File

@ -74,7 +74,7 @@ abstract class PolygonBase extends ParametricPath {
void cornerRadiusChanged(double from, double to); void cornerRadiusChanged(double from, double to);
@override @override
void copy(PolygonBase source) { void copy(covariant PolygonBase source) {
super.copy(source); super.copy(source);
_points = source._points; _points = source._points;
_cornerRadius = source._cornerRadius; _cornerRadius = source._cornerRadius;

View File

@ -150,7 +150,7 @@ abstract class RectangleBase extends ParametricPath {
void cornerRadiusBRChanged(double from, double to); void cornerRadiusBRChanged(double from, double to);
@override @override
void copy(RectangleBase source) { void copy(covariant RectangleBase source) {
super.copy(source); super.copy(source);
_linkCornerRadius = source._linkCornerRadius; _linkCornerRadius = source._linkCornerRadius;
_cornerRadiusTL = source._cornerRadiusTL; _cornerRadiusTL = source._cornerRadiusTL;

View File

@ -52,7 +52,7 @@ abstract class StarBase extends Polygon {
void innerRadiusChanged(double from, double to); void innerRadiusChanged(double from, double to);
@override @override
void copy(StarBase source) { void copy(covariant StarBase source) {
super.copy(source); super.copy(source);
_innerRadius = source._innerRadius; _innerRadius = source._innerRadius;
} }

View File

@ -45,7 +45,7 @@ abstract class StraightVertexBase extends PathVertex<Weight> {
void radiusChanged(double from, double to); void radiusChanged(double from, double to);
@override @override
void copy(StraightVertexBase source) { void copy(covariant StraightVertexBase source) {
super.copy(source); super.copy(source);
_radius = source._radius; _radius = source._radius;
} }

View File

@ -106,7 +106,7 @@ abstract class TransformComponentBase extends ContainerComponent {
void opacityChanged(double from, double to); void opacityChanged(double from, double to);
@override @override
void copy(TransformComponentBase source) { void copy(covariant TransformComponentBase source) {
super.copy(source); super.copy(source);
_rotation = source._rotation; _rotation = source._rotation;
_scaleX = source._scaleX; _scaleX = source._scaleX;

View File

@ -0,0 +1,24 @@
import 'package:rive/src/core/core.dart';
import 'package:rive/src/generated/animation/keyframe_bool_base.dart';
import 'package:rive/src/generated/rive_core_context.dart';
export 'package:rive/src/generated/animation/keyframe_bool_base.dart';
/// KeyFrame for animating bool properties.
class KeyFrameBool extends KeyFrameBoolBase {
@override
bool get canInterpolate => false;
@override
void apply(Core<CoreContext> object, int propertyKey, double mix) {
RiveCoreContext.setBool(object, propertyKey, value);
}
@override
void applyInterpolation(Core<CoreContext> object, int propertyKey,
double currentTime, KeyFrameBool nextFrame, double mix) {
RiveCoreContext.setBool(object, propertyKey, value);
}
@override
void valueChanged(bool from, bool to) {}
}

View File

@ -3,10 +3,6 @@ import 'package:rive/src/generated/animation/keyframe_double_base.dart';
import 'package:rive/src/generated/rive_core_context.dart'; import 'package:rive/src/generated/rive_core_context.dart';
export 'package:rive/src/generated/animation/keyframe_double_base.dart'; export 'package:rive/src/generated/animation/keyframe_double_base.dart';
double toDegrees(double rad) {
return rad / 3.14 * 180;
}
void _apply( void _apply(
Core<CoreContext> object, int propertyKey, double mix, double value) { Core<CoreContext> object, int propertyKey, double mix, double value) {
if (mix == 1) { if (mix == 1) {

View File

@ -5,4 +5,46 @@ class ComponentFlags {
// Whether the component was locked for editing in the editor. // Whether the component was locked for editing in the editor.
static const int locked = 1 << 1; static const int locked = 1 << 1;
/// These options are used by [TransformComponentConstraint]s, any other
/// component that's not in that class hierarchy can re-use these values as
/// they won't collide.
///
/// -----------
/// Whether the [TransformComponentConstraint]'s constrained value is offset
/// from the design time value (in the matching space).
static const int offset = 1 << 2;
/// Whether the transform component is copied.
static const int copy = 1 << 3;
/// Set when a minimum value should be applied to the constrained value.
static const int min = 1 << 4;
/// Set when a maximum value should be applied to the constrained value.
static const int max = 1 << 5;
/// Whether an X transform component is copied.
static const int copyX = 1 << 3;
/// Set when a minimum value should be applied to the constrained X value.
static const int minX = 1 << 4;
/// Set when a maximum value should be applied to the constrained X value.
static const int maxX = 1 << 5;
/// Whether a Y transform component is copied.
static const int copyY = 1 << 6;
/// Set when a minimum value should be applied to the constrained Y value.
static const int minY = 1 << 7;
/// Set when a maximum value should be applied to the constrained Y value.
static const int maxY = 1 << 8;
/// End of TransformComponentConstraint
///
/// ----------
} }

View File

@ -0,0 +1,101 @@
import 'dart:math';
import 'package:rive/src/rive_core/constraints/constraint.dart';
import 'package:rive/src/rive_core/math/mat2d.dart';
import 'package:rive/src/rive_core/math/transform_components.dart';
import 'package:rive/src/generated/constraints/rotation_constraint_base.dart';
import 'package:rive/src/rive_core/transform_component.dart';
import 'package:rive/src/rive_core/transform_space.dart';
export 'package:rive/src/generated/constraints/rotation_constraint_base.dart';
/// A constraint copies the rotation from the target component to the
/// constrained component in world or local space and applies copy/min/max
/// rules.
class RotationConstraint extends RotationConstraintBase {
@override
void constrain(TransformComponent component) {
var transformA = component.worldTransform;
var transformB = Mat2D();
Mat2D.decompose(transformA, componentsA);
if (target == null) {
Mat2D.copy(transformB, transformA);
TransformComponents.copy(componentsB, componentsA);
} else {
Mat2D.copy(transformB, target!.worldTransform);
if (sourceSpace == TransformSpace.local) {
var inverse = Mat2D();
if (!Mat2D.invert(inverse, parentWorld(target!))) {
return;
}
Mat2D.multiply(transformB, inverse, transformB);
}
Mat2D.decompose(transformB, componentsB);
if (!doesCopy) {
componentsB.rotation =
destSpace == TransformSpace.local ? 1 : componentsA.rotation;
} else {
componentsB.rotation = componentsB.rotation * copyFactor;
if (offset) {
componentsB.rotation = componentsB.rotation + component.rotation;
}
}
if (destSpace == TransformSpace.local) {
// Destination space is in parent transform coordinates. Recompose the
// parent local transform and get it in world, then decompose the world
// for interpolation.
Mat2D.compose(transformB, componentsB);
var grandParentWorld = parentWorld(component);
Mat2D.multiply(transformB, grandParentWorld, transformB);
Mat2D.decompose(transformB, componentsB);
}
}
bool clampLocal = minMaxSpace == TransformSpace.local;
if (clampLocal) {
// Apply min max in local space, so transform to local coordinates first.
Mat2D.compose(transformB, componentsB);
Mat2D inverse = Mat2D();
if (!Mat2D.invert(inverse, parentWorld(component))) {
return;
}
Mat2D.multiply(transformB, inverse, transformB);
Mat2D.decompose(transformB, componentsB);
}
if (this.max && componentsB.rotation > maxValue) {
componentsB.rotation = maxValue;
}
if (this.min && componentsB.rotation < minValue) {
componentsB.rotation = minValue;
}
if (clampLocal) {
// Transform back to world.
Mat2D.compose(transformB, componentsB);
Mat2D.multiply(transformB, parentWorld(component), transformB);
Mat2D.decompose(transformB, componentsB);
}
var pi2 = pi * 2;
var angleA = componentsA.rotation % pi2;
var angleB = componentsB.rotation % pi2;
var diff = angleB - angleA;
if (diff > pi) {
diff -= pi2;
} else if (diff < -pi) {
diff += pi2;
}
componentsB.rotation = componentsA.rotation + diff * strength;
componentsB.x = componentsA.x;
componentsB.y = componentsA.y;
componentsB.scaleX = componentsA.scaleX;
componentsB.scaleY = componentsA.scaleY;
componentsB.skew = componentsA.skew;
Mat2D.compose(component.worldTransform, componentsB);
}
}

View File

@ -0,0 +1,106 @@
import 'package:rive/src/rive_core/constraints/constraint.dart';
import 'package:rive/src/rive_core/math/mat2d.dart';
import 'package:rive/src/rive_core/math/transform_components.dart';
import 'package:rive/src/generated/constraints/scale_constraint_base.dart';
import 'package:rive/src/rive_core/transform_component.dart';
import 'package:rive/src/rive_core/transform_space.dart';
export 'package:rive/src/generated/constraints/scale_constraint_base.dart';
/// A constraint copies the scale from the target component to the
/// constrained component in world or local space and applies copy/min/max
/// rules.
class ScaleConstraint extends ScaleConstraintBase {
@override
void constrain(TransformComponent component) {
var transformA = component.worldTransform;
var transformB = Mat2D();
Mat2D.decompose(transformA, componentsA);
if (target == null) {
Mat2D.copy(transformB, transformA);
TransformComponents.copy(componentsB, componentsA);
} else {
Mat2D.copy(transformB, target!.worldTransform);
if (sourceSpace == TransformSpace.local) {
var inverse = Mat2D();
if (!Mat2D.invert(inverse, parentWorld(target!))) {
return;
}
Mat2D.multiply(transformB, inverse, transformB);
}
Mat2D.decompose(transformB, componentsB);
if (!doesCopy) {
componentsB.scaleX =
destSpace == TransformSpace.local ? 1 : componentsA.scaleX;
} else {
componentsB.scaleX = componentsB.scaleX * copyFactor;
if (offset) {
componentsB.scaleX = componentsB.scaleX * component.scaleX;
}
}
if (!doesCopyY) {
componentsB.scaleY =
destSpace == TransformSpace.local ? 0 : componentsA.scaleY;
} else {
componentsB.scaleY = componentsB.scaleY * copyFactorY;
if (offset) {
componentsB.scaleY = componentsB.scaleY * component.scaleY;
}
}
if (destSpace == TransformSpace.local) {
// Destination space is in parent transform coordinates. Recompose the
// parent local transform and get it in world, then decompose the world
// for interpolation.
Mat2D.compose(transformB, componentsB);
Mat2D.multiply(transformB, parentWorld(component), transformB);
Mat2D.decompose(transformB, componentsB);
}
}
bool clamplocal = minMaxSpace == TransformSpace.local;
if (clamplocal) {
// Apply min max in local space, so transform to local coordinates first.
Mat2D.compose(transformB, componentsB);
var inverse = Mat2D();
if (!Mat2D.invert(inverse, parentWorld(component))) {
return;
}
Mat2D.multiply(transformB, inverse, transformB);
Mat2D.decompose(transformB, componentsB);
}
if (max && componentsB.scaleX > maxValue) {
componentsB.scaleX = maxValue;
}
if (min && componentsB.scaleX < minValue) {
componentsB.scaleX = minValue;
}
if (maxY && componentsB.scaleY > maxValueY) {
componentsB.scaleY = maxValueY;
}
if (minY && componentsB.scaleY < minValueY) {
componentsB.scaleY = minValueY;
}
if (clamplocal) {
// Transform back to world.
Mat2D.compose(transformB, componentsB);
Mat2D.multiply(transformB, parentWorld(component), transformB);
Mat2D.decompose(transformB, componentsB);
}
var ti = 1 - strength;
componentsB.rotation = componentsA.rotation;
componentsB.x = componentsA.x;
componentsB.y = componentsA.y;
componentsB.scaleX =
componentsA.scaleX * ti + componentsB.scaleX * strength;
componentsB.scaleY =
componentsA.scaleY * ti + componentsB.scaleY * strength;
componentsB.skew = componentsA.skew;
Mat2D.compose(component.worldTransform, componentsB);
}
}

View File

@ -0,0 +1,33 @@
import 'package:rive/src/generated/constraints/transform_component_constraint_base.dart';
import 'package:rive/src/rive_core/transform_space.dart';
export 'package:rive/src/generated/constraints/transform_component_constraint_base.dart';
abstract class TransformComponentConstraint
extends TransformComponentConstraintBase {
TransformSpace get minMaxSpace => TransformSpace.values[minMaxSpaceValue];
set minMaxSpace(TransformSpace value) => minMaxSpaceValue = value.index;
@override
void minMaxSpaceValueChanged(int from, int to) => markConstraintDirty();
@override
void minValueChanged(double from, double to) => markConstraintDirty();
@override
void maxValueChanged(double from, double to) => markConstraintDirty();
@override
void copyFactorChanged(double from, double to) => markConstraintDirty();
@override
void doesCopyChanged(bool from, bool to) => markConstraintDirty();
@override
void maxChanged(bool from, bool to) => markConstraintDirty();
@override
void minChanged(bool from, bool to) => markConstraintDirty();
@override
void offsetChanged(bool from, bool to) => markConstraintDirty();
}

View File

@ -0,0 +1,23 @@
import 'package:rive/src/generated/constraints/transform_component_constraint_y_base.dart';
export 'package:rive/src/generated/constraints/transform_component_constraint_y_base.dart';
abstract class TransformComponentConstraintY
extends TransformComponentConstraintYBase {
@override
void minValueYChanged(double from, double to) => markConstraintDirty();
@override
void maxValueYChanged(double from, double to) => markConstraintDirty();
@override
void copyFactorYChanged(double from, double to) => markConstraintDirty();
@override
void doesCopyYChanged(bool from, bool to) => markConstraintDirty();
@override
void maxYChanged(bool from, bool to) => markConstraintDirty();
@override
void minYChanged(bool from, bool to) => markConstraintDirty();
}

View File

@ -2,7 +2,6 @@ import 'dart:math';
import 'package:rive/src/rive_core/constraints/constraint.dart'; import 'package:rive/src/rive_core/constraints/constraint.dart';
import 'package:rive/src/rive_core/math/mat2d.dart'; import 'package:rive/src/rive_core/math/mat2d.dart';
import 'package:rive/src/rive_core/math/transform_components.dart';
import 'package:rive/src/generated/constraints/transform_constraint_base.dart'; import 'package:rive/src/generated/constraints/transform_constraint_base.dart';
import 'package:rive/src/rive_core/transform_component.dart'; import 'package:rive/src/rive_core/transform_component.dart';
import 'package:rive/src/rive_core/transform_space.dart'; import 'package:rive/src/rive_core/transform_space.dart';
@ -11,21 +10,6 @@ export 'package:rive/src/generated/constraints/transform_constraint_base.dart';
/// A constraint copies the transform from the target component to the /// A constraint copies the transform from the target component to the
/// constrained component in world or local space. /// constrained component in world or local space.
class TransformConstraint extends TransformConstraintBase { class TransformConstraint extends TransformConstraintBase {
final TransformComponents componentsA = TransformComponents();
final TransformComponents componentsB = TransformComponents();
TransformSpace get destSpace => TransformSpace.values[destSpaceValue];
set destSpace(TransformSpace value) => destSpaceValue = value.index;
TransformSpace get sourceSpace => TransformSpace.values[sourceSpaceValue];
set sourceSpace(TransformSpace value) => sourceSpaceValue = value.index;
@override
void destSpaceValueChanged(int from, int to) => markConstraintDirty();
@override
void sourceSpaceValueChanged(int from, int to) => markConstraintDirty();
@override @override
void constrain(TransformComponent component) { void constrain(TransformComponent component) {
if (target == null) { if (target == null) {

View File

@ -0,0 +1,21 @@
import 'package:rive/src/rive_core/math/transform_components.dart';
import 'package:rive/src/generated/constraints/transform_space_constraint_base.dart';
import 'package:rive/src/rive_core/transform_space.dart';
export 'package:rive/src/generated/constraints/transform_space_constraint_base.dart';
abstract class TransformSpaceConstraint extends TransformSpaceConstraintBase {
final TransformComponents componentsA = TransformComponents();
final TransformComponents componentsB = TransformComponents();
TransformSpace get destSpace => TransformSpace.values[destSpaceValue];
set destSpace(TransformSpace value) => destSpaceValue = value.index;
TransformSpace get sourceSpace => TransformSpace.values[sourceSpaceValue];
set sourceSpace(TransformSpace value) => sourceSpaceValue = value.index;
@override
void destSpaceValueChanged(int from, int to) => markConstraintDirty();
@override
void sourceSpaceValueChanged(int from, int to) => markConstraintDirty();
}

View File

@ -0,0 +1,93 @@
import 'package:rive/src/rive_core/constraints/constraint.dart';
import 'package:rive/src/rive_core/math/mat2d.dart';
import 'package:rive/src/rive_core/math/vec2d.dart';
import 'package:rive/src/generated/constraints/translation_constraint_base.dart';
import 'package:rive/src/rive_core/transform_component.dart';
import 'package:rive/src/rive_core/transform_space.dart';
export 'package:rive/src/generated/constraints/translation_constraint_base.dart';
/// A constraint copies the translation from the target component to the
/// constrained component in world or local space and applies copy/min/max
/// rules.
class TranslationConstraint extends TranslationConstraintBase {
@override
void constrain(TransformComponent component) {
var transformA = component.worldTransform;
var translationA = Vec2D.fromValues(transformA[4], transformA[5]);
var translationB = Vec2D();
if (target == null) {
Vec2D.copy(translationB, translationA);
} else {
var transformB = Mat2D.clone(target!.worldTransform);
if (sourceSpace == TransformSpace.local) {
var inverse = Mat2D();
if (!Mat2D.invert(inverse, parentWorld(target!))) {
return;
}
Mat2D.multiply(transformB, inverse, transformB);
}
translationB[0] = transformB[4];
translationB[1] = transformB[5];
if (!doesCopy) {
translationB[0] =
destSpace == TransformSpace.local ? 0 : translationA[0];
} else {
translationB[0] *= copyFactor;
if (offset) {
translationB[0] += component.x;
}
}
if (!doesCopyY) {
translationB[1] =
destSpace == TransformSpace.local ? 0 : translationA[1];
} else {
translationB[1] *= copyFactorY;
if (offset) {
translationB[1] += component.y;
}
}
if (destSpace == TransformSpace.local) {
// Destination space is in parent transform coordinates.
Vec2D.transformMat2D(
translationB, translationB, parentWorld(component));
}
}
bool clampLocal = minMaxSpace == TransformSpace.local;
if (clampLocal) {
// Apply min max in local space, so transform to local coordinates first.
var invert = Mat2D();
if (!Mat2D.invert(invert, parentWorld(component))) {
return;
}
// Get our target world coordinates in parent local.
Vec2D.transformMat2D(translationB, translationB, invert);
}
if (max && translationB[0] > maxValue) {
translationB[0] = maxValue;
}
if (min && translationB[0] < minValue) {
translationB[0] = minValue;
}
if (maxY && translationB[1] > maxValueY) {
translationB[1] = maxValueY;
}
if (minY && translationB[1] < minValueY) {
translationB[1] = minValueY;
}
if (clampLocal) {
// Transform back to world.
Vec2D.transformMat2D(translationB, translationB, parentWorld(component));
}
var ti = 1 - strength;
// Just interpolate world translation
transformA[4] = translationA[0] * ti + translationB[0] * strength;
transformA[5] = translationA[1] * ti + translationB[1] * strength;
}
}

View File

@ -3,7 +3,10 @@ import 'package:rive/src/rive_core/component.dart';
import 'package:rive/src/rive_core/component_dirt.dart'; import 'package:rive/src/rive_core/component_dirt.dart';
import 'package:rive/src/rive_core/constraints/constraint.dart'; import 'package:rive/src/rive_core/constraints/constraint.dart';
import 'package:rive/src/rive_core/constraints/ik_constraint.dart'; import 'package:rive/src/rive_core/constraints/ik_constraint.dart';
import 'package:rive/src/rive_core/constraints/rotation_constraint.dart';
import 'package:rive/src/rive_core/constraints/scale_constraint.dart';
import 'package:rive/src/rive_core/constraints/transform_constraint.dart'; import 'package:rive/src/rive_core/constraints/transform_constraint.dart';
import 'package:rive/src/rive_core/constraints/translation_constraint.dart';
import 'package:rive/src/rive_core/container_component.dart'; import 'package:rive/src/rive_core/container_component.dart';
import 'package:rive/src/rive_core/draw_rules.dart'; import 'package:rive/src/rive_core/draw_rules.dart';
import 'package:rive/src/rive_core/drawable.dart'; import 'package:rive/src/rive_core/drawable.dart';
@ -169,6 +172,9 @@ abstract class TransformComponent extends TransformComponentBase {
case TransformConstraintBase.typeKey: case TransformConstraintBase.typeKey:
case IKConstraintBase.typeKey: case IKConstraintBase.typeKey:
case DistanceConstraintBase.typeKey: case DistanceConstraintBase.typeKey:
case TranslationConstraintBase.typeKey:
case RotationConstraintBase.typeKey:
case ScaleConstraintBase.typeKey:
_constraints.add(child as Constraint); _constraints.add(child as Constraint);
break; break;
} }