mirror of
https://github.com/rive-app/rive-flutter.git
synced 2025-05-19 22:36:51 +08:00
Adding support for corner radius.
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
## [0.7.3] - 2021-04-19 16:53:18
|
||||
- Adding support for Rectangle corner radius properties and animation.
|
||||
|
||||
## [0.7.2] - 2021-04-12 16:57:54
|
||||
- Breaking change! StateMachineInput has been renamed to SMIInput to follow conventions in other runtimes and clearly disambiguate between core.StateMachineInput (the backing type in Rive's core system, which is not explicitly exposed to this runtime) and the input instances which should be used by controllers in the Flutter ecosystem.
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
```yaml
|
||||
dependencies:
|
||||
rive: ^0.7.2
|
||||
rive: ^0.7.3
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
@ -627,9 +627,29 @@ class RiveCoreContext {
|
||||
object.originY = value;
|
||||
}
|
||||
break;
|
||||
case RectangleBase.cornerRadiusPropertyKey:
|
||||
case RectangleBase.linkCornerRadiusPropertyKey:
|
||||
if (object is RectangleBase && value is bool) {
|
||||
object.linkCornerRadius = value;
|
||||
}
|
||||
break;
|
||||
case RectangleBase.cornerRadiusTLPropertyKey:
|
||||
if (object is RectangleBase && value is double) {
|
||||
object.cornerRadius = value;
|
||||
object.cornerRadiusTL = value;
|
||||
}
|
||||
break;
|
||||
case RectangleBase.cornerRadiusTRPropertyKey:
|
||||
if (object is RectangleBase && value is double) {
|
||||
object.cornerRadiusTR = value;
|
||||
}
|
||||
break;
|
||||
case RectangleBase.cornerRadiusBLPropertyKey:
|
||||
if (object is RectangleBase && value is double) {
|
||||
object.cornerRadiusBL = value;
|
||||
}
|
||||
break;
|
||||
case RectangleBase.cornerRadiusBRPropertyKey:
|
||||
if (object is RectangleBase && value is double) {
|
||||
object.cornerRadiusBR = value;
|
||||
}
|
||||
break;
|
||||
case CubicMirroredVertexBase.rotationPropertyKey:
|
||||
@ -895,7 +915,10 @@ class RiveCoreContext {
|
||||
case ParametricPathBase.heightPropertyKey:
|
||||
case ParametricPathBase.originXPropertyKey:
|
||||
case ParametricPathBase.originYPropertyKey:
|
||||
case RectangleBase.cornerRadiusPropertyKey:
|
||||
case RectangleBase.cornerRadiusTLPropertyKey:
|
||||
case RectangleBase.cornerRadiusTRPropertyKey:
|
||||
case RectangleBase.cornerRadiusBLPropertyKey:
|
||||
case RectangleBase.cornerRadiusBRPropertyKey:
|
||||
case CubicMirroredVertexBase.rotationPropertyKey:
|
||||
case CubicMirroredVertexBase.distancePropertyKey:
|
||||
case PolygonBase.cornerRadiusPropertyKey:
|
||||
@ -935,6 +958,7 @@ class RiveCoreContext {
|
||||
case ShapePaintBase.isVisiblePropertyKey:
|
||||
case StrokeBase.transformAffectsStrokePropertyKey:
|
||||
case PointsPathBase.isClosedPropertyKey:
|
||||
case RectangleBase.linkCornerRadiusPropertyKey:
|
||||
case ClippingShapeBase.isVisiblePropertyKey:
|
||||
return boolType;
|
||||
default:
|
||||
@ -1108,8 +1132,14 @@ class RiveCoreContext {
|
||||
return (object as ParametricPathBase).originX;
|
||||
case ParametricPathBase.originYPropertyKey:
|
||||
return (object as ParametricPathBase).originY;
|
||||
case RectangleBase.cornerRadiusPropertyKey:
|
||||
return (object as RectangleBase).cornerRadius;
|
||||
case RectangleBase.cornerRadiusTLPropertyKey:
|
||||
return (object as RectangleBase).cornerRadiusTL;
|
||||
case RectangleBase.cornerRadiusTRPropertyKey:
|
||||
return (object as RectangleBase).cornerRadiusTR;
|
||||
case RectangleBase.cornerRadiusBLPropertyKey:
|
||||
return (object as RectangleBase).cornerRadiusBL;
|
||||
case RectangleBase.cornerRadiusBRPropertyKey:
|
||||
return (object as RectangleBase).cornerRadiusBR;
|
||||
case CubicMirroredVertexBase.rotationPropertyKey:
|
||||
return (object as CubicMirroredVertexBase).rotation;
|
||||
case CubicMirroredVertexBase.distancePropertyKey:
|
||||
@ -1196,6 +1226,8 @@ class RiveCoreContext {
|
||||
return (object as StrokeBase).transformAffectsStroke;
|
||||
case PointsPathBase.isClosedPropertyKey:
|
||||
return (object as PointsPathBase).isClosed;
|
||||
case RectangleBase.linkCornerRadiusPropertyKey:
|
||||
return (object as RectangleBase).linkCornerRadius;
|
||||
case ClippingShapeBase.isVisiblePropertyKey:
|
||||
return (object as ClippingShapeBase).isVisible;
|
||||
}
|
||||
@ -1442,8 +1474,17 @@ class RiveCoreContext {
|
||||
case ParametricPathBase.originYPropertyKey:
|
||||
(object as ParametricPathBase).originY = value;
|
||||
break;
|
||||
case RectangleBase.cornerRadiusPropertyKey:
|
||||
(object as RectangleBase).cornerRadius = value;
|
||||
case RectangleBase.cornerRadiusTLPropertyKey:
|
||||
(object as RectangleBase).cornerRadiusTL = value;
|
||||
break;
|
||||
case RectangleBase.cornerRadiusTRPropertyKey:
|
||||
(object as RectangleBase).cornerRadiusTR = value;
|
||||
break;
|
||||
case RectangleBase.cornerRadiusBLPropertyKey:
|
||||
(object as RectangleBase).cornerRadiusBL = value;
|
||||
break;
|
||||
case RectangleBase.cornerRadiusBRPropertyKey:
|
||||
(object as RectangleBase).cornerRadiusBR = value;
|
||||
break;
|
||||
case CubicMirroredVertexBase.rotationPropertyKey:
|
||||
(object as CubicMirroredVertexBase).rotation = value;
|
||||
@ -1566,6 +1607,9 @@ class RiveCoreContext {
|
||||
case PointsPathBase.isClosedPropertyKey:
|
||||
(object as PointsPathBase).isClosed = value;
|
||||
break;
|
||||
case RectangleBase.linkCornerRadiusPropertyKey:
|
||||
(object as RectangleBase).linkCornerRadius = value;
|
||||
break;
|
||||
case ClippingShapeBase.isVisiblePropertyKey:
|
||||
(object as ClippingShapeBase).isVisible = value;
|
||||
break;
|
||||
|
@ -25,27 +25,127 @@ abstract class RectangleBase extends ParametricPath {
|
||||
};
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// CornerRadius field with key 31.
|
||||
static const double cornerRadiusInitialValue = 0;
|
||||
double _cornerRadius = cornerRadiusInitialValue;
|
||||
static const int cornerRadiusPropertyKey = 31;
|
||||
/// LinkCornerRadius field with key 164.
|
||||
static const bool linkCornerRadiusInitialValue = true;
|
||||
bool _linkCornerRadius = linkCornerRadiusInitialValue;
|
||||
static const int linkCornerRadiusPropertyKey = 164;
|
||||
|
||||
/// Radius of the corners of this rectangle
|
||||
double get cornerRadius => _cornerRadius;
|
||||
/// Whether the TL corner radius defines all the radiuses
|
||||
bool get linkCornerRadius => _linkCornerRadius;
|
||||
|
||||
/// Change the [_cornerRadius] field value.
|
||||
/// [cornerRadiusChanged] will be invoked only if the field's value has
|
||||
/// Change the [_linkCornerRadius] field value.
|
||||
/// [linkCornerRadiusChanged] will be invoked only if the field's value has
|
||||
/// changed.
|
||||
set cornerRadius(double value) {
|
||||
if (_cornerRadius == value) {
|
||||
set linkCornerRadius(bool value) {
|
||||
if (_linkCornerRadius == value) {
|
||||
return;
|
||||
}
|
||||
double from = _cornerRadius;
|
||||
_cornerRadius = value;
|
||||
bool from = _linkCornerRadius;
|
||||
_linkCornerRadius = value;
|
||||
if (hasValidated) {
|
||||
cornerRadiusChanged(from, value);
|
||||
linkCornerRadiusChanged(from, value);
|
||||
}
|
||||
}
|
||||
|
||||
void cornerRadiusChanged(double from, double to);
|
||||
void linkCornerRadiusChanged(bool from, bool to);
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// CornerRadiusTL field with key 31.
|
||||
static const double cornerRadiusTLInitialValue = 0;
|
||||
double _cornerRadiusTL = cornerRadiusTLInitialValue;
|
||||
static const int cornerRadiusTLPropertyKey = 31;
|
||||
|
||||
/// Top left radius of the corners of this rectangle
|
||||
double get cornerRadiusTL => _cornerRadiusTL;
|
||||
|
||||
/// Change the [_cornerRadiusTL] field value.
|
||||
/// [cornerRadiusTLChanged] will be invoked only if the field's value has
|
||||
/// changed.
|
||||
set cornerRadiusTL(double value) {
|
||||
if (_cornerRadiusTL == value) {
|
||||
return;
|
||||
}
|
||||
double from = _cornerRadiusTL;
|
||||
_cornerRadiusTL = value;
|
||||
if (hasValidated) {
|
||||
cornerRadiusTLChanged(from, value);
|
||||
}
|
||||
}
|
||||
|
||||
void cornerRadiusTLChanged(double from, double to);
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// CornerRadiusTR field with key 161.
|
||||
static const double cornerRadiusTRInitialValue = 0;
|
||||
double _cornerRadiusTR = cornerRadiusTRInitialValue;
|
||||
static const int cornerRadiusTRPropertyKey = 161;
|
||||
|
||||
/// Top right radius of the corners of this rectangle
|
||||
double get cornerRadiusTR => _cornerRadiusTR;
|
||||
|
||||
/// Change the [_cornerRadiusTR] field value.
|
||||
/// [cornerRadiusTRChanged] will be invoked only if the field's value has
|
||||
/// changed.
|
||||
set cornerRadiusTR(double value) {
|
||||
if (_cornerRadiusTR == value) {
|
||||
return;
|
||||
}
|
||||
double from = _cornerRadiusTR;
|
||||
_cornerRadiusTR = value;
|
||||
if (hasValidated) {
|
||||
cornerRadiusTRChanged(from, value);
|
||||
}
|
||||
}
|
||||
|
||||
void cornerRadiusTRChanged(double from, double to);
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// CornerRadiusBL field with key 162.
|
||||
static const double cornerRadiusBLInitialValue = 0;
|
||||
double _cornerRadiusBL = cornerRadiusBLInitialValue;
|
||||
static const int cornerRadiusBLPropertyKey = 162;
|
||||
|
||||
/// Bottom left radius of the corners of this rectangle
|
||||
double get cornerRadiusBL => _cornerRadiusBL;
|
||||
|
||||
/// Change the [_cornerRadiusBL] field value.
|
||||
/// [cornerRadiusBLChanged] will be invoked only if the field's value has
|
||||
/// changed.
|
||||
set cornerRadiusBL(double value) {
|
||||
if (_cornerRadiusBL == value) {
|
||||
return;
|
||||
}
|
||||
double from = _cornerRadiusBL;
|
||||
_cornerRadiusBL = value;
|
||||
if (hasValidated) {
|
||||
cornerRadiusBLChanged(from, value);
|
||||
}
|
||||
}
|
||||
|
||||
void cornerRadiusBLChanged(double from, double to);
|
||||
|
||||
/// --------------------------------------------------------------------------
|
||||
/// CornerRadiusBR field with key 163.
|
||||
static const double cornerRadiusBRInitialValue = 0;
|
||||
double _cornerRadiusBR = cornerRadiusBRInitialValue;
|
||||
static const int cornerRadiusBRPropertyKey = 163;
|
||||
|
||||
/// Bottom right radius of the corners of this rectangle
|
||||
double get cornerRadiusBR => _cornerRadiusBR;
|
||||
|
||||
/// Change the [_cornerRadiusBR] field value.
|
||||
/// [cornerRadiusBRChanged] will be invoked only if the field's value has
|
||||
/// changed.
|
||||
set cornerRadiusBR(double value) {
|
||||
if (_cornerRadiusBR == value) {
|
||||
return;
|
||||
}
|
||||
double from = _cornerRadiusBR;
|
||||
_cornerRadiusBR = value;
|
||||
if (hasValidated) {
|
||||
cornerRadiusBRChanged(from, value);
|
||||
}
|
||||
}
|
||||
|
||||
void cornerRadiusBRChanged(double from, double to);
|
||||
}
|
||||
|
@ -12,22 +12,32 @@ class Rectangle extends RectangleBase {
|
||||
StraightVertex.procedural()
|
||||
..x = ox
|
||||
..y = oy
|
||||
..radius = cornerRadius,
|
||||
..radius = cornerRadiusTL,
|
||||
StraightVertex.procedural()
|
||||
..x = ox + width
|
||||
..y = oy
|
||||
..radius = cornerRadius,
|
||||
..radius = linkCornerRadius ? cornerRadiusTL : cornerRadiusTR,
|
||||
StraightVertex.procedural()
|
||||
..x = ox + width
|
||||
..y = oy + height
|
||||
..radius = cornerRadius,
|
||||
..radius = linkCornerRadius ? cornerRadiusTL : cornerRadiusBR,
|
||||
StraightVertex.procedural()
|
||||
..x = ox
|
||||
..y = oy + height
|
||||
..radius = cornerRadius
|
||||
..radius = linkCornerRadius ? cornerRadiusTL : cornerRadiusBL
|
||||
];
|
||||
}
|
||||
|
||||
@override
|
||||
void cornerRadiusChanged(double from, double to) => markPathDirty();
|
||||
void cornerRadiusTLChanged(double from, double to) => markPathDirty();
|
||||
@override
|
||||
void cornerRadiusTRChanged(double from, double to) => markPathDirty();
|
||||
@override
|
||||
void cornerRadiusBLChanged(double from, double to) => markPathDirty();
|
||||
@override
|
||||
void cornerRadiusBRChanged(double from, double to) => markPathDirty();
|
||||
@override
|
||||
void linkCornerRadiusChanged(bool from, bool to) {
|
||||
markPathDirty();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: rive
|
||||
description: Rive 2 Flutter Runtime. This package provides runtime functionality for playing back and interacting with animations built with the Rive editor available at https://rive.app.
|
||||
version: 0.7.2
|
||||
version: 0.7.3
|
||||
repository: https://github.com/rive-app/rive-flutter
|
||||
homepage: https://rive.app
|
||||
|
||||
|
Reference in New Issue
Block a user