Skip to content

Commit 53056d7

Browse files
HayesGordonHayesGordon
andcommitted
feat(flutter): compile with runtime scripting (#11432) 3c44afce94
* feat(flutter): compile with runtime scripting * chore: revert editor only code * chore: revert * chore: add back dummy editor script linking Fix ScriptedDrawable save/restore (#11451) e7142dcfed No double deref luau (#11448) 62fcec60de Add opacity support to ScriptedDrawables (#11446) 9b416a02f6 fix(scripting): search first parent transform component to build scri… (#11443) 99ca3a30cc fix(scripting): search first parent transform component to build script node feature: modulate opacity (#11427) 128d9d61e0 * feature: modulate opacity * fix: clang-format * fix: rust renderer has a no-op modulateOpacity * fix: no-op modulateOpacity for canvas android * feature: modulate opacity on android canvas * fix: rcp ref * fix: missing override * fix: gms * fix: make flutter_renderer match cg one * fix: josh pr feedback * fix: remove CG transparency layer * fix: save modulated gradient up-front * fix: store only one gradient ref * fix: remove specific constructor * fix: use GradDataArray! * fix: expose currentModulatedOpacity * fix: cg_factory modulated opacity value * fix: modulate negative opacity test * fix: verify double modulate negative also clamps feature(scripting): add support for accessing view models and enum pr… (#11437) 620000211e feature(scripting): add support for accessing view models and enum properties Nnnnn provide path node data (#11428) 67006966a5 chore: replace path effect signature to pass full node to scripting Scripting namespaces (#11429) f810efd11a feature: add support for data binding scripted artboard inputs (#11423) 48d14f1521 chore: do not track nested artboard count feature: configure scripting timeout & improve Data warnings (#11425) 8328e97639 * feature: configure timeout * fix: check duplicate names of viewmodels/enums too * feature: ui_strings for warning messages * fix: check isNumber instead of isNil feature(scripting): instance linear animations (#11386) 722a1ae998 feat(scripting): build dummy luau vm if disabled (#11422) 393e19b4fa fix: Scroll with snapping max scroll target (#11419) ce274af56c Nnnnn different fixes (#11415) 4b0ea7e631 * fix: invalidate effects when sorted * improve scripted converters code feat(scripting): forward declare luastate (#11418) a08d538dbf Fixes an issue when building runtimes with scripting enabled where certain headers may not be included feature: pass view model instance to bindable artboard (#10815) 3734dc3ab9 Nnnnn fix memory lua issues (#11412) ba94f03ad0 * push scripted drawable to stack twice to ensure it is not destroyed before use * code improvements fix: trigger change on solid color change (#11399) b5a73917b1 chore: advance scripting only if it is still active (#11394) 0488666fb0 * chore: advance scripting only if it is still active chore: Move clockwiseAtomic shaders to the new system (#11388) 85c5519c6e With clockwise mode, we introduced ".vert" and ".frag" files and started sharing the main vertex shaders with multiple fragment shaders. This PR is a cleanup that removes redundant code and moves the clockwiseAtomic shaders to that same system. clockwiseAtomic shaders also work out paint colors via varyings now instead of storage buffers, which seems better but doesn't register a difference in performance. test: Add a 'paintType' option to player (#11371) 209e1b6d96 Allows us to turn off fills or strokes for testing. fix(runtime): ScriptedArtboard origin fix (#11395) 88f2054b8a fix(runtime): additional null checks on audio play (#11281) a4e9d50469 * fix(runtime): additional null checks on audio play * chore: add additional null check for safety fix(scripting): some crashed related to paths (#11378) c05b97d6d5 * fix(scripting): some crashed related to paths chore: Enable with_rive_scripting flag for wasm (#11329) 8e395d6bb0 Co-authored-by: Gordon <pggordonhayes@gmail.com>
1 parent 1ed742e commit 53056d7

File tree

7 files changed

+162
-1
lines changed

7 files changed

+162
-1
lines changed

.rive_head

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
da1c7a6ae24fac3039646b49e0a1383ffa508ff5
1+
3c44afce94534d7640213c924b80166c7f28ca68

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## Upcoming
22

3+
- Adds runtime [Rive Scripting](https://rive.app/docs/scripting/getting-started) support.
4+
35
### Fixes
46

57
- Fixed [585](https://github.com/rive-app/rive-flutter/issues/585) - missing `artboard` `DataType` enum.

example/assets/blinko.riv

2.56 MB
Binary file not shown.

example/assets/centaur_game.riv

1.15 MB
Binary file not shown.
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
import 'package:flutter/foundation.dart';
2+
import 'package:flutter/material.dart';
3+
import 'package:rive/rive.dart';
4+
import 'package:rive_example/main.dart' show RiveExampleApp;
5+
6+
class DemoScripting extends StatefulWidget {
7+
const DemoScripting({super.key});
8+
9+
@override
10+
State<DemoScripting> createState() => _DemoScriptingState();
11+
}
12+
13+
class _DemoScriptingState extends State<DemoScripting>
14+
with SingleTickerProviderStateMixin {
15+
late final TabController _tabController;
16+
17+
final List<String> _tabTitles = [
18+
'Blinko',
19+
'Centaur Game',
20+
];
21+
22+
@override
23+
void initState() {
24+
super.initState();
25+
_tabController = TabController(length: _tabTitles.length, vsync: this);
26+
}
27+
28+
@override
29+
void dispose() {
30+
_tabController.dispose();
31+
super.dispose();
32+
}
33+
34+
@override
35+
Widget build(BuildContext context) {
36+
return Column(
37+
children: [
38+
Padding(
39+
padding: const EdgeInsets.all(8.0),
40+
child: TabBar(
41+
controller: _tabController,
42+
tabs: _tabTitles.map((title) => Tab(text: title)).toList(),
43+
),
44+
),
45+
Expanded(
46+
child: TabBarView(
47+
controller: _tabController,
48+
children: const [
49+
_BlinkoExample(),
50+
_CentaurGame(),
51+
],
52+
),
53+
),
54+
],
55+
);
56+
}
57+
}
58+
59+
class _BlinkoExample extends StatefulWidget {
60+
const _BlinkoExample();
61+
62+
@override
63+
State<_BlinkoExample> createState() => __BlinkoExampleState();
64+
}
65+
66+
class __BlinkoExampleState extends State<_BlinkoExample> {
67+
late final fileLoader = FileLoader.fromAsset(
68+
'assets/blinko.riv',
69+
riveFactory: RiveExampleApp.getCurrentFactory,
70+
);
71+
72+
@override
73+
void dispose() {
74+
// This widget state owns the file loader, dispose it.
75+
fileLoader.dispose();
76+
super.dispose();
77+
}
78+
79+
@override
80+
Widget build(BuildContext context) {
81+
return RiveWidgetBuilder(
82+
fileLoader: fileLoader,
83+
dataBind: DataBind.auto(),
84+
builder: (context, state) => switch (state) {
85+
RiveLoading() => const Center(
86+
child: Center(child: CircularProgressIndicator()),
87+
),
88+
RiveFailed() => ErrorWidget.withDetails(
89+
message: state.error.toString(),
90+
error: FlutterError(state.error.toString()),
91+
),
92+
RiveLoaded() => RiveWidget(
93+
controller: state.controller,
94+
)
95+
},
96+
);
97+
}
98+
}
99+
100+
class _CentaurGame extends StatefulWidget {
101+
const _CentaurGame();
102+
103+
@override
104+
State<_CentaurGame> createState() => __CentaurGameState();
105+
}
106+
107+
class __CentaurGameState extends State<_CentaurGame> {
108+
late final fileLoader = FileLoader.fromAsset(
109+
'assets/centaur_game.riv',
110+
riveFactory: RiveExampleApp.getCurrentFactory,
111+
);
112+
@override
113+
void dispose() {
114+
// This widget state owns the file loader, dispose it.
115+
fileLoader.dispose();
116+
super.dispose();
117+
}
118+
119+
@override
120+
Widget build(BuildContext context) {
121+
// Check if running on mobile
122+
if (defaultTargetPlatform == TargetPlatform.iOS ||
123+
defaultTargetPlatform == TargetPlatform.android) {
124+
return const Center(
125+
child: Padding(
126+
padding: EdgeInsets.all(24.0),
127+
child: Text(
128+
'This demo only has controls for desktop.',
129+
style: TextStyle(fontSize: 16),
130+
textAlign: TextAlign.center,
131+
),
132+
),
133+
);
134+
}
135+
136+
return RiveWidgetBuilder(
137+
fileLoader: fileLoader,
138+
dataBind: DataBind.auto(),
139+
builder: (context, state) => switch (state) {
140+
RiveLoading() => const Center(
141+
child: Center(child: CircularProgressIndicator()),
142+
),
143+
RiveFailed() => ErrorWidget.withDetails(
144+
message: state.error.toString(),
145+
error: FlutterError(state.error.toString()),
146+
),
147+
RiveLoaded() => RiveWidget(
148+
controller: state.controller,
149+
)
150+
},
151+
);
152+
}
153+
}

example/lib/examples/examples.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export 'databinding.dart';
33
export 'databinding_artboards.dart';
44
export 'databinding_images.dart';
55
export 'databinding_lists.dart';
6+
export 'demo_scripting.dart';
67
export 'events.dart';
78
export 'hit_test_behaviour.dart';
89
export 'inputs.dart';

example/lib/main.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ class _RiveExampleAppState extends State<RiveExampleApp> {
7878
),
7979
]),
8080
const _Section('Rive Features', [
81+
_Page(
82+
'Demo Scripting',
83+
DemoScripting(),
84+
'Example Rive file with scripting.',
85+
),
8186
_Page(
8287
'Data Binding',
8388
ExampleDataBinding(),

0 commit comments

Comments
 (0)