mirror of
https://github.com/rive-app/rive-flutter.git
synced 2025-06-26 09:48:01 +08:00
Merge pull request #42 from rive-app/visibility_toggles
Adding visibility toggles and prepping for 0.6.5.
This commit is contained in:
@ -1,3 +1,9 @@
|
|||||||
|
## [0.6.5] - 2020-12-22 16:49:39
|
||||||
|
|
||||||
|
- Fixing issue with older minor versions crashing when newer minor files included objects with unknown keys. The runtime can now read beyond those.
|
||||||
|
- Shapes and paths hidden in the editor will not show up at runtime.
|
||||||
|
- Runtime header now exposes Rive project id.
|
||||||
|
|
||||||
## [0.6.4] - 2020-12-11 15:43:01
|
## [0.6.4] - 2020-12-11 15:43:01
|
||||||
|
|
||||||
- Adding support for parametric polygon and star shapes.
|
- Adding support for parametric polygon and star shapes.
|
||||||
|
@ -39,4 +39,24 @@ abstract class DrawableBase extends Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void blendModeValueChanged(int from, int to);
|
void blendModeValueChanged(int from, int to);
|
||||||
|
|
||||||
|
/// --------------------------------------------------------------------------
|
||||||
|
/// DrawableFlags field with key 129.
|
||||||
|
int _drawableFlags = 0;
|
||||||
|
static const int drawableFlagsPropertyKey = 129;
|
||||||
|
int get drawableFlags => _drawableFlags;
|
||||||
|
|
||||||
|
/// Change the [_drawableFlags] field value.
|
||||||
|
/// [drawableFlagsChanged] will be invoked only if the field's value has
|
||||||
|
/// changed.
|
||||||
|
set drawableFlags(int value) {
|
||||||
|
if (_drawableFlags == value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int from = _drawableFlags;
|
||||||
|
_drawableFlags = value;
|
||||||
|
drawableFlagsChanged(from, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawableFlagsChanged(int from, int to);
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,7 @@ import 'package:rive/src/generated/shapes/paint/solid_color_base.dart';
|
|||||||
import 'package:rive/src/generated/shapes/paint/stroke_base.dart';
|
import 'package:rive/src/generated/shapes/paint/stroke_base.dart';
|
||||||
import 'package:rive/src/generated/shapes/paint/trim_path_base.dart';
|
import 'package:rive/src/generated/shapes/paint/trim_path_base.dart';
|
||||||
import 'package:rive/src/generated/shapes/parametric_path_base.dart';
|
import 'package:rive/src/generated/shapes/parametric_path_base.dart';
|
||||||
|
import 'package:rive/src/generated/shapes/path_base.dart';
|
||||||
import 'package:rive/src/generated/shapes/path_composer_base.dart';
|
import 'package:rive/src/generated/shapes/path_composer_base.dart';
|
||||||
import 'package:rive/src/generated/shapes/path_vertex_base.dart';
|
import 'package:rive/src/generated/shapes/path_vertex_base.dart';
|
||||||
import 'package:rive/src/generated/shapes/points_path_base.dart';
|
import 'package:rive/src/generated/shapes/points_path_base.dart';
|
||||||
@ -428,11 +429,21 @@ class RiveCoreContext {
|
|||||||
object.y = value;
|
object.y = value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case PathBase.pathFlagsPropertyKey:
|
||||||
|
if (object is PathBase && value is int) {
|
||||||
|
object.pathFlags = value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case DrawableBase.blendModeValuePropertyKey:
|
case DrawableBase.blendModeValuePropertyKey:
|
||||||
if (object is DrawableBase && value is int) {
|
if (object is DrawableBase && value is int) {
|
||||||
object.blendModeValue = value;
|
object.blendModeValue = value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case DrawableBase.drawableFlagsPropertyKey:
|
||||||
|
if (object is DrawableBase && value is int) {
|
||||||
|
object.drawableFlags = value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case PathVertexBase.xPropertyKey:
|
case PathVertexBase.xPropertyKey:
|
||||||
if (object is PathVertexBase && value is double) {
|
if (object is PathVertexBase && value is double) {
|
||||||
object.x = value;
|
object.x = value;
|
||||||
@ -729,7 +740,9 @@ class RiveCoreContext {
|
|||||||
case StrokeBase.joinPropertyKey:
|
case StrokeBase.joinPropertyKey:
|
||||||
case TrimPathBase.modeValuePropertyKey:
|
case TrimPathBase.modeValuePropertyKey:
|
||||||
case FillBase.fillRulePropertyKey:
|
case FillBase.fillRulePropertyKey:
|
||||||
|
case PathBase.pathFlagsPropertyKey:
|
||||||
case DrawableBase.blendModeValuePropertyKey:
|
case DrawableBase.blendModeValuePropertyKey:
|
||||||
|
case DrawableBase.drawableFlagsPropertyKey:
|
||||||
case WeightBase.valuesPropertyKey:
|
case WeightBase.valuesPropertyKey:
|
||||||
case WeightBase.indicesPropertyKey:
|
case WeightBase.indicesPropertyKey:
|
||||||
case CubicWeightBase.inValuesPropertyKey:
|
case CubicWeightBase.inValuesPropertyKey:
|
||||||
@ -868,8 +881,12 @@ class RiveCoreContext {
|
|||||||
return (object as TrimPathBase).modeValue;
|
return (object as TrimPathBase).modeValue;
|
||||||
case FillBase.fillRulePropertyKey:
|
case FillBase.fillRulePropertyKey:
|
||||||
return (object as FillBase).fillRule;
|
return (object as FillBase).fillRule;
|
||||||
|
case PathBase.pathFlagsPropertyKey:
|
||||||
|
return (object as PathBase).pathFlags;
|
||||||
case DrawableBase.blendModeValuePropertyKey:
|
case DrawableBase.blendModeValuePropertyKey:
|
||||||
return (object as DrawableBase).blendModeValue;
|
return (object as DrawableBase).blendModeValue;
|
||||||
|
case DrawableBase.drawableFlagsPropertyKey:
|
||||||
|
return (object as DrawableBase).drawableFlags;
|
||||||
case WeightBase.valuesPropertyKey:
|
case WeightBase.valuesPropertyKey:
|
||||||
return (object as WeightBase).values;
|
return (object as WeightBase).values;
|
||||||
case WeightBase.indicesPropertyKey:
|
case WeightBase.indicesPropertyKey:
|
||||||
@ -1121,9 +1138,15 @@ class RiveCoreContext {
|
|||||||
case FillBase.fillRulePropertyKey:
|
case FillBase.fillRulePropertyKey:
|
||||||
(object as FillBase).fillRule = value;
|
(object as FillBase).fillRule = value;
|
||||||
break;
|
break;
|
||||||
|
case PathBase.pathFlagsPropertyKey:
|
||||||
|
(object as PathBase).pathFlags = value;
|
||||||
|
break;
|
||||||
case DrawableBase.blendModeValuePropertyKey:
|
case DrawableBase.blendModeValuePropertyKey:
|
||||||
(object as DrawableBase).blendModeValue = value;
|
(object as DrawableBase).blendModeValue = value;
|
||||||
break;
|
break;
|
||||||
|
case DrawableBase.drawableFlagsPropertyKey:
|
||||||
|
(object as DrawableBase).drawableFlags = value;
|
||||||
|
break;
|
||||||
case WeightBase.valuesPropertyKey:
|
case WeightBase.valuesPropertyKey:
|
||||||
(object as WeightBase).values = value;
|
(object as WeightBase).values = value;
|
||||||
break;
|
break;
|
||||||
|
@ -19,4 +19,23 @@ abstract class PathBase extends Node {
|
|||||||
ContainerComponentBase.typeKey,
|
ContainerComponentBase.typeKey,
|
||||||
ComponentBase.typeKey
|
ComponentBase.typeKey
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// --------------------------------------------------------------------------
|
||||||
|
/// PathFlags field with key 128.
|
||||||
|
int _pathFlags = 0;
|
||||||
|
static const int pathFlagsPropertyKey = 128;
|
||||||
|
int get pathFlags => _pathFlags;
|
||||||
|
|
||||||
|
/// Change the [_pathFlags] field value.
|
||||||
|
/// [pathFlagsChanged] will be invoked only if the field's value has changed.
|
||||||
|
set pathFlags(int value) {
|
||||||
|
if (_pathFlags == value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int from = _pathFlags;
|
||||||
|
_pathFlags = value;
|
||||||
|
pathFlagsChanged(from, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void pathFlagsChanged(int from, int to);
|
||||||
}
|
}
|
||||||
|
@ -172,6 +172,9 @@ class Artboard extends ArtboardBase with ShapePaintContainer {
|
|||||||
for (var drawable = _firstDrawable;
|
for (var drawable = _firstDrawable;
|
||||||
drawable != null;
|
drawable != null;
|
||||||
drawable = drawable.prev) {
|
drawable = drawable.prev) {
|
||||||
|
if (drawable.isHidden) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
drawable.draw(canvas);
|
drawable.draw(canvas);
|
||||||
}
|
}
|
||||||
canvas.restore();
|
canvas.restore();
|
||||||
|
4
lib/src/rive_core/component_flags.dart
Normal file
4
lib/src/rive_core/component_flags.dart
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
class ComponentFlags {
|
||||||
|
static const int hidden = 1 << 0;
|
||||||
|
static const int locked = 1 << 1;
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
import 'package:rive/src/rive_core/component_dirt.dart';
|
import 'package:rive/src/rive_core/component_dirt.dart';
|
||||||
|
import 'package:rive/src/rive_core/component_flags.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/shapes/clipping_shape.dart';
|
import 'package:rive/src/rive_core/shapes/clipping_shape.dart';
|
||||||
@ -60,4 +61,8 @@ abstract class Drawable extends DrawableBase {
|
|||||||
_clippingShapes = clippingShapes.isEmpty ? null : clippingShapes;
|
_clippingShapes = clippingShapes.isEmpty ? null : clippingShapes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void drawableFlagsChanged(int from, int to) => addDirt(ComponentDirt.paint);
|
||||||
|
bool get isHidden => (drawableFlags & ComponentFlags.hidden) != 0;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,18 @@ class AABB {
|
|||||||
-double.maxFinite
|
-double.maxFinite
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
double get area => width * height;
|
factory AABB.expand(AABB from, double amount) {
|
||||||
|
var aabb = AABB.clone(from);
|
||||||
|
if (aabb.width < amount) {
|
||||||
|
aabb[0] -= amount / 2;
|
||||||
|
aabb[2] += amount / 2;
|
||||||
|
}
|
||||||
|
if (aabb.height < amount) {
|
||||||
|
aabb[1] -= amount / 2;
|
||||||
|
aabb[3] += amount / 2;
|
||||||
|
}
|
||||||
|
return aabb;
|
||||||
|
}
|
||||||
bool get isEmpty => !AABB.isValid(this);
|
bool get isEmpty => !AABB.isValid(this);
|
||||||
Vec2D includePoint(Vec2D point, Mat2D transform) {
|
Vec2D includePoint(Vec2D point, Mat2D transform) {
|
||||||
var transformedPoint = transform == null
|
var transformedPoint = transform == null
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
import 'package:rive/src/utilities/utilities.dart';
|
||||||
import 'mat2d.dart';
|
import 'mat2d.dart';
|
||||||
|
|
||||||
class Vec2D {
|
class Vec2D {
|
||||||
@ -163,7 +164,13 @@ class Vec2D {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
String v = _buffer[0].toString() + ", ";
|
String v = _buffer[0].toString() + ', ';
|
||||||
return v + _buffer[1].toString();
|
return v + _buffer[1].toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object o) =>
|
||||||
|
o is Vec2D && _buffer[0] == o[0] && _buffer[1] == o[1];
|
||||||
|
@override
|
||||||
|
int get hashCode => szudzik(_buffer[0].hashCode, _buffer[1].hashCode);
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,11 @@ const riveVersion = RuntimeVersion(6, 3);
|
|||||||
class RuntimeHeader {
|
class RuntimeHeader {
|
||||||
static const String fingerprint = 'RIVE';
|
static const String fingerprint = 'RIVE';
|
||||||
final RuntimeVersion version;
|
final RuntimeVersion version;
|
||||||
final int ownerId;
|
final int projectId;
|
||||||
final int fileId;
|
final int fileId;
|
||||||
final HashMap<int, int> propertyToFieldIndex;
|
final HashMap<int, int> propertyToFieldIndex;
|
||||||
RuntimeHeader(
|
RuntimeHeader(
|
||||||
{@required this.ownerId,
|
{@required this.projectId,
|
||||||
@required this.fileId,
|
@required this.fileId,
|
||||||
@required this.version,
|
@required this.version,
|
||||||
this.propertyToFieldIndex});
|
this.propertyToFieldIndex});
|
||||||
@ -36,7 +36,7 @@ class RuntimeHeader {
|
|||||||
throw RiveUnsupportedVersionException(riveVersion.major,
|
throw RiveUnsupportedVersionException(riveVersion.major,
|
||||||
riveVersion.minor, readMajorVersion, readMinorVersion);
|
riveVersion.minor, readMajorVersion, readMinorVersion);
|
||||||
}
|
}
|
||||||
int ownerId = reader.readVarUint();
|
int projectId = reader.readVarUint();
|
||||||
int fileId = reader.readVarUint();
|
int fileId = reader.readVarUint();
|
||||||
var propertyFields = HashMap<int, int>();
|
var propertyFields = HashMap<int, int>();
|
||||||
var propertyKeys = <int>[];
|
var propertyKeys = <int>[];
|
||||||
@ -57,7 +57,7 @@ class RuntimeHeader {
|
|||||||
currentBit += 2;
|
currentBit += 2;
|
||||||
}
|
}
|
||||||
return RuntimeHeader(
|
return RuntimeHeader(
|
||||||
ownerId: ownerId,
|
projectId: projectId,
|
||||||
fileId: fileId,
|
fileId: fileId,
|
||||||
version: RuntimeVersion(readMajorVersion, readMinorVersion),
|
version: RuntimeVersion(readMajorVersion, readMinorVersion),
|
||||||
propertyToFieldIndex: propertyFields);
|
propertyToFieldIndex: propertyFields);
|
||||||
|
@ -2,6 +2,7 @@ import 'dart:math';
|
|||||||
import 'dart:ui' as ui;
|
import 'dart:ui' as ui;
|
||||||
import 'package:rive/src/rive_core/component.dart';
|
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/component_flags.dart';
|
||||||
import 'package:rive/src/rive_core/math/circle_constant.dart';
|
import 'package:rive/src/rive_core/math/circle_constant.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/vec2d.dart';
|
import 'package:rive/src/rive_core/math/vec2d.dart';
|
||||||
@ -215,6 +216,10 @@ abstract class Path extends PathBase {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void pathFlagsChanged(int from, int to) => markPathDirty();
|
||||||
|
bool get isHidden => (pathFlags & ComponentFlags.hidden) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
class RenderPath {
|
class RenderPath {
|
||||||
|
@ -32,6 +32,9 @@ class PathComposer extends PathComposerBase {
|
|||||||
Mat2D inverseWorld = Mat2D();
|
Mat2D inverseWorld = Mat2D();
|
||||||
if (Mat2D.invert(inverseWorld, world)) {
|
if (Mat2D.invert(inverseWorld, world)) {
|
||||||
for (final path in _shape.paths) {
|
for (final path in _shape.paths) {
|
||||||
|
if (path.isHidden) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
Mat2D localTransform;
|
Mat2D localTransform;
|
||||||
var transform = path.pathTransform;
|
var transform = path.pathTransform;
|
||||||
if (transform != null) {
|
if (transform != null) {
|
||||||
@ -46,6 +49,9 @@ class PathComposer extends PathComposerBase {
|
|||||||
if (buildWorldPath) {
|
if (buildWorldPath) {
|
||||||
worldPath.reset();
|
worldPath.reset();
|
||||||
for (final path in _shape.paths) {
|
for (final path in _shape.paths) {
|
||||||
|
if (path.isHidden) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
worldPath.addPath(path.uiPath, ui.Offset.zero,
|
worldPath.addPath(path.uiPath, ui.Offset.zero,
|
||||||
matrix4: path.pathTransform?.mat4);
|
matrix4: path.pathTransform?.mat4);
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ class Polygon extends PolygonBase {
|
|||||||
void pointsChanged(int from, int to) => markPathDirty();
|
void pointsChanged(int from, int to) => markPathDirty();
|
||||||
@override
|
@override
|
||||||
List<PathVertex<Weight>> get vertices {
|
List<PathVertex<Weight>> get vertices {
|
||||||
var vertexList = List<StraightVertex>(points);
|
var vertexList = List<StraightVertex>.filled(points, null);
|
||||||
var halfWidth = width / 2;
|
var halfWidth = width / 2;
|
||||||
var halfHeight = height / 2;
|
var halfHeight = height / 2;
|
||||||
var angle = -pi / 2;
|
var angle = -pi / 2;
|
||||||
|
@ -11,7 +11,8 @@ class Star extends StarBase {
|
|||||||
@override
|
@override
|
||||||
List<PathVertex<Weight>> get vertices {
|
List<PathVertex<Weight>> get vertices {
|
||||||
var actualPoints = points * 2;
|
var actualPoints = points * 2;
|
||||||
var vertexList = List<StraightVertex>(actualPoints);
|
var vertexList =
|
||||||
|
List<StraightVertex>.filled(actualPoints, null, growable: false);
|
||||||
var halfWidth = width / 2;
|
var halfWidth = width / 2;
|
||||||
var halfHeight = height / 2;
|
var halfHeight = height / 2;
|
||||||
var innerHalfWidth = width * innerRadius / 2;
|
var innerHalfWidth = width * innerRadius / 2;
|
||||||
|
@ -100,7 +100,7 @@ class RiveFile {
|
|||||||
animation.artboard = artboard;
|
animation.artboard = artboard;
|
||||||
if (animation is LinearAnimation) {
|
if (animation is LinearAnimation) {
|
||||||
var numKeyedObjects = reader.readVarUint();
|
var numKeyedObjects = reader.readVarUint();
|
||||||
var keyedObjects = List<KeyedObject>(numKeyedObjects);
|
var keyedObjects = List<KeyedObject>.filled(numKeyedObjects, null);
|
||||||
for (int j = 0; j < numKeyedObjects; j++) {
|
for (int j = 0; j < numKeyedObjects; j++) {
|
||||||
var keyedObject =
|
var keyedObject =
|
||||||
_readRuntimeObject<KeyedObject>(reader, propertyToField);
|
_readRuntimeObject<KeyedObject>(reader, propertyToField);
|
||||||
@ -153,8 +153,8 @@ class RiveFile {
|
|||||||
|
|
||||||
assert(!artboard.children.contains(artboard),
|
assert(!artboard.children.contains(artboard),
|
||||||
'artboard should never contain itself as a child');
|
'artboard should never contain itself as a child');
|
||||||
for (final object in artboard.objects.toList(growable:false)) {
|
for (final object in artboard.objects.toList(growable: false)) {
|
||||||
if(object == null) {
|
if (object == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
object.onAdded();
|
object.onAdded();
|
||||||
|
9
lib/src/utilities/utilities.dart
Normal file
9
lib/src/utilities/utilities.dart
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
/// Szudzik's function for hashing two ints together
|
||||||
|
int szudzik(int a, int b) {
|
||||||
|
assert(a != null && b != null);
|
||||||
|
// a and b must be >= 0
|
||||||
|
|
||||||
|
int x = a.abs();
|
||||||
|
int y = b.abs();
|
||||||
|
return x >= y ? x * x + x + y : x + y * y;
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
name: rive
|
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.
|
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.6.4
|
version: 0.6.5
|
||||||
repository: https://github.com/rive-app/rive-flutter
|
repository: https://github.com/rive-app/rive-flutter
|
||||||
homepage: https://rive.app
|
homepage: https://rive.app
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user