feat(inspector): separate input and output color controls

Give video clips a dedicated color tab with immediate input interpretation,
automatic detection, and reset controls. Clarify project output color space,
source-stream scope, and unavailable metadata across localized UI text.

Share unknown-source color defaults with the SDK and retain independent
property tab scroll state. Include localized resources and control previews.

Validation: full application analysis, 1261 Flutter tests passed
(9 skipped), generated-code verification, and 171 tool tests.
This commit is contained in:
lingjhf committed 2026-10-10 22:43:35 +08:00
1 parent 4912aa1ab0
commit 7ebe0c8e2e
35 files changed
+449 -171

No files matched your search

@@ -0,0 +1,87 @@
import 'package:cutdex/l10n/l10n.dart';
import 'package:cutdex_ui/icons.dart';
import 'package:cutdex_ui/theme.dart';
import 'package:cutdex_ui/widgets.dart';
import 'package:flutter/material.dart';
class ColorInterpretationControls extends StatelessWidget {
const ColorInterpretationControls({
super.key,
required this.value,
this.notice,
required this.options,
this.onChanged,
});
final String value;
final String? notice;
final List<AppSelectOption<String>> options;
final ValueChanged<String>? onChanged;
@override
Widget build(BuildContext context) {
final secondary = Theme.of(context).colorScheme.onSurfaceVariant;
final desktop = AppTheme.isDesktop(context);
return AppPropertySection(
bottomSpacing: desktop ? AppSpacing.small : null,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Row(
children: [
Expanded(
flex: 4,
child: Tooltip(
message: context.l10n.mediaColorInterpretationScope,
child: Text(
context.l10n.mediaInputColorSpace,
style: AppTheme.propertySectionTitleStyle(context),
),
),
),
Expanded(
flex: 6,
child: AppSelect<String>(
key: const Key('media-color-menu'),
emptyLabel: context.l10n.noMatchingOptions,
outlined: false,
controlHeight: desktop ? AppInspectorMetrics.input : 32,
label: context.l10n.mediaInputColorSpace,
value: value,
onChanged: onChanged,
options: options,
),
),
IconButton(
key: const Key('media-color-reset'),
tooltip: context.l10n.resetMediaColorInterpretation,
icon: const Icon(AppIcons.reset, size: 16),
style: IconButton.styleFrom(
minimumSize: Size.square(
desktop ? AppInspectorMetrics.action : 40,
),
padding: EdgeInsets.zero,
tapTargetSize: desktop
? MaterialTapTargetSize.shrinkWrap
: MaterialTapTargetSize.padded,
),
onPressed: value == 'auto' || onChanged == null
? null
: () => onChanged!('auto'),
),
],
),
if (notice != null) ...[
const SizedBox(height: 2),
Text(
notice!,
key: const Key('media-color-status'),
style: Theme.of(context).textTheme.bodySmall
?.copyWith(color: secondary),
),
],
],
),
);
}
}
@@ -0,0 +1,79 @@
import 'package:cutdex/l10n/app_localizations.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 'color_interpretation_controls.dart';
@Preview(
name: 'Color — narrow automatic',
group: 'Properties',
size: Size(220, 220),
)
Widget narrowColorControlsPreview() => _host(desktop: true);
@Preview(
name: 'Color — manual light',
group: 'Properties',
size: Size(280, 220),
)
Widget manualColorControlsPreview() =>
_host(desktop: true, brightness: Brightness.light, value: 'rec2020HLG');
@Preview(name: 'Color — loading', group: 'Properties', size: Size(260, 220))
Widget loadingColorControlsPreview() => _host(desktop: true, loading: true);
@Preview(name: 'Color — mobile', group: 'Properties', size: Size(400, 260))
Widget mobileColorControlsPreview() => _host(desktop: false);
Widget _host({
required bool desktop,
Brightness brightness = Brightness.dark,
String value = 'auto',
bool loading = false,
}) {
final theme = AppTheme.forPalette(AppPalette.graphite, brightness);
return MaterialApp(
debugShowCheckedModeBanner: false,
locale: const Locale('zh'),
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
theme: AppTheme.propertiesPanelTheme(
desktop ? AppTheme.desktopWorkspaceTheme(theme) : theme,
),
home: Scaffold(
body: _ColorControlsPreview(initialValue: value, loading: loading),
),
);
}
class _ColorControlsPreview extends StatefulWidget {
const _ColorControlsPreview({
required this.initialValue,
required this.loading,
});
final String initialValue;
final bool loading;
@override
State<_ColorControlsPreview> createState() => _ColorControlsPreviewState();
}
class _ColorControlsPreviewState extends State<_ColorControlsPreview> {
late String _value = widget.initialValue;
@override
Widget build(BuildContext context) => ColorInterpretationControls(
value: _value,
notice: widget.loading ? '色彩信息未读取' : null,
onChanged: widget.loading
? null
: (value) => setState(() => _value = value),
options: [
AppSelectOption('auto', widget.loading ? '自动' : '自动 · Rec.709'),
const AppSelectOption('rec709', 'Rec.709'),
const AppSelectOption('rec2020HLG', 'Rec.2020 HLG'),
],
);
}
@@ -4,10 +4,10 @@ import 'package:cutdex_sdk/runtime.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:cutdex_ui/theme.dart';
import 'package:cutdex_ui/widgets.dart';
import '../../workspace/media_color_interpretation.dart';
import 'color_interpretation_controls.dart';
import '../../shared/widgets/listenable_selector.dart';
import '../../workspace/timeline_session.dart';
import '../preview/preview_panel.dart';
@@ -40,20 +40,15 @@ class ColorInterpretationProperties extends ConsumerWidget {
final detected = colors?.elementAtOrNull(trackIndex);
final reported =
colors != null && trackIndex >= 0 && trackIndex < colors.length;
final status = selected != null
? context.l10n.manualColorSpace(selected.label(context.l10n))
: detected != null
? context.l10n.detectedColorSpace(detected.label(context.l10n))
: reported
final notice = !reported
? context.l10n.colorInfoNotLoaded
: selected == null && detected == null
? context.l10n.unknownColorSpace
: context.l10n.colorInfoNotLoaded;
final selector = AppSelect<String>(
emptyLabel: context.l10n.noMatchingOptions,
key: const Key('media-color-menu'),
outlined: false,
label: context.l10n.mediaColorInterpretation,
: null;
return ColorInterpretationControls(
value: selected?.name ?? 'auto',
onChanged: !reported
notice: notice,
onChanged: !reported || !session.acceptsEdits
? null
: (value) => session.commands.setMediaColor(
assetId,
@@ -61,66 +56,16 @@ class ColorInterpretationProperties extends ConsumerWidget {
value == 'auto' ? null : MediaColorSpace.values.byName(value),
),
options: [
AppSelectOption('auto', context.l10n.auto),
AppSelectOption(
'auto',
detected == null
? context.l10n.auto
: '${context.l10n.auto} · ${detected.label(context.l10n)}',
),
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(
child: Text(
context.l10n.mediaColorSpace,
style: AppTheme.propertySectionTitleStyle(context),
),
),
Flexible(child: selector),
],
),
Text(
status,
key: const Key('media-color-status'),
style: Theme.of(context).textTheme.bodySmall,
),
],
);
return AppPropertySection(
bottomSpacing: AppTheme.isDesktop(context) ? 0 : null,
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(
bottom: AppInspectorMetrics.groupGap,
),
minTileHeight: AppInspectorMetrics.sectionHeader,
dense: true,
maintainState: true,
initiallyExpanded: selected != null,
shape: const Border(),
collapsedShape: const Border(),
children: [controls],
)
: controls,
);
}
return ListenableSelector(
@@ -80,8 +80,8 @@ class ProjectProperties extends StatelessWidget {
() => session.canvas.label(context),
),
info(
context.l10n.projectColorSpace,
() => switch (session.projectColorSpace) {
context.l10n.projectOutputColorSpace,
() => switch (session.projectOutputColorSpace) {
RenderColorSpace.rec2020HLG => 'HDR · Rec.2020 HLG',
RenderColorSpace.rec2020PQ => 'HDR · Rec.2020 PQ',
_ => 'SDR · Rec.709',
@@ -56,7 +56,7 @@ class _ProjectSettingsDialogState extends State<ProjectSettingsDialog> {
.timeline(widget.session.activeSequenceId!)
.format
.frameDuration;
_color = widget.session.projectColorSpace;
_color = widget.session.projectOutputColorSpace;
_preset = _sizes.entries
.where((e) => e.value.$1 == canvas.width && e.value.$2 == canvas.height)
.firstOrNull
@@ -198,12 +198,12 @@ class _ProjectSettingsDialogState extends State<ProjectSettingsDialog> {
),
),
AppField(
label: l10n.projectColorSpace,
label: l10n.projectOutputColorSpace,
child: AppSelect<RenderColorSpace>(
emptyLabel: context.l10n.noMatchingOptions,
key: const ValueKey('project-color-space'),
value: _color,
label: l10n.projectColorSpace,
label: l10n.projectOutputColorSpace,
options: const [
AppSelectOption(RenderColorSpace.rec709, 'SDR · Rec.709'),
AppSelectOption(
+14 -15
View File
@@ -146,26 +146,22 @@ class PropertiesContent extends ConsumerWidget {
clip: clip,
hasAudio: hasAudio,
),
picture: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (payload?.type == 'video' && binding?.videoTrackIndex != null)
ColorInterpretationProperties(
color: payload?.type == 'video' && binding?.videoTrackIndex != null
? ColorInterpretationProperties(
projectId: projectId,
timelineId: timelineId,
session: session,
assetId: payload!.assetIds.single,
trackIndex: binding!.videoTrackIndex!,
),
PictureProperties(
key: ValueKey((sequence, clip.id)),
projectId: projectId,
timelineId: timelineId,
session: session,
sequence: sequence,
clip: clip,
),
],
)
: const SizedBox.shrink(),
picture: PictureProperties(
key: ValueKey((sequence, clip.id)),
projectId: projectId,
timelineId: timelineId,
session: session,
sequence: sequence,
clip: clip,
),
animation: PictureProperties(
key: ValueKey((sequence, clip.id, 'animation')),
@@ -189,6 +185,7 @@ class _ClipProperties extends StatefulWidget {
required this.sequence,
required this.clip,
required this.picture,
required this.color,
required this.mask,
required this.audio,
required this.speed,
@@ -203,6 +200,7 @@ class _ClipProperties extends StatefulWidget {
final SequenceId sequence;
final ElementRecord clip;
final Widget picture;
final Widget color;
final Widget mask;
final Widget audio;
final Widget speed;
@@ -266,6 +264,7 @@ class _ClipPropertiesState extends State<_ClipProperties> {
children: [
...switch (_selected) {
PropertyCategory.picture => [widget.picture],
PropertyCategory.color => [widget.color],
PropertyCategory.mask => [widget.mask],
PropertyCategory.audio => [widget.audio],
PropertyCategory.speed => [widget.speed],
@@ -125,6 +125,7 @@ List<PropertyCategory> categoriesForClip(ElementRecord clip, String? type) {
return switch (type) {
'video' => [
PropertyCategory.picture,
PropertyCategory.color,
PropertyCategory.mask,
PropertyCategory.audio,
PropertyCategory.speed,
@@ -14,6 +14,7 @@ final propertyCategoryProvider =
enum PropertyCategory {
picture,
color,
mask,
audio,
speed,
@@ -22,6 +23,7 @@ enum PropertyCategory {
String label(BuildContext context) => switch (this) {
picture => context.l10n.pictureProperties,
color => context.l10n.color,
mask => context.l10n.mask,
audio => context.l10n.audio,
speed => context.l10n.speedChange,