From b6fbd4fe9e077af6afe57d6af928ecd117d5ed30 Mon Sep 17 00:00:00 2001 From: luigi-rosso Date: Tue, 1 Aug 2023 18:44:45 +0000 Subject: [PATCH] Fix transform constraint trying to transform to shape bounds. Diffs= bd9a2e12a Fix transform constraint trying to transform to shape bounds. (#5727) Co-authored-by: Luigi Rosso --- .rive_head | 2 +- CHANGELOG.md | 6 +++++- lib/src/rive_core/constraints/transform_constraint.dart | 2 +- lib/src/rive_core/text/text.dart | 4 ++++ lib/src/rive_core/transform_component.dart | 3 +++ pubspec.yaml | 6 +++--- 6 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.rive_head b/.rive_head index 11b66b7..24cf700 100644 --- a/.rive_head +++ b/.rive_head @@ -1 +1 @@ -1192a06b993dcff0ced88aa8bcd0a0cf58fdafe1 +bd9a2e12a6ce10f5122f696b23c7a7db9d21e0a3 diff --git a/CHANGELOG.md b/CHANGELOG.md index db24fed..094de5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ +## 0.11.10 + +- Fixes an issue with the origin on the TransformConstraint affecting non-text objects. + ## 0.11.9 -- Fix [335](https://github.com/rive-app/rive-flutter/issues/335) _debugDisposed issue +- Fix [335](https://github.com/rive-app/rive-flutter/issues/335) \_debugDisposed issue - Fix issue showing text when the default font is not available at `assets/fonts/Inter-Regular.ttf` ([338](https://github.com/rive-app/rive-flutter/issues/338)). We will set first valid font we encounter in a rive file as default font instead. ## 0.11.8 diff --git a/lib/src/rive_core/constraints/transform_constraint.dart b/lib/src/rive_core/constraints/transform_constraint.dart index 10e02e5..d4ef0ed 100644 --- a/lib/src/rive_core/constraints/transform_constraint.dart +++ b/lib/src/rive_core/constraints/transform_constraint.dart @@ -12,7 +12,7 @@ export 'package:rive/src/generated/constraints/transform_constraint_base.dart'; /// constrained component in world or local space. class TransformConstraint extends TransformConstraintBase { Mat2D get targetTransform { - var bounds = target!.localBounds; + var bounds = target!.constraintBounds; var local = Mat2D.fromTranslation( Vec2D.fromValues( bounds.left + bounds.width * originX, diff --git a/lib/src/rive_core/text/text.dart b/lib/src/rive_core/text/text.dart index 4c12615..d2d2dc2 100644 --- a/lib/src/rive_core/text/text.dart +++ b/lib/src/rive_core/text/text.dart @@ -188,6 +188,7 @@ class Text extends TextBase with TextStyleContainer { _syncRuns(); } + Mat2D get originTransform => Mat2D.multiply( Mat2D(), worldTransform, @@ -209,6 +210,9 @@ class Text extends TextBase with TextStyleContainer { height: _bounds.height, ); + @override + AABB get constraintBounds => localBounds; + void forEachGlyph( bool Function(LineRunGlyph, double, double, GlyphLine) callback) { var lines = _lines; diff --git a/lib/src/rive_core/transform_component.dart b/lib/src/rive_core/transform_component.dart index b61a059..38ed4ae 100644 --- a/lib/src/rive_core/transform_component.dart +++ b/lib/src/rive_core/transform_component.dart @@ -209,4 +209,7 @@ abstract class TransformComponent extends TransformComponentBase { } AABB get localBounds => AABB.collapsed(Vec2D()); + + /// Bounds to use for constraining to object space. + AABB get constraintBounds => AABB.collapsed(Vec2D()); } diff --git a/pubspec.yaml b/pubspec.yaml index 5d98b9d..ca90e26 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: rive -version: 0.11.9 +version: 0.11.10 homepage: 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. repository: https://github.com/rive-app/rive-flutter @@ -10,8 +10,8 @@ topics: - widgets - widget environment: - sdk: ">=2.14.0 <4.0.0" - flutter: ">=2.5.0" + sdk: '>=2.14.0 <4.0.0' + flutter: '>=2.5.0' dependencies: collection: ^1.15.0 flutter: