perf(editor): integrate native preview and prioritize timeline interaction
Gitea CI / Check code and tests (pull_request) Failing after 7m0s
Gitea CI / Gitea CI passed (pull_request) Failing after 5s
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 / Check code and tests (pull_request) Failing after 7m0s
Gitea CI / Gitea CI passed (pull_request) Failing after 5s
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
This commit is contained in:
1 parent
0ecf920669
commit
4f746be301
34 files changed
+3278
-145
No files matched your search
@@ -36,11 +36,13 @@ class EditorWorkspace extends ConsumerStatefulWidget {
|
||||
required this.integratedTitlebar,
|
||||
required this.headerLeading,
|
||||
this.projectLoading = false,
|
||||
this.timelineLoading = false,
|
||||
this.showProjectName = true,
|
||||
this.experience = DeviceExperience.desktop,
|
||||
});
|
||||
|
||||
final bool projectLoading;
|
||||
final bool timelineLoading;
|
||||
final String projectId;
|
||||
final String timelineId;
|
||||
final String projectName;
|
||||
@@ -55,6 +57,7 @@ class EditorWorkspace extends ConsumerStatefulWidget {
|
||||
|
||||
class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
|
||||
final _previewKey = GlobalKey();
|
||||
bool get _timelinePending => widget.projectLoading || widget.timelineLoading;
|
||||
EditorPresentationController get _presentation =>
|
||||
ref.read(editorPresentationProvider(widget.projectId));
|
||||
ProjectViewSettingsData get _viewSettings =>
|
||||
@@ -82,15 +85,16 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
|
||||
child: EditorPreviewPanel(
|
||||
projectId: widget.projectId,
|
||||
timelineId: widget.timelineId,
|
||||
pending: widget.projectLoading,
|
||||
pending: _timelinePending,
|
||||
),
|
||||
);
|
||||
final timeline = EditorTimelinePanel(
|
||||
projectId: widget.projectId,
|
||||
timelineId: widget.timelineId,
|
||||
pending: widget.projectLoading,
|
||||
timelineLoading: widget.timelineLoading,
|
||||
);
|
||||
final properties = widget.projectLoading
|
||||
final properties = _timelinePending
|
||||
? const EditorEmptyPanel()
|
||||
: EditorPropertiesPanel(
|
||||
projectId: widget.projectId,
|
||||
@@ -153,7 +157,7 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
|
||||
),
|
||||
Flexible(
|
||||
fit: FlexFit.loose,
|
||||
child: widget.projectLoading
|
||||
child: _timelinePending
|
||||
? const SizedBox.shrink()
|
||||
: _TimelineSaveStatus(
|
||||
projectId: widget.projectId,
|
||||
@@ -288,7 +292,7 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
|
||||
projectId: widget.projectId,
|
||||
),
|
||||
},
|
||||
properties: widget.projectLoading
|
||||
properties: _timelinePending
|
||||
? properties
|
||||
: switch (widget.experience) {
|
||||
DeviceExperience.desktop => properties,
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:flutter/services.dart';
|
||||
|
||||
import 'package:cutdex_ui/theme.dart';
|
||||
import 'package:cutdex_native/cutdex_native.dart';
|
||||
import 'package:cutdex_sdk/runtime.dart';
|
||||
|
||||
/// Moves the existing preview into the root overlay, retaining its native view.
|
||||
class PreviewFullscreenHost extends StatefulWidget {
|
||||
@@ -158,7 +159,7 @@ class PreviewFullscreenLayout extends StatelessWidget {
|
||||
borderRadius: BorderRadius.circular(AppRadius.large),
|
||||
)
|
||||
: null,
|
||||
child: toolbar,
|
||||
child: NativePreviewOcclusion(child: toolbar),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -225,29 +225,38 @@ class _EditorPreviewContent extends ConsumerWidget {
|
||||
listenable: activeController.positionChanges,
|
||||
builder: (context, _) => Theme(
|
||||
data: AppTheme.previewCanvasTheme,
|
||||
child:
|
||||
activeController.maskEditingElement != null ||
|
||||
activeController.obscureEditingElement != null
|
||||
? MaskInteractionOverlay(
|
||||
controller: activeController,
|
||||
canvasRect: rect,
|
||||
obscure:
|
||||
activeController.obscureEditingElement !=
|
||||
null,
|
||||
)
|
||||
: PreviewInteractionOverlay(
|
||||
onError: (error) =>
|
||||
ErrorNotificationHost.maybeOf(context)?.show(
|
||||
ErrorNotification(
|
||||
content: Text(
|
||||
context.l10n.canvasTransformFailed,
|
||||
child: NativePreviewOverlay(
|
||||
session: activeController.session!,
|
||||
enabled:
|
||||
activeController.selectedVisualIds.isNotEmpty ||
|
||||
activeController.maskEditingElement != null ||
|
||||
activeController.obscureEditingElement != null,
|
||||
child:
|
||||
activeController.maskEditingElement != null ||
|
||||
activeController.obscureEditingElement != null
|
||||
? MaskInteractionOverlay(
|
||||
controller: activeController,
|
||||
canvasRect: rect,
|
||||
obscure:
|
||||
activeController.obscureEditingElement !=
|
||||
null,
|
||||
)
|
||||
: PreviewInteractionOverlay(
|
||||
onError: (error) =>
|
||||
ErrorNotificationHost.maybeOf(
|
||||
context,
|
||||
)?.show(
|
||||
ErrorNotification(
|
||||
content: Text(
|
||||
context.l10n.canvasTransformFailed,
|
||||
),
|
||||
details: error.toString(),
|
||||
),
|
||||
details: error.toString(),
|
||||
),
|
||||
),
|
||||
controller: activeController,
|
||||
canvasRect: rect,
|
||||
),
|
||||
controller: activeController,
|
||||
canvasRect: rect,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
: null;
|
||||
@@ -339,7 +348,9 @@ class _EditorPreviewContent extends ConsumerWidget {
|
||||
return Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
if (preview.session case final session?)
|
||||
if (preview.session case final session?
|
||||
when preview.error == null &&
|
||||
preview.durationTick > 0)
|
||||
RuntimePreview(session: session),
|
||||
ListenableSelector(
|
||||
listenable: Listenable.merge([
|
||||
@@ -367,14 +378,17 @@ class _EditorPreviewContent extends ConsumerWidget {
|
||||
padding: const EdgeInsets.all(
|
||||
AppSpacing.medium,
|
||||
),
|
||||
child: Text(
|
||||
context.l10n.mediaOffline(
|
||||
unavailable.join(', '),
|
||||
child: NativePreviewOcclusion(
|
||||
child: Text(
|
||||
context.l10n.mediaOffline(
|
||||
unavailable.join(', '),
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow:
|
||||
TextOverflow.ellipsis,
|
||||
textAlign:
|
||||
TextAlign.center,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow:
|
||||
TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -559,7 +573,8 @@ class _SourcePreviewPanel extends ConsumerWidget {
|
||||
return Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
RuntimePreview(session: session),
|
||||
if (!source.audioOnly)
|
||||
RuntimePreview(session: session),
|
||||
if (source.audioOnly)
|
||||
IgnorePointer(
|
||||
child: AudioAssetTile(
|
||||
|
||||
@@ -467,9 +467,11 @@ class _EditingPageState extends ConsumerState<EditingPage> {
|
||||
projectId: visibleProject.id,
|
||||
timelineId: displayDefaults
|
||||
? ''
|
||||
: state.timeline!.id,
|
||||
: state.visibleTimelineId!,
|
||||
projectName: visibleProject.name,
|
||||
projectLoading: displayDefaults,
|
||||
timelineLoading:
|
||||
state.openingTimelineId != null,
|
||||
showProjectName:
|
||||
desktop &&
|
||||
_mode == WorkspaceMode.cut,
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'package:cutdex_ui/theme.dart';
|
||||
import 'package:cutdex_ui/widgets.dart';
|
||||
|
||||
import '../../workspace/media_color_interpretation.dart';
|
||||
import '../../shared/widgets/listenable_selector.dart';
|
||||
import '../../workspace/timeline_session.dart';
|
||||
import '../preview/preview_panel.dart';
|
||||
|
||||
@@ -95,8 +96,12 @@ class ColorInterpretationProperties extends ConsumerWidget {
|
||||
);
|
||||
}
|
||||
|
||||
return ListenableBuilder(
|
||||
return ListenableSelector(
|
||||
listenable: Listenable.merge([session, ?preview]),
|
||||
select: () => (
|
||||
session.mediaColorInterpretation(assetId, trackIndex),
|
||||
preview?.videoColorSpaces(assetId),
|
||||
),
|
||||
builder: (_, _) => contents(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import 'package:cutdex_ui/theme.dart';
|
||||
import 'package:cutdex_ui/widgets.dart';
|
||||
|
||||
import '../../workspace/timeline_session.dart';
|
||||
import '../../shared/widgets/listenable_selector.dart';
|
||||
import '../preview/preview_panel.dart';
|
||||
import 'property_number_input.dart';
|
||||
import 'picture_edits.dart';
|
||||
@@ -43,6 +44,7 @@ class PictureProperties extends ConsumerStatefulWidget {
|
||||
|
||||
class _PicturePropertiesState extends ConsumerState<PictureProperties> {
|
||||
bool _locked = true;
|
||||
bool _hasFocusedControl = false;
|
||||
PictureEditsProvider get _editProvider =>
|
||||
pictureEditsProvider(widget.session, widget.sequence, widget.clip.id);
|
||||
PictureEdits get _edits => ref.read(_editProvider.notifier);
|
||||
@@ -177,6 +179,43 @@ class _PicturePropertiesState extends ConsumerState<PictureProperties> {
|
||||
|
||||
ClipAnimation? _animation() => _edits.animation();
|
||||
ClipTransform? _current() => _animation()?.value;
|
||||
|
||||
Object _presentation(PreviewController? preview) {
|
||||
final view = widget.session.view(widget.sequence);
|
||||
final animation = _animation();
|
||||
final live = preview?.activeSequence() == widget.sequence
|
||||
? preview?.transforms.valueFor(widget.clip.id)
|
||||
: null;
|
||||
final value =
|
||||
(_scrubValid ? _scrubTimeline : null) ??
|
||||
live ??
|
||||
animation?.value ??
|
||||
ClipTransform.fromRecord(widget.clip);
|
||||
final timeDependent =
|
||||
widget.animationView ||
|
||||
TransformChannel.values.any(
|
||||
(channel) => animation?.animated(channel) == true,
|
||||
);
|
||||
return (
|
||||
widget.session.activeSequenceId,
|
||||
view.version.kernelVersion,
|
||||
widget.session.canvas,
|
||||
animation?.containsPlayhead,
|
||||
timeDependent || _hasFocusedControl ? animation?.playhead : null,
|
||||
value.x,
|
||||
value.y,
|
||||
value.scale,
|
||||
value.scaleY,
|
||||
value.rotation,
|
||||
_scrubValid,
|
||||
_scrubBase != null,
|
||||
_saving,
|
||||
_error,
|
||||
preview?.aspectRatioLocked ?? _locked,
|
||||
preview?.transforms.hasPending == true && _scrubEdit == null,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _editKeys(
|
||||
PreviewController? preview,
|
||||
TransformChannel channel, {
|
||||
@@ -216,7 +255,7 @@ class _PicturePropertiesState extends ConsumerState<PictureProperties> {
|
||||
final value =
|
||||
(_scrubValid ? _scrubTimeline : null) ??
|
||||
live ??
|
||||
_current() ??
|
||||
animation?.value ??
|
||||
ClipTransform.fromRecord(widget.clip);
|
||||
final locked = preview?.aspectRatioLocked ?? _locked;
|
||||
final canvas = widget.session.canvas;
|
||||
@@ -627,12 +666,20 @@ class _PicturePropertiesState extends ConsumerState<PictureProperties> {
|
||||
);
|
||||
}
|
||||
|
||||
return ListenableBuilder(
|
||||
listenable: Listenable.merge([
|
||||
widget.session.view(widget.sequence),
|
||||
if (preview != null) ...[preview, preview.transforms],
|
||||
]),
|
||||
builder: (_, _) => contents(),
|
||||
return Focus(
|
||||
onFocusChange: (focused) {
|
||||
if (mounted && focused != _hasFocusedControl) {
|
||||
setState(() => _hasFocusedControl = focused);
|
||||
}
|
||||
},
|
||||
child: ListenableSelector<Object>(
|
||||
listenable: Listenable.merge([
|
||||
widget.session.view(widget.sequence),
|
||||
if (preview != null) ...[preview, preview.transforms],
|
||||
]),
|
||||
select: () => _presentation(preview),
|
||||
builder: (_, _) => contents(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,22 +24,49 @@ class PropertiesInspectorController extends ChangeNotifier {
|
||||
PropertiesInspectorController(this.session) {
|
||||
session.addListener(_sessionChanged);
|
||||
_bindView();
|
||||
_captureSelection();
|
||||
}
|
||||
final EditorTimelineSession session;
|
||||
Listenable? _editingChanges;
|
||||
SequenceId? _lastSequence;
|
||||
Object? _lastVersion;
|
||||
Set<Object> _lastSelection = {};
|
||||
SequenceId? get sequence => session.activeSequenceId;
|
||||
|
||||
void _bindView() {
|
||||
final id = sequence;
|
||||
final next = id == null ? null : session.view(id).editingChanges;
|
||||
if (identical(next, _editingChanges)) return;
|
||||
_editingChanges?.removeListener(notifyListeners);
|
||||
_editingChanges?.removeListener(_viewChanged);
|
||||
_editingChanges = next;
|
||||
_editingChanges?.addListener(notifyListeners);
|
||||
_editingChanges?.addListener(_viewChanged);
|
||||
}
|
||||
|
||||
bool _captureSelection() {
|
||||
final id = sequence;
|
||||
final view = id == null ? null : session.view(id);
|
||||
final version = view?.version.kernelVersion;
|
||||
final selected = view?.selectedIdentities ?? const <Object>{};
|
||||
if (id == _lastSequence &&
|
||||
identical(version, _lastVersion) &&
|
||||
setEquals(selected, _lastSelection)) {
|
||||
return false;
|
||||
}
|
||||
_lastSequence = id;
|
||||
_lastVersion = version;
|
||||
_lastSelection = selected.toSet();
|
||||
return true;
|
||||
}
|
||||
|
||||
void _viewChanged() {
|
||||
// The inspector's selection shell does not depend on the playhead. Its
|
||||
// property editors subscribe separately to position and live edit changes.
|
||||
if (_captureSelection()) notifyListeners();
|
||||
}
|
||||
|
||||
void _sessionChanged() {
|
||||
_bindView();
|
||||
_captureSelection();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -66,7 +93,7 @@ class PropertiesInspectorController extends ChangeNotifier {
|
||||
@override
|
||||
void dispose() {
|
||||
session.removeListener(_sessionChanged);
|
||||
_editingChanges?.removeListener(notifyListeners);
|
||||
_editingChanges?.removeListener(_viewChanged);
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,10 +37,12 @@ class EditorTimelinePanel extends StatelessWidget {
|
||||
required this.projectId,
|
||||
required this.timelineId,
|
||||
this.pending = false,
|
||||
this.timelineLoading = false,
|
||||
});
|
||||
final String projectId;
|
||||
final String timelineId;
|
||||
final bool pending;
|
||||
final bool timelineLoading;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Theme(
|
||||
@@ -56,10 +58,15 @@ class EditorTimelinePanel extends StatelessWidget {
|
||||
),
|
||||
const Divider(height: 1),
|
||||
Expanded(
|
||||
child: _TimelineSessionContent(
|
||||
projectId: projectId,
|
||||
timelineId: timelineId,
|
||||
),
|
||||
child: timelineLoading
|
||||
? const EditorTimelineDefaults(
|
||||
key: Key('timeline-pending'),
|
||||
showTabs: false,
|
||||
)
|
||||
: _TimelineSessionContent(
|
||||
projectId: projectId,
|
||||
timelineId: timelineId,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -183,7 +190,11 @@ class _TimelineTabsBarState extends ConsumerState<_TimelineTabsBar> {
|
||||
(ref.read(projectsProvider).value?.projectBusy ?? false);
|
||||
|
||||
Future<void> _openTimeline(TimelineSummary timeline) async {
|
||||
if (_operationsBusy || timeline.id == widget.timelineId) return;
|
||||
if (widget.creating ||
|
||||
(ref.read(projectsProvider).value?.projectBusy ?? false) ||
|
||||
timeline.id == widget.timelineId) {
|
||||
return;
|
||||
}
|
||||
await ref
|
||||
.read(projectsProvider.notifier)
|
||||
.openTimeline(widget.projectId, timeline.id);
|
||||
@@ -798,6 +809,13 @@ class _TimelineEditorState extends State<_TimelineEditor> {
|
||||
],
|
||||
),
|
||||
const Spacer(),
|
||||
_toolbarButton(
|
||||
key: const ValueKey('timeline-fit'),
|
||||
tooltip: context.l10n.fitTimeline,
|
||||
semanticLabel: context.l10n.fitTimeline,
|
||||
onPressed: controller.fitTimeline,
|
||||
icon: Icons.fit_screen,
|
||||
),
|
||||
if (controller.commandRejection != null)
|
||||
Tooltip(
|
||||
message: controller.commandRejection!,
|
||||
|
||||
Reference in new issue
Block a user