feat(workspace): refresh desktop editing experience and prepare 0.1.2
Gitea CI / Build Android APK (pull_request) Canceled after 0s
Gitea CI / Build Windows x64 app (pull_request) Canceled after 0s
Gitea CI / Audit and package Windows x64 (pull_request) Canceled after 0s
Gitea CI / Assemble and validate CI artifacts (pull_request) Canceled after 0s
Gitea CI / Gitea CI passed (pull_request) Canceled after 0s
Gitea CI / Check code and tests (pull_request) Canceled after 6m29s

This commit is contained in:
lingjhf committed 2026-10-09 01:56:01 +08:00
1 parent aa5255d1e4
commit 2e0033ce2d
260 files changed
+43963 -5591

No files matched your search

+188 -166
View File
@@ -1,9 +1,12 @@
import '../../shared/widgets/listenable_selector.dart';
import 'package:cutdex/l10n/l10n.dart';
import 'package:cutdex/features/properties/audio_gain_scale.dart';
import 'package:cutdex_sdk/timeline/engine.dart';
import 'package:cutdex_sdk/timeline/model.dart';
import 'package:flutter/material.dart';
import 'package:cutdex_ui/icons.dart';
import 'package:cutdex_ui/widgets.dart';
import 'package:cutdex_ui/theme.dart';
@@ -123,8 +126,28 @@ class _AudioPropertiesState extends State<AudioProperties> {
@override
Widget build(BuildContext context) {
final view = widget.session.view(widget.sequence);
return ListenableBuilder(
listenable: view,
return ListenableSelector<Object>(
listenable: Listenable.merge([view, widget.session]),
select: () {
final query = view.version.kernelVersion.query();
final handle = query.elementById(widget.clip.id);
final record = handle == null ? widget.clip : query.element(handle);
final localTick = handle == null
? 0
: view.playheadTick - query.absoluteStart(handle);
final tick = TimelineSourceClock(record).nearestSourceTick(
localTick.clamp(0, record.duration > 0 ? record.duration - 1 : 0),
);
final gain = ClipAudioGain.fromRecord(record, sourceTick: tick);
return (
record,
gain.db,
gain.muted,
record.parameters?[ClipAudioGain.gainId]?.keyframeAt(tick),
widget.session.acceptsEdits,
_editValid,
);
},
builder: (context, _) {
final query = view.version.kernelVersion.query();
final handle = query.elementById(widget.clip.id);
@@ -147,7 +170,7 @@ class _AudioPropertiesState extends State<AudioProperties> {
}
if (ClipAudioGain.isDetached(record)) {
return Padding(
padding: AppSpacing.panelSection,
padding: AppTheme.propertySectionPadding(context),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
@@ -155,10 +178,10 @@ class _AudioPropertiesState extends State<AudioProperties> {
context.l10n.audioDetached,
style: AppTheme.propertySectionTitleStyle(context),
),
const SizedBox(height: AppSpacing.small),
SizedBox(height: AppTheme.propertyRowGap(context)),
OutlinedButton.icon(
key: const Key('audio-restore'),
icon: const Icon(Icons.volume_up_outlined),
icon: const Icon(AppIcons.volume),
label: Text(context.l10n.restoreAudio),
onPressed: !enabled || !widget.session.acceptsEdits
? null
@@ -187,172 +210,171 @@ class _AudioPropertiesState extends State<AudioProperties> {
),
);
}
final volumeActions = <Widget>[
IconButton(
key: const Key('audio-key'),
tooltip: context.l10n.toggleKeyframe(
keyed ? context.l10n.delete : context.l10n.addKeyframeAction,
context.l10n.volume,
),
isSelected: keyed,
icon: Transform.rotate(
angle: 0.7853981633974483,
child: Icon(
keyed ? AppIcons.squareFilled : AppIcons.square,
size: 12,
),
),
onPressed: !enabled
? null
: () {
if (_dirty && !_submit(_text.text)) return;
_focus.unfocus();
FocusManager.instance.applyFocusChangesIfNeeded();
try {
widget.session.commands.editKeyframeChannel(
sequence: widget.sequence,
clip: widget.clip.id,
tick: view.playheadTick,
parameterIds: [ClipAudioGain.gainId],
);
} catch (_) {
setState(
() => _error = context.l10n.updateKeyframesFailed,
);
}
},
),
IconButton(
key: const Key('audio-mute'),
tooltip: value.muted ? context.l10n.unmute : context.l10n.mute,
isSelected: value.muted,
icon: Icon(value.muted ? AppIcons.mute : AppIcons.volume),
onPressed: !enabled
? null
: () {
_editVersion = null;
_editTick = null;
_commit(ClipAudioGain(saved.db, muted: !saved.muted));
},
),
IconButton(
key: const Key('audio-reset'),
tooltip: context.l10n.resetVolume,
icon: const Icon(AppIcons.reset),
onPressed: !enabled
? null
: () {
_editVersion = null;
_editTick = null;
_commit(const ClipAudioGain(0));
},
),
];
final volumeControls = Row(
children: [
Expanded(
child: AppSlider(
key: const Key('audio-slider'),
value: value.muted ? 0 : AudioGainScale.positionAt(value.db),
semanticFormatterCallback: (p) => p == 0
? context.l10n.mute
: '${AudioGainScale.formatDb(AudioGainScale.dbAt(p))} dB',
onChangeStart: !enabled
? null
: (_) {
_focus.unfocus();
FocusManager.instance.applyFocusChangesIfNeeded();
_beginEdit();
},
onChanged: !enabled
? null
: (p) => setState(() {
if (!_editValid) {
widget.session.clearAudioGainPreview(widget.clip.id);
_timeline = null;
return;
}
_dirty = false;
_timeline = p == 0
? ClipAudioGain(saved.db, muted: true)
: ClipAudioGain(
AudioGainScale.quantizeDb(
AudioGainScale.dbAt(p),
),
);
widget.session.previewAudioGain(
widget.sequence,
widget.clip.id,
_timeline!,
);
}),
onChangeEnd: !enabled
? null
: (_) => _commit(_timeline ?? saved),
),
),
SizedBox(width: AppTheme.propertyRowGap(context)),
SizedBox(
width: 84,
child: AppTextField(
key: const Key('audio-db'),
controller: _text,
focusNode: _focus,
label: null,
unit: 'dB',
enabled: enabled,
errorText: _error,
keyboardType: const TextInputType.numberWithOptions(
signed: true,
decimal: true,
),
onChanged: (_) {
if (!_dirty) {
_beginEdit();
}
_dirty = true;
},
onSubmitted: _submit,
),
),
],
);
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Padding(
padding: AppSpacing.panelSection,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Row(
children: [
Expanded(
child: Text(
widget.hasAudio
? context.l10n.volume
: context.l10n.unboundAudio,
style: AppTheme.propertySectionTitleStyle(context),
padding: AppTheme.propertySectionPadding(context),
child: AppTheme.isDesktop(context)
? AppPropertyGroup(
label: widget.hasAudio
? context.l10n.volume
: context.l10n.unboundAudio,
actions: volumeActions,
child: volumeControls,
)
: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Row(
children: [
Expanded(
child: Text(
widget.hasAudio
? context.l10n.volume
: context.l10n.unboundAudio,
style: AppTheme.propertySectionTitleStyle(
context,
),
),
),
...volumeActions,
],
),
),
IconButton(
key: const Key('audio-key'),
tooltip: context.l10n.toggleKeyframe(
keyed
? context.l10n.delete
: context.l10n.addKeyframeAction,
context.l10n.volume,
),
isSelected: keyed,
icon: Transform.rotate(
angle: 0.7853981633974483,
child: Icon(
keyed ? Icons.square : Icons.crop_square,
size: 12,
),
),
onPressed: !enabled
? null
: () {
if (_dirty && !_submit(_text.text)) return;
_focus.unfocus();
FocusManager.instance
.applyFocusChangesIfNeeded();
try {
widget.session.commands.editKeyframeChannel(
sequence: widget.sequence,
clip: widget.clip.id,
tick: view.playheadTick,
parameterIds: [ClipAudioGain.gainId],
);
} catch (_) {
setState(
() => _error =
context.l10n.updateKeyframesFailed,
);
}
},
),
IconButton(
key: const Key('audio-mute'),
tooltip: value.muted
? context.l10n.unmute
: context.l10n.mute,
isSelected: value.muted,
icon: Icon(
value.muted ? Icons.volume_off : Icons.volume_up,
),
onPressed: !enabled
? null
: () {
_editVersion = null;
_editTick = null;
_commit(
ClipAudioGain(saved.db, muted: !saved.muted),
);
},
),
IconButton(
key: const Key('audio-reset'),
tooltip: context.l10n.resetVolume,
icon: const Icon(Icons.restart_alt),
onPressed: !enabled
? null
: () {
_editVersion = null;
_editTick = null;
_commit(const ClipAudioGain(0));
},
),
],
),
const SizedBox(height: AppSpacing.small),
Row(
children: [
Expanded(
child: AppSlider(
key: const Key('audio-slider'),
value: value.muted
? 0
: AudioGainScale.positionAt(value.db),
semanticFormatterCallback: (p) => p == 0
? context.l10n.mute
: '${AudioGainScale.formatDb(AudioGainScale.dbAt(p))} dB',
onChangeStart: !enabled
? null
: (_) {
_focus.unfocus();
FocusManager.instance
.applyFocusChangesIfNeeded();
_beginEdit();
},
onChanged: !enabled
? null
: (p) => setState(() {
if (!_editValid) {
widget.session.clearAudioGainPreview(
widget.clip.id,
);
_timeline = null;
return;
}
_dirty = false;
_timeline = p == 0
? ClipAudioGain(saved.db, muted: true)
: ClipAudioGain(
AudioGainScale.quantizeDb(
AudioGainScale.dbAt(p),
),
);
widget.session.previewAudioGain(
widget.sequence,
widget.clip.id,
_timeline!,
);
}),
onChangeEnd: !enabled
? null
: (_) => _commit(_timeline ?? saved),
),
),
const SizedBox(width: AppSpacing.small),
SizedBox(
width: 84,
child: AppTextField(
key: const Key('audio-db'),
controller: _text,
focusNode: _focus,
label: null,
unit: 'dB',
enabled: enabled,
errorText: _error,
keyboardType: const TextInputType.numberWithOptions(
signed: true,
decimal: true,
),
onChanged: (_) {
if (!_dirty) {
_beginEdit();
}
_dirty = true;
},
onSubmitted: _submit,
),
),
],
),
],
),
SizedBox(height: AppTheme.propertyRowGap(context)),
volumeControls,
],
),
),
],
);
+283 -146
View File
@@ -1,9 +1,13 @@
import '../../shared/widgets/listenable_selector.dart';
import '../../shared/widgets/presentation_list.dart';
import 'package:cutdex/shared/widgets/error_notification_host.dart';
import 'package:cutdex/l10n/l10n.dart';
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_sdk/timeline/model.dart';
import 'package:flutter/material.dart';
import 'package:cutdex_ui/icons.dart';
import 'package:cutdex_ui/theme.dart';
import 'package:cutdex_ui/widgets.dart';
@@ -187,15 +191,15 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
final matches = cues.indexed
.where((entry) => entry.$2.text.toLowerCase().contains(_captionQuery))
.toList();
final actionSize = AppTheme.isDesktop(context)
? AppInspectorMetrics.action
: 28.0;
return Column(
children: [
Padding(
padding: const EdgeInsets.symmetric(
horizontal: AppSpacing.panelContentHorizontal,
vertical: AppSpacing.small,
),
padding: AppTheme.propertySectionPadding(context),
child: SizedBox(
height: 28,
height: AppTheme.propertyInputHeight(context),
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
@@ -203,7 +207,7 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
child: TextField(
key: const ValueKey('caption-search'),
controller: _captionSearch,
style: Theme.of(context).textTheme.bodyMedium,
style: AppTheme.inputTextStyle(context),
cursorHeight: AppTheme.inputCursorHeight(context),
textAlignVertical: TextAlignVertical.center,
textInputAction: TextInputAction.search,
@@ -212,12 +216,16 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
context.l10n.captions,
),
isDense: true,
constraints: const BoxConstraints.tightFor(height: 28),
constraints: BoxConstraints.tightFor(
height: AppTheme.isDesktop(context)
? AppInspectorMetrics.input
: 28,
),
contentPadding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 0,
),
prefixIcon: const Icon(Icons.search, size: 14),
prefixIcon: const Icon(AppIcons.search, size: 14),
prefixIconConstraints: const BoxConstraints(
minWidth: 28,
minHeight: 28,
@@ -229,27 +237,29 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
),
),
const SizedBox(width: 4),
IconButton(
key: const ValueKey('caption-wrap-toggle'),
tooltip: _wrapCaptions
? context.l10n.captionSingleLine
: context.l10n.captionWrapLines,
isSelected: _wrapCaptions,
color: _wrapCaptions
? Theme.of(context).colorScheme.primary
: null,
icon: const Icon(Icons.wrap_text, size: 16),
padding: EdgeInsets.zero,
style: IconButton.styleFrom(
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
visualDensity: VisualDensity.standard,
Align(
child: IconButton(
key: const ValueKey('caption-wrap-toggle'),
tooltip: _wrapCaptions
? context.l10n.captionSingleLine
: context.l10n.captionWrapLines,
isSelected: _wrapCaptions,
color: _wrapCaptions
? Theme.of(context).colorScheme.primary
: null,
icon: const Icon(AppIcons.textWrap, size: 16),
padding: EdgeInsets.zero,
style: IconButton.styleFrom(
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
visualDensity: VisualDensity.standard,
),
constraints: BoxConstraints.tightFor(
width: actionSize,
height: actionSize,
),
onPressed: () =>
setState(() => _wrapCaptions = !_wrapCaptions),
),
constraints: const BoxConstraints.tightFor(
width: 28,
height: 28,
),
onPressed: () =>
setState(() => _wrapCaptions = !_wrapCaptions),
),
],
),
@@ -273,8 +283,10 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
children: [
for (final (index, cue) in matches)
Padding(
padding: const EdgeInsets.symmetric(
horizontal: AppSpacing.panelContentHorizontal,
padding: EdgeInsets.symmetric(
horizontal: AppTheme.isDesktop(context)
? AppInspectorMetrics.padding
: AppSpacing.panelContentHorizontal,
vertical: AppSpacing.hairline,
),
child: Material(
@@ -332,21 +344,20 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
),
const SizedBox(width: 4),
SizedBox(
width: 28,
height: 28,
width: actionSize,
height: actionSize,
child: IconButton(
key: ValueKey(
'caption-action-${cue.id}',
),
tooltip: context.l10n.select,
padding: EdgeInsets.zero,
constraints:
const BoxConstraints.tightFor(
width: 28,
height: 28,
),
constraints: BoxConstraints.tightFor(
width: actionSize,
height: actionSize,
),
icon: const Icon(
Icons.chevron_right,
AppIcons.chevronRight,
size: 14,
),
onPressed: () => _selectCue(cue.id),
@@ -368,8 +379,42 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
}
@override
Widget build(BuildContext context) => ListenableBuilder(
Widget build(BuildContext context) => ListenableSelector<Object>(
listenable: widget.session,
select: () {
final query = widget.session.persistence
.timeline(widget.sequence)
.current
.query();
final handle = query.elementById(ElementId(widget.clipId));
if (handle == null) return (null, widget.session.acceptsEdits);
final clip = query.element(handle);
final role = clip.containerStoryline != null
? handle
: widget.session.captionRole(widget.sequence);
final child = role == null
? null
: query.element(role).containerStoryline;
return (
clip,
clip.payloadRef == null
? null
: widget.session.payloadFor(clip.payloadRef!),
query.localContext(handle).start,
widget.session.acceptsEdits,
widget.session.version,
PresentationList([
if (child != null)
for (final cue in query.storylineElements(child))
(
query.element(cue),
query.element(cue).payloadRef == null
? null
: widget.session.payloadFor(query.element(cue).payloadRef!),
),
]),
);
},
builder: (context, _) {
final q = widget.session.persistence
.timeline(widget.sequence)
@@ -402,7 +447,9 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
final selected = isRole ? _CaptionPropertyCategory.captions : _selected;
Widget panel(Widget content) => WorkspacePanel(
paintBackground: false,
headerHeight: CompactPanelTabs.height,
headerHeight: AppTheme.isDesktop(context)
? AppDesktopMetrics.panelHeader
: CompactPanelTabs.height,
headerPadding: EdgeInsets.zero,
showHeaderDivider: false,
controls: CompactPanelTabs<_CaptionPropertyCategory>(
@@ -421,6 +468,12 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
final caption = widget.session.caption(widget.sequence, widget.clipId);
final version = widget.session.version;
final editContext = (
widget.session,
widget.sequence,
widget.clipId,
version,
);
final start = RationalTime.timelineTicks(q.localContext(handle).start)
.seconds;
final duration = RationalTime.timelineTicks(clip.duration).seconds;
@@ -436,17 +489,21 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
required double scale,
String? unit,
int decimalPlaces = 2,
bool inlineLabel = false,
String? prefix,
required SetCaption Function(double, String) command,
}) => PropertyNumberInput(
key: ValueKey('caption-$field'),
label: label,
inlineLabel: inlineLabel,
prefix: prefix,
unit: unit,
decimalPlaces: decimalPlaces,
value: shown(field, value),
enabled: true,
readOnly: _scrubField != null,
scrubbing: _scrubField == field,
editContext: (widget.clipId, version),
editContext: editContext,
submit: (next) async {
if (!next.isFinite || next < min || next > max) return false;
return _save(command(next, version));
@@ -457,6 +514,51 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
onScrubCancel: _cancelScrub,
);
final baselineInput = number(
field: 'positionY',
inlineLabel: AppTheme.isDesktop(context),
prefix: AppTheme.isDesktop(context) ? 'Y' : null,
label: context.l10n.vertical,
value: caption.positionY,
min: -.5,
max: .5,
scale: .002,
decimalPlaces: 3,
command: (value, expected) => SetCaption(
captionId: widget.clipId,
positionY: value,
expectedVersion: expected,
),
);
final contentInput = _CaptionTextInput(
key: ValueKey(('caption-text', widget.clipId)),
editContext: editContext,
value: caption.text,
maxLines: 3,
onSubmit: (text) => _save(
SetCaption(
captionId: widget.clipId,
text: text,
expectedVersion: version,
),
),
);
final deleteAction = IconButton(
tooltip: context.l10n.deleteCaption,
icon: const Icon(AppIcons.delete),
onPressed: () {
try {
widget.session.commands.applyEdit(
widget.sequence,
DeleteClip(widget.clipId, expectedVersion: version),
);
} on CommandRejected {
ErrorNotificationHost.maybeOf(context)?.show(
ErrorNotification(content: Text(context.l10n.captionChanged)),
);
}
},
);
return panel(
ScrollEdgeFadeBuilder(
key: const ValueKey('caption-detail-scroll-fade'),
@@ -465,58 +567,39 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
padding: const EdgeInsets.symmetric(vertical: AppSpacing.small),
children:
[
Row(
children: [
Expanded(
child: Text(
context.l10n.textClip,
style: AppTheme.propertySectionTitleStyle(
context,
if (AppTheme.isDesktop(context))
AppPropertyGroup(
label: context.l10n.content,
actions: [deleteAction],
child: contentInput,
)
else ...[
Row(
children: [
Expanded(
child: Text(
context.l10n.textClip,
style: AppTheme.propertySectionTitleStyle(
context,
),
),
),
),
IconButton(
tooltip: context.l10n.deleteCaption,
icon: const Icon(Icons.delete_outline),
onPressed: () {
try {
widget.session.commands.applyEdit(
widget.sequence,
DeleteClip(
widget.clipId,
expectedVersion: version,
),
);
} on CommandRejected {
ErrorNotificationHost.maybeOf(context)?.show(
ErrorNotification(
content: Text(context.l10n.captionChanged),
),
);
}
},
),
],
),
const SizedBox(height: AppSpacing.small),
Text(
context.l10n.content,
style: AppTheme.propertySectionTitleStyle(context),
),
const SizedBox(height: AppSpacing.small),
_CaptionTextInput(
key: ValueKey(('caption-text', widget.clipId)),
value: caption.text,
maxLines: 3,
onSubmit: (text) => _save(
SetCaption(
captionId: widget.clipId,
text: text,
expectedVersion: version,
),
deleteAction,
],
),
SizedBox(height: AppTheme.propertyRowGap(context)),
Text(
context.l10n.content,
style: AppTheme.propertySectionTitleStyle(context),
),
SizedBox(height: AppTheme.propertyRowGap(context)),
contentInput,
],
SizedBox(
height: AppTheme.isDesktop(context)
? AppInspectorMetrics.groupGap
: AppSpacing.small,
),
const SizedBox(height: AppSpacing.small),
number(
field: 'fontSize',
label: context.l10n.fontSize,
@@ -531,9 +614,14 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
expectedVersion: expected,
),
),
const SizedBox(height: AppSpacing.small),
SizedBox(
height: AppTheme.isDesktop(context)
? AppInspectorMetrics.groupGap
: AppSpacing.small,
),
_CaptionColorInput(
key: ValueKey(('caption-color', widget.clipId)),
editContext: editContext,
value: caption.color,
label: context.l10n.color,
onSubmit: (color) => _save(
@@ -544,9 +632,14 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
),
),
),
const SizedBox(height: AppSpacing.small),
SizedBox(
height: AppTheme.isDesktop(context)
? AppInspectorMetrics.groupGap
: AppSpacing.small,
),
_CaptionColorInput(
key: ValueKey(('caption-strokeColor', widget.clipId)),
editContext: editContext,
value: caption.strokeColor,
label: context.l10n.outlineColor,
onSubmit: (color) => _save(
@@ -557,7 +650,11 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
),
),
),
const SizedBox(height: AppSpacing.small),
SizedBox(
height: AppTheme.isDesktop(context)
? AppInspectorMetrics.groupGap
: AppSpacing.small,
),
number(
field: 'strokeWidth',
label: context.l10n.outlineWidth,
@@ -573,42 +670,56 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
),
),
if (widget.transformProperties case final transform?) ...[
const SizedBox(height: AppSpacing.medium),
const Divider(height: 1),
const SizedBox(height: AppSpacing.medium),
Text(
context.l10n.transform,
style: AppTheme.propertySectionTitleStyle(context),
SizedBox(
height: AppTheme.isDesktop(context)
? AppInspectorMetrics.groupGap
: AppSpacing.medium,
),
const SizedBox(height: AppSpacing.small),
const Divider(height: 1),
SizedBox(
height: AppTheme.isDesktop(context)
? AppInspectorMetrics.groupGap
: AppSpacing.medium,
),
if (!AppTheme.isDesktop(context)) ...[
Text(
context.l10n.transform,
style: AppTheme.propertySectionTitleStyle(context),
),
SizedBox(height: AppTheme.propertyRowGap(context)),
],
transform,
],
const SizedBox(height: AppSpacing.medium),
Text(
context.l10n.captionBaseline,
style: AppTheme.propertySectionTitleStyle(context),
SizedBox(
height: AppTheme.isDesktop(context)
? AppInspectorMetrics.groupGap
: AppSpacing.medium,
),
const SizedBox(height: AppSpacing.small),
number(
field: 'positionY',
label: context.l10n.vertical,
value: caption.positionY,
min: -.5,
max: .5,
scale: .002,
decimalPlaces: 3,
command: (value, expected) => SetCaption(
captionId: widget.clipId,
positionY: value,
expectedVersion: expected,
if (AppTheme.isDesktop(context))
AppPropertyGroup(
label: context.l10n.captionBaseline,
child: baselineInput,
)
else ...[
Text(
context.l10n.captionBaseline,
style: AppTheme.propertySectionTitleStyle(context),
),
SizedBox(height: AppTheme.propertyRowGap(context)),
baselineInput,
],
SizedBox(
height: AppTheme.isDesktop(context)
? AppInspectorMetrics.groupGap
: AppSpacing.medium,
),
const SizedBox(height: AppSpacing.medium),
Text(
context.l10n.time,
style: AppTheme.propertySectionTitleStyle(context),
),
const SizedBox(height: AppSpacing.small),
if (!AppTheme.isDesktop(context)) ...[
Text(
context.l10n.time,
style: AppTheme.propertySectionTitleStyle(context),
),
SizedBox(height: AppTheme.propertyRowGap(context)),
],
LayoutBuilder(
builder: (context, constraints) {
Widget startField() => number(
@@ -641,19 +752,23 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
expectedVersion: expected,
),
);
if (constraints.maxWidth < 240) {
if (constraints.maxWidth <
(AppTheme.isDesktop(context) ? 180 : 240)) {
return Column(
children: [
startField(),
const SizedBox(height: AppSpacing.small),
SizedBox(
height: AppTheme.propertyRowGap(context),
),
durationField(),
],
);
}
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(child: startField()),
const SizedBox(width: AppSpacing.small),
SizedBox(width: AppTheme.propertyRowGap(context)),
Expanded(child: durationField()),
],
);
@@ -666,8 +781,10 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
identical(item, widget.transformProperties)
? item
: Padding(
padding: const EdgeInsets.symmetric(
horizontal: AppSpacing.panelContentHorizontal,
padding: EdgeInsets.symmetric(
horizontal: AppTheme.isDesktop(context)
? AppInspectorMetrics.padding
: AppSpacing.panelContentHorizontal,
),
child: item,
),
@@ -684,11 +801,13 @@ class _CaptionTextInput extends StatefulWidget {
const _CaptionTextInput({
super.key,
required this.value,
required this.editContext,
required this.onSubmit,
this.label,
this.maxLines = 1,
});
final String value;
final Object editContext;
final String? label;
final int maxLines;
final bool Function(String) onSubmit;
@@ -727,6 +846,12 @@ class _CaptionTextInputState extends State<_CaptionTextInput> {
@override
void didUpdateWidget(covariant _CaptionTextInput oldWidget) {
super.didUpdateWidget(oldWidget);
// A new callback carries the new authored version. Never let a draft from
// the previous binding borrow that version and overwrite a newer edit.
if (oldWidget.editContext != widget.editContext) {
_dirty = false;
_error = null;
}
if (!_dirty && _controller.text != widget.value) {
_controller.text = widget.value;
}
@@ -763,34 +888,46 @@ class _CaptionColorInput extends StatelessWidget {
const _CaptionColorInput({
super.key,
required this.value,
required this.editContext,
required this.label,
required this.onSubmit,
});
final String value;
final Object editContext;
final String label;
final bool Function(String) onSubmit;
@override
Widget build(BuildContext context) => Row(
children: [
Container(
width: 20,
height: 20,
decoration: BoxDecoration(
color: Color(int.parse('FF${value.substring(1)}', radix: 16)),
border: Border.all(color: Theme.of(context).colorScheme.outline),
borderRadius: BorderRadius.circular(AppRadius.extraSmall),
Widget build(BuildContext context) {
final desktop = AppTheme.isDesktop(context);
final controls = Row(
children: [
Container(
width: 20,
height: 20,
decoration: BoxDecoration(
color: Color(int.parse('FF${value.substring(1)}', radix: 16)),
border: Border.all(color: Theme.of(context).colorScheme.outline),
borderRadius: BorderRadius.circular(AppRadius.extraSmall),
),
),
),
const SizedBox(width: AppSpacing.small),
Expanded(
child: _CaptionTextInput(
value: value,
label: label,
onSubmit: onSubmit,
const SizedBox(width: AppSpacing.small),
Expanded(
child: _CaptionTextInput(
value: value,
editContext: editContext,
label: desktop ? null : label,
onSubmit: onSubmit,
),
),
),
],
);
],
);
return desktop
? AppPropertyGroup(
label: label,
child: Semantics(label: label, child: controls),
)
: controls;
}
}
@@ -47,12 +47,35 @@ class ColorInterpretationProperties extends ConsumerWidget {
: reported
? context.l10n.unknownColorSpace
: context.l10n.colorInfoNotLoaded;
return Padding(
padding: AppSpacing.panelSection,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
spacing: AppSpacing.gap,
children: [
final selector = AppSelect<String>(
emptyLabel: context.l10n.noMatchingOptions,
key: const Key('media-color-menu'),
outlined: false,
label: context.l10n.mediaColorInterpretation,
value: selected?.name ?? 'auto',
onChanged: !reported
? null
: (value) => session.commands.setMediaColor(
assetId,
trackIndex,
value == 'auto' ? null : MediaColorSpace.values.byName(value),
),
options: [
AppSelectOption('auto', context.l10n.auto),
for (final color in RenderColorSpace.values)
AppSelectOption(color.name, color.label(context.l10n)),
],
);
final controls = Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
spacing: AppSpacing.gap,
children: [
if (AppTheme.isDesktop(context)) ...[
AppPropertyGroup(
label: context.l10n.mediaColorSpace,
child: selector,
),
] else
Row(
children: [
Expanded(
@@ -61,38 +84,42 @@ class ColorInterpretationProperties extends ConsumerWidget {
style: AppTheme.propertySectionTitleStyle(context),
),
),
Flexible(
child: AppSelect<String>(
emptyLabel: context.l10n.noMatchingOptions,
key: const Key('media-color-menu'),
outlined: false,
label: context.l10n.mediaColorInterpretation,
value: selected?.name ?? 'auto',
onChanged: !reported
? null
: (value) => session.commands.setMediaColor(
assetId,
trackIndex,
value == 'auto'
? null
: MediaColorSpace.values.byName(value),
),
options: [
AppSelectOption('auto', context.l10n.auto),
for (final color in RenderColorSpace.values)
AppSelectOption(color.name, color.label(context.l10n)),
],
),
),
Flexible(child: selector),
],
),
Text(
status,
key: const Key('media-color-status'),
style: Theme.of(context).textTheme.bodySmall,
),
],
),
Text(
status,
key: const Key('media-color-status'),
style: Theme.of(context).textTheme.bodySmall,
),
],
);
return Padding(
padding: AppTheme.propertySectionPadding(context),
child: AppTheme.isDesktop(context)
? ExpansionTile(
key: PageStorageKey((
'media-color-section',
assetId,
trackIndex,
)),
title: Text(
context.l10n.mediaColorInterpretation,
style: AppTheme.propertySectionTitleStyle(context),
),
tilePadding: EdgeInsets.zero,
childrenPadding: const EdgeInsets.only(
top: AppInspectorMetrics.rowGap,
),
minTileHeight: AppInspectorMetrics.input,
dense: true,
maintainState: true,
initiallyExpanded: selected != null,
shape: const Border(),
collapsedShape: const Border(),
children: [controls],
)
: controls,
);
}
File diff suppressed because it is too large. Load diff
+348 -239
View File
@@ -12,11 +12,13 @@ import 'package:cutdex_sdk/timeline/model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:cutdex_ui/icons.dart';
import 'package:cutdex_ui/theme.dart';
import 'package:cutdex_ui/widgets.dart';
import '../../workspace/timeline_session.dart';
import '../../shared/widgets/listenable_selector.dart';
import '../../shared/state/operation_scope.dart';
import '../preview/preview_panel.dart';
import 'property_number_input.dart';
import 'picture_edits.dart';
@@ -43,6 +45,17 @@ class PictureProperties extends ConsumerStatefulWidget {
}
class _PicturePropertiesState extends ConsumerState<PictureProperties> {
Object get _editIdentity => (
widget.projectId,
widget.timelineId,
widget.session,
widget.sequence,
widget.clip.id,
);
PreviewController? _boundPreview;
Object get _operationContext => (_editIdentity, _boundPreview);
late final _operations = OperationScope<Object>(_operationContext);
late final _seeks = OperationScope<Object>(_operationContext);
bool _locked = true;
bool _hasFocusedControl = false;
PictureEditsProvider get _editProvider =>
@@ -50,17 +63,56 @@ class _PicturePropertiesState extends ConsumerState<PictureProperties> {
PictureEdits get _edits => ref.read(_editProvider.notifier);
bool get _saving => ref.read(_editProvider).isLoading;
bool Function() _guard() {
final isCurrent = _operations.capture();
final session = widget.session;
final sequence = widget.sequence;
final clip = widget.clip.id;
return () =>
mounted &&
isCurrent() &&
_scrubBase == null &&
identical(widget.session, session) &&
widget.sequence == sequence &&
widget.clip.id == clip;
}
@override
void didUpdateWidget(covariant PictureProperties oldWidget) {
super.didUpdateWidget(oldWidget);
final previousIdentity = (
oldWidget.projectId,
oldWidget.timelineId,
oldWidget.session,
oldWidget.sequence,
oldWidget.clip.id,
);
if (previousIdentity != _editIdentity) {
final edit = _clearScrub();
if (edit != null) scheduleMicrotask(edit.cancel);
}
_operations.bind(_operationContext);
_seeks.bind(_operationContext);
}
Future<void> _seek(PreviewController? preview, int tick) async {
final isCurrent = _guard();
final isLatest = _seeks.begin();
final session = widget.session;
final sequence = widget.sequence;
final view = session.view(sequence);
final version = view.version.kernelVersion;
final position = view.playheadTick;
await preview?.pauseForCanvasInteraction();
if (!isCurrent() ||
!isLatest() ||
session.activeSequenceId != sequence ||
view.playheadTick != position ||
!identical(view.version.kernelVersion, version)) {
return;
}
view.seekTo(tick);
}
String? get _error => switch (ref.read(_editProvider).error) {
PictureEditException(:final failure) => switch (failure) {
PictureEditFailure.keyframes => context.l10n.updateKeyframesFailed,
@@ -78,6 +130,18 @@ class _PicturePropertiesState extends ConsumerState<PictureProperties> {
String? _scrubField;
ClipTransform Function(ClipTransform, double)? _scrubChange;
PreviewTransformEdit? _clearScrub() {
final edit = _scrubEdit;
_scrubEdit = null;
_scrubBase = null;
_scrubTimeline = null;
_scrubField = null;
_scrubChange = null;
_scrubVersion = null;
_scrubTick = null;
return edit;
}
bool _startScrub(
PreviewController? preview,
String field,
@@ -144,13 +208,8 @@ class _PicturePropertiesState extends ConsumerState<PictureProperties> {
_cancelScrub();
return;
}
final edit = _scrubEdit;
_scrubEdit = null;
_scrubBase = null;
_scrubField = null;
_scrubChange = null;
_scrubVersion = null;
setState(() => _scrubTimeline = null);
final edit = _clearScrub();
setState(() {});
if (edit != null) {
unawaited(edit.end());
} else {
@@ -159,20 +218,16 @@ class _PicturePropertiesState extends ConsumerState<PictureProperties> {
}
void _cancelScrub() {
final edit = _scrubEdit;
_scrubEdit = null;
_scrubBase = null;
_scrubField = null;
_scrubChange = null;
_scrubVersion = null;
if (mounted) setState(() => _scrubTimeline = null);
final edit = _clearScrub();
if (mounted) setState(() {});
edit?.cancel();
}
@override
void dispose() {
final edit = _scrubEdit;
_scrubEdit = null;
_operations.dispose();
_seeks.dispose();
final edit = _clearScrub();
if (edit != null) scheduleMicrotask(edit.cancel);
super.dispose();
}
@@ -198,7 +253,12 @@ class _PicturePropertiesState extends ConsumerState<PictureProperties> {
);
return (
widget.session.activeSequenceId,
view.version.kernelVersion,
animation?.record,
animation?.start,
animation?.frameTicks,
_hasFocusedControl || _scrubBase != null
? view.version.kernelVersion
: null,
widget.session.canvas,
animation?.containsPlayhead,
timeDependent || _hasFocusedControl ? animation?.playhead : null,
@@ -247,6 +307,13 @@ class _PicturePropertiesState extends ConsumerState<PictureProperties> {
.watch(editorPreviewProvider(widget.projectId, widget.timelineId))
.asData
?.value;
if (!identical(_boundPreview, preview)) {
final edit = _clearScrub();
if (edit != null) scheduleMicrotask(edit.cancel);
_boundPreview = preview;
_operations.bind(_operationContext);
_seeks.bind(_operationContext);
}
Widget contents() {
final animation = _animation();
final live = preview?.activeSequence() == widget.sequence
@@ -275,7 +342,10 @@ class _PicturePropertiesState extends ConsumerState<PictureProperties> {
color: animated ? Theme.of(context).colorScheme.primary : null,
icon: Transform.rotate(
angle: math.pi / 4,
child: Icon(keyed ? Icons.square : Icons.crop_square, size: 12),
child: Icon(
keyed ? AppIcons.squareFilled : AppIcons.square,
size: 12,
),
),
onPressed:
enabled &&
@@ -287,31 +357,37 @@ class _PicturePropertiesState extends ConsumerState<PictureProperties> {
);
}
final desktop = AppTheme.isDesktop(context);
final gap = AppTheme.propertyRowGap(context);
Widget axes(TransformChannel channel, Widget first, Widget second) =>
LayoutBuilder(
builder: (context, constraints) => Row(
children: [
Expanded(
child: constraints.maxWidth < 240
? Column(
children: [
first,
const SizedBox(height: AppSpacing.small),
second,
],
)
: Row(
children: [
Expanded(child: first),
const SizedBox(width: AppSpacing.small),
Expanded(child: second),
],
),
),
const SizedBox(width: AppSpacing.small),
keyButton(channel),
],
),
builder: (context, constraints) {
final pair = constraints.maxWidth < (desktop ? 180 : 240)
? Column(
children: [
first,
SizedBox(height: gap),
second,
],
)
: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(child: first),
SizedBox(width: gap),
Expanded(child: second),
],
);
return desktop
? pair
: Row(
children: [
Expanded(child: pair),
SizedBox(width: gap),
keyButton(channel),
],
);
},
);
Widget keyTools(TransformChannel channel) {
@@ -323,15 +399,12 @@ class _PicturePropertiesState extends ConsumerState<PictureProperties> {
final previous = times.where((t) => t < tick).lastOrNull;
final next = times.where((t) => t > tick).firstOrNull;
final canEdit = enabled && _scrubBase == null && !canvasDragging;
Future<void> seek(int target) async {
await preview?.pauseForCanvasInteraction();
if (mounted && widget.session.activeSequenceId == widget.sequence) {
widget.session.view(widget.sequence).seekTo(target);
}
}
Future<void> seek(int target) => _seek(preview, target);
return SizedBox(
height: AppControlSize.standard,
height: AppTheme.isDesktop(context)
? AppInspectorMetrics.action
: AppControlSize.standard,
child: Row(
children: [
Text(
@@ -345,13 +418,13 @@ class _PicturePropertiesState extends ConsumerState<PictureProperties> {
onPressed: canEdit && previous != null
? () => seek(previous)
: null,
icon: const Icon(Icons.chevron_left, size: 16),
icon: const Icon(AppIcons.chevronLeft, size: 16),
),
IconButton(
key: ValueKey('picture-key-next-${channel.name}'),
tooltip: context.l10n.nextKeyframe(channel.label(context)),
onPressed: canEdit && next != null ? () => seek(next) : null,
icon: const Icon(Icons.chevron_right, size: 16),
icon: const Icon(AppIcons.chevronRight, size: 16),
),
AppDropdownMenu(
key: ValueKey('picture-key-menu-${channel.name}'),
@@ -362,7 +435,7 @@ class _PicturePropertiesState extends ConsumerState<PictureProperties> {
),
focusNode: focus,
onPressed: toggle,
icon: const Icon(Icons.more_horiz, size: 16),
icon: const Icon(AppIcons.more, size: 16),
),
items: [
for (final (mode, label) in [
@@ -412,9 +485,15 @@ class _PicturePropertiesState extends ConsumerState<PictureProperties> {
double min = double.negativeInfinity,
double max = double.infinity,
bool wrapRotation = false,
bool inlineLabel = false,
String? prefix,
IconData? prefixIcon,
}) => PropertyNumberInput(
key: ValueKey(id),
label: label,
inlineLabel: inlineLabel,
prefix: prefix,
prefixIcon: prefixIcon,
unit: unit,
value: value,
enabled: !_saving,
@@ -435,17 +514,170 @@ class _PicturePropertiesState extends ConsumerState<PictureProperties> {
onScrubCancel: _cancelScrub,
scrubbing: _scrubField == id,
editContext: (
_editIdentity,
preview,
widget.session.view(widget.sequence).version.kernelVersion,
widget.session.view(widget.sequence).playheadTick,
),
);
Widget section(List<Widget> children) => Padding(
padding: AppSpacing.panelSection,
padding: AppTheme.propertySectionPadding(context),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: children,
),
);
final position = axes(
TransformChannel.position,
number(
'picture-x',
'X',
value.x * canvas.width,
(c, v) => c.copyWith(x: v / canvas.width),
inlineLabel: true,
),
number(
'picture-y',
'Y',
value.y * canvas.height,
(c, v) => c.copyWith(y: v / canvas.height),
inlineLabel: true,
),
);
final rotationInput = number(
'picture-rotation',
context.l10n.rotation,
value.rotation,
(c, v) => c.copyWith(rotation: v),
unit: '°',
wrapRotation: true,
inlineLabel: desktop,
prefixIcon: desktop ? AppIcons.angle : null,
);
final rotation = desktop
? rotationInput
: Row(
children: [
Expanded(child: rotationInput),
SizedBox(width: gap),
keyButton(TransformChannel.rotation),
],
);
final scale = axes(
TransformChannel.scale,
number(
'picture-scale-x',
'W',
value.scale * 100,
(c, v) => c.copyWith(
scale: v / 100,
scaleY: locked ? c.scaleY * v / 100 / c.scale : c.scaleY,
),
unit: '%',
min: locked ? math.max(1.0, value.scale / value.scaleY) : 1,
max: locked
? math.min(10000.0, 10000 * value.scale / value.scaleY)
: 10000,
inlineLabel: true,
),
number(
'picture-scale-y',
'H',
value.scaleY * 100,
(c, v) => c.copyWith(
scaleY: v / 100,
scale: locked ? c.scale * v / 100 / c.scaleY : c.scale,
),
unit: '%',
min: locked ? math.max(1.0, value.scaleY / value.scale) : 1,
max: locked
? math.min(10000.0, 10000 * value.scaleY / value.scale)
: 10000,
inlineLabel: true,
),
);
final lock = IconButton(
key: const Key('picture-lock'),
tooltip: context.l10n.keepAspectRatio,
icon: const Icon(AppIcons.unlock),
selectedIcon: const Icon(AppIcons.lockFilled),
isSelected: locked,
onPressed: enabled
? () {
if (preview?.transforms.hasPending == true) return;
preview?.setAspectRatioLocked(!locked);
setState(() => _locked = !locked);
}
: null,
);
final alignmentControls = LayoutBuilder(
builder: (context, constraints) => Wrap(
spacing: AppSpacing.small,
runSpacing: AppSpacing.small,
children: [
for (final group in [
[
(
CanvasAlignment.left,
context.l10n.alignLeft,
AppIcons.alignLeft,
),
(
CanvasAlignment.horizontalCenter,
context.l10n.alignHorizontalCenter,
AppIcons.alignHorizontalCenter,
),
(
CanvasAlignment.right,
context.l10n.alignRight,
AppIcons.alignRight,
),
],
[
(CanvasAlignment.top, context.l10n.alignTop, AppIcons.alignTop),
(
CanvasAlignment.verticalCenter,
context.l10n.alignVerticalCenter,
AppIcons.alignVerticalCenter,
),
(
CanvasAlignment.bottom,
context.l10n.alignBottom,
AppIcons.alignBottom,
),
],
])
SizedBox(
width: constraints.maxWidth < 200
? constraints.maxWidth
: (constraints.maxWidth - AppSpacing.small) / 2,
child: AppButtonGroup(
expanded: true,
label: context.l10n.alignment,
children: [
for (final (alignment, label, icon) in group)
IconButton(
key: ValueKey('picture-align-${alignment.name}'),
tooltip: label,
icon: Icon(icon, size: AppIconSize.standard),
onPressed: () {
if (!enabled ||
canvasDragging ||
preview == null ||
preview.busy ||
preview.visualForProperties(widget.clip.id) ==
null) {
return;
}
unawaited(_align(preview, alignment));
},
),
],
),
),
],
),
);
final content = Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
@@ -454,202 +686,79 @@ class _PicturePropertiesState extends ConsumerState<PictureProperties> {
_KeyframeTimeline(
animation: animation,
enabled: enabled && !canvasDragging && _scrubBase == null,
onSeek: (tick) async {
await preview?.pauseForCanvasInteraction();
if (mounted &&
widget.session.activeSequenceId == widget.sequence) {
widget.session.view(widget.sequence).seekTo(tick);
}
},
onSeek: (tick) => _seek(preview, tick),
),
]),
],
if (!widget.animationView) ...[
if (!widget.animationView)
section([
if (desktop)
AppPropertyGroup(
label: context.l10n.alignment,
child: alignmentControls,
)
else ...[
Text(
context.l10n.alignment,
style: AppTheme.propertySectionTitleStyle(context),
),
SizedBox(height: gap),
alignmentControls,
],
]),
if (desktop) ...[
section([
AppPropertyGroup(
label: context.l10n.position,
actions: [keyButton(TransformChannel.position)],
child: position,
),
keyTools(TransformChannel.position),
]),
section([
AppPropertyGroup(
label: context.l10n.scale,
actions: [lock, keyButton(TransformChannel.scale)],
child: scale,
),
keyTools(TransformChannel.scale),
]),
section([
AppPropertyGroup(
label: context.l10n.rotation,
actions: [keyButton(TransformChannel.rotation)],
child: rotation,
),
keyTools(TransformChannel.rotation),
]),
] else ...[
section([
Text(
context.l10n.alignment,
context.l10n.position,
style: AppTheme.propertySectionTitleStyle(context),
),
const SizedBox(height: AppSpacing.small),
LayoutBuilder(
builder: (context, constraints) => Wrap(
spacing: AppSpacing.small,
runSpacing: AppSpacing.small,
children: [
for (final group in [
[
(
CanvasAlignment.left,
context.l10n.alignLeft,
Icons.align_horizontal_left,
),
(
CanvasAlignment.horizontalCenter,
context.l10n.alignHorizontalCenter,
Icons.align_horizontal_center,
),
(
CanvasAlignment.right,
context.l10n.alignRight,
Icons.align_horizontal_right,
),
],
[
(
CanvasAlignment.top,
context.l10n.alignTop,
Icons.align_vertical_top,
),
(
CanvasAlignment.verticalCenter,
context.l10n.alignVerticalCenter,
Icons.align_vertical_center,
),
(
CanvasAlignment.bottom,
context.l10n.alignBottom,
Icons.align_vertical_bottom,
),
],
])
SizedBox(
width: constraints.maxWidth < 200
? constraints.maxWidth
: (constraints.maxWidth - AppSpacing.small) / 2,
child: AppButtonGroup(
expanded: true,
label: context.l10n.alignment,
children: [
for (final (alignment, label, icon) in group)
IconButton(
key: ValueKey(
'picture-align-${alignment.name}',
),
tooltip: label,
icon: Icon(icon, size: AppIconSize.standard),
onPressed: () {
if (!enabled ||
canvasDragging ||
preview == null ||
preview.busy ||
preview.visualForProperties(
widget.clip.id,
) ==
null) {
return;
}
unawaited(_align(preview, alignment));
},
),
],
),
),
],
),
SizedBox(height: gap),
position,
keyTools(TransformChannel.position),
]),
section([rotation, keyTools(TransformChannel.rotation)]),
section([
Row(
children: [
Expanded(
child: Text(
context.l10n.scale,
style: AppTheme.propertySectionTitleStyle(context),
),
),
lock,
],
),
SizedBox(height: gap),
scale,
keyTools(TransformChannel.scale),
]),
],
section([
Text(
context.l10n.position,
style: AppTheme.propertySectionTitleStyle(context),
),
const SizedBox(height: AppSpacing.small),
axes(
TransformChannel.position,
number(
'picture-x',
'X',
value.x * canvas.width,
(c, v) => c.copyWith(x: v / canvas.width),
),
number(
'picture-y',
'Y',
value.y * canvas.height,
(c, v) => c.copyWith(y: v / canvas.height),
),
),
keyTools(TransformChannel.position),
]),
section([
Row(
children: [
Expanded(
child: number(
'picture-rotation',
context.l10n.rotation,
value.rotation,
(c, v) => c.copyWith(rotation: v),
unit: '°',
wrapRotation: true,
),
),
const SizedBox(width: AppSpacing.small),
keyButton(TransformChannel.rotation),
],
),
keyTools(TransformChannel.rotation),
]),
section([
Row(
children: [
Expanded(
child: Text(
context.l10n.scale,
style: AppTheme.propertySectionTitleStyle(context),
),
),
IconButton(
key: const Key('picture-lock'),
tooltip: context.l10n.keepAspectRatio,
icon: const Icon(Icons.lock_open_outlined),
selectedIcon: const Icon(Icons.lock_outline),
isSelected: locked,
onPressed: enabled
? () {
if (preview?.transforms.hasPending == true) return;
preview?.setAspectRatioLocked(!locked);
setState(() => _locked = !locked);
}
: null,
),
],
),
const SizedBox(height: AppSpacing.small),
axes(
TransformChannel.scale,
number(
'picture-scale-x',
'W',
value.scale * 100,
(c, v) => c.copyWith(
scale: v / 100,
scaleY: locked ? c.scaleY * v / 100 / c.scale : c.scaleY,
),
unit: '%',
min: locked ? math.max(1.0, value.scale / value.scaleY) : 1,
max: locked
? math.min(10000.0, 10000 * value.scale / value.scaleY)
: 10000,
),
number(
'picture-scale-y',
'H',
value.scaleY * 100,
(c, v) => c.copyWith(
scaleY: v / 100,
scale: locked ? c.scale * v / 100 / c.scaleY : c.scale,
),
unit: '%',
min: locked ? math.max(1.0, value.scaleY / value.scale) : 1,
max: locked
? math.min(10000.0, 10000 * value.scaleY / value.scale)
: 10000,
),
),
keyTools(TransformChannel.scale),
]),
if (_error != null)
section([
Text(
@@ -793,7 +902,7 @@ class _KeyframeTimeline extends StatelessWidget {
icon: Transform.rotate(
angle: math.pi / 4,
child: Icon(
Icons.square,
AppIcons.squareFilled,
size: 9,
color: tick == animation.playhead
? colors.primary
+87 -55
View File
@@ -1,14 +1,17 @@
import 'package:cutdex/l10n/l10n.dart';
import 'package:cutdex_sdk/runtime/contracts.dart';
import 'package:cutdex_sdk/timeline/model.dart';
import 'package:cutdex_sdk/timeline/engine.dart';
import 'package:flutter/material.dart';
import 'package:cutdex_ui/theme.dart';
import 'package:cutdex_ui/widgets.dart';
import '../../workspace/timeline_session.dart';
import '../../shared/widgets/listenable_selector.dart';
import 'canvas_presets.dart';
import 'project_settings_dialog.dart';
import 'project_property_row.dart';
/// Project information uses the live editing session, including unsaved edits.
class ProjectProperties extends StatelessWidget {
@@ -18,34 +21,41 @@ class ProjectProperties extends StatelessWidget {
@override
Widget build(BuildContext context) {
final sequence = session.activeSequenceId;
final timeline = sequence == null
? null
: session.persistence.timeline(sequence);
final duration = sequence == null
? 0
: session.sequenceDurationTicks(sequence);
final frame = timeline?.format.frameDuration;
final fps = frame == null ? null : frame.denominator / frame.numerator;
final canvas = session.canvas;
String number(double value) => value == value.roundToDouble()
? value.toStringAsFixed(0)
: value.toStringAsFixed(3).replaceFirst(RegExp(r'0+$'), '');
TimelineKernel? timeline() {
final sequence = session.activeSequenceId;
return sequence == null ? null : session.persistence.timeline(sequence);
}
Widget info(String label, String Function() value) =>
_Info(label, session, value);
return WorkspacePanel(
paintBackground: false,
title: context.l10n.projectProperties,
trailing: TextButton(
key: const ValueKey('project-settings-edit'),
onPressed: () => showAppDialog<void>(
context: context,
builder: (_) => ProjectSettingsDialog(session: session),
trailing: SizedBox(
height: AppTheme.isDesktop(context) ? AppInspectorMetrics.input : null,
child: TextButton(
key: const ValueKey('project-settings-edit'),
style: AppTheme.isDesktop(context)
? AppTheme.toolbarButtonStyle(context)
: null,
onPressed: () => showAppDialog<void>(
context: context,
builder: (_) => ProjectSettingsDialog(session: session),
),
child: Text(context.l10n.modify),
),
child: Text(context.l10n.modify),
),
headerHeight: AppControlSize.panelToolbar,
headerPadding: const EdgeInsets.symmetric(
horizontal: AppSpacing.panelContentHorizontal,
headerHeight: AppTheme.isDesktop(context)
? AppDesktopMetrics.panelHeader
: AppControlSize.panelToolbar,
headerPadding: EdgeInsets.symmetric(
horizontal: AppTheme.isDesktop(context)
? AppInspectorMetrics.padding
: AppSpacing.panelContentHorizontal,
),
showHeaderDivider: false,
child: ScrollEdgeFadeBuilder(
@@ -55,32 +65,40 @@ class ProjectProperties extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
_Info(context.l10n.timelineName, session.document.name),
_Info(
context.l10n.canvasSize,
'${number(canvas.width)} × ${number(canvas.height)} px',
info(context.l10n.timelineName, () => session.document.name),
info(context.l10n.canvasSize, () {
final canvas = session.canvas;
return '${number(canvas.width)} × ${number(canvas.height)} px';
}),
info(
context.l10n.canvasRatio,
() => session.canvas.label(context),
),
_Info(context.l10n.canvasRatio, canvas.label(context)),
_Info(
info(
context.l10n.projectColorSpace,
switch (session.projectColorSpace) {
() => switch (session.projectColorSpace) {
RenderColorSpace.rec2020HLG => 'HDR · Rec.2020 HLG',
RenderColorSpace.rec2020PQ => 'HDR · Rec.2020 PQ',
_ => 'SDR · Rec.709',
},
),
_Info(
info(
context.l10n.currentSequence,
timeline?.name ?? context.l10n.none,
),
_Info(
context.l10n.frameRate,
fps == null ? '—' : '${number(fps)} fps',
),
_Info(
context.l10n.totalDuration,
'${(duration / TimelineClock.ticksPerSecond).toStringAsFixed(2)} ${context.l10n.seconds}',
() => timeline()?.name ?? context.l10n.none,
),
info(context.l10n.frameRate, () {
final frame = timeline()?.format.frameDuration;
return frame == null
? '—'
: '${number(frame.denominator / frame.numerator)} fps';
}),
info(context.l10n.totalDuration, () {
final sequence = session.activeSequenceId;
final duration = sequence == null
? 0
: session.sequenceDurationTicks(sequence);
return '${(duration / TimelineClock.ticksPerSecond).toStringAsFixed(2)} ${context.l10n.seconds}';
}),
],
),
),
@@ -90,27 +108,41 @@ class ProjectProperties extends StatelessWidget {
}
class _Info extends StatelessWidget {
const _Info(this.label, this.value);
const _Info(this.label, this.session, this.select);
final String label;
final String value;
final EditorTimelineSession session;
final String Function() select;
@override
Widget build(BuildContext context) => Padding(
padding: AppSpacing.panelSection,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
spacing: AppSpacing.small,
children: [
Text(label, style: Theme.of(context).textTheme.bodySmall),
Expanded(
child: Text(
value,
textAlign: TextAlign.right,
style: Theme.of(context).textTheme.bodyMedium,
),
),
],
),
);
Widget build(BuildContext context) {
if (AppTheme.isDesktop(context)) {
return ListenableSelector<String>(
listenable: session,
select: select,
builder: (context, value) =>
ProjectPropertyRow(label: label, value: value),
);
}
final value = ListenableSelector<String>(
listenable: session,
select: select,
builder: (context, value) => Text(
value,
textAlign: TextAlign.right,
style: Theme.of(context).textTheme.bodyMedium,
),
);
return Padding(
padding: AppTheme.propertySectionPadding(context),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
spacing: AppSpacing.small,
children: [
Text(label, style: Theme.of(context).textTheme.bodySmall),
Expanded(child: value),
],
),
);
}
}
@@ -0,0 +1,63 @@
import 'package:cutdex_ui/theme.dart';
import 'package:flutter/material.dart';
/// Read-only project metadata shares label and value columns in the inspector.
class ProjectPropertyRow extends StatelessWidget {
const ProjectPropertyRow({
super.key,
required this.label,
required this.value,
});
final String label;
final String value;
@override
Widget build(BuildContext context) => Padding(
padding: const EdgeInsets.symmetric(
horizontal: AppInspectorMetrics.padding,
vertical: AppInspectorMetrics.rowGap,
),
child: ConstrainedBox(
constraints: const BoxConstraints(minHeight: AppInspectorMetrics.input),
child: Align(
alignment: Alignment.center,
heightFactor: 1,
child: Row(
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.alphabetic,
children: [
Expanded(
flex: 2,
child: Tooltip(
message: label,
child: Text(
label,
maxLines: 3,
overflow: TextOverflow.ellipsis,
style: AppTheme.toolbarTextStyle(context).copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
),
),
const SizedBox(width: AppInspectorMetrics.rowGap * 2),
Expanded(
flex: 3,
child: Tooltip(
message: value,
child: Text(
value,
maxLines: 3,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.right,
style: AppTheme.toolbarTextStyle(context),
),
),
),
],
),
),
),
);
}
@@ -0,0 +1,41 @@
import 'package:cutdex_ui/theme.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widget_previews.dart';
import 'project_property_row.dart';
@Preview(
name: 'Project summary — narrow',
group: 'Desktop properties',
size: Size(220, 300),
)
Widget narrowProjectSummaryPreview() => _preview(Brightness.dark);
@Preview(
name: 'Project summary — light',
group: 'Desktop properties',
size: Size(320, 300),
)
Widget lightProjectSummaryPreview() => _preview(Brightness.light);
Widget _preview(Brightness brightness) => MaterialApp(
debugShowCheckedModeBanner: false,
theme: AppTheme.desktopWorkspaceTheme(
AppTheme.forPalette(AppPalette.graphite, brightness),
),
home: const Scaffold(
body: SingleChildScrollView(
child: Column(
children: [
ProjectPropertyRow(label: '时间线名称', value: '旅行短片'),
ProjectPropertyRow(label: '画布大小', value: '1920 × 1080 px'),
ProjectPropertyRow(label: '画布比例', value: '16:9'),
ProjectPropertyRow(label: '项目色彩空间', value: 'HDR · Rec.2020 HLG'),
ProjectPropertyRow(label: '当前序列', value: '海边日落与城市漫游'),
ProjectPropertyRow(label: '帧率', value: '29.97 fps'),
ProjectPropertyRow(label: '总时长', value: '24.50 秒'),
],
),
),
),
);
+49 -22
View File
@@ -247,8 +247,16 @@ class _ClipPropertiesState extends State<_ClipProperties> {
_selectCategory,
),
child: ScrollEdgeFadeBuilder(
key: PageStorageKey((clip.id, _selected)),
key: ValueKey((widget.sequence, clip.id, _selected)),
builder: (controller) => SingleChildScrollView(
// Keep scroll offsets separate from nested expansion state and from
// the legacy inspector key, which may already contain a bool.
key: PageStorageKey((
'property-scroll',
widget.sequence,
clip.id,
_selected,
)),
controller: controller,
// Inspector controls stop at their bounds; macOS's default elastic
// physics repeatedly displaces the content during edge scrolling.
@@ -289,28 +297,42 @@ class _Property extends StatelessWidget {
final String value;
@override
Widget build(BuildContext context) => Padding(
padding: AppSpacing.panelSection,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
spacing: AppSpacing.small,
children: [
Expanded(
child: Text(
label,
style: AppTheme.propertySectionTitleStyle(context),
),
),
Expanded(
child: Text(
value,
textAlign: TextAlign.right,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
padding: AppTheme.isDesktop(context)
? const EdgeInsets.symmetric(
horizontal: AppInspectorMetrics.padding,
vertical: 4,
)
: AppSpacing.panelSection,
child: AppTheme.isDesktop(context)
? AppPropertyGroup(
label: label,
child: Text(
value,
textAlign: TextAlign.right,
style: Theme.of(context).textTheme.bodyMedium,
),
)
: Row(
crossAxisAlignment: CrossAxisAlignment.start,
spacing: AppSpacing.small,
children: [
Expanded(
child: Text(
label,
style: AppTheme.propertySectionTitleStyle(context),
),
),
Expanded(
child: Text(
value,
textAlign: TextAlign.right,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
),
],
),
),
],
),
);
}
@@ -320,7 +342,12 @@ class _Message extends StatelessWidget {
@override
Widget build(BuildContext context) => Center(
child: Padding(
padding: AppSpacing.panelSection,
padding: AppTheme.isDesktop(context)
? const EdgeInsets.symmetric(
horizontal: AppInspectorMetrics.padding,
vertical: 4,
)
: AppSpacing.panelSection,
child: Text(
text,
textAlign: TextAlign.center,
@@ -1,3 +1,4 @@
import 'package:cutdex_ui/icons.dart';
import 'package:flutter/material.dart';
import 'properties_content.dart';
@@ -20,6 +21,7 @@ class PropertiesEditorPage extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 16),
child: DropdownButton<PropertyCategory>(
key: const Key('property-category-picker'),
icon: const Icon(AppIcons.expandMore),
isExpanded: true,
underline: const SizedBox.shrink(),
value: selected,
@@ -31,6 +31,7 @@ class PropertiesInspectorController extends ChangeNotifier {
SequenceId? _lastSequence;
Object? _lastVersion;
Set<Object> _lastSelection = {};
List<Object> _lastShell = const [];
SequenceId? get sequence => session.activeSequenceId;
void _bindView() {
@@ -42,20 +43,40 @@ class PropertiesInspectorController extends ChangeNotifier {
_editingChanges?.addListener(_viewChanged);
}
bool _captureSelection() {
bool _captureSelection({bool force = false}) {
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 &&
if (!force &&
id == _lastSequence &&
identical(version, _lastVersion) &&
setEquals(selected, _lastSelection)) {
return false;
}
final shell = <Object>[
for (final clip in selectedClips)
(
clip.id,
clip.structure,
clip.enabled,
clip.payloadRef == null
? null
: session.payloadFor(clip.payloadRef!)?.type,
clip.payloadRef == null
? null
: session.mediaBinding(clip.payloadRef!)?.audioSelection,
clip.payloadRef == null
? null
: session.mediaBinding(clip.payloadRef!)?.videoTrackIndex,
),
];
final changed = id != _lastSequence || !listEquals(shell, _lastShell);
_lastSequence = id;
_lastVersion = version;
_lastSelection = selected.toSet();
return true;
_lastShell = shell;
return changed;
}
void _viewChanged() {
@@ -66,8 +87,7 @@ class PropertiesInspectorController extends ChangeNotifier {
void _sessionChanged() {
_bindView();
_captureSelection();
notifyListeners();
if (_captureSelection(force: true)) notifyListeners();
}
List<ElementRecord> get selectedClips {
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:cutdex_ui/widgets.dart';
import 'package:cutdex_ui/theme.dart';
import 'properties_content.dart';
export 'properties_presentation_state.dart';
@@ -18,7 +19,9 @@ class EditorPropertiesPanel extends StatelessWidget {
Widget build(BuildContext context) => PropertiesContent(
projectId: projectId,
timelineId: timelineId,
categoryHeaderHeight: CompactPanelTabs.height,
categoryHeaderHeight: AppTheme.isDesktop(context)
? AppDesktopMetrics.panelHeader
: CompactPanelTabs.height,
categoryControls: (context, categories, selected, onSelected) =>
CompactPanelTabs<PropertyCategory>(
values: categories,
@@ -2,7 +2,10 @@ import 'package:cutdex/l10n/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../../shared/state/operation_scope.dart';
import 'package:cutdex_ui/widgets.dart';
import 'package:cutdex_ui/theme.dart';
class PropertyNumberInput extends StatefulWidget {
const PropertyNumberInput({
@@ -13,6 +16,10 @@ class PropertyNumberInput extends StatefulWidget {
required this.readOnly,
required this.submit,
this.unit,
this.inlineLabel = false,
this.prefix,
this.prefixIcon,
this.labelActions = const [],
this.decimalPlaces = 2,
this.onScrubStart,
required this.onScrubUpdate,
@@ -23,6 +30,10 @@ class PropertyNumberInput extends StatefulWidget {
}) : assert(decimalPlaces >= 0 && decimalPlaces <= 20);
final String? label;
final String? unit;
final bool inlineLabel;
final String? prefix;
final IconData? prefixIcon;
final List<Widget> labelActions;
final int decimalPlaces;
final bool Function()? onScrubStart;
final ValueChanged<double> onScrubUpdate;
@@ -42,6 +53,7 @@ class _PropertyNumberInputState extends State<PropertyNumberInput> {
late final _text = TextEditingController(text: _format(widget.value));
final _focus = FocusNode();
bool _dirty = false;
late final _operations = OperationScope<Object>(widget.editContext);
String? _error;
String _format(double value) {
var text = value.toStringAsFixed(widget.decimalPlaces);
@@ -67,8 +79,9 @@ class _PropertyNumberInputState extends State<PropertyNumberInput> {
return;
}
_dirty = false;
final isCurrent = _operations.begin();
final accepted = await widget.submit(value);
if (!mounted) return;
if (!mounted || !isCurrent()) return;
setState(() {
_error = accepted ? null : context.l10n.notApplied;
_text.text = _format(widget.value);
@@ -78,6 +91,7 @@ class _PropertyNumberInputState extends State<PropertyNumberInput> {
@override
void didUpdateWidget(covariant PropertyNumberInput oldWidget) {
super.didUpdateWidget(oldWidget);
_operations.bind(widget.editContext);
if ((oldWidget.enabled && !widget.enabled) ||
oldWidget.editContext != widget.editContext ||
(!oldWidget.readOnly && widget.readOnly)) {
@@ -92,6 +106,7 @@ class _PropertyNumberInputState extends State<PropertyNumberInput> {
@override
void dispose() {
_operations.dispose();
_focus.removeListener(_blur);
_focus.dispose();
_text.dispose();
@@ -99,21 +114,34 @@ class _PropertyNumberInputState extends State<PropertyNumberInput> {
}
@override
Widget build(BuildContext context) => Focus(
onKeyEvent: (_, event) {
if (event is KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.escape) {
setState(() {
_dirty = false;
_error = null;
_text.text = _format(widget.value);
});
_focus.unfocus();
return KeyEventResult.handled;
}
return KeyEventResult.ignored;
},
child: AppTextField(
Widget build(BuildContext context) {
final labelAbove =
AppTheme.isCompactInspector(context) && !widget.inlineLabel;
final label = widget.onScrubStart == null
? Text(widget.label ?? '', style: AppTheme.propertyLabelStyle(context))
: AppScrubLabel(
label: widget.prefix ?? widget.label!,
icon: widget.prefixIcon,
style: labelAbove
? AppTheme.propertySectionTitleStyle(context)
: null,
alignment: labelAbove ? Alignment.centerLeft : Alignment.center,
padding: labelAbove
? EdgeInsets.zero
: const EdgeInsets.symmetric(horizontal: AppSpacing.small),
enabled: widget.enabled && (!widget.readOnly || widget.scrubbing),
onStart: () {
_operations.invalidate();
_dirty = false;
_error = null;
_text.text = _format(widget.value);
return widget.onScrubStart!();
},
onUpdate: widget.onScrubUpdate,
onEnd: widget.onScrubEnd,
onCancel: widget.onScrubCancel,
);
final input = AppTextField(
controller: _text,
focusNode: _focus,
enabled: widget.enabled,
@@ -124,29 +152,35 @@ class _PropertyNumberInputState extends State<PropertyNumberInput> {
signed: true,
),
label: widget.label,
leading: widget.onScrubStart == null
? null
: AppScrubLabel(
label: widget.label!,
enabled: widget.enabled && (!widget.readOnly || widget.scrubbing),
onStart: () {
_dirty = false;
_error = null;
_text.text = _format(widget.value);
return widget.onScrubStart!();
},
onUpdate: widget.onScrubUpdate,
onEnd: widget.onScrubEnd,
onCancel: widget.onScrubCancel,
),
labelAbove: labelAbove,
labelActions: widget.labelActions,
leading: widget.onScrubStart == null ? null : label,
unit: widget.unit,
errorText: _error,
onChanged: (_) {
_operations.invalidate();
_dirty = true;
if (_error != null) setState(() => _error = null);
},
onEditingComplete: () {},
onSubmitted: (_) => _submit(),
),
);
);
return Focus(
onKeyEvent: (_, event) {
if (event is KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.escape) {
setState(() {
_operations.invalidate();
_dirty = false;
_error = null;
_text.text = _format(widget.value);
});
_focus.unfocus();
return KeyEventResult.handled;
}
return KeyEventResult.ignored;
},
child: input,
);
}
}
+202 -81
View File
@@ -1,3 +1,5 @@
import '../../shared/widgets/listenable_selector.dart';
import 'package:cutdex/shared/widgets/error_notification_host.dart';
import 'dart:math' as math;
@@ -10,6 +12,7 @@ import 'package:flutter/material.dart';
import '../../l10n/l10n.dart';
import 'package:cutdex_ui/icons.dart';
import 'package:cutdex_ui/theme.dart';
import 'package:cutdex_ui/widgets.dart';
@@ -139,8 +142,37 @@ class _SpeedPropertiesState extends State<SpeedProperties> {
@override
Widget build(BuildContext context) {
final view = widget.session.view(widget.sequence);
return ListenableBuilder(
return ListenableSelector<Object>(
listenable: Listenable.merge([view, widget.session]),
select: () {
final query = view.version.kernelVersion.query();
final handle = query.elementById(widget.clip);
final record = handle == null ? null : query.element(handle);
final segments = record == null
? null
: widget.session.clipSpeedSegments(record);
final custom = widget.session.isCustomSpeedEnabled(
widget.sequence,
widget.clip,
);
final tick = handle == null
? 0
: view.playheadTick - query.absoluteStart(handle);
final split =
custom &&
segments != null &&
tick > 0 &&
tick < record!.duration &&
!segments.any((segment) => segment.projectStart == tick);
return (
record,
custom,
split,
widget.session.acceptsEdits,
view.isDragging,
_version == null || identical(_version, view.version.kernelVersion),
);
},
builder: (context, _) {
final query = view.version.kernelVersion.query();
final handle = query.elementById(widget.clip);
@@ -173,41 +205,54 @@ class _SpeedPropertiesState extends State<SpeedProperties> {
? _timeline ?? saved ?? 1
: saved ?? 1;
return Padding(
padding: AppSpacing.panelSection,
padding: AppTheme.propertySectionPadding(context),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Row(
children: [
Expanded(
child: Text(
context.l10n.speed,
style: AppTheme.propertySectionTitleStyle(context),
ConstrainedBox(
constraints: BoxConstraints(
minHeight: AppTheme.isDesktop(context)
? AppInspectorMetrics.action
: AppControlSize.propertyControl,
),
child: Row(
children: [
Expanded(
child: Text(
context.l10n.speed,
style: AppTheme.propertySectionTitleStyle(context),
),
),
),
Text(
saved == null && segments != null
? context.l10n.segmentedSpeed
: '${value.toStringAsFixed(2)}×',
key: const Key('clip-speed-value'),
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
Text(
saved == null && segments != null
? context.l10n.segmentedSpeed
: '${value.toStringAsFixed(2)}×',
key: const Key('clip-speed-value'),
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
),
const SizedBox(width: AppSpacing.small),
TextButton(
onPressed: canReset
? () {
_version = null;
_commit(1);
}
: null,
child: const Text('1×'),
),
],
SizedBox(width: AppTheme.propertyRowGap(context)),
TextButton(
style: AppTheme.isDesktop(context)
? TextButton.styleFrom(
minimumSize: const Size(24, 24),
padding: EdgeInsets.zero,
)
: null,
onPressed: canReset
? () {
_version = null;
_commit(1);
}
: null,
child: const Text('1×'),
),
],
),
),
if (saved != null) ...[
const SizedBox(height: AppSpacing.small),
SizedBox(height: AppTheme.propertyRowGap(context)),
AppSlider(
key: const Key('clip-speed-slider'),
value: ((math.log(value.clamp(0.1, 100)) / math.ln10 + 1) / 3)
@@ -252,64 +297,140 @@ class _SpeedPropertiesState extends State<SpeedProperties> {
context.l10n.speedSegmentCount(segments.length),
style: Theme.of(context).textTheme.bodySmall,
),
const SizedBox(height: AppSpacing.small),
Row(
children: [
Expanded(
child: Text(
context.l10n.custom,
style: AppTheme.propertySectionTitleStyle(context),
SizedBox(
height: AppTheme.isDesktop(context)
? AppInspectorMetrics.groupGap
: AppSpacing.small,
),
if (AppTheme.isDesktop(context))
AppPropertyGroup(
label: context.l10n.custom,
actions: [
AppSwitch(
key: const Key('clip-custom-speed-toggle'),
value: custom,
semanticLabel: context.l10n.custom,
onChanged: canReset
? (value) {
_discardPreview();
setState(() {
_timeline = null;
_version = null;
});
widget.session.setCustomSpeedEnabled(
widget.sequence,
widget.clip,
value,
);
}
: null,
),
],
child: SizedBox(
width: double.infinity,
height: AppTheme.isDesktop(context)
? AppInspectorMetrics.input
: AppControlSize.propertyControl,
child: OutlinedButton.icon(
key: const Key('split-speed-segment'),
onPressed: canSplit
? () {
try {
final current = view.version.kernelVersion
.query();
final target = current.elementById(widget.clip);
if (target == null) return;
widget.session.splitClipSpeedAt(
widget.sequence,
widget.clip,
view.playheadTick -
current.absoluteStart(target),
);
} catch (error) {
ErrorNotificationHost.of(context).show(
ErrorNotification(
content: Text(
context.l10n.errorMessage(error),
),
details: error.toString(),
),
);
}
}
: null,
icon: const Icon(AppIcons.cut),
label: Text(context.l10n.splitSpeedAtPlayhead),
),
),
AppSwitch(
key: const Key('clip-custom-speed-toggle'),
value: custom,
semanticLabel: context.l10n.custom,
onChanged: canReset
? (value) {
_discardPreview();
setState(() {
_timeline = null;
_version = null;
});
widget.session.setCustomSpeedEnabled(
widget.sequence,
widget.clip,
value,
);
)
else ...[
Row(
children: [
Expanded(
child: Text(
context.l10n.custom,
style: AppTheme.propertySectionTitleStyle(context),
),
),
AppSwitch(
key: const Key('clip-custom-speed-toggle'),
value: custom,
semanticLabel: context.l10n.custom,
onChanged: canReset
? (value) {
_discardPreview();
setState(() {
_timeline = null;
_version = null;
});
widget.session.setCustomSpeedEnabled(
widget.sequence,
widget.clip,
value,
);
}
: null,
),
],
),
SizedBox(height: AppTheme.propertyRowGap(context)),
SizedBox(
width: double.infinity,
height: AppTheme.isDesktop(context)
? AppInspectorMetrics.input
: AppControlSize.propertyControl,
child: OutlinedButton.icon(
key: const Key('split-speed-segment'),
onPressed: canSplit
? () {
try {
final current = view.version.kernelVersion
.query();
final target = current.elementById(widget.clip);
if (target == null) return;
widget.session.splitClipSpeedAt(
widget.sequence,
widget.clip,
view.playheadTick -
current.absoluteStart(target),
);
} catch (error) {
ErrorNotificationHost.of(context).show(
ErrorNotification(
content: Text(
context.l10n.errorMessage(error),
),
details: error.toString(),
),
);
}
}
: null,
icon: const Icon(AppIcons.cut),
label: Text(context.l10n.splitSpeedAtPlayhead),
),
],
),
const SizedBox(height: AppSpacing.small),
SizedBox(
width: double.infinity,
height: AppControlSize.propertyControl,
child: OutlinedButton.icon(
key: const Key('split-speed-segment'),
onPressed: canSplit
? () {
try {
widget.session.splitClipSpeedAt(
widget.sequence,
widget.clip,
localPlayhead,
);
} catch (error) {
ErrorNotificationHost.of(context).show(
ErrorNotification(
content: Text(context.l10n.errorMessage(error)),
details: error.toString(),
),
);
}
}
: null,
icon: const Icon(Icons.content_cut),
label: Text(context.l10n.splitSpeedAtPlayhead),
),
),
],
if (segments == null)
Text(
context.l10n.speedNotAvailable,