Gitea CI / Check code and tests (pull_request) Failing after 8s
Gitea CI / Build Android APK (pull_request) Skipped
Gitea CI / Build Windows x64 app (pull_request) Skipped
Gitea CI / Audit and package Windows x64 (pull_request) Skipped
Gitea CI / Assemble and validate CI artifacts (pull_request) Skipped
Gitea CI / Gitea CI passed (pull_request) Failing after 1s
85 lines
2.2 KiB
Dart
85 lines
2.2 KiB
Dart
import 'package:cutdex_core/editor.dart';
|
|
import 'package:cutdex_preview/cutdex_preview.dart';
|
|
import 'package:cutdex_core/timeline/model.dart';
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'property_edit_boundary.dart';
|
|
import '../../workspace/timeline_session.dart';
|
|
|
|
/// Owns the asynchronous edit boundary for one selected clip.
|
|
class PropertyEditController extends ChangeNotifier {
|
|
PropertyEditController({
|
|
required this.session,
|
|
required this.sequence,
|
|
required this.clip,
|
|
required this.projectId,
|
|
required this.timelineId,
|
|
required this.operation,
|
|
});
|
|
final EditorTimelineSession session;
|
|
final SequenceId sequence;
|
|
final ElementId clip;
|
|
final String projectId, timelineId, operation;
|
|
Object get identity => (session, sequence, clip, projectId, timelineId);
|
|
late final _boundary = PropertyEditBoundary(session, sequence, clip);
|
|
bool _disposed = false;
|
|
bool _saving = false;
|
|
bool _failed = false;
|
|
bool get saving => _saving;
|
|
bool get failed => _failed;
|
|
|
|
@override
|
|
void dispose() {
|
|
_disposed = true;
|
|
_boundary.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
ClipParameterAnimation? get animation {
|
|
final view = session.view(sequence);
|
|
final query = view.version.kernelVersion.query();
|
|
final handle = query.elementById(clip);
|
|
return handle == null
|
|
? null
|
|
: ClipParameterAnimation(
|
|
query.element(handle),
|
|
view.playheadTick - query.absoluteStart(handle),
|
|
);
|
|
}
|
|
|
|
Future<bool> run(
|
|
PreviewController? preview,
|
|
void Function(EditorCommandService, int) action, {
|
|
bool seek = false,
|
|
}) async {
|
|
if (_disposed || saving || !_boundary.canRun(preview)) return false;
|
|
try {
|
|
return await _boundary.run(
|
|
preview,
|
|
(target) {
|
|
action(session.commands, target.tick);
|
|
return true;
|
|
},
|
|
operation: operation,
|
|
seek: seek,
|
|
started: () {
|
|
_saving = true;
|
|
_failed = false;
|
|
notifyListeners();
|
|
},
|
|
);
|
|
} catch (_) {
|
|
if (!_disposed) {
|
|
_failed = true;
|
|
notifyListeners();
|
|
}
|
|
return false;
|
|
} finally {
|
|
if (!_disposed) {
|
|
_saving = false;
|
|
notifyListeners();
|
|
}
|
|
}
|
|
}
|
|
}
|