Files
cutdex/lib/features/properties/property_keyframe_controls.dart
T
lingjhf 789af7a68e feat(inspector): edit animated effects, strokes and corner distortion
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.
2026-10-10 16:55:27 +08:00

106 lines
3.4 KiB
Dart

import 'dart:math' as math;
import 'package:cutdex/l10n/l10n.dart';
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_sdk/timeline/model.dart';
import 'package:cutdex_ui/icons.dart';
import 'package:cutdex_ui/widgets.dart';
import 'package:flutter/material.dart';
typedef PropertyKeyframeEdit = Future<bool> Function(
List<String> ids, {
KeyframeAction? action,
ParameterInterpolation? interpolation,
});
/// Keyframe controls share channel state and intent callbacks across property fields.
class PropertyKeyframeControls {
const PropertyKeyframeControls({
required this.stack,
required this.enabled,
required this.onEdit,
required this.onSeek,
});
final ClipParameterAnimation stack;
final bool enabled;
final PropertyKeyframeEdit onEdit;
final Future<bool> Function(int localTick) onSeek;
Widget button(
BuildContext context,
List<String> ids,
String label,
String id,
) => IconButton(
key: ValueKey(id),
tooltip: context.l10n.toggleKeyframe(
stack.keyed(ids) ? context.l10n.delete : context.l10n.addKeyframeAction,
label,
),
isSelected: stack.keyed(ids),
color: stack.animated(ids) ? Theme.of(context).colorScheme.primary : null,
icon: Transform.rotate(
angle: math.pi / 4,
child: Icon(
stack.keyed(ids) ? AppIcons.squareFilled : AppIcons.square,
size: 12,
),
),
onPressed: enabled && ids.isNotEmpty ? () => onEdit(ids) : null,
);
Widget menu(BuildContext context, List<String> ids, String label, String id) {
final offsets = stack.keyOffsets(ids);
final currentTick = stack.localTick;
final previous = offsets.where((t) => t < currentTick).lastOrNull;
final next = offsets.where((t) => t > currentTick).firstOrNull;
return AppDropdownMenu(
enabled: enabled,
builder: (context, toggle, focus) => IconButton(
key: ValueKey('$id-menu'),
focusNode: focus,
tooltip: context.l10n.keyframeSettings(label),
onPressed: enabled ? toggle : null,
icon: const Icon(AppIcons.more, size: 16),
),
items: [
AppMenuItem(
closeAncestors: false,
label: context.l10n.previousKeyframe(label),
onPressed: previous == null ? null : () => onSeek(previous),
),
AppMenuItem(
closeAncestors: false,
label: context.l10n.nextKeyframe(label),
onPressed: next == null ? null : () => onSeek(next),
),
for (final (mode, text) in [
(ParameterInterpolation.linear, context.l10n.linear),
(ParameterInterpolation.hold, context.l10n.hold),
(ParameterInterpolation.easeIn, context.l10n.easeIn),
(ParameterInterpolation.easeOut, context.l10n.easeOut),
(ParameterInterpolation.easeInOut, context.l10n.easeInOut),
])
AppMenuItem(
closeAncestors: false,
label: text,
onPressed: stack.keyed(ids)
? () => onEdit(
ids,
action: KeyframeAction.set,
interpolation: mode,
)
: null,
),
AppMenuItem(
closeAncestors: false,
label: context.l10n.removeAllKeyframes,
onPressed: stack.animated(ids)
? () => onEdit(ids, action: KeyframeAction.clear)
: null,
),
],
);
}
}