Replace the shadow-only inspector with layered effect and stroke controls and per-corner distortion editors. Share color inputs, layer rows, keyframe controls and property edit boundaries; keep nested selection menus within their property popover and update localized labels. Add property editing, preview interaction and benchmark comparison coverage. Validation: Dart analysis reports no issues and 160 targeted application tests pass. The macOS development app was rebuilt and visually checked during native rendering validation. Exclude local dependency override changes from the committed lockfile.
212 lines
7.1 KiB
Dart
212 lines
7.1 KiB
Dart
import 'package:cutdex/l10n/l10n.dart';
|
|
import 'package:cutdex_sdk/editor.dart';
|
|
import 'package:cutdex_sdk/timeline/model.dart';
|
|
import 'package:cutdex_sdk/timeline/engine.dart';
|
|
import 'package:cutdex_ui/icons.dart';
|
|
import 'package:cutdex_ui/theme.dart';
|
|
import 'package:cutdex_ui/widgets.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/widget_previews.dart';
|
|
|
|
import 'property_keyframe_controls.dart';
|
|
import 'property_number_input.dart';
|
|
|
|
/// Presentation of four position channels; editing and native lifetime live in the host.
|
|
class DistortionParameterEditor extends StatelessWidget {
|
|
const DistortionParameterEditor({
|
|
super.key,
|
|
required this.value,
|
|
required this.extent,
|
|
required this.enabled,
|
|
required this.editing,
|
|
required this.perspective,
|
|
required this.keyframes,
|
|
required this.editContext,
|
|
required this.onSubmit,
|
|
required this.onReset,
|
|
required this.onPerspective,
|
|
this.onToggle,
|
|
this.error,
|
|
});
|
|
final ClipDistortion value;
|
|
final Size extent;
|
|
final bool enabled, editing, perspective;
|
|
final PropertyKeyframeControls keyframes;
|
|
final Object editContext;
|
|
final Future<bool> Function(int corner, int axis, double value) onSubmit;
|
|
final VoidCallback? onToggle;
|
|
final VoidCallback onReset;
|
|
final ValueChanged<bool> onPerspective;
|
|
final String? error;
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final keys = keyframes, l = context.l10n;
|
|
final labels = [
|
|
l.distortionTopLeft,
|
|
l.distortionTopRight,
|
|
l.distortionBottomRight,
|
|
l.distortionBottomLeft,
|
|
];
|
|
return AppPropertySection(
|
|
child: AppPropertyGroup(
|
|
label: l.distortion,
|
|
padChild: false,
|
|
actions: [
|
|
keys.button(
|
|
context,
|
|
ClipDistortion.ids,
|
|
l.distortion,
|
|
'distortion-key',
|
|
),
|
|
keys.menu(context, ClipDistortion.ids, l.distortion, 'distortion'),
|
|
],
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
AppPropertyRow(
|
|
children: [
|
|
TextButton(
|
|
key: const ValueKey('distortion-edit'),
|
|
onPressed: enabled ? onToggle : null,
|
|
child: Text(editing ? l.finishDistortion : l.editDistortion),
|
|
),
|
|
IconButton(
|
|
key: const ValueKey('distortion-reset'),
|
|
tooltip: l.resetDistortion,
|
|
icon: const Icon(AppIcons.reset, size: 16),
|
|
onPressed: enabled ? onReset : null,
|
|
),
|
|
],
|
|
),
|
|
AppPropertyRow(
|
|
children: [
|
|
AppSelect<bool>(
|
|
value: perspective,
|
|
label: l.distortion,
|
|
emptyLabel: l.freeDistortion,
|
|
options: [
|
|
AppSelectOption(false, l.freeDistortion),
|
|
AppSelectOption(true, l.perspectiveDistortion),
|
|
],
|
|
onChanged: enabled ? onPerspective : null,
|
|
),
|
|
],
|
|
),
|
|
for (var i = 0; i < 4; i++) ...[
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: Text(
|
|
labels[i],
|
|
style: Theme.of(context).textTheme.labelSmall,
|
|
),
|
|
),
|
|
keys.menu(
|
|
context,
|
|
ClipDistortion.ids.sublist(i * 2, i * 2 + 2),
|
|
labels[i],
|
|
'distortion-${ClipDistortion.names[i]}',
|
|
),
|
|
],
|
|
),
|
|
),
|
|
AppPropertyRow(
|
|
trailing: keys.button(
|
|
context,
|
|
ClipDistortion.ids.sublist(i * 2, i * 2 + 2),
|
|
labels[i],
|
|
'distortion-${ClipDistortion.names[i]}-key',
|
|
),
|
|
children: [
|
|
for (var axis = 0; axis < 2; axis++)
|
|
PropertyNumberInput(
|
|
key: ValueKey(
|
|
'distortion-${ClipDistortion.names[i]}-${axis == 0 ? 'x' : 'y'}',
|
|
),
|
|
label: axis == 0 ? 'X' : 'Y',
|
|
inlineLabel: true,
|
|
prefix: axis == 0 ? 'X' : 'Y',
|
|
value:
|
|
value.values[i * 2 + axis] *
|
|
(axis == 0 ? extent.width : extent.height),
|
|
enabled: enabled,
|
|
readOnly: false,
|
|
editContext: editContext,
|
|
submit: (v) => onSubmit(i, axis, v),
|
|
onScrubUpdate: (_) {},
|
|
onScrubEnd: () {},
|
|
onScrubCancel: () {},
|
|
scrubbing: false,
|
|
),
|
|
],
|
|
),
|
|
],
|
|
if (error != null)
|
|
Padding(padding: const EdgeInsets.all(16), child: Text(error!)),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
@Preview(name: 'Distortion / desktop', size: Size(240, 400))
|
|
Widget distortionEditorPreview() {
|
|
var value = const ClipDistortion(topLeft: (.05, .1));
|
|
var perspective = false, editing = false;
|
|
final stack = ClipParameterAnimation(
|
|
ElementRecord(
|
|
id: ElementId('preview'),
|
|
structure: ElementStructure.content,
|
|
duration: 1,
|
|
sourceStart: 0,
|
|
sourceDuration: 1,
|
|
enabled: true,
|
|
),
|
|
0,
|
|
);
|
|
return MaterialApp(
|
|
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
|
supportedLocales: AppLocalizations.supportedLocales,
|
|
theme: AppTheme.propertiesPanelTheme(
|
|
AppTheme.desktopWorkspaceTheme(AppTheme.penDark),
|
|
),
|
|
home: Scaffold(
|
|
body: StatefulBuilder(
|
|
builder: (context, update) => SingleChildScrollView(
|
|
child: DistortionParameterEditor(
|
|
value: value,
|
|
extent: const Size(300, 200),
|
|
enabled: true,
|
|
editing: editing,
|
|
perspective: perspective,
|
|
editContext: 'preview',
|
|
keyframes: PropertyKeyframeControls(
|
|
stack: stack,
|
|
enabled: true,
|
|
onEdit: (ids, {action, interpolation}) async => true,
|
|
onSeek: (_) async => true,
|
|
),
|
|
onSubmit: (corner, axis, input) async {
|
|
final p = value.corners[corner];
|
|
final next = value.withCorner(
|
|
corner,
|
|
axis == 0 ? input / 300 : p.$1,
|
|
axis == 1 ? input / 200 : p.$2,
|
|
);
|
|
if (!next.isValid) return false;
|
|
update(() => value = next);
|
|
return true;
|
|
},
|
|
onReset: () => update(() => value = const ClipDistortion()),
|
|
onToggle: () => update(() => editing = !editing),
|
|
onPerspective: (v) => update(() => perspective = v),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|