feat: initial Cutdex application
Add the Flutter video editing application with project management, media import, timeline editing, preview, AI assistance, diagnostics and settings. Include shared UI and native host packages, platform runners, application tests and release tooling. Provide usage and contribution guides, the MIT license and third-party notices. Exclude local credentials, build outputs and validation data.
This commit is contained in:
commit
27e77fff39
718 files changed
+183958
No files matched your search
@@ -0,0 +1,135 @@
|
||||
import 'package:cutdex_sdk/editor.dart';
|
||||
import 'package:cutdex_sdk/timeline/model.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'support/preview_fixture.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
test(
|
||||
'grouped keys interpolate, retain other channels, undo and persist',
|
||||
() async {
|
||||
final f = await createPreviewFixture(
|
||||
Uri.file('/test/video.mov'),
|
||||
clipDuration: RationalTime.seconds(5),
|
||||
);
|
||||
addTearDown(() async {
|
||||
await f.workspace.close();
|
||||
await f.directory.delete(recursive: true);
|
||||
});
|
||||
final id = SequenceId('one');
|
||||
final clip = ElementId('clip');
|
||||
final view = f.timeline.view(id);
|
||||
ClipAnimation at(int second) {
|
||||
final q = view.version.kernelVersion.query();
|
||||
return ClipAnimation.at(
|
||||
q,
|
||||
q.elementById(clip)!,
|
||||
second * TimelineClock.ticksPerSecond,
|
||||
TimelineClock.ticksPerSecond ~/ 30,
|
||||
);
|
||||
}
|
||||
|
||||
void commit(List<ParameterCurveDto> curves) =>
|
||||
f.timeline.commitParameters(
|
||||
id,
|
||||
f.timeline.previewParameters(id, clip, curves),
|
||||
parameterTargets: ClipTransform.targets,
|
||||
);
|
||||
commit(at(0).toggle(TransformChannel.position));
|
||||
commit(at(2).edit(at(2).value.copyWith(x: .4, y: .2)));
|
||||
expect(at(1).value.x, closeTo(.2, 1e-10));
|
||||
expect(at(1).value.y, closeTo(.1, 1e-10));
|
||||
expect(at(2).keyed(TransformChannel.position), isTrue);
|
||||
expect(at(0).keyTimes(TransformChannel.position), [
|
||||
0,
|
||||
2 * TimelineClock.ticksPerSecond,
|
||||
]);
|
||||
commit(at(1).edit(at(1).value.copyWith(rotation: 45)));
|
||||
expect(at(0).value.rotation, 45);
|
||||
expect(at(2).value.x, .4);
|
||||
final before = view.version.kernelVersion;
|
||||
commit(
|
||||
at(0).setInterpolation(
|
||||
TransformChannel.position,
|
||||
ParameterInterpolation.hold,
|
||||
),
|
||||
);
|
||||
expect(at(1).value.x, 0);
|
||||
view.undo();
|
||||
expect(view.version.kernelVersion, same(before));
|
||||
expect(at(1).value.x, closeTo(.2, 1e-10));
|
||||
view.redo();
|
||||
expect(at(1).value.x, 0);
|
||||
view.undo();
|
||||
await f.timeline.flush();
|
||||
final saved = await f.workspace.project!.loadTimeline('project');
|
||||
final savedClip = saved.sequences.first.elements.single;
|
||||
expect(
|
||||
savedClip.parameters
|
||||
.firstWhere((p) => p.definition.id == 'canvas.position.x')
|
||||
.keyframes
|
||||
.length,
|
||||
2,
|
||||
);
|
||||
expect(
|
||||
saved.settings['parameterTargets'],
|
||||
containsPair('canvas.position.y', 'position.y'),
|
||||
);
|
||||
commit(at(2).toggle(TransformChannel.position));
|
||||
expect(at(2).value.x, 0);
|
||||
commit(at(0).toggle(TransformChannel.position));
|
||||
expect(at(0).animated(TransformChannel.position), isFalse);
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
'independent dimensions remain grouped and clearing holds evaluated values',
|
||||
() async {
|
||||
final f = await createPreviewFixture(
|
||||
Uri.file('/test/video.mov'),
|
||||
clipDuration: RationalTime.seconds(5),
|
||||
);
|
||||
addTearDown(() async {
|
||||
await f.workspace.close();
|
||||
await f.directory.delete(recursive: true);
|
||||
});
|
||||
final id = SequenceId('one');
|
||||
final clip = ElementId('clip');
|
||||
final view = f.timeline.view(id);
|
||||
ClipAnimation at(int seconds) {
|
||||
final q = view.version.kernelVersion.query();
|
||||
return ClipAnimation.at(
|
||||
q,
|
||||
q.elementById(clip)!,
|
||||
seconds * TimelineClock.ticksPerSecond,
|
||||
TimelineClock.ticksPerSecond ~/ 30,
|
||||
);
|
||||
}
|
||||
|
||||
void commit(List<ParameterCurveDto> curves) =>
|
||||
f.timeline.commitParameters(
|
||||
id,
|
||||
f.timeline.previewParameters(id, clip, curves),
|
||||
parameterTargets: ClipTransform.targets,
|
||||
);
|
||||
commit(at(0).toggle(TransformChannel.scale));
|
||||
commit(at(2).edit(at(2).value.copyWith(scaleY: 3)));
|
||||
expect(at(1).value.scale, 1);
|
||||
expect(at(1).value.scaleY, 2);
|
||||
expect(at(2).keyed(TransformChannel.scale), isTrue);
|
||||
commit(at(1).clear(TransformChannel.scale));
|
||||
expect(at(0).animated(TransformChannel.scale), isFalse);
|
||||
expect(at(0).value.scaleY, 2);
|
||||
expect(at(4).value.scaleY, 2);
|
||||
expect(at(5).containsPlayhead, isFalse);
|
||||
expect(() => at(5).toggle(TransformChannel.scale), throwsStateError);
|
||||
commit(at(2).toggle(TransformChannel.rotation));
|
||||
commit(at(2).edit(at(2).value.copyWith(rotation: 90)));
|
||||
commit(at(2).toggle(TransformChannel.rotation));
|
||||
expect(at(0).animated(TransformChannel.rotation), isFalse);
|
||||
expect(at(0).value.rotation, 90);
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user