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
358 lines
11 KiB
Dart
358 lines
11 KiB
Dart
import 'package:cutdex/l10n/l10n.dart';
|
|
import 'package:cutdex_core/timeline/engine.dart';
|
|
import 'package:cutdex_core/timeline/model.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import 'package:cutdex_ui/theme.dart';
|
|
|
|
import 'properties_inspector_controller.dart';
|
|
|
|
import 'package:cutdex_ui/widgets.dart';
|
|
|
|
import '../../workspace/timeline_provider.dart';
|
|
import '../../workspace/timeline_session.dart';
|
|
import 'audio_properties.dart';
|
|
import 'caption_properties.dart';
|
|
import 'color_interpretation_properties.dart';
|
|
import 'mask_properties.dart';
|
|
import 'picture_properties.dart';
|
|
import 'project_properties.dart';
|
|
import 'properties_presentation_state.dart';
|
|
import 'speed_properties.dart';
|
|
|
|
export 'properties_presentation_state.dart';
|
|
|
|
typedef PropertyCategoryControls = Widget Function(
|
|
BuildContext context,
|
|
List<PropertyCategory> categories,
|
|
PropertyCategory selected,
|
|
ValueChanged<PropertyCategory> onSelected,
|
|
);
|
|
|
|
class PropertiesContent extends ConsumerWidget {
|
|
const PropertiesContent({
|
|
super.key,
|
|
required this.projectId,
|
|
required this.timelineId,
|
|
required this.categoryControls,
|
|
required this.categoryHeaderHeight,
|
|
});
|
|
final String projectId;
|
|
final String timelineId;
|
|
final PropertyCategoryControls categoryControls;
|
|
final double categoryHeaderHeight;
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final state = ref.watch(editorTimelineProvider(projectId, timelineId));
|
|
final content = state.when(
|
|
error: (_, _) => WorkspacePanel(
|
|
paintBackground: false,
|
|
child: _Message(context.l10n.loadClipPropertiesFailed),
|
|
),
|
|
data: (session) {
|
|
final inspector = ref.watch(
|
|
propertiesInspectorProvider((projectId, timelineId)),
|
|
);
|
|
if (inspector == null) return const SizedBox.shrink();
|
|
return ListenableBuilder(
|
|
listenable: inspector,
|
|
builder: (context, _) => _selection(context, inspector, ref),
|
|
);
|
|
},
|
|
loading: () => const WorkspacePanel(
|
|
key: Key('properties-pending'),
|
|
paintBackground: false,
|
|
child: SizedBox.expand(),
|
|
),
|
|
);
|
|
return Theme(
|
|
data: AppTheme.propertiesPanelTheme(Theme.of(context)),
|
|
child: content,
|
|
);
|
|
}
|
|
|
|
Widget _selection(
|
|
BuildContext context,
|
|
PropertiesInspectorController inspector,
|
|
WidgetRef ref,
|
|
) {
|
|
final session = inspector.session;
|
|
final sequence = inspector.sequence;
|
|
final clips = inspector.selectedClips;
|
|
if (sequence == null || clips.isEmpty) {
|
|
return ProjectProperties(session: session);
|
|
}
|
|
if (clips.length > 1) {
|
|
return WorkspacePanel(
|
|
paintBackground: false,
|
|
child: _Message(context.l10n.selectedClipsHint(clips.length)),
|
|
);
|
|
}
|
|
final clip = clips.single;
|
|
final payload = clip.payloadRef == null
|
|
? null
|
|
: session.payloadFor(clip.payloadRef!);
|
|
final binding = clip.payloadRef == null
|
|
? null
|
|
: session.mediaBinding(clip.payloadRef!);
|
|
final hasAudio = binding?.audioSelection != null;
|
|
if (payload?.type == 'caption' || payload?.type == 'caption-role') {
|
|
return CaptionProperties(
|
|
session: session,
|
|
sequence: sequence,
|
|
clipId: clip.id.value,
|
|
transformProperties: payload?.type == 'caption'
|
|
? PictureProperties(
|
|
key: ValueKey((sequence, clip.id, 'caption-transform')),
|
|
projectId: projectId,
|
|
timelineId: timelineId,
|
|
session: session,
|
|
sequence: sequence,
|
|
clip: clip,
|
|
)
|
|
: null,
|
|
);
|
|
}
|
|
return _ClipProperties(
|
|
key: ValueKey((sequence, clip.id)),
|
|
categoryControls: categoryControls,
|
|
categoryHeaderHeight: categoryHeaderHeight,
|
|
category: ref.watch(
|
|
propertyCategoryProvider((
|
|
projectId,
|
|
timelineId,
|
|
'${sequence.value}/${clip.id.value}',
|
|
)),
|
|
),
|
|
session: session,
|
|
sequence: sequence,
|
|
clip: clip,
|
|
mask: MaskProperties(
|
|
projectId: projectId,
|
|
timelineId: timelineId,
|
|
element: clip.id,
|
|
),
|
|
speed: SpeedProperties(
|
|
session: session,
|
|
sequence: sequence,
|
|
clip: clip.id,
|
|
),
|
|
audio: AudioProperties(
|
|
key: ValueKey((sequence, clip.id, 'audio')),
|
|
session: session,
|
|
sequence: sequence,
|
|
clip: clip,
|
|
hasAudio: hasAudio,
|
|
),
|
|
color: payload?.type == 'video' && binding?.videoTrackIndex != null
|
|
? ColorInterpretationProperties(
|
|
projectId: projectId,
|
|
timelineId: timelineId,
|
|
session: session,
|
|
assetId: payload!.assetIds.single,
|
|
trackIndex: binding!.videoTrackIndex!,
|
|
)
|
|
: 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')),
|
|
projectId: projectId,
|
|
timelineId: timelineId,
|
|
session: session,
|
|
sequence: sequence,
|
|
clip: clip,
|
|
animationView: true,
|
|
),
|
|
type: payload?.type,
|
|
hasAudio: hasAudio,
|
|
);
|
|
}
|
|
}
|
|
|
|
class _ClipProperties extends StatefulWidget {
|
|
const _ClipProperties({
|
|
super.key,
|
|
required this.session,
|
|
required this.sequence,
|
|
required this.clip,
|
|
required this.picture,
|
|
required this.color,
|
|
required this.mask,
|
|
required this.audio,
|
|
required this.speed,
|
|
required this.animation,
|
|
required this.type,
|
|
required this.hasAudio,
|
|
required this.categoryControls,
|
|
required this.categoryHeaderHeight,
|
|
required this.category,
|
|
});
|
|
final EditorTimelineSession session;
|
|
final SequenceId sequence;
|
|
final ElementRecord clip;
|
|
final Widget picture;
|
|
final Widget color;
|
|
final Widget mask;
|
|
final Widget audio;
|
|
final Widget speed;
|
|
final Widget animation;
|
|
final String? type;
|
|
final bool hasAudio;
|
|
final PropertyCategoryControls categoryControls;
|
|
final double categoryHeaderHeight;
|
|
final ValueNotifier<PropertyCategory?> category;
|
|
@override
|
|
State<_ClipProperties> createState() => _ClipPropertiesState();
|
|
}
|
|
|
|
class _ClipPropertiesState extends State<_ClipProperties> {
|
|
PropertyCategory get _selected {
|
|
final categories = categoriesForClip(widget.clip, widget.type);
|
|
return categories.contains(widget.category.value)
|
|
? widget.category.value!
|
|
: categories.first;
|
|
}
|
|
|
|
void _selectCategory(PropertyCategory category) =>
|
|
widget.category.value = category;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => ListenableBuilder(
|
|
listenable: widget.category,
|
|
builder: (context, _) => _buildProperties(context),
|
|
);
|
|
|
|
Widget _buildProperties(BuildContext context) {
|
|
final clip = widget.clip;
|
|
return WorkspacePanel(
|
|
paintBackground: false,
|
|
headerHeight: widget.categoryHeaderHeight,
|
|
headerPadding: EdgeInsets.zero,
|
|
showHeaderDivider: false,
|
|
controls: widget.categoryControls(
|
|
context,
|
|
categoriesForClip(clip, widget.type),
|
|
_selected,
|
|
_selectCategory,
|
|
),
|
|
child: ScrollEdgeFadeBuilder(
|
|
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.
|
|
physics: const ClampingScrollPhysics(),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
...switch (_selected) {
|
|
PropertyCategory.picture => [widget.picture],
|
|
PropertyCategory.color => [widget.color],
|
|
PropertyCategory.mask => [widget.mask],
|
|
PropertyCategory.audio => [widget.audio],
|
|
PropertyCategory.speed => [widget.speed],
|
|
PropertyCategory.animation => [widget.animation],
|
|
PropertyCategory.basic => [
|
|
_Property(context.l10n.type, switch (clip.structure) {
|
|
ElementStructure.gap => context.l10n.gap,
|
|
ElementStructure.container => context.l10n.compoundClip,
|
|
ElementStructure.content =>
|
|
widget.type ?? context.l10n.unboundMedia,
|
|
}),
|
|
_Property(
|
|
context.l10n.status,
|
|
clip.enabled ? context.l10n.enable : context.l10n.disable,
|
|
),
|
|
],
|
|
},
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _Property extends StatelessWidget {
|
|
const _Property(this.label, this.value);
|
|
final String label;
|
|
final String value;
|
|
@override
|
|
Widget build(BuildContext context) => Padding(
|
|
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,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
class _Message extends StatelessWidget {
|
|
const _Message(this.text);
|
|
final String text;
|
|
@override
|
|
Widget build(BuildContext context) => Center(
|
|
child: Padding(
|
|
padding: AppTheme.isDesktop(context)
|
|
? const EdgeInsets.symmetric(
|
|
horizontal: AppInspectorMetrics.padding,
|
|
vertical: 4,
|
|
)
|
|
: AppSpacing.panelSection,
|
|
child: Text(
|
|
text,
|
|
textAlign: TextAlign.center,
|
|
style: Theme.of(context).textTheme.bodySmall,
|
|
),
|
|
),
|
|
);
|
|
}
|