Gitea CI / Assemble and validate CI artifacts (push) Successful in 1m47s
Gitea CI / Check code and tests (push) Successful in 7m15s
Gitea CI / Build Android APK (push) Successful in 4m6s
Gitea CI / Build Windows x64 app (push) Successful in 3m34s
Gitea CI / Audit and package Windows x64 (push) Successful in 1m29s
Gitea CI / Gitea CI passed (push) Successful in 1s
Gitea Release / Prepare draft Release (push) Failing after 8s
Gitea Release / Upload Android to draft Release (push) Skipped
Gitea Release / Upload Windows to draft Release (push) Skipped
Gitea Release / Verify and publish Release (push) Skipped
106 lines
3.4 KiB
Dart
106 lines
3.4 KiB
Dart
import 'dart:math' as math;
|
|
|
|
import 'package:cutdex/l10n/l10n.dart';
|
|
import 'package:cutdex_core/editor.dart';
|
|
import 'package:cutdex_core/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,
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|