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
112 lines
3.5 KiB
Dart
112 lines
3.5 KiB
Dart
part of 'preview_controller.dart';
|
|
|
|
/// Uses the same retained GPU frame and deferred publication as mask editing.
|
|
extension PreviewObscureEditing on PreviewController {
|
|
bool get obscureDragging => _obscureBase != null;
|
|
ElementId? get obscureEditingElement =>
|
|
_editingElement(PreviewCanvasEditMode.obscure);
|
|
int get obscureEditGeneration => _obscureGeneration;
|
|
void setObscureEditing(ElementId? id, {Object? owner}) =>
|
|
_setCanvasEditing(PreviewCanvasEditMode.obscure, id, owner: owner);
|
|
|
|
void releaseObscureEditing(Object owner) =>
|
|
_releaseCanvasEditing(PreviewCanvasEditMode.obscure, owner);
|
|
|
|
ClipObscureAnimation? obscureAnimation(ElementId id) {
|
|
final stack = maskStackFor(id);
|
|
if (stack == null) return null;
|
|
final animation = ClipObscureAnimation(stack.record, stack.localTick);
|
|
return animation.exists ? animation : null;
|
|
}
|
|
|
|
ClipMask? obscureFor(ElementId id) =>
|
|
id == obscureEditingElement && _pendingObscure != null
|
|
? _pendingObscure
|
|
: obscureAnimation(id)?.value;
|
|
Map<String, double> _obscureValuesFor(ElementId id) => {
|
|
...?obscureAnimation(id)?.values,
|
|
if (id == obscureEditingElement && _pendingObscure != null)
|
|
for (final f in ClipObscureAnimation.channels.expand((c) => c))
|
|
'obscure.$f': _pendingObscure!.values[f]!,
|
|
};
|
|
Future<bool> beginObscureEdit() async {
|
|
final id = obscureEditingElement;
|
|
if (id == null ||
|
|
!canPlay ||
|
|
_view == null ||
|
|
obscureAnimation(id)?.containsPlayhead != true ||
|
|
!_nativeVisuals.any((v) => v.elementId == id)) {
|
|
return false;
|
|
}
|
|
if (transforms.hasPending || _keyframePreviewing) cancelTransform();
|
|
final generation = ++_obscureGeneration;
|
|
_obscureBase = _view!.version.kernelVersion;
|
|
_obscureTick = positionTick;
|
|
_pendingObscure = obscureAnimation(id)!.value;
|
|
final bool ready;
|
|
try {
|
|
ready = await transforms.ensureContext();
|
|
} catch (_) {
|
|
if (generation == _obscureGeneration) cancelObscureEdit();
|
|
rethrow;
|
|
}
|
|
if (!ready || _closed || generation != _obscureGeneration) {
|
|
if (generation == _obscureGeneration) cancelObscureEdit();
|
|
return false;
|
|
}
|
|
_renderObscure();
|
|
return true;
|
|
}
|
|
|
|
void _renderObscure() {
|
|
final id = obscureEditingElement;
|
|
if (id == null || _transformHandle == null) return;
|
|
final visual = visualForProperties(id);
|
|
if (visual != null) _updateTransform(id, visual.transform, () {});
|
|
}
|
|
|
|
void updateObscure(ClipMask next) {
|
|
if (_obscureBase == null ||
|
|
!next.isValid ||
|
|
next.width > 3 ||
|
|
next.height > 3) {
|
|
return;
|
|
}
|
|
_pendingObscure = next;
|
|
_renderObscure();
|
|
_notify();
|
|
}
|
|
|
|
void endObscureEdit() {
|
|
final id = obscureEditingElement, next = _pendingObscure;
|
|
try {
|
|
if (id != null &&
|
|
next != null &&
|
|
identical(_obscureBase, _view?.version.kernelVersion) &&
|
|
_obscureTick == positionTick) {
|
|
final curves = obscureAnimation(id)!.edit(next);
|
|
if (curves.isNotEmpty) {
|
|
void edit() =>
|
|
timeline.publishParameters(activeSequence()!, id, curves);
|
|
if (_nativeTransforming) {
|
|
_publishInteractiveParameters(edit);
|
|
} else {
|
|
edit();
|
|
}
|
|
}
|
|
}
|
|
} finally {
|
|
cancelObscureEdit();
|
|
}
|
|
}
|
|
|
|
void cancelObscureEdit() {
|
|
_obscureGeneration++;
|
|
_obscureBase = null;
|
|
_obscureTick = null;
|
|
_pendingObscure = null;
|
|
_renderObscure();
|
|
_notify();
|
|
}
|
|
}
|