Move editor UI into the app and release verified Core dependencies (#14)
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

This commit was merged in pull request #14.
This commit is contained in:
lingjhf committed 2026-10-11 19:59:40 +00:00
1 parent abc1868550
commit 06f1c26681
452 files changed
+43806 -2329

No files matched your search

@@ -1,6 +1,6 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
enum DesktopContent { workspace, library, resourceLibrary, settings }
enum DesktopContent { workspace, library, resourceLibrary, workflow, settings }
typedef DesktopContentSelection = ({
DesktopContent surface,
+1 -1
View File
@@ -1,5 +1,5 @@
import 'package:cutdex_ui/theme.dart';
import 'package:cutdex_sdk/timeline_ui.dart';
import 'package:cutdex_timeline_ui/cutdex_timeline_ui.dart';
import 'package:flutter/material.dart';
/// Connects the application palette to the SDK timeline presentation.
+94 -72
View File
@@ -17,9 +17,9 @@ class DesktopWindowFrame extends StatelessWidget {
this.projectTabs,
this.headerTrailing = const SizedBox.shrink(),
this.settingsSelected = false,
this.resourceLibrarySelected = false,
this.onResourceLibraryPressed,
this.workflowSelected = false,
required this.onHomePressed,
required this.onWorkflowPressed,
required this.onSettingsPressed,
required this.child,
});
@@ -35,9 +35,9 @@ class DesktopWindowFrame extends StatelessWidget {
final Widget? projectTabs;
final Widget headerTrailing;
final bool settingsSelected;
final bool resourceLibrarySelected;
final VoidCallback? onResourceLibraryPressed;
final bool workflowSelected;
final VoidCallback onHomePressed;
final VoidCallback onWorkflowPressed;
final VoidCallback onSettingsPressed;
final Widget child;
@@ -119,88 +119,110 @@ class DesktopWindowFrame extends StatelessWidget {
Expanded(
child: Row(
children: [
if (projectTabs == null)
SizedBox(
key: const Key('desktop-navigation-rail'),
width: railWidth,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
child: Column(
children: [
for (final section in [0, 2])
Padding(
padding: const EdgeInsets.only(bottom: 8),
child: IconButton.filledTonal(
key: ValueKey(switch (section) {
0 => 'desktop-rail-home',
_ => 'desktop-rail-resources',
}),
tooltip: switch (section) {
0 => context.l10n.navigationHome,
_ => context.l10n.navigationLibrary,
},
isSelected:
!settingsSelected &&
(section == 2
? resourceLibrarySelected
: !resourceLibrarySelected),
style: IconButton.styleFrom(
fixedSize: const Size.square(railButtonSize),
minimumSize: const Size.square(railButtonSize),
maximumSize: const Size.square(railButtonSize),
padding: EdgeInsets.zero,
iconSize: railIconSize,
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
backgroundColor:
!settingsSelected &&
(section == 2
? resourceLibrarySelected
: !resourceLibrarySelected)
? null
: Colors.transparent,
SizedBox(
key: const Key('desktop-navigation-rail'),
width: railWidth,
child: LayoutBuilder(
builder: (context, constraints) => SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: constraints.maxHeight,
),
child: IntrinsicHeight(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
child: Column(
children: [
IconButton.filledTonal(
key: const ValueKey('desktop-rail-home'),
tooltip: context.l10n.navigationHome,
isSelected:
!settingsSelected && !workflowSelected,
style: IconButton.styleFrom(
fixedSize: const Size.square(railButtonSize),
minimumSize: const Size.square(
railButtonSize,
),
maximumSize: const Size.square(
railButtonSize,
),
padding: EdgeInsets.zero,
iconSize: railIconSize,
tapTargetSize:
MaterialTapTargetSize.shrinkWrap,
backgroundColor:
settingsSelected || workflowSelected
? Colors.transparent
: null,
),
onPressed: onHomePressed,
icon: const Icon(AppIcons.home),
),
onPressed: switch (section) {
0 => onHomePressed,
_ => onResourceLibraryPressed,
},
icon: Icon(switch (section) {
0 => AppIcons.home,
_ => AppIcons.folder,
}),
),
const SizedBox(height: 8),
IconButton.filledTonal(
key: const ValueKey('desktop-rail-workflow'),
tooltip: context.l10n.workflow,
isSelected: workflowSelected,
style: IconButton.styleFrom(
fixedSize: const Size.square(railButtonSize),
minimumSize: const Size.square(
railButtonSize,
),
maximumSize: const Size.square(
railButtonSize,
),
padding: EdgeInsets.zero,
iconSize: railIconSize,
tapTargetSize:
MaterialTapTargetSize.shrinkWrap,
backgroundColor: workflowSelected
? null
: Colors.transparent,
),
onPressed: onWorkflowPressed,
icon: const Icon(AppIcons.timeline),
),
const Spacer(),
IconButton(
key: const Key('desktop-rail-settings'),
tooltip: context.l10n.settings,
isSelected: settingsSelected,
onPressed: onSettingsPressed,
style: IconButton.styleFrom(
fixedSize: const Size.square(railButtonSize),
minimumSize: const Size.square(
railButtonSize,
),
maximumSize: const Size.square(
railButtonSize,
),
padding: EdgeInsets.zero,
iconSize: railIconSize,
tapTargetSize:
MaterialTapTargetSize.shrinkWrap,
),
icon: const Icon(AppIcons.settings),
),
],
),
const Spacer(),
IconButton(
key: const Key('project-settings-button'),
tooltip: context.l10n.settings,
isSelected: settingsSelected,
onPressed: onSettingsPressed,
style: IconButton.styleFrom(
fixedSize: const Size.square(railButtonSize),
minimumSize: const Size.square(railButtonSize),
maximumSize: const Size.square(railButtonSize),
padding: EdgeInsets.zero,
iconSize: railIconSize,
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
icon: const Icon(AppIcons.settings),
),
],
),
),
),
),
),
Expanded(
child: Padding(
padding: EdgeInsets.only(
left: projectTabs == null ? 0 : contentInset,
padding: const EdgeInsets.only(
left: contentInset,
right: contentInset,
bottom: contentInset,
),
child: SizedBox(
key: const Key('desktop-content-container'),
child: WindowHeaderPane(
offset: Offset(
projectTabs == null ? railWidth : contentInset,
offset: const Offset(
railWidth + contentInset,
headerHeight,
),
child: LayoutBuilder(
+121 -9
View File
@@ -32,6 +32,11 @@ class DesktopWorkspaceShell extends StatefulWidget {
required this.scaffoldKey,
required this.navigationDrawer,
this.projectTabsLayout = false,
this.timelineHeight,
this.onTimelineHeightChanged,
this.onJunctionResizeEnd,
this.onSidebarResizeEnd,
this.sidebarCanExpand = true,
});
static const gutterWidth = WorkspaceLayoutMetrics.desktopSpacing;
@@ -47,12 +52,53 @@ class DesktopWorkspaceShell extends StatefulWidget {
final GlobalKey<ScaffoldState> scaffoldKey;
final Widget navigationDrawer;
final bool projectTabsLayout;
final double? timelineHeight;
final ValueChanged<double>? onTimelineHeightChanged;
final VoidCallback? onJunctionResizeEnd;
final VoidCallback? onSidebarResizeEnd;
final bool sidebarCanExpand;
@override
State<DesktopWorkspaceShell> createState() => _DesktopWorkspaceShellState();
}
class _DesktopWorkspaceShellState extends State<DesktopWorkspaceShell> {
double? _sidebarRestoreWidth;
bool _sidebarJunctionDragging = false;
void _startSidebarResize(double width, {bool junction = false}) {
_sidebarRestoreWidth = width;
if (junction) setState(() => _sidebarJunctionDragging = true);
}
void _resizeSidebar(double requestedWidth, double maximum) {
if (!widget.sidebarCanExpand || widget.controller.agentFloating) return;
if (requestedWidth < WorkspaceLayoutMetrics.sidebarSnapThreshold) {
if (!widget.sidebarCollapsed) {
final restoreWidth = _sidebarRestoreWidth;
if (restoreWidth != null && widget.sidebarWidth != restoreWidth) {
widget.onSidebarWidthChanged(restoreWidth);
}
widget.onSidebarCollapsedChanged(true);
}
return;
}
if (widget.sidebarCollapsed) widget.onSidebarCollapsedChanged(false);
widget.onSidebarWidthChanged(
requestedWidth.clamp(WorkspaceLayoutMetrics.sidebarMinimumWidth, maximum),
);
}
void _finishSidebarResize() {
_sidebarRestoreWidth = null;
if (_sidebarJunctionDragging) {
setState(() => _sidebarJunctionDragging = false);
widget.onJunctionResizeEnd?.call();
} else {
widget.onSidebarResizeEnd?.call();
}
}
@override
void initState() {
super.initState();
@@ -64,6 +110,11 @@ class _DesktopWorkspaceShellState extends State<DesktopWorkspaceShell> {
@override
void didUpdateWidget(covariant DesktopWorkspaceShell oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.controller.agentFloating ||
!widget.sidebarCanExpand ||
widget.onTimelineHeightChanged == null) {
_sidebarJunctionDragging = false;
}
if (oldWidget.controller != widget.controller) {
oldWidget.controller.removeListener(_changed);
widget.controller.addListener(_changed);
@@ -85,6 +136,9 @@ class _DesktopWorkspaceShellState extends State<DesktopWorkspaceShell> {
required ValueChanged<double> onResize,
double direction = 1,
VoidCallback? onEnd,
VoidCallback? onStart,
Set<WorkspaceResizeBoundary> highlightTargets = const {},
Offset highlightOffset = Offset.zero,
}) => SizedBox(
width: WorkspaceLayoutMetrics.desktopResizeHitExtent,
height: double.infinity,
@@ -95,11 +149,17 @@ class _DesktopWorkspaceShellState extends State<DesktopWorkspaceShell> {
direction: direction,
onResize: onResize,
onEnd: onEnd,
onStart: onStart,
highlightTargets: highlightTargets,
highlightOffset: highlightOffset,
),
);
@override
Widget build(BuildContext context) => widget.projectTabsLayout
Widget build(BuildContext context) =>
WorkspaceResizeHighlightScope(child: _workspace(context));
Widget _workspace(BuildContext context) => widget.projectTabsLayout
? _projectWorkspace(context)
: LayoutBuilder(
builder: (context, constraints) {
@@ -164,6 +224,7 @@ class _DesktopWorkspaceShellState extends State<DesktopWorkspaceShell> {
return Scaffold(
key: widget.scaffoldKey,
drawerEnableOpenDragGesture: false,
backgroundColor: Colors.transparent,
drawer: Drawer(
width: 320,
@@ -317,6 +378,12 @@ class _DesktopWorkspaceShellState extends State<DesktopWorkspaceShell> {
.toDouble();
final floating = widget.controller.agentFloating;
final collapsed = widget.sidebarCollapsed || floating;
double resolveTimelineHeight(double? height) =>
WorkspaceLayoutMetrics.resolveTimelineHeight(
constraints.maxHeight,
height,
);
final timelineHeight = resolveTimelineHeight(widget.timelineHeight);
final geometry = DesktopWorkspaceGeometry(
sidebarWidth: sidebarWidth,
agentWidth: 0,
@@ -324,6 +391,7 @@ class _DesktopWorkspaceShellState extends State<DesktopWorkspaceShell> {
);
return Scaffold(
key: widget.scaffoldKey,
drawerEnableOpenDragGesture: false,
backgroundColor: Colors.transparent,
drawer: Drawer(
width: 320,
@@ -356,20 +424,64 @@ class _DesktopWorkspaceShellState extends State<DesktopWorkspaceShell> {
),
],
),
if (!collapsed)
if (!floating &&
widget.sidebarCanExpand &&
WorkspaceLayoutPolicy.desktopNavigationFits(width))
Positioned(
left: sidebarWidth - WorkspaceLayoutMetrics.desktopResizeSlop,
left: collapsed
? 0
: sidebarWidth - WorkspaceLayoutMetrics.desktopResizeSlop,
top: 0,
bottom: 0,
child: _gutter(
name: 'project-sidebar',
initialWidth: sidebarWidth,
onResize: (value) => widget.onSidebarWidthChanged(
value.clamp(
WorkspaceLayoutMetrics.sidebarMinimumWidth,
maximum,
),
highlightTargets: const {WorkspaceResizeBoundary.sidebar},
highlightOffset: collapsed
? const Offset(
-WorkspaceLayoutMetrics.desktopResizeHitExtent / 2,
0,
)
: Offset.zero,
initialWidth: collapsed ? 0 : sidebarWidth,
onStart: () => _startSidebarResize(sidebarWidth),
onResize: (value) => _resizeSidebar(value, maximum),
onEnd: _finishSidebarResize,
),
),
if (!floating &&
widget.sidebarCanExpand &&
WorkspaceLayoutPolicy.desktopNavigationFits(width) &&
widget.onTimelineHeightChanged != null)
Positioned(
left: collapsed
? 0
: sidebarWidth - WorkspaceLayoutMetrics.desktopResizeSlop,
bottom:
timelineHeight - WorkspaceLayoutMetrics.desktopResizeSlop,
width: WorkspaceLayoutMetrics.desktopResizeHitExtent,
height: WorkspaceLayoutMetrics.desktopResizeHitExtent,
child: WorkspaceResizeHandle.junction(
key: const Key('desktop-chat-timeline-junction'),
highlightOffset: collapsed
? const Offset(
-WorkspaceLayoutMetrics.desktopResizeHitExtent / 2,
0,
)
: Offset.zero,
highlightTargets: const {
WorkspaceResizeBoundary.sidebar,
WorkspaceResizeBoundary.timeline,
},
initialWidth: collapsed ? 0 : sidebarWidth,
initialHeight: timelineHeight,
verticalDirection: -1,
onStart: () =>
_startSidebarResize(sidebarWidth, junction: true),
onWidthChanged: (value) => _resizeSidebar(value, maximum),
onHeightChanged: (value) => widget.onTimelineHeightChanged!(
resolveTimelineHeight(value),
),
onEnd: _finishSidebarResize,
),
),
if (floating)
+1 -1
View File
@@ -1,7 +1,7 @@
import 'dart:async';
import 'dart:io';
import 'package:cutdex_sdk/runtime.dart';
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
import 'package:cutdex_native/cutdex_native.dart';
import 'package:flutter/foundation.dart';
import 'package:path/path.dart' as p;
@@ -2,24 +2,20 @@ import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:flutter/services.dart';
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
/// Native QPC clock calibration and bounded asynchronous diagnostics sampling.
class BenchDiagnostics {
BenchDiagnostics(this.sessionId, this.clock);
final String sessionId;
BenchDiagnostics(this.session, this.clock);
final RuntimeSession session;
final Stopwatch clock;
static const _channel = MethodChannel('cutdex_runtime');
double uncertaintyMs = double.infinity, _offset = 0;
Timer? _timer;
Future<void>? _pending;
Object? _sampleError;
double now() => _offset + clock.elapsedMicroseconds / 1000;
Future<Map<String, dynamic>> read() async =>
(await _channel.invokeMapMethod<String, dynamic>('previewDiagnostics', {
'sessionId': sessionId,
}))!;
Future<Map<String, Object?>> read() => session.previewDiagnostics();
Future<void> calibrate() async {
for (var i = 0; i < 20; i++) {
@@ -1,6 +1,6 @@
import 'package:cutdex_sdk/timeline/model.dart';
import 'package:cutdex_sdk/timeline/layout.dart';
import 'package:cutdex_sdk/timeline_ui.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:cutdex_core/timeline/layout.dart';
import 'package:cutdex_timeline_ui/cutdex_timeline_ui.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/rendering.dart';
@@ -2,11 +2,11 @@ import 'dart:async';
import 'dart:io';
import 'package:cutdex/features/preview/preview_panel.dart';
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_sdk/runtime.dart';
import 'package:cutdex_sdk/timeline/model.dart';
import 'package:cutdex_sdk/timeline/layout.dart';
import 'package:cutdex_sdk/timeline_ui.dart';
import 'package:cutdex_core/editor.dart';
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:cutdex_core/timeline/layout.dart';
import 'package:cutdex_timeline_ui/cutdex_timeline_ui.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
@@ -84,7 +84,7 @@ Future<void> runFullAppViewportBench(ViewportBenchConfig config) async {
if (clipStart < 0 || clipEnd > viewport.width) {
throw StateError('Clip outside viewport');
}
final native = diagnostics = BenchDiagnostics(preview.session!.id, clock);
final native = diagnostics = BenchDiagnostics(preview.session!, clock);
await native.calibrate();
capture = await BenchCapture.start(config, output);
final record = records = BenchRecords(output);
+2 -2
View File
@@ -2,8 +2,8 @@ import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:cutdex_sdk/timeline/layout.dart';
import 'package:cutdex_sdk/timeline_ui.dart';
import 'package:cutdex_core/timeline/layout.dart';
import 'package:cutdex_timeline_ui/cutdex_timeline_ui.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
+1 -1
View File
@@ -191,7 +191,7 @@ Future<void> _run(String output) async {
.cached((projectId, id));
if (preview?.session != null && uiMs != null && dataMs != null) {
final diagnostic = await BenchDiagnostics(
preview!.session!.id,
preview!.session!,
clock,
).read().timeout(const Duration(seconds: 2));
if ((diagnostic['sourceSubmitted'] as num?) != null &&
@@ -1,4 +1,4 @@
import 'package:cutdex_sdk/project.dart';
import 'package:cutdex_core/project.dart';
import 'package:flutter/material.dart';
import '../media/media_asset_cover.dart';
+1 -1
View File
@@ -7,7 +7,7 @@ import '../../shared/theme/composer_style.dart';
import 'package:cutdex/l10n/l10n.dart';
import 'package:cutdex_sdk/project.dart';
import 'package:cutdex_core/project.dart';
import '../../integrations/platform/platform_capabilities.dart';
import 'agent_composer_controller.dart';
@@ -1,4 +1,4 @@
import 'package:cutdex_sdk/project.dart';
import 'package:cutdex_core/project.dart';
import 'package:flutter/foundation.dart';
import '../../workspace/external_media_import.dart';
@@ -6,7 +6,7 @@ import 'dart:convert';
import 'package:cutdex_agent/cutdex_agent.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:cutdex_sdk/runtime.dart';
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
import 'package:uuid/uuid.dart';
import '../../diagnostics/agent_request_diagnostics.dart';
@@ -1,4 +1,4 @@
import 'package:cutdex_sdk/project.dart';
import 'package:cutdex_core/project.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'agent_media_attachments.freezed.dart';
@@ -1,5 +1,5 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:cutdex_sdk/project.dart';
import 'package:cutdex_core/project.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@@ -1,5 +1,5 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:cutdex_sdk/project.dart';
import 'package:cutdex_core/project.dart';
import 'package:cutdex_ui/icons.dart';
import 'package:flutter/material.dart';
+33 -11
View File
@@ -80,7 +80,6 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
ProjectViewSettings get _viewController =>
ref.read(projectViewSettingsProvider(widget.projectId).notifier);
bool get _propertiesOpen => _viewSettings.propertiesOpen;
double? get _timelineHeight => _viewSettings.timelineHeight;
void _saveViewSettings() {
if (widget.projectId.isEmpty ||
@@ -93,7 +92,8 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
@override
Widget build(BuildContext context) {
final viewSettings = ref.watch(
projectViewSettingsProvider(widget.projectId),
projectViewSettingsProvider(widget.projectId)
.select((value) => (value.hasValue, value.value?.propertiesOpen)),
);
final preview = KeyedSubtree(
key: _previewKey,
@@ -205,10 +205,15 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
if (desktop) mediaButton,
Expanded(
child: desktop
? _PreviewHeaderTitle(
projectId: widget.projectId,
timelineId: widget.timelineId,
pending: _timelinePending,
? Padding(
padding: const EdgeInsets.symmetric(
horizontal: AppSpacing.small,
),
child: _PreviewHeaderTitle(
projectId: widget.projectId,
timelineId: widget.timelineId,
pending: _timelinePending,
),
)
: widget.showProjectName
? Row(
@@ -249,7 +254,7 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
? context.l10n.collapseProperties
: context.l10n.expandProperties,
isSelected: propertiesOpen,
onPressed: !viewSettings.hasValue
onPressed: !viewSettings.$1
? null
: () {
if (desktop) {
@@ -285,23 +290,40 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
),
),
);
Widget dockedEditing({required bool showTools}) =>
ExpandedEditorLayout(
Widget dockedEditing({required bool showTools}) => Consumer(
builder: (context, ref, _) {
final dimensions = ref.watch(
projectViewSettingsProvider(widget.projectId).select(
(value) =>
(value.value?.mediaWidth, value.value?.timelineHeight),
),
);
return ExpandedEditorLayout(
preview: preview,
header: header,
properties: properties,
media: media,
showMedia: dockMedia,
showProperties: showTools && dockProperties,
timelineHeight: _timelineHeight,
mediaWidth: dimensions.$1,
onMediaWidthChanged: (width) {
if (viewSettings.$1) {
_viewController.setMediaWidth(width);
}
},
onMediaWidthChangeEnd: _saveViewSettings,
timelineHeight: dimensions.$2,
onTimelineHeightChanged: (height) {
if (viewSettings.hasValue) {
if (viewSettings.$1) {
_viewController.setTimelineHeight(height);
}
},
onTimelineHeightChangeEnd: _saveViewSettings,
onJunctionResizeEnd: _saveViewSettings,
timeline: timeline,
);
},
);
return Stack(
fit: StackFit.expand,
children: [
@@ -32,7 +32,7 @@ class EditorTimelineDefaults extends StatelessWidget {
: 26,
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: AppTheme.isDesktop(context) ? AppSpacing.tiny : 0,
horizontal: AppTheme.isDesktop(context) ? AppSpacing.small : 0,
),
child: Row(
children: [
@@ -90,7 +90,9 @@ class EditorTimelineDefaults extends StatelessWidget {
),
)
: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
padding: const EdgeInsets.symmetric(
horizontal: AppSpacing.medium,
),
child: AppCommandToolbar(
groups: [
[
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import '../../../integrations/platform/device_experience.dart';
import '../../../l10n/l10n.dart';
import '../../../shared/layout/workspace_layout_metrics.dart';
import 'package:cutdex_ui/icons.dart';
import 'package:cutdex_ui/theme.dart';
@@ -61,6 +62,11 @@ class BoundedEditorLayout extends StatelessWidget {
: context.l10n.expandProperties,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: desktop && tool == EditorTool.properties
? AppTheme.propertiesPanelTheme(Theme.of(context))
.textTheme
.titleSmall
: null,
),
),
],
@@ -103,7 +109,12 @@ class BoundedEditorLayout extends StatelessWidget {
right: 0,
width: page
? constraints.maxWidth
: math.min(320, constraints.maxWidth),
: math.min(
desktop && tool == EditorTool.properties
? WorkspaceLayoutMetrics.propertiesPanelWidth
: 320,
constraints.maxWidth,
),
child: Material(
key: const Key('editor-tool-surface'),
elevation: page ? 0 : 8,
@@ -15,9 +15,13 @@ class ExpandedEditorLayout extends StatefulWidget {
required this.media,
required this.showMedia,
required this.showProperties,
required this.mediaWidth,
required this.onMediaWidthChanged,
required this.onMediaWidthChangeEnd,
required this.timelineHeight,
required this.onTimelineHeightChanged,
required this.onTimelineHeightChangeEnd,
required this.onJunctionResizeEnd,
required this.timeline,
});
@@ -27,9 +31,13 @@ class ExpandedEditorLayout extends StatefulWidget {
final Widget media;
final bool showMedia;
final bool showProperties;
final double? mediaWidth;
final ValueChanged<double> onMediaWidthChanged;
final VoidCallback onMediaWidthChangeEnd;
final double? timelineHeight;
final ValueChanged<double> onTimelineHeightChanged;
final VoidCallback onTimelineHeightChangeEnd;
final VoidCallback onJunctionResizeEnd;
final Widget timeline;
@override
@@ -50,28 +58,35 @@ class _ExpandedEditorLayoutState extends State<ExpandedEditorLayout> {
WorkspaceCard(key: Key('editor-$name-card'), child: child);
@override
Widget build(BuildContext context) => LayoutBuilder(
Widget build(BuildContext context) =>
WorkspaceResizeHighlightScope(child: _layout());
Widget _layout() => LayoutBuilder(
builder: (context, constraints) {
final maximum = math.max(
0.0,
constraints.maxHeight -
gap -
WorkspaceLayoutMetrics.previewMinimumHeight,
);
final minimum = math.min(
WorkspaceLayoutMetrics.timelineMinimumHeight,
maximum,
);
final timelineHeight =
(widget.timelineHeight ??
constraints.maxHeight *
WorkspaceLayoutMetrics.timelineDefaultHeightFraction)
.clamp(minimum, maximum)
.toDouble();
const mediaWidth = WorkspaceLayoutMetrics.mediaPanelWidth;
double resolveTimelineHeight(double? height) =>
WorkspaceLayoutMetrics.resolveTimelineHeight(
constraints.maxHeight,
height,
);
final timelineHeight = resolveTimelineHeight(widget.timelineHeight);
final propertiesWidth = widget.showProperties
? WorkspaceLayoutMetrics.propertiesPanelWidth
: 0.0;
final mediaMaximumWidth = math.max(
0.0,
constraints.maxWidth -
WorkspaceLayoutMetrics.previewMinimumWidth -
gap -
(widget.showProperties ? propertiesWidth + gap : 0),
);
final mediaMinimumWidth = math.min(
WorkspaceLayoutMetrics.mediaPanelMinimumWidth,
mediaMaximumWidth,
);
final mediaWidth =
(widget.mediaWidth ?? WorkspaceLayoutMetrics.mediaPanelWidth)
.clamp(mediaMinimumWidth, mediaMaximumWidth)
.toDouble();
return Stack(
fit: StackFit.expand,
children: [
@@ -130,6 +145,24 @@ class _ExpandedEditorLayoutState extends State<ExpandedEditorLayout> {
),
],
),
if (widget.showMedia)
Positioned(
key: const Key('editor-media-divider'),
left: mediaWidth - WorkspaceLayoutMetrics.desktopResizeSlop,
top: 0,
bottom: timelineHeight + gap,
width: WorkspaceLayoutMetrics.desktopResizeHitExtent,
child: WorkspaceResizeHandle(
key: const Key('editor-media-resize'),
highlightTargets: const {WorkspaceResizeBoundary.media},
axis: Axis.horizontal,
initialValue: mediaWidth,
onResize: (width) => widget.onMediaWidthChanged(
width.clamp(mediaMinimumWidth, mediaMaximumWidth).toDouble(),
),
onEnd: widget.onMediaWidthChangeEnd,
),
),
Positioned(
key: const Key('editor-timeline-divider'),
left: 0,
@@ -138,15 +171,39 @@ class _ExpandedEditorLayoutState extends State<ExpandedEditorLayout> {
height: WorkspaceLayoutMetrics.desktopResizeHitExtent,
child: WorkspaceResizeHandle(
key: const Key('editor-timeline-resize'),
highlightTargets: const {WorkspaceResizeBoundary.timeline},
axis: Axis.vertical,
initialValue: timelineHeight,
direction: -1,
onResize: (height) => widget.onTimelineHeightChanged(
height.clamp(minimum, maximum).toDouble(),
),
onResize: (height) =>
widget.onTimelineHeightChanged(resolveTimelineHeight(height)),
onEnd: widget.onTimelineHeightChangeEnd,
),
),
if (widget.showMedia)
Positioned(
left: mediaWidth - WorkspaceLayoutMetrics.desktopResizeSlop,
bottom: timelineHeight - WorkspaceLayoutMetrics.desktopResizeSlop,
width: WorkspaceLayoutMetrics.desktopResizeHitExtent,
height: WorkspaceLayoutMetrics.desktopResizeHitExtent,
child: WorkspaceResizeHandle.junction(
key: const Key('editor-media-timeline-junction'),
highlightTargets: const {
WorkspaceResizeBoundary.media,
WorkspaceResizeBoundary.timeline,
},
initialWidth: mediaWidth,
initialHeight: timelineHeight,
verticalDirection: -1,
onWidthChanged: (width) => widget.onMediaWidthChanged(
width.clamp(mediaMinimumWidth, mediaMaximumWidth).toDouble(),
),
onHeightChanged: (height) => widget.onTimelineHeightChanged(
resolveTimelineHeight(height),
),
onEnd: widget.onJunctionResizeEnd,
),
),
],
);
},
+3 -3
View File
@@ -1,8 +1,8 @@
import 'dart:math' as math;
import 'package:cutdex_sdk/project.dart';
import 'package:cutdex_sdk/timeline/model.dart';
import 'package:cutdex_sdk/timeline_ui.dart';
import 'package:cutdex_core/project.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:cutdex_timeline_ui/cutdex_timeline_ui.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
@@ -1,7 +1,7 @@
import 'package:cutdex/diagnostics/app_diagnostics.dart';
import 'package:cutdex/errors/app_failure.dart';
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_core/editor.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
@@ -7,7 +7,7 @@ import 'subtitle_download.dart';
import 'subtitle_task_actions.dart';
import 'package:cutdex/l10n/l10n.dart';
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_core/editor.dart';
import 'package:flutter/material.dart';
import '../../integrations/runtime/processing_resource_repository.dart';
@@ -1,4 +1,4 @@
import 'package:cutdex_sdk/project.dart';
import 'package:cutdex_core/project.dart';
import 'package:cutdex_ui/icons.dart';
import 'package:cutdex_ui/theme.dart';
import 'package:flutter/material.dart';
@@ -24,12 +24,23 @@ class DesktopMediaAssetTile extends StatelessWidget {
final MediaAvailability? availability;
static TextStyle? _nameStyle(BuildContext context) =>
Theme.of(context).textTheme.bodyMedium
?.copyWith(fontSize: 13, height: 20 / 13);
Theme.of(context).textTheme.bodyMedium?.copyWith(
fontFamily: 'packages/cutdex_ui/Inter',
fontSize: AppInspectorMetrics.fontSize,
height: AppInspectorMetrics.lineHeight / AppInspectorMetrics.fontSize,
fontWeight: FontWeight.w500,
fontVariations: const [FontVariation('wght', 500)],
letterSpacing: AppInspectorMetrics.fontSize * .005,
);
static TextStyle? _metadataStyle(BuildContext context) =>
Theme.of(context).textTheme.bodySmall
?.copyWith(fontSize: 12, height: 16 / 12);
Theme.of(context).textTheme.bodySmall?.copyWith(
fontFamily: 'packages/cutdex_ui/Inter',
fontSize: AppInspectorMetrics.fontSize,
height: AppInspectorMetrics.lineHeight / AppInspectorMetrics.fontSize,
fontVariations: const [FontVariation('wght', 450)],
letterSpacing: AppInspectorMetrics.fontSize * .005,
);
/// Font fallback and fractional scaling can round a line above size × height.
static double gridLabelHeight(BuildContext context) {
@@ -106,7 +117,7 @@ class DesktopMediaAssetTile extends StatelessWidget {
);
final cover = ClipRRect(
key: ValueKey('desktop-media-cover-${asset.id}'),
borderRadius: BorderRadius.circular(4),
borderRadius: BorderRadius.circular(AppInspectorMetrics.radius),
child: Stack(
children: [
if (unavailable)
@@ -215,66 +226,3 @@ class DesktopMediaAssetTile extends StatelessWidget {
);
}
}
/// List labels follow the same column widths and breakpoints as asset rows.
class DesktopMediaListHeader extends StatelessWidget {
const DesktopMediaListHeader({super.key});
@override
Widget build(BuildContext context) => Padding(
padding: const EdgeInsets.symmetric(
horizontal: DesktopMediaMetrics.padding + DesktopMediaMetrics.tilePadding,
),
child: LayoutBuilder(
builder: (context, constraints) {
final columns = DesktopMediaListColumns(constraints.maxWidth);
Widget label(String text, {bool end = false}) => Text(
text,
maxLines: 1,
overflow: TextOverflow.ellipsis,
textAlign: end ? TextAlign.end : TextAlign.start,
style: DesktopMediaAssetTile._metadataStyle(context)
?.copyWith(color: Theme.of(context).colorScheme.onSurfaceVariant),
);
return SizedBox(
height: (MediaQuery.textScalerOf(context).scale(16) + 8).clamp(
DesktopMediaMetrics.listHeader,
double.infinity,
),
child: Row(
children: [
Expanded(
child: Padding(
padding: const EdgeInsetsDirectional.only(
start:
DesktopMediaMetrics.listCover + DesktopMediaMetrics.gap,
),
child: label(context.l10n.name),
),
),
if (columns.duration)
SizedBox(
width: DesktopMediaListColumns.durationWidth,
child: label(context.l10n.duration, end: true),
),
if (columns.specification) ...[
const SizedBox(width: DesktopMediaMetrics.gap),
SizedBox(
width: DesktopMediaListColumns.specificationWidth,
child: label(context.l10n.mediaSpecification),
),
],
if (columns.kind) ...[
const SizedBox(width: DesktopMediaMetrics.gap),
SizedBox(
width: DesktopMediaListColumns.kindWidth,
child: label(context.l10n.mediaCategory),
),
],
],
),
);
},
),
);
}
+1 -1
View File
@@ -1,4 +1,4 @@
import 'package:cutdex_sdk/project.dart';
import 'package:cutdex_core/project.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
+1 -1
View File
@@ -1,6 +1,6 @@
import 'dart:math' as math;
import 'package:cutdex_sdk/project.dart';
import 'package:cutdex_core/project.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
+106 -105
View File
@@ -6,7 +6,7 @@ import 'package:cutdex/errors/app_failure.dart';
import 'dart:math' as math;
import 'package:cutdex/l10n/l10n.dart';
import 'package:cutdex_sdk/project.dart';
import 'package:cutdex_core/project.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
@@ -298,6 +298,95 @@ class _MediaBrowserBodyState extends ConsumerState<MediaBrowserBody>
_anchorOwner = null;
_anchorAssets = const [];
}
Widget item(BuildContext context, int index) {
final asset = assets[index];
return Consumer(
builder: (context, ref, _) {
final availability = ref
.watch(mediaAvailabilityProvider(widget.projectId, asset))
.asData
?.value;
final unavailable =
availability != null &&
availability != MediaAvailability.available;
return ListenableSelector<(bool, bool)>(
listenable: _browser,
select: () => (_selectedAssetId == asset.id, _checkingDrop),
builder: (context, presentation) => AppContextMenu(
key: ValueKey(('media-menu', asset.id)),
itemsBuilder: (_) {
final available = ref.read(projectsProvider).asData?.value;
final canEdit =
available?.activeProject?.id == widget.projectId &&
available?.projectBusy == false &&
!_checkingDrop;
final sequence = timeline?.activeSequenceId;
return [
AppMenuItem(
label: context.l10n.addToTimeline,
icon: AppIcons.add,
onPressed:
canEdit &&
!unavailable &&
sequence != null &&
available?.timeline?.id == timelineId
? () => _action(() => _browser.insertAsset(asset))
: null,
),
AppMenuItem(
label: context.l10n.rename,
icon: AppIcons.rename,
onPressed: canEdit ? () => _rename(asset) : null,
),
AppMenuItem(
label: defaultTargetPlatform == TargetPlatform.macOS
? context.l10n.revealFinder
: context.l10n.revealFileManager,
icon: AppIcons.folderOpen,
onPressed: canEdit && _desktop
? () => _action(() => _browser.reveal(asset))
: null,
),
const AppMenuSeparator(),
AppMenuItem(
label: context.l10n.removeMedia,
icon: AppIcons.delete,
destructive: true,
onPressed: canEdit ? () => _remove(asset) : null,
),
];
},
child: Listener(
onPointerDown: (event) {
if (event.buttons == 2) {
_selectedAssetId = asset.id;
}
},
child: _SelectableAsset(
key: ValueKey(asset.id),
grid: _isGrid,
desktop: widget.desktop,
drag: MediaAssetDrag(
projectId: widget.projectId,
assetId: asset.id,
),
name: asset.name,
draggable:
widget.draggable &&
!workspace!.projectBusy &&
!presentation.$2 &&
!unavailable,
selected: presentation.$1,
onTap: () => _browser.selectAsset(asset),
child: _assetTile(asset, availability),
),
),
),
);
},
);
}
final content = assets.isEmpty
? Center(
child: Padding(
@@ -382,105 +471,6 @@ class _MediaBrowserBodyState extends ConsumerState<MediaBrowserBody>
height: constraints.maxHeight,
);
}
Widget item(BuildContext context, int index) {
final asset = assets[index];
return Consumer(
builder: (context, ref, _) {
final availability = ref
.watch(
mediaAvailabilityProvider(widget.projectId, asset),
)
.asData
?.value;
final unavailable =
availability != null &&
availability != MediaAvailability.available;
return ListenableSelector<(bool, bool)>(
listenable: _browser,
select: () =>
(_selectedAssetId == asset.id, _checkingDrop),
builder: (context, presentation) => AppContextMenu(
key: ValueKey(('media-menu', asset.id)),
itemsBuilder: (_) {
final available = ref
.read(projectsProvider)
.asData
?.value;
final canEdit =
available?.activeProject?.id ==
widget.projectId &&
available?.projectBusy == false &&
!_checkingDrop;
final sequence = timeline?.activeSequenceId;
return [
AppMenuItem(
label: context.l10n.addToTimeline,
icon: AppIcons.add,
onPressed:
canEdit &&
!unavailable &&
sequence != null &&
available?.timeline?.id == timelineId
? () => _action(
() => _browser.insertAsset(asset),
)
: null,
),
AppMenuItem(
label: context.l10n.rename,
icon: AppIcons.rename,
onPressed: canEdit ? () => _rename(asset) : null,
),
AppMenuItem(
label:
defaultTargetPlatform == TargetPlatform.macOS
? context.l10n.revealFinder
: context.l10n.revealFileManager,
icon: AppIcons.folderOpen,
onPressed: canEdit && _desktop
? () => _action(() => _browser.reveal(asset))
: null,
),
const AppMenuSeparator(),
AppMenuItem(
label: context.l10n.removeMedia,
icon: AppIcons.delete,
destructive: true,
onPressed: canEdit ? () => _remove(asset) : null,
),
];
},
child: Listener(
onPointerDown: (event) {
if (event.buttons == 2) {
_selectedAssetId = asset.id;
}
},
child: _SelectableAsset(
key: ValueKey(asset.id),
grid: _isGrid,
desktop: widget.desktop,
drag: MediaAssetDrag(
projectId: widget.projectId,
assetId: asset.id,
),
name: asset.name,
draggable:
widget.draggable &&
!workspace!.projectBusy &&
!presentation.$2 &&
!unavailable,
selected: presentation.$1,
onTap: () => _browser.selectAsset(asset),
child: _assetTile(asset, availability),
),
),
),
);
},
);
}
Widget scrollView(ScrollController controller) => !_isGrid
? widget.desktop
? ListView.builder(
@@ -509,9 +499,10 @@ class _MediaBrowserBodyState extends ConsumerState<MediaBrowserBody>
separatorBuilder: (_, _) =>
SizedBox(height: spacing),
)
: GridView.builder(
: GridView.custom(
key: PageStorageKey(('media-grid', widget.projectId)),
controller: controller,
semanticChildCount: assets.length,
padding: EdgeInsets.all(padding),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: columns,
@@ -528,8 +519,10 @@ class _MediaBrowserBodyState extends ConsumerState<MediaBrowserBody>
labelHeight +
2,
),
itemCount: assets.length,
itemBuilder: item,
childrenDelegate: _MediaChildrenDelegate(
item,
childCount: assets.length,
),
);
if (widget.desktop) {
return ScrollEdgeFade(
@@ -546,8 +539,6 @@ class _MediaBrowserBodyState extends ConsumerState<MediaBrowserBody>
if (!widget.desktop) return content;
return Column(
children: [
if (!_isGrid)
const DesktopMediaListHeader(key: Key('media-list-header')),
Expanded(child: content),
const Divider(height: 1),
SizedBox(
@@ -811,3 +802,13 @@ class _SelectableAsset extends StatelessWidget {
);
}
}
// Constraint changes reflow existing cells without rebuilding menus and tiles.
// A new builder is created when assets, filters or the project change.
class _MediaChildrenDelegate extends SliverChildBuilderDelegate {
const _MediaChildrenDelegate(super.builder, {super.childCount});
@override
bool shouldRebuild(covariant _MediaChildrenDelegate oldDelegate) =>
builder != oldDelegate.builder || childCount != oldDelegate.childCount;
}
@@ -1,4 +1,4 @@
import 'package:cutdex_sdk/project.dart';
import 'package:cutdex_core/project.dart';
import 'package:flutter/foundation.dart';
import '../../integrations/platform/file_picker.dart';
@@ -30,9 +30,9 @@ enum MediaSort { importOrder, nameAscending, nameDescending }
/// Desktop thumbnail density, independent of touch-page presentation.
enum MediaGridSize {
small(120),
medium(160),
large(200);
small(96),
medium(120),
large(160);
const MediaGridSize(this.targetWidth);
final double targetWidth;
+4 -5
View File
@@ -2,15 +2,14 @@ import 'dart:math' as math;
/// Shared desktop geometry for cards, rows, headers and browse anchoring.
abstract final class DesktopMediaMetrics {
static const padding = 12.0;
static const padding = 16.0;
static const gap = 8.0;
static const tilePadding = 5.0;
static const tilePadding = 8.0;
static const listCover = 56.0;
static const listRow = 48.0;
static const listHeader = 28.0;
static int columns(double width, double targetWidth) =>
math.max(1, ((width + gap) / (targetWidth + gap)).floor());
math.max(1, ((width + gap) / (targetWidth + gap)).ceil());
static double gridExtent(double tileWidth, double labelHeight) =>
(tileWidth - tilePadding * 2) * 9 / 16 +
@@ -19,7 +18,7 @@ abstract final class DesktopMediaMetrics {
tilePadding * 2;
}
/// Matching list-column visibility for a header and its asset rows.
/// List-column visibility within asset rows.
final class DesktopMediaListColumns {
const DesktopMediaListColumns(double width)
: duration = width >= 240,
+97 -27
View File
@@ -292,6 +292,34 @@ class _MediaBrowserToolbarState extends State<MediaBrowserToolbar> {
}
Widget _desktopToolbar(BuildContext context, RecentProject? selected) {
final desktopButtonStyle = AppTheme.toolbarButtonStyle(context).copyWith(
textStyle: WidgetStatePropertyAll(
Theme.of(context).textTheme.bodyMedium!.copyWith(
fontFamily: 'packages/cutdex_ui/Inter',
fontSize: AppInspectorMetrics.fontSize,
height: AppInspectorMetrics.lineHeight / AppInspectorMetrics.fontSize,
fontWeight: FontWeight.w400,
fontVariations: const [FontVariation('wght', 450)],
letterSpacing: AppInspectorMetrics.fontSize * .005,
),
),
minimumSize: const WidgetStatePropertyAll(
Size(0, AppInspectorMetrics.input),
),
maximumSize: const WidgetStatePropertyAll(
Size(double.infinity, AppInspectorMetrics.input),
),
padding: const WidgetStatePropertyAll(
EdgeInsets.symmetric(horizontal: AppSpacing.small),
),
shape: const WidgetStatePropertyAll(
RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(AppInspectorMetrics.radius),
),
),
),
);
Widget category() => Semantics(
label: context.l10n.mediaCategory,
child: AppDropdownMenu(
@@ -309,6 +337,7 @@ class _MediaBrowserToolbarState extends State<MediaBrowserToolbar> {
buttonKey: const Key('media-category-button'),
focusNode: focus,
onPressed: toggle,
style: desktopButtonStyle,
child: Row(
children: [
Expanded(
@@ -341,9 +370,14 @@ class _MediaBrowserToolbarState extends State<MediaBrowserToolbar> {
else
SizedBox(
key: const Key('media-project-row'),
height: 36,
height: AppInspectorMetrics.row,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
padding: const EdgeInsetsDirectional.fromSTEB(
AppInspectorMetrics.padding,
AppInspectorMetrics.rowPadding,
AppInspectorMetrics.trailingPadding,
AppInspectorMetrics.rowPadding,
),
child: LayoutBuilder(
builder: (context, constraints) => Row(
children: [
@@ -369,6 +403,7 @@ class _MediaBrowserToolbarState extends State<MediaBrowserToolbar> {
buttonKey: const Key('media-project-button'),
focusNode: focusNode,
onPressed: toggle,
style: desktopButtonStyle,
child: Row(
children: [
Expanded(
@@ -385,7 +420,7 @@ class _MediaBrowserToolbarState extends State<MediaBrowserToolbar> {
),
),
),
const SizedBox(width: 4),
const SizedBox(width: AppSpacing.small),
ConstrainedBox(
constraints: BoxConstraints(
maxWidth: (constraints.maxWidth * .45).clamp(
@@ -394,12 +429,12 @@ class _MediaBrowserToolbarState extends State<MediaBrowserToolbar> {
),
),
child: SizedBox(
height: 28,
height: AppInspectorMetrics.input,
child: Tooltip(
message: context.l10n.importMedia,
child: TextButton(
key: const Key('media-import-button'),
style: AppTheme.toolbarButtonStyle(context),
style: desktopButtonStyle,
onPressed: canImport ? onImport : null,
child: Text(
context.l10n.importMedia,
@@ -427,6 +462,14 @@ class _MediaBrowserToolbarState extends State<MediaBrowserToolbar> {
Widget Function() category,
String Function(MediaSort) sortLabel,
) {
final searchText = Theme.of(context).textTheme.bodyMedium?.copyWith(
fontFamily: 'packages/cutdex_ui/Inter',
fontSize: AppInspectorMetrics.fontSize,
height: AppInspectorMetrics.lineHeight / AppInspectorMetrics.fontSize,
fontVariations: const [FontVariation('wght', 450)],
letterSpacing: AppInspectorMetrics.fontSize * .005,
);
final colors = Theme.of(context).colorScheme;
List<Widget> sortItems() => [
for (final value in MediaSort.values)
AppMenuItem(
@@ -462,7 +505,7 @@ class _MediaBrowserToolbarState extends State<MediaBrowserToolbar> {
required IconData icon,
required List<Widget> items,
}) => SizedBox.square(
dimension: 28,
dimension: AppInspectorMetrics.action,
child: AppDropdownMenu(
items: items,
builder: (context, toggle, focus) => IconButton(
@@ -477,9 +520,14 @@ class _MediaBrowserToolbarState extends State<MediaBrowserToolbar> {
);
return SizedBox(
key: const Key('media-filter-row'),
height: 40,
height: AppInspectorMetrics.row,
child: Padding(
padding: const EdgeInsets.fromLTRB(12, 4, 12, 4),
padding: const EdgeInsets.fromLTRB(
AppInspectorMetrics.padding,
AppInspectorMetrics.rowPadding,
AppInspectorMetrics.trailingPadding,
AppInspectorMetrics.rowPadding,
),
child: LayoutBuilder(
builder: (context, constraints) {
final wide = constraints.maxWidth >= 400;
@@ -490,13 +538,10 @@ class _MediaBrowserToolbarState extends State<MediaBrowserToolbar> {
key: const Key('media-search'),
controller: _search,
enabled: widget.onQueryChanged != null,
style: AppTheme.inputTextStyle(
context,
style: AppTheme.toolbarTextStyle(context),
),
style: AppTheme.inputTextStyle(context, style: searchText),
cursorHeight: AppTheme.inputCursorHeight(
context,
style: AppTheme.toolbarTextStyle(context),
style: searchText,
),
textAlignVertical: TextAlignVertical.center,
decoration: InputDecoration(
@@ -505,36 +550,61 @@ class _MediaBrowserToolbarState extends State<MediaBrowserToolbar> {
),
hintStyle: AppTheme.inputHintStyle(
context,
style: AppTheme.toolbarTextStyle(context),
style: searchText,
),
filled: true,
fillColor: colors.surfaceContainer,
isDense: true,
constraints: const BoxConstraints(minHeight: 32),
constraints: const BoxConstraints(
minHeight: AppInspectorMetrics.input,
),
contentPadding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 4,
horizontal: AppSpacing.small,
),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(AppInspectorMetrics.radius),
),
borderSide: BorderSide.none,
),
enabledBorder: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(AppInspectorMetrics.radius),
),
borderSide: BorderSide.none,
),
focusedBorder: OutlineInputBorder(
borderRadius: const BorderRadius.all(
Radius.circular(AppInspectorMetrics.radius),
),
borderSide: BorderSide(color: colors.primary),
),
prefixIcon: constraints.maxWidth < 160
? null
: const Icon(AppIcons.search, size: 16),
prefixIconConstraints: const BoxConstraints(
minWidth: 28,
minHeight: 28,
minWidth: AppInspectorMetrics.input,
minHeight: AppInspectorMetrics.input,
),
),
onChanged: (value) => widget.onQueryChanged?.call(value),
),
),
const SizedBox(width: 4),
const SizedBox(width: AppSpacing.small),
if (wide) ...[
SizedBox(width: 88, height: 28, child: category()),
const SizedBox(width: 4),
SizedBox(
width: 88,
height: AppInspectorMetrics.input,
child: category(),
),
const SizedBox(width: AppSpacing.small),
menuButton(
key: const Key('media-sort-button'),
tooltip: context.l10n.sortMedia,
icon: AppIcons.sort,
items: sortItems(),
),
const SizedBox(width: 4),
const SizedBox(width: AppSpacing.small),
menuButton(
key: const Key('media-size-button'),
tooltip: context.l10n.mediaThumbnailSize,
@@ -564,9 +634,9 @@ class _MediaBrowserToolbarState extends State<MediaBrowserToolbar> {
...sizeItems(),
],
),
const SizedBox(width: 4),
const SizedBox(width: AppSpacing.small),
SizedBox.square(
dimension: 28,
dimension: AppInspectorMetrics.action,
child: IconButton(
key: const Key('media-layout-toggle'),
onPressed: onToggleGrid,
@@ -581,9 +651,9 @@ class _MediaBrowserToolbarState extends State<MediaBrowserToolbar> {
),
),
if (widget.projectScoped) ...[
const SizedBox(width: 4),
const SizedBox(width: AppSpacing.small),
SizedBox.square(
dimension: 28,
dimension: AppInspectorMetrics.action,
child: IconButton(
key: const Key('media-import-button'),
onPressed: canImport ? () => onImport() : null,
+1 -1
View File
@@ -1,4 +1,4 @@
import 'package:cutdex_sdk/timeline/model.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'processing_targets.freezed.dart';
+26 -27
View File
@@ -115,9 +115,13 @@ class _ResourceSectionTabsState extends State<ResourceSectionTabs> {
final l10n = AppLocalizations.of(context)!;
return SizedBox(
key: const Key('resource-section-tabs'),
height: 36,
height: AppDesktopMetrics.timelineTabs,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 5),
padding: const EdgeInsetsDirectional.only(
start: AppSpacing.small,
top: 4,
bottom: 4,
),
child: ScrollEdgeFade(
controller: _scrollController,
axis: Axis.horizontal,
@@ -127,35 +131,30 @@ class _ResourceSectionTabsState extends State<ResourceSectionTabs> {
key: const Key('resource-tabs-list'),
controller: _scrollController,
scrollDirection: Axis.horizontal,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 4),
child: Row(
children: [
for (final section in ResourceSection.values) ...[
if (section != ResourceSection.values.first)
const SizedBox(width: 4),
KeyedSubtree(
key: widget.selected == section
? _selectedTabKey
: null,
child: Semantics(
selected: widget.selected == section,
child: TextButton(
key: ValueKey('resource-tab-${section.name}'),
style: AppTheme.timelineTabStyle(
context,
selected: widget.selected == section,
),
onPressed: widget.onSelected == null
? null
: () => widget.onSelected!(section),
child: Text(section.label(l10n), maxLines: 1),
child: Row(
children: [
for (final section in ResourceSection.values) ...[
if (section != ResourceSection.values.first)
const SizedBox(width: AppSpacing.tiny),
KeyedSubtree(
key: widget.selected == section ? _selectedTabKey : null,
child: Semantics(
selected: widget.selected == section,
child: TextButton(
key: ValueKey('resource-tab-${section.name}'),
style: AppTheme.timelineTabStyle(
context,
selected: widget.selected == section,
),
onPressed: widget.onSelected == null
? null
: () => widget.onSelected!(section),
child: Text(section.label(l10n), maxLines: 1),
),
),
],
),
],
),
],
),
),
),
+3 -3
View File
@@ -1,9 +1,9 @@
import 'package:cutdex/diagnostics/app_diagnostics.dart';
import 'package:cutdex/errors/app_failure.dart';
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_sdk/project.dart';
import 'package:cutdex_sdk/timeline/model.dart';
import 'package:cutdex_core/editor.dart';
import 'package:cutdex_core/project.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
@@ -1,5 +1,5 @@
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_sdk/timeline/model.dart';
import 'package:cutdex_core/editor.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
+2 -2
View File
@@ -2,8 +2,8 @@ import '../../shared/widgets/listenable_selector.dart';
import 'package:cutdex/l10n/l10n.dart';
import 'package:cutdex_sdk/project.dart';
import 'package:cutdex_sdk/runtime/processing_contracts.dart';
import 'package:cutdex_core/project.dart';
import 'package:cutdex_native_flutter/processing_contracts.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
+1 -1
View File
@@ -1,4 +1,4 @@
import 'package:cutdex_sdk/project.dart';
import 'package:cutdex_core/project.dart';
import 'package:flutter/material.dart';
import 'media_asset_cover.dart';
@@ -1,6 +1,6 @@
import 'dart:async';
import 'package:cutdex_sdk/timeline/model.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:flutter/material.dart';
import '../../l10n/l10n.dart';
+1 -1
View File
@@ -6,7 +6,7 @@ import 'package:flutter/services.dart';
import 'package:cutdex_ui/theme.dart';
import 'package:cutdex_native/cutdex_native.dart';
import 'package:cutdex_sdk/runtime.dart';
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
/// Moves the existing preview into the root overlay, retaining its native view.
class PreviewFullscreenHost extends StatefulWidget {
+3 -2
View File
@@ -2,8 +2,9 @@ import 'package:cutdex/l10n/l10n.dart';
import '../../errors/app_failure.dart';
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_sdk/runtime.dart';
import 'package:cutdex_core/editor.dart';
import 'package:cutdex_core/execution.dart';
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
String previewErrorMessage(Object e, AppLocalizations l10n) => switch (e) {
AppException(:final failure) => l10n.failureMessage(failure),
+72 -13
View File
@@ -6,11 +6,11 @@ import 'dart:async';
import 'package:cutdex/features/properties/canvas_presets.dart';
import 'package:cutdex/l10n/l10n.dart';
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_sdk/preview.dart';
import 'package:cutdex_sdk/project.dart';
import 'package:cutdex_sdk/runtime.dart';
import 'package:cutdex_sdk/timeline/model.dart';
import 'package:cutdex_core/editor.dart';
import 'package:cutdex_preview/cutdex_preview.dart';
import 'package:cutdex_core/project.dart';
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
@@ -228,6 +228,8 @@ class _EditorPreviewContent extends ConsumerWidget {
select: () => (
activeController.positionTick,
activeController.selectedVisualIds.isNotEmpty,
activeController.distortionEditingElement,
activeController.distortionPerspective,
activeController.maskEditingElement,
activeController.obscureEditingElement,
),
@@ -621,6 +623,22 @@ class _PreviewToolbar extends StatelessWidget {
final PreviewController? controller;
final SourcePreviewController? source;
ButtonStyle? _compactButtonStyle(BuildContext context) =>
AppTheme.isDesktop(context)
? IconButton.styleFrom(
fixedSize: const Size.square(AppInspectorMetrics.action),
minimumSize: const Size.square(AppInspectorMetrics.action),
maximumSize: const Size.square(AppInspectorMetrics.action),
padding: EdgeInsets.zero,
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(AppInspectorMetrics.radius),
),
),
)
: null;
@override
Widget build(BuildContext context) {
if (PreviewFullscreenScope.of(context)?.fullscreen == true) {
@@ -661,7 +679,7 @@ class _PreviewToolbar extends StatelessWidget {
try {
final time = CommandTime(tick, TimelineClock.ticksPerSecond);
if (source case final source?) {
await source.control(SourcePreviewAction.seek, at: time);
await source.seekInteractive(tick);
} else if (preview?.activeSequence() case final sequence?) {
await preview!.controlPreview(sequence, PreviewAction.seek, at: time);
}
@@ -705,12 +723,25 @@ class _PreviewToolbar extends StatelessWidget {
);
},
icon: Icon(direction < 0 ? AppIcons.previousFrame : AppIcons.nextFrame),
style: _compactButtonStyle(context),
),
);
Widget _build(BuildContext context) {
final preview = controller;
final playing = source?.playing ?? preview?.playing ?? false;
final timeTextStyle = AppTheme.isDesktop(context)
? Theme.of(context).textTheme.bodyMedium?.copyWith(
fontFamily: 'packages/cutdex_ui/Inter',
fontSize: AppInspectorMetrics.fontSize,
height:
AppInspectorMetrics.lineHeight / AppInspectorMetrics.fontSize,
fontVariations: const [FontVariation('wght', 450)],
letterSpacing: AppInspectorMetrics.fontSize * .005,
fontFeatures: [const FontFeature.tabularFigures()],
)
: Theme.of(context).textTheme.bodySmall
?.copyWith(fontFeatures: [const FontFeature.tabularFigures()]);
final frameDuration =
source?.frameDuration ??
preview?.frameDuration ??
@@ -762,7 +793,9 @@ class _PreviewToolbar extends StatelessWidget {
? AppDesktopMetrics.playbackBar
: AppControlSize.panelHeader,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.compact),
padding: const EdgeInsets.symmetric(
horizontal: AppInspectorMetrics.padding,
),
child: LayoutBuilder(
builder: (context, constraints) {
final controls = Row(
@@ -803,13 +836,14 @@ class _PreviewToolbar extends StatelessWidget {
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.bodySmall?.copyWith(
fontFeatures: [const FontFeature.tabularFigures()],
),
style: timeTextStyle,
),
),
),
if (AppTheme.isDesktop(context)) _frameButton(context, -1),
if (AppTheme.isDesktop(context)) ...[
const SizedBox(width: AppSpacing.small),
_frameButton(context, -1),
],
ListenableSelector(
listenable: source ?? preview,
select: () => (
@@ -826,10 +860,14 @@ class _PreviewToolbar extends StatelessWidget {
? preview.togglePlayback
: null,
icon: Icon(playing ? AppIcons.pause : AppIcons.play),
style: _compactButtonStyle(context),
);
},
),
if (AppTheme.isDesktop(context)) _frameButton(context, 1),
if (AppTheme.isDesktop(context)) ...[
_frameButton(context, 1),
const SizedBox(width: AppSpacing.small),
],
Expanded(
child: ListenableSelector(
listenable: source ?? preview,
@@ -854,8 +892,9 @@ class _PreviewToolbar extends StatelessWidget {
tooltip: context.l10n.retryPreview,
onPressed: preview.busy ? null : preview.retry,
icon: const Icon(AppIcons.refresh),
style: _compactButtonStyle(context),
),
const SizedBox(width: AppSpacing.gap),
const SizedBox(width: AppSpacing.small),
],
if (source == null &&
PreviewFullscreenScope.of(context)?.fullscreen !=
@@ -865,6 +904,25 @@ class _PreviewToolbar extends StatelessWidget {
emptyLabel: context.l10n.noMatchingOptions,
label: context.l10n.canvasRatio,
outlined: false,
controlHeight: AppTheme.isDesktop(context)
? AppInspectorMetrics.input
: null,
textStyle: AppTheme.isDesktop(context)
? Theme.of(
context,
).textTheme.bodyMedium?.copyWith(
fontFamily: 'packages/cutdex_ui/Inter',
fontSize: AppInspectorMetrics.fontSize,
height:
AppInspectorMetrics.lineHeight /
AppInspectorMetrics.fontSize,
fontVariations: const [
FontVariation('wght', 450),
],
letterSpacing:
AppInspectorMetrics.fontSize * .005,
)
: null,
value:
preview?.canvas ?? ProjectCanvas.widescreen,
onChanged: preview?.setCanvas,
@@ -894,6 +952,7 @@ class _PreviewToolbar extends StatelessWidget {
? AppIcons.exitFullscreen
: AppIcons.fullscreen,
),
style: _compactButtonStyle(context),
),
],
),
+77 -22
View File
@@ -45,6 +45,7 @@ import 'project_switch_region.dart';
import 'project_sidebar.dart';
import 'project_tabs_bar.dart';
import 'project_tabs_controller.dart';
import 'workflow_page.dart';
import 'widgets/name_dialog.dart';
/// The single application surface: project navigation beside the editor.
@@ -294,6 +295,19 @@ class _EditingPageState extends ConsumerState<EditingPage> {
);
final projects = ref.read(projectsProvider);
final state = projects.value ?? const ProjectState();
final editorProjectId = state.timeline == null
? null
: state.activeProject?.id;
final editorViewSettings = desktop && editorProjectId != null
? ref.watch(
projectViewSettingsProvider(editorProjectId).select(
(value) => (
ready: value.hasValue,
timelineHeight: value.value?.timelineHeight,
),
),
)
: null;
return EditorWindowChrome(
headerHeight: desktop ? DesktopWindowFrame.headerHeight : 48,
builder: (context, integrated) => Scaffold(
@@ -631,30 +645,33 @@ class _EditingPageState extends ConsumerState<EditingPage> {
),
),
);
bool isActiveContent(DesktopContent surface) =>
surface == DesktopContent.workspace
? contentSelection.surface ==
DesktopContent.workspace ||
contentSelection.surface ==
DesktopContent.library ||
contentSelection.surface ==
DesktopContent.resourceLibrary
: contentSelection.surface == surface;
Widget contentSurface(
DesktopContent surface,
Widget child,
) => ExcludeFocus(
excluding:
(contentSelection.surface ==
DesktopContent.settings) !=
(surface == DesktopContent.settings),
excluding: !isActiveContent(surface),
child: TickerMode(
enabled:
(contentSelection.surface ==
DesktopContent.settings) ==
(surface == DesktopContent.settings),
enabled: isActiveContent(surface),
child: child,
),
);
Widget desktopContents(
Widget workspace,
) => IndexedStack(
index:
contentSelection.surface ==
DesktopContent.settings
? 1
: 0,
index: switch (contentSelection.surface) {
DesktopContent.settings => 1,
DesktopContent.workflow => 2,
_ => 0,
},
children: [
contentSurface(
DesktopContent.workspace,
@@ -685,6 +702,10 @@ class _EditingPageState extends ConsumerState<EditingPage> {
)
: const SizedBox.shrink(),
),
contentSurface(
DesktopContent.workflow,
const WorkflowPage(),
),
],
);
return switch (experience) {
@@ -773,17 +794,23 @@ class _EditingPageState extends ConsumerState<EditingPage> {
],
),
),
resourceLibrarySelected:
contentSelection.surface ==
DesktopContent.resourceLibrary,
onResourceLibraryPressed: () => selectSidebar(
DesktopContent.resourceLibrary,
),
settingsSelected:
contentSelection.surface ==
DesktopContent.settings,
onHomePressed: () =>
selectSidebar(DesktopContent.workspace),
workflowSelected:
contentSelection.surface ==
DesktopContent.workflow,
onHomePressed: () {
selectSidebar(DesktopContent.workspace);
_setMode(WorkspaceMode.agent);
},
onWorkflowPressed: () {
ref
.read(desktopContentProvider.notifier)
.select(DesktopContent.workflow);
_desktopScaffoldKey.currentState
?.closeDrawer();
},
onSettingsPressed: () =>
showSettingsPage(context),
child: desktopContents(
@@ -794,15 +821,43 @@ class _EditingPageState extends ConsumerState<EditingPage> {
navigationDrawer: navigation(drawer: true),
mode: _mode,
sidebarCollapsed: navigationCollapsed,
sidebarCanExpand: !navigationHiddenBySpace,
sidebarWidth: _sidebarWidthOverride,
timelineHeight:
editorViewSettings?.timelineHeight,
onTimelineHeightChanged:
editorViewSettings?.ready == true &&
!_switchingProject
? (height) => ref
.read(
projectViewSettingsProvider(
editorProjectId!,
).notifier,
)
.setTimelineHeight(height)
: null,
onJunctionResizeEnd: () {
_saveViewState();
if (editorViewSettings?.ready == true) {
unawaited(
ref
.read(
projectViewSettingsProvider(
editorProjectId!,
).notifier,
)
.save(),
);
}
},
onSidebarCollapsedChanged: (value) {
_sidebarCollapsed = value;
_saveViewState();
},
onSidebarWidthChanged: (value) {
_sidebarWidthOverride = value;
_saveViewState();
},
onSidebarResizeEnd: _saveViewState,
sidebarBuilder: (geometry, expand) =>
navigation(
geometry: geometry,
+50
View File
@@ -0,0 +1,50 @@
import 'package:cutdex/l10n/l10n.dart';
import 'package:cutdex/shared/layout/workspace_layout_metrics.dart';
import 'package:cutdex_ui/icons.dart';
import 'package:flutter/material.dart';
class WorkflowPage extends StatelessWidget {
const WorkflowPage({super.key});
@override
Widget build(BuildContext context) => ColoredBox(
color: Theme.of(context).colorScheme.surface,
child: Padding(
padding: const EdgeInsets.all(WorkspaceLayoutMetrics.desktopOuterSpacing),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
context.l10n.workflow,
style: Theme.of(context).textTheme.titleLarge,
),
Expanded(
child: Center(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 420),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
AppIcons.timeline,
size: 40,
color: Theme.of(context).colorScheme.primary,
),
const SizedBox(height: 16),
Text(
context.l10n.workflowDescription,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
],
),
),
),
),
],
),
),
);
}
@@ -1,12 +1,17 @@
import 'package:flutter/widgets.dart';
import 'package:cutdex/l10n/l10n.dart';
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_core/editor.dart';
extension TransformChannelLabel on TransformChannel {
String label(BuildContext context) => switch (this) {
TransformChannel.position => context.l10n.position,
TransformChannel.rotation => context.l10n.rotation,
TransformChannel.scale => context.l10n.scale,
TransformChannel.cornerRadius => context.l10n.cornerRadius,
TransformChannel.distortTopLeft => context.l10n.distortionTopLeft,
TransformChannel.distortTopRight => context.l10n.distortionTopRight,
TransformChannel.distortBottomRight => context.l10n.distortionBottomRight,
TransformChannel.distortBottomLeft => context.l10n.distortionBottomLeft,
};
}
+12 -10
View File
@@ -2,8 +2,8 @@ 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:cutdex_core/timeline/engine.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:flutter/material.dart';
import 'package:cutdex_ui/icons.dart';
@@ -12,9 +12,9 @@ import 'package:cutdex_ui/theme.dart';
import '../../workspace/timeline_session.dart';
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_core/editor.dart';
export 'package:cutdex_sdk/editor.dart' show ClipAudioGain;
export 'package:cutdex_core/editor.dart' show ClipAudioGain;
class AudioProperties extends StatefulWidget {
const AudioProperties({
@@ -169,8 +169,7 @@ class _AudioPropertiesState extends State<AudioProperties> {
if (_text.text != text) _text.text = text;
}
if (ClipAudioGain.isDetached(record)) {
return Padding(
padding: AppTheme.propertySectionPadding(context),
return AppPropertySection(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
@@ -343,15 +342,18 @@ class _AudioPropertiesState extends State<AudioProperties> {
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Padding(
padding: AppTheme.propertySectionPadding(context),
AppPropertySection(
child: AppTheme.isDesktop(context)
? AppPropertyGroup(
label: widget.hasAudio
? context.l10n.volume
: context.l10n.unboundAudio,
actions: volumeActions,
child: volumeControls,
actions: volumeActions.skip(1).toList(),
padChild: false,
child: AppPropertyRow(
trailing: volumeActions.first,
children: [volumeControls],
),
)
: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
+1 -1
View File
@@ -1,6 +1,6 @@
import 'package:flutter/widgets.dart';
import 'package:cutdex/l10n/l10n.dart';
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_core/editor.dart';
abstract final class ProjectCanvasPresets {
static const values = {
+58 -28
View File
@@ -3,8 +3,8 @@ 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:cutdex_core/editor.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:flutter/material.dart';
import 'package:cutdex_ui/icons.dart';
@@ -196,8 +196,7 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
: 28.0;
return Column(
children: [
Padding(
padding: AppTheme.propertySectionPadding(context),
AppPropertySection(
child: SizedBox(
height: AppTheme.propertyInputHeight(context),
child: Row(
@@ -226,9 +225,13 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
vertical: 0,
),
prefixIcon: const Icon(AppIcons.search, size: 14),
prefixIconConstraints: const BoxConstraints(
minWidth: 28,
minHeight: 28,
prefixIconConstraints: BoxConstraints(
minWidth: AppTheme.isCompactInspector(context)
? 24
: 28,
minHeight: AppTheme.isCompactInspector(context)
? 24
: 28,
),
),
onChanged: (value) => setState(
@@ -448,7 +451,7 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
Widget panel(Widget content) => WorkspacePanel(
paintBackground: false,
headerHeight: AppTheme.isDesktop(context)
? AppDesktopMetrics.panelHeader
? AppInspectorMetrics.sectionHeader
: CompactPanelTabs.height,
headerPadding: EdgeInsets.zero,
showHeaderDivider: false,
@@ -564,7 +567,9 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
key: const ValueKey('caption-detail-scroll-fade'),
builder: (controller) => ListView(
controller: controller,
padding: const EdgeInsets.symmetric(vertical: AppSpacing.small),
padding: AppTheme.isDesktop(context)
? EdgeInsets.zero
: const EdgeInsets.symmetric(vertical: AppSpacing.small),
children:
[
if (AppTheme.isDesktop(context))
@@ -775,16 +780,21 @@ class _CaptionPropertiesState extends State<CaptionProperties> {
},
),
]
.where(
(item) =>
!AppTheme.isDesktop(context) ||
(item is! SizedBox && item is! Divider),
)
.map(
(item) =>
item is SizedBox ||
identical(item, widget.transformProperties)
? item
: AppTheme.isDesktop(context)
? AppPropertySection(child: item)
: Padding(
padding: EdgeInsets.symmetric(
horizontal: AppTheme.isDesktop(context)
? AppInspectorMetrics.padding
: AppSpacing.panelContentHorizontal,
padding: const EdgeInsets.symmetric(
horizontal: AppSpacing.panelContentHorizontal,
),
child: item,
),
@@ -804,11 +814,13 @@ class _CaptionTextInput extends StatefulWidget {
required this.editContext,
required this.onSubmit,
this.label,
this.leading,
this.maxLines = 1,
});
final String value;
final Object editContext;
final String? label;
final Widget? leading;
final int maxLines;
final bool Function(String) onSubmit;
@@ -870,6 +882,7 @@ class _CaptionTextInputState extends State<_CaptionTextInput> {
controller: _controller,
focusNode: _focus,
label: widget.label,
leading: widget.leading,
minLines: widget.maxLines,
maxLines: widget.maxLines,
textInputAction: TextInputAction.done,
@@ -901,17 +914,39 @@ class _CaptionColorInput extends StatelessWidget {
@override
Widget build(BuildContext context) {
final desktop = AppTheme.isDesktop(context);
final swatch = Container(
width: desktop ? 14 : 20,
height: desktop ? 14 : 20,
decoration: BoxDecoration(
color: Color(int.parse('FF${value.substring(1)}', radix: 16)),
border: Border.all(
color: desktop
? Theme.of(context).colorScheme.outlineVariant
: Theme.of(context).colorScheme.outline,
),
borderRadius: BorderRadius.circular(AppRadius.extraSmall),
),
);
if (desktop) {
return AppPropertyGroup(
label: label,
padChild: false,
child: AppPropertyRow(
reserveTrailing: false,
children: [
_CaptionTextInput(
value: value,
editContext: editContext,
leading: SizedBox(width: 24, child: Center(child: swatch)),
onSubmit: onSubmit,
),
],
),
);
}
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),
),
),
swatch,
const SizedBox(width: AppSpacing.small),
Expanded(
child: _CaptionTextInput(
@@ -923,11 +958,6 @@ class _CaptionColorInput extends StatelessWidget {
),
],
);
return desktop
? AppPropertyGroup(
label: label,
child: Semantics(label: label, child: controls),
)
: controls;
return controls;
}
}
@@ -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'),
],
);
}
@@ -1,13 +1,13 @@
import 'package:cutdex/l10n/l10n.dart';
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_sdk/runtime.dart';
import 'package:cutdex_core/editor.dart';
import 'package:cutdex_native_flutter/cutdex_native_flutter.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 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,
);
}
return ListenableSelector(
@@ -0,0 +1,211 @@
import 'package:cutdex/l10n/l10n.dart';
import 'package:cutdex_core/editor.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:cutdex_core/timeline/engine.dart';
import 'package:cutdex_ui/icons.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 'property_keyframe_controls.dart';
import 'property_number_input.dart';
/// Presentation of four position channels; editing and native lifetime live in the host.
class DistortionParameterEditor extends StatelessWidget {
const DistortionParameterEditor({
super.key,
required this.value,
required this.extent,
required this.enabled,
required this.editing,
required this.perspective,
required this.keyframes,
required this.editContext,
required this.onSubmit,
required this.onReset,
required this.onPerspective,
this.onToggle,
this.error,
});
final ClipDistortion value;
final Size extent;
final bool enabled, editing, perspective;
final PropertyKeyframeControls keyframes;
final Object editContext;
final Future<bool> Function(int corner, int axis, double value) onSubmit;
final VoidCallback? onToggle;
final VoidCallback onReset;
final ValueChanged<bool> onPerspective;
final String? error;
@override
Widget build(BuildContext context) {
final keys = keyframes, l = context.l10n;
final labels = [
l.distortionTopLeft,
l.distortionTopRight,
l.distortionBottomRight,
l.distortionBottomLeft,
];
return AppPropertySection(
child: AppPropertyGroup(
label: l.distortion,
padChild: false,
actions: [
keys.button(
context,
ClipDistortion.ids,
l.distortion,
'distortion-key',
),
keys.menu(context, ClipDistortion.ids, l.distortion, 'distortion'),
],
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
AppPropertyRow(
children: [
TextButton(
key: const ValueKey('distortion-edit'),
onPressed: enabled ? onToggle : null,
child: Text(editing ? l.finishDistortion : l.editDistortion),
),
IconButton(
key: const ValueKey('distortion-reset'),
tooltip: l.resetDistortion,
icon: const Icon(AppIcons.reset, size: 16),
onPressed: enabled ? onReset : null,
),
],
),
AppPropertyRow(
children: [
AppSelect<bool>(
value: perspective,
label: l.distortion,
emptyLabel: l.freeDistortion,
options: [
AppSelectOption(false, l.freeDistortion),
AppSelectOption(true, l.perspectiveDistortion),
],
onChanged: enabled ? onPerspective : null,
),
],
),
for (var i = 0; i < 4; i++) ...[
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Row(
children: [
Expanded(
child: Text(
labels[i],
style: Theme.of(context).textTheme.labelSmall,
),
),
keys.menu(
context,
ClipDistortion.ids.sublist(i * 2, i * 2 + 2),
labels[i],
'distortion-${ClipDistortion.names[i]}',
),
],
),
),
AppPropertyRow(
trailing: keys.button(
context,
ClipDistortion.ids.sublist(i * 2, i * 2 + 2),
labels[i],
'distortion-${ClipDistortion.names[i]}-key',
),
children: [
for (var axis = 0; axis < 2; axis++)
PropertyNumberInput(
key: ValueKey(
'distortion-${ClipDistortion.names[i]}-${axis == 0 ? 'x' : 'y'}',
),
label: axis == 0 ? 'X' : 'Y',
inlineLabel: true,
prefix: axis == 0 ? 'X' : 'Y',
value:
value.values[i * 2 + axis] *
(axis == 0 ? extent.width : extent.height),
enabled: enabled,
readOnly: false,
editContext: editContext,
submit: (v) => onSubmit(i, axis, v),
onScrubUpdate: (_) {},
onScrubEnd: () {},
onScrubCancel: () {},
scrubbing: false,
),
],
),
],
if (error != null)
Padding(padding: const EdgeInsets.all(16), child: Text(error!)),
],
),
),
);
}
}
@Preview(name: 'Distortion / desktop', size: Size(240, 400))
Widget distortionEditorPreview() {
var value = const ClipDistortion(topLeft: (.05, .1));
var perspective = false, editing = false;
final stack = ClipParameterAnimation(
ElementRecord(
id: ElementId('preview'),
structure: ElementStructure.content,
duration: 1,
sourceStart: 0,
sourceDuration: 1,
enabled: true,
),
0,
);
return MaterialApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
theme: AppTheme.propertiesPanelTheme(
AppTheme.desktopWorkspaceTheme(AppTheme.penDark),
),
home: Scaffold(
body: StatefulBuilder(
builder: (context, update) => SingleChildScrollView(
child: DistortionParameterEditor(
value: value,
extent: const Size(300, 200),
enabled: true,
editing: editing,
perspective: perspective,
editContext: 'preview',
keyframes: PropertyKeyframeControls(
stack: stack,
enabled: true,
onEdit: (ids, {action, interpolation}) async => true,
onSeek: (_) async => true,
),
onSubmit: (corner, axis, input) async {
final p = value.corners[corner];
final next = value.withCorner(
corner,
axis == 0 ? input / 300 : p.$1,
axis == 1 ? input / 200 : p.$2,
);
if (!next.isValid) return false;
update(() => value = next);
return true;
},
onReset: () => update(() => value = const ClipDistortion()),
onToggle: () => update(() => editing = !editing),
onPerspective: (v) => update(() => perspective = v),
),
),
),
),
);
}
@@ -0,0 +1,196 @@
import 'dart:async';
import 'package:cutdex/l10n/l10n.dart';
import 'package:cutdex_core/editor.dart';
import 'package:cutdex_preview/cutdex_preview.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../workspace/timeline_session.dart';
import '../preview/preview_panel.dart';
import 'property_edit_controller.dart';
import 'property_keyframe_controls.dart';
import 'distortion_parameter_editor.dart';
class DistortionProperties extends ConsumerStatefulWidget {
const DistortionProperties({
super.key,
required this.projectId,
required this.timelineId,
required this.session,
required this.sequence,
required this.clip,
});
final String projectId, timelineId;
final EditorTimelineSession session;
final SequenceId sequence;
final ElementId clip;
@override
ConsumerState<DistortionProperties> createState() =>
_DistortionPropertiesState();
}
class _DistortionPropertiesState extends ConsumerState<DistortionProperties> {
PropertyEditController _create() => PropertyEditController(
session: widget.session,
sequence: widget.sequence,
clip: widget.clip,
projectId: widget.projectId,
timelineId: widget.timelineId,
operation: 'setTransform',
);
late PropertyEditController _controller = _create();
PreviewController? _preview;
bool _perspective = false;
void _release() {
final previous = _preview;
_preview = null;
if (previous != null) {
scheduleMicrotask(() => previous.releaseDistortionEditing(this));
}
}
@override
void didUpdateWidget(covariant DistortionProperties oldWidget) {
super.didUpdateWidget(oldWidget);
if (_controller.identity !=
(
widget.session,
widget.sequence,
widget.clip,
widget.projectId,
widget.timelineId,
)) {
_release();
_controller.dispose();
_controller = _create();
}
}
@override
void dispose() {
_release();
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final preview = ref
.watch(editorPreviewProvider(widget.projectId, widget.timelineId))
.asData
?.value;
if (!identical(_preview, preview)) {
_release();
_preview = preview;
}
final view = widget.session.view(widget.sequence);
return ListenableBuilder(
listenable: Listenable.merge([
_controller,
view,
if (preview != null) preview.transforms,
if (preview != null) preview.positionChanges,
]),
builder: (context, _) {
final stack = _controller.animation;
if (stack == null) return const SizedBox.shrink();
final visual = preview?.visualForProperties(widget.clip);
final value = preview?.transforms.hasPending == true && visual != null
? visual.transform
: ClipTransform.fromRecord(
stack.record,
sourceTick: stack.sourceTick,
);
final extent =
visual?.geometry.distortionSize ??
Size(widget.session.canvas.width, widget.session.canvas.height);
final enabled =
!_controller.saving &&
stack.containsPlayhead &&
preview?.transforms.hasPending != true;
Future<bool> edit(void Function(EditorCommandService, int) action) =>
_controller.run(preview, action);
final keys = PropertyKeyframeControls(
stack: stack,
enabled: enabled,
onEdit: (ids, {action, interpolation}) => edit(
(c, t) => c.editKeyframeChannel(
sequence: widget.sequence,
clip: widget.clip,
tick: t,
parameterIds: ids,
action: action,
interpolation: interpolation,
),
),
onSeek: (offset) => _controller.run(
preview,
(_, t) => view.seekTo(t - stack.localTick + offset),
seek: true,
),
);
final editing = preview?.distortionEditingElement == widget.clip;
final l = context.l10n;
Future<bool> submit(int corner, int axis, double input) => edit(
(c, t) => c.setTransform(
sequence: widget.sequence,
clip: widget.clip,
tick: t,
change: (current) {
final p = current.distortion.corners[corner];
return current.copyWith(
distortion: current.distortion.withCorner(
corner,
axis == 0 ? input / extent.width : p.$1,
axis == 1 ? input / extent.height : p.$2,
),
);
},
),
);
return DistortionParameterEditor(
value: value.distortion,
extent: extent,
enabled: enabled,
editing: editing,
perspective: _perspective,
keyframes: keys,
editContext: _controller.identity,
error: _controller.failed ? l.updateOperationFailed : null,
onSubmit: submit,
onToggle: preview == null
? null
: () => _controller.run(
preview,
(_, t) => preview.setDistortionEditing(
editing ? null : widget.clip,
owner: this,
perspective: _perspective,
),
seek: true,
),
onReset: () => edit(
(c, t) => c.setTransform(
sequence: widget.sequence,
clip: widget.clip,
tick: t,
change: (v) => v.copyWith(distortion: const ClipDistortion()),
),
),
onPerspective: (v) {
setState(() => _perspective = v);
if (editing) {
preview!.setDistortionEditing(
widget.clip,
owner: this,
perspective: v,
);
}
},
);
},
);
}
}
@@ -0,0 +1,15 @@
import 'package:cutdex/l10n/l10n.dart';
import 'package:cutdex_core/editor.dart';
import 'package:flutter/widgets.dart';
extension EffectTypeLabel on ClipEffectType {
String label(BuildContext context) => switch (this) {
ClipEffectType.dropShadow => context.l10n.dropShadow,
ClipEffectType.innerShadow => context.l10n.innerShadow,
ClipEffectType.layerBlur => context.l10n.layerBlur,
ClipEffectType.backgroundBlur => context.l10n.backgroundBlur,
ClipEffectType.glass => context.l10n.glassEffect,
ClipEffectType.noise => context.l10n.noiseEffect,
ClipEffectType.texture => context.l10n.textureEffect,
};
}
+132
View File
@@ -0,0 +1,132 @@
import 'package:cutdex/l10n/l10n.dart';
import 'package:cutdex_core/editor.dart';
import 'package:cutdex_ui/icons.dart';
import 'package:cutdex_ui/widgets.dart';
import 'package:flutter/material.dart';
import 'property_keyframe_controls.dart';
import 'effect_labels.dart';
import 'property_layer_row.dart';
class EffectList extends StatelessWidget {
const EffectList({
super.key,
required this.stack,
required this.enabled,
required this.keyframes,
required this.onAdd,
required this.onReorder,
required this.onToggle,
required this.onRemove,
required this.editorBuilder,
this.error,
});
final ClipEffectStack stack;
final bool enabled;
final PropertyKeyframeControls keyframes;
final void Function(ClipEffectType) onAdd;
final void Function(List<String>) onReorder;
final void Function(ClipEffectLayer) onToggle, onRemove;
final Widget Function(ClipEffectLayer) editorBuilder;
final String? error;
@override
Widget build(BuildContext context) {
final layers = stack.layers;
return AppPropertySection(
bottomSpacing: layers.isEmpty ? 0 : null,
child: AppPropertyGroup(
label: context.l10n.effects,
padChild: false,
actions: [
keyframes.button(
context,
stack.parameterIds,
context.l10n.effects,
'effects-key',
),
AppDropdownMenu(
enabled: enabled,
builder: (context, toggle, focus) => IconButton(
key: const ValueKey('effect-add'),
focusNode: focus,
tooltip: context.l10n.addEffect,
onPressed: enabled ? toggle : null,
icon: const Icon(AppIcons.add, size: 16),
),
items: [
for (final type in ClipEffectType.values)
AppMenuItem(
label: type.label(context),
onPressed: enabled && stack.canAdd(type)
? () => onAdd(type)
: null,
),
],
),
],
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
ReorderableListView(
shrinkWrap: true,
primary: false,
padding: EdgeInsets.zero,
physics: const NeverScrollableScrollPhysics(),
buildDefaultDragHandles: false,
onReorderItem: (from, to) {
if (!enabled) return;
final order = layers.map((l) => l.id).toList();
order.insert(to, order.removeAt(from));
onReorder(order);
},
children: [
for (var i = 0; i < layers.length; i++)
PropertyLayerRow(
key: ValueKey('effect-layer-${layers[i].id}'),
id: layers[i].id,
prefix: 'effect',
index: i,
enabled: enabled,
visible: layers[i].enabled,
label: layers[i].type.label(context),
tooltip: context.l10n.effects,
onVisibility: () => onToggle(layers[i]),
onRemove: () => onRemove(layers[i]),
menuItems: [
for (final (delta, label) in [
(-1, context.l10n.effectMoveUp),
(1, context.l10n.effectMoveDown),
])
AppMenuItem(
label: label,
closeAncestors: false,
onPressed:
!enabled ||
i + delta < 0 ||
i + delta >= layers.length
? null
: () {
final order = layers
.map((l) => l.id)
.toList();
order.insert(i + delta, order.removeAt(i));
onReorder(order);
},
),
],
editor: editorBuilder(layers[i]),
),
],
),
if (error != null)
Text(
error!,
style: TextStyle(color: Theme.of(context).colorScheme.error),
),
],
),
),
);
}
}
@@ -0,0 +1,245 @@
import 'package:cutdex/l10n/l10n.dart';
import 'package:cutdex_core/editor.dart';
import 'package:cutdex_ui/theme.dart';
import 'package:cutdex_ui/widgets.dart';
import 'package:flutter/material.dart';
import 'property_keyframe_controls.dart';
import 'effect_labels.dart';
import 'property_color_input.dart';
import 'property_number_input.dart';
class EffectParameterEditor extends StatelessWidget {
const EffectParameterEditor({
super.key,
required this.layer,
required this.stack,
required this.enabled,
required this.editContext,
required this.keyframes,
required this.onChange,
required this.onTypeChange,
});
final ClipEffectLayer layer;
final ClipEffectStack stack;
final bool enabled;
final Object editContext;
final PropertyKeyframeControls keyframes;
final Future<bool> Function(Map<String, double>) onChange;
final void Function(ClipEffectType) onTypeChange;
String _fieldLabel(BuildContext context, String field) => switch (field) {
'x' => 'X',
'y' => 'Y',
'blur' => context.l10n.shadowBlur,
'spread' => context.l10n.shadowSpread,
'opacity' => context.l10n.shadowOpacity,
'blurEnd' => context.l10n.effectBlurEnd,
'start.x' => context.l10n.effectStartX,
'start.y' => context.l10n.effectStartY,
'end.x' => context.l10n.effectEndX,
'end.y' => context.l10n.effectEndY,
'lightAngle' => context.l10n.effectLightAngle,
'lightIntensity' => context.l10n.effectLightIntensity,
'refraction' => context.l10n.effectRefraction,
'depth' => context.l10n.effectDepth,
'dispersion' => context.l10n.effectDispersion,
'frost' => context.l10n.effectFrost,
'splay' => context.l10n.effectSplay,
'size' => context.l10n.effectNoiseSize,
'density' => context.l10n.effectDensity,
'radius' => context.l10n.effectTextureRadius,
'seed' => context.l10n.effectSeed,
_ => field,
};
Widget _number(BuildContext context, String field) {
final label = _fieldLabel(context, field);
final structural = EffectParameterTarget.structural.contains(field);
final percentage = {
'opacity',
'density',
'lightIntensity',
'splay',
}.contains(field);
final factor = percentage ? 100.0 : 1.0;
final definition = EffectParameterTarget.definition(field);
return Padding(
padding: const EdgeInsets.only(bottom: 4),
child: Row(
children: [
Expanded(
child: PropertyNumberInput(
key: ValueKey('effect-${layer.id}-$field'),
label: label,
value: layer.values[field]! * factor,
unit: percentage ? '%' : null,
enabled: enabled && layer.enabled,
readOnly: false,
scrubbing: false,
editContext: (editContext, layer.id, layer.type),
onScrubUpdate: (_) {},
onScrubEnd: () {},
onScrubCancel: () {},
submit: (v) => !definition.accepts(v / factor)
? Future.value(false)
: onChange({field: v / factor}),
),
),
if (!structural) ...[
keyframes.button(
context,
[layer.target(field)],
label,
'effect-${layer.id}-$field-key',
),
keyframes.menu(
context,
[layer.target(field)],
label,
'effect-${layer.id}-$field',
),
] else
const SizedBox(width: 48),
],
),
);
}
Widget _color(BuildContext context, String prefix, String label) {
final fields = ['${prefix}r', '${prefix}g', '${prefix}b'];
final values = fields.map((f) => layer.values[f]!).toList();
final hex = values
.map((v) => (v * 255).round().toRadixString(16).padLeft(2, '0'))
.join()
.toUpperCase();
final ids = fields.map(layer.target).toList();
return Padding(
padding: const EdgeInsets.only(bottom: 4),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(label, style: AppTheme.propertyLabelStyle(context)),
Row(
children: [
Expanded(
child: PropertyColorInput(
key: ValueKey('effect-${layer.id}-$prefix'),
value: hex,
color: Color.from(
alpha: 1,
red: values[0],
green: values[1],
blue: values[2],
),
enabled: enabled && layer.enabled,
editContext: (editContext, layer.id, layer.type),
submit: (rgb) => onChange({
fields[0]: ((rgb >> 16) & 255) / 255,
fields[1]: ((rgb >> 8) & 255) / 255,
fields[2]: (rgb & 255) / 255,
}),
),
),
keyframes.button(
context,
ids,
label,
'effect-${layer.id}-$prefix-key',
),
keyframes.menu(context, ids, label, 'effect-${layer.id}-$prefix'),
],
),
],
),
);
}
Widget _mode(BuildContext context, String field, List<String> labels) =>
Padding(
padding: const EdgeInsets.only(bottom: 8),
child: SizedBox(
height: 24,
child: AppSelect<int>(
closeAncestors: false,
key: ValueKey('effect-${layer.id}-$field'),
value: layer.values[field]!.round(),
label: field == 'noiseMode'
? context.l10n.effectNoiseMode
: context.l10n.shadowBlur,
emptyLabel: context.l10n.effects,
options: [
for (var i = 0; i < labels.length; i++)
AppSelectOption(i, labels[i]),
],
onChanged: enabled && layer.enabled
? (v) => onChange({field: v.toDouble()})
: null,
),
),
);
@override
Widget build(BuildContext context) => Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
SizedBox(
height: 24,
child: AppSelect<ClipEffectType>(
closeAncestors: false,
key: ValueKey('effect-${layer.id}-type'),
value: layer.type,
label: context.l10n.effects,
emptyLabel: context.l10n.effects,
options: [
for (final type in ClipEffectType.values)
if (stack.canAdd(type, excludingId: layer.id))
AppSelectOption(type, type.label(context)),
],
onChanged: enabled ? onTypeChange : null,
),
),
const SizedBox(height: 8),
if (layer.values.containsKey('progressive'))
_mode(context, 'progressive', [
context.l10n.effectUniform,
context.l10n.effectProgressive,
]),
if (layer.values.containsKey('noiseMode'))
_mode(context, 'noiseMode', [
context.l10n.effectMono,
context.l10n.effectDuo,
context.l10n.effectMulti,
]),
for (final field in layer.values.keys)
if (!field.startsWith('color') &&
!{'progressive', 'noiseMode', 'clipToShape'}.contains(field) &&
!(layer.values['progressive'] == 0 &&
{
'blurEnd',
'start.x',
'start.y',
'end.x',
'end.y',
}.contains(field)))
_number(context, field),
if (layer.values.containsKey('color.r') && layer.values['noiseMode'] != 2)
_color(context, 'color.', context.l10n.color),
if (layer.values['noiseMode'] == 1)
_color(context, 'color2.', context.l10n.effectSecondColor),
if (layer.values.containsKey('clipToShape'))
CheckboxListTile(
key: ValueKey('effect-${layer.id}-clipToShape'),
dense: true,
contentPadding: EdgeInsets.zero,
title: Text(
context.l10n.effectClipToShape,
style: Theme.of(context).textTheme.bodyMedium,
),
value: layer.values['clipToShape'] == 1,
onChanged: enabled && layer.enabled
? (v) => onChange({'clipToShape': v == true ? 1 : 0})
: null,
),
],
);
}
@@ -0,0 +1,172 @@
import 'package:cutdex/l10n/l10n.dart';
import 'package:cutdex_core/editor.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../workspace/timeline_session.dart';
import '../preview/preview_panel.dart';
import 'property_edit_controller.dart';
import 'property_keyframe_controls.dart';
import 'effect_list.dart';
import 'effect_parameter_editor.dart';
class EffectProperties extends ConsumerStatefulWidget {
const EffectProperties({
super.key,
required this.projectId,
required this.timelineId,
required this.session,
required this.sequence,
required this.clip,
});
final String projectId, timelineId;
final EditorTimelineSession session;
final SequenceId sequence;
final ElementId clip;
@override
ConsumerState<EffectProperties> createState() => _EffectPropertiesState();
}
class _EffectPropertiesState extends ConsumerState<EffectProperties> {
Object get _identity => (
widget.session,
widget.sequence,
widget.clip,
widget.projectId,
widget.timelineId,
);
PropertyEditController _createController() => PropertyEditController(
session: widget.session,
sequence: widget.sequence,
clip: widget.clip,
projectId: widget.projectId,
timelineId: widget.timelineId,
operation: 'editEffect',
);
late PropertyEditController _controller = _createController();
@override
void didUpdateWidget(covariant EffectProperties oldWidget) {
super.didUpdateWidget(oldWidget);
if (_controller.identity != _identity) {
_controller.dispose();
_controller = _createController();
}
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final preview = ref
.watch(editorPreviewProvider(widget.projectId, widget.timelineId))
.asData
?.value;
final controller = _controller;
final view = widget.session.view(widget.sequence);
return ListenableBuilder(
listenable: Listenable.merge([controller, view]),
builder: (context, _) {
final animation = controller.animation;
if (animation == null) return const SizedBox.shrink();
final stack = ClipEffectStack(animation.record, animation.localTick);
final enabled =
!controller.saving &&
stack.containsPlayhead &&
preview?.transforms.hasPending != true;
Future<bool> edit(void Function(EditorCommandService, int) action) =>
controller.run(preview, action);
final keyframes = PropertyKeyframeControls(
stack: stack,
enabled: enabled,
onEdit: (ids, {action, interpolation}) => edit(
(c, t) => c.editKeyframeChannel(
sequence: widget.sequence,
clip: widget.clip,
tick: t,
parameterIds: ids,
action: action,
interpolation: interpolation,
),
),
onSeek: (offset) => controller.run(
preview,
(_, tick) => view.seekTo(tick - stack.localTick + offset),
seek: true,
),
);
return EffectList(
stack: stack,
enabled: enabled,
keyframes: keyframes,
error: controller.failed ? context.l10n.updateEffectFailed : null,
onAdd: (type) => edit(
(c, t) => c.addEffect(
sequence: widget.sequence,
clip: widget.clip,
tick: t,
effectId: c.newEffectId(),
type: type,
),
),
onReorder: (order) => edit(
(c, t) => c.configureEffects(
sequence: widget.sequence,
clip: widget.clip,
tick: t,
order: order,
),
),
onToggle: (layer) => edit(
(c, t) => c.configureEffects(
sequence: widget.sequence,
clip: widget.clip,
tick: t,
effectId: layer.id,
enabled: !layer.enabled,
),
),
onRemove: (layer) => edit(
(c, t) => c.removeEffect(
sequence: widget.sequence,
clip: widget.clip,
tick: t,
effectId: layer.id,
),
),
editorBuilder: (layer) => EffectParameterEditor(
layer: layer,
stack: stack,
enabled: enabled,
editContext: controller.identity,
keyframes: keyframes,
onChange: (values) => edit(
(c, t) => c.setEffect(
sequence: widget.sequence,
clip: widget.clip,
tick: t,
effectId: layer.id,
values: values,
),
),
onTypeChange: (type) => edit(
(c, t) => c.changeEffectType(
sequence: widget.sequence,
clip: widget.clip,
tick: t,
effectId: layer.id,
type: type,
),
),
),
);
},
);
}
}
+101 -60
View File
@@ -9,9 +9,9 @@ import 'package:cutdex/l10n/l10n.dart';
import 'dart:math' as math;
import 'package:cutdex/features/properties/animation_labels.dart';
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_sdk/preview.dart';
import 'package:cutdex_sdk/timeline/model.dart';
import 'package:cutdex_core/editor.dart';
import 'package:cutdex_preview/cutdex_preview.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
@@ -180,7 +180,7 @@ class _MaskPropertiesState extends ConsumerState<MaskProperties> {
}
},
child: ListenableSelector<Object>(
listenable: preview,
listenable: Listenable.merge([preview, preview.positionChanges]),
select: () {
final mask = preview.maskFor(widget.element);
final animation = preview.maskAnimation(widget.element);
@@ -264,10 +264,11 @@ class _MaskPropertiesState extends ConsumerState<MaskProperties> {
}) => PropertyNumberInput(
key: ValueKey((selectedId, label)),
label: label,
inlineLabel: inlineLabel,
labelActions: AppTheme.isDesktop(context) && !inlineLabel
? [key(label)]
: const [],
inlineLabel: inlineLabel || AppTheme.isDesktop(context),
prefix: AppTheme.isDesktop(context) && !inlineLabel ? '' : null,
prefixIcon: AppTheme.isDesktop(context) && wrapRotation
? AppIcons.angle
: null,
unit: unit,
value: value,
enabled: enabled,
@@ -338,45 +339,65 @@ class _MaskPropertiesState extends ConsumerState<MaskProperties> {
if (mounted) setState(() => _scrubField = null);
},
);
Widget axes(String label, Widget first, Widget second) =>
LayoutBuilder(
builder: (context, constraints) {
final desktop = AppTheme.isDesktop(context);
final gap = AppTheme.propertyRowGap(context);
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
? AppPropertyGroup(
label: label,
actions: [key(label)],
child: pair,
)
: Row(
children: [
Expanded(child: pair),
SizedBox(width: gap),
key(label),
],
);
},
Widget axes(
String label,
Widget first,
Widget second, {
Widget? additional,
}) => LayoutBuilder(
builder: (context, constraints) {
final desktop = AppTheme.isDesktop(context);
final gap = AppTheme.propertyRowGap(context);
if (desktop) {
return AppPropertyGroup(
label: label,
padChild: false,
child: Column(
children: [
AppPropertyRow(
trailing: key(label),
children: [first, second],
),
?additional,
],
),
);
}
final pair = constraints.maxWidth < 240
? Column(
children: [
first,
SizedBox(height: gap),
second,
],
)
: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(child: first),
SizedBox(width: gap),
Expanded(child: second),
],
);
return Row(
children: [
Expanded(child: pair),
SizedBox(width: gap),
key(label),
],
);
},
);
Widget singleField(String label, Widget input) =>
AppTheme.isDesktop(context)
? input
? AppPropertyGroup(
label: label,
padChild: false,
child: AppPropertyRow(
trailing: key(label),
children: [input],
),
)
: Row(
children: [
Expanded(child: input),
@@ -395,8 +416,7 @@ class _MaskPropertiesState extends ConsumerState<MaskProperties> {
style: AppTheme.propertySectionTitleStyle(context),
),
);
Widget section(List<Widget> children) => Padding(
padding: AppTheme.propertySectionPadding(context),
Widget section(List<Widget> children) => AppPropertySection(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: children,
@@ -586,8 +606,11 @@ class _MaskPropertiesState extends ConsumerState<MaskProperties> {
if (AppTheme.isDesktop(context))
AppPropertyGroup(
label: context.l10n.type,
actions: [shapeReset()],
child: shapeSelector(),
padChild: false,
child: AppPropertyRow(
trailing: shapeReset(),
children: [shapeSelector()],
),
)
else
Row(
@@ -620,22 +643,40 @@ class _MaskPropertiesState extends ConsumerState<MaskProperties> {
unit: '%',
inlineLabel: true,
),
additional: AppTheme.isDesktop(context)
? AppPropertyRow(
trailing: key(context.l10n.rotation),
children: [
field(
context.l10n.rotation,
mask.rotation,
-180,
180,
(v) => mask.copyWith(rotation: v),
unit: '°',
wrapRotation: true,
),
const SizedBox.shrink(),
],
)
: null,
),
]),
section([
singleField(
context.l10n.rotation,
field(
if (!AppTheme.isDesktop(context))
section([
singleField(
context.l10n.rotation,
mask.rotation,
-180,
180,
(v) => mask.copyWith(rotation: v),
unit: '°',
wrapRotation: true,
field(
context.l10n.rotation,
mask.rotation,
-180,
180,
(v) => mask.copyWith(rotation: v),
unit: '°',
wrapRotation: true,
),
),
),
]),
]),
section([
heading(context.l10n.size),
axes(
+30 -59
View File
@@ -1,25 +1,19 @@
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_sdk/preview.dart';
import 'package:cutdex_sdk/timeline/engine.dart';
import 'package:cutdex_sdk/timeline/model.dart';
import 'dart:async';
import 'package:cutdex_core/editor.dart';
import 'package:cutdex_preview/cutdex_preview.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import '../../workspace/timeline_session.dart';
import 'property_edit_boundary.dart';
part 'picture_edits.g.dart';
part 'picture_edits.freezed.dart';
enum PictureEditFailure { keyframes, alignment, invalidTransform, transform }
@freezed
abstract class PictureEditTarget with _$PictureEditTarget {
const factory PictureEditTarget({
required TimelineVersion version,
required int tick,
}) = _PictureEditTarget;
}
@freezed
abstract class PictureEditException
with _$PictureEditException
@@ -31,35 +25,16 @@ abstract class PictureEditException
@riverpod
class PictureEdits extends _$PictureEdits {
Future<bool>? _pending;
late PropertyEditBoundary _boundary;
@override
AsyncValue<void> build(
EditorTimelineSession session,
SequenceId sequence,
ElementId clip,
) => const AsyncData(null);
PictureEditTarget _capture() {
final view = session.view(sequence);
return PictureEditTarget(
version: view.version.kernelVersion,
tick: view.playheadTick,
);
}
bool _valid(
PictureEditTarget target,
bool Function() isCurrent,
PreviewController? preview,
) {
if (!ref.mounted ||
!isCurrent() ||
session.activeSequenceId != sequence ||
preview?.transforms.hasPending == true) {
return false;
}
final view = session.view(sequence);
return target.tick == view.playheadTick &&
identical(target.version, view.version.kernelVersion);
_boundary = PropertyEditBoundary(session, sequence, clip);
ref.onDispose(_boundary.dispose);
return const AsyncData(null);
}
ClipAnimation? animation() {
@@ -86,10 +61,9 @@ class PictureEdits extends _$PictureEdits {
if (state.isLoading || preview?.transforms.hasPending == true) {
return Future.value(false);
}
final target = _capture();
final work = _run(PictureEditFailure.transform, () async {
await preview?.pauseForCanvasInteraction();
if (!_valid(target, isCurrent, preview)) return false;
final work = _run(PictureEditFailure.transform, preview, isCurrent, (
target,
) {
final current = animation()?.value;
if (current == null) return false;
final value = change(current);
@@ -100,7 +74,9 @@ class PictureEdits extends _$PictureEdits {
value.y == current.y &&
value.scale == current.scale &&
value.scaleY == current.scaleY &&
value.rotation == current.rotation) {
value.rotation == current.rotation &&
value.sameCorners(current) &&
value.distortion.same(current.distortion)) {
return true;
}
session.commands.setTransform(
@@ -132,10 +108,7 @@ class PictureEdits extends _$PictureEdits {
preview?.transforms.hasPending == true) {
return;
}
final target = _capture();
await _run(PictureEditFailure.keyframes, () async {
await preview?.pauseForCanvasInteraction();
if (!_valid(target, isCurrent, preview)) return false;
await _run(PictureEditFailure.keyframes, preview, isCurrent, (target) {
session.commands.editKeyframeChannel(
sequence: sequence,
clip: clip,
@@ -154,7 +127,6 @@ class PictureEdits extends _$PictureEdits {
required bool Function() isCurrent,
}) async {
if (state.isLoading || preview.transforms.hasPending) return;
final target = _capture();
final current = animation();
if (current == null) return;
final command = AlignClip(
@@ -166,12 +138,13 @@ class PictureEdits extends _$PictureEdits {
alignment: alignment,
expectedVersion: session.version,
);
await _run(PictureEditFailure.alignment, () async {
await preview.pauseForCanvasInteraction();
await _run(PictureEditFailure.alignment, preview, isCurrent, (
target,
) async {
await session.alignClip(
sequence,
command,
isCancelled: () => !_valid(target, isCurrent, preview),
isCancelled: () => !target.isCurrent,
);
return true;
});
@@ -179,24 +152,22 @@ class PictureEdits extends _$PictureEdits {
Future<bool> _run(
PictureEditFailure failure,
Future<bool> Function() action,
PreviewController? preview,
bool Function() isCurrent,
FutureOr<bool> Function(PropertyEditContext) action,
) async {
final lease = ref.keepAlive();
state = const AsyncLoading();
try {
final applied = await session.runEditAsync(
switch (failure) {
final applied = await _boundary.run(
preview,
action,
isCurrent: () => ref.mounted && isCurrent(),
started: () => state = const AsyncLoading(),
operation: switch (failure) {
PictureEditFailure.keyframes => 'editKeyframes',
PictureEditFailure.alignment => 'alignClip',
_ => 'setTransform',
},
sequence,
action,
context: {
'clipIds': [clip.value],
'entryPoint': 'property',
'playheadTick': session.view(sequence).playheadTick,
},
);
if (ref.mounted) state = const AsyncData(null);
return applied;
@@ -12,318 +12,6 @@ part of 'picture_edits.dart';
// GENERATED CODE - DO NOT MODIFY BY HAND
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$PictureEditTarget {
TimelineVersion get version;
int get tick;
/// Create a copy of PictureEditTarget
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$PictureEditTargetCopyWith<PictureEditTarget> get copyWith =>
_$PictureEditTargetCopyWithImpl<PictureEditTarget>(
this as PictureEditTarget,
_$identity,
);
@override
bool operator ==(Object other) {
final _this = this as PictureEditTarget;
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is PictureEditTarget &&
(identical(other.version, _this.version) ||
other.version == _this.version) &&
(identical(other.tick, _this.tick) || other.tick == _this.tick));
}
@override
int get hashCode {
final _this = this as PictureEditTarget;
return Object.hash(runtimeType, _this.version, _this.tick);
}
@override
String toString() {
final _this = this as PictureEditTarget;
return 'PictureEditTarget(version: ${_this.version}, tick: ${_this.tick})';
}
}
/// @nodoc
abstract mixin class $PictureEditTargetCopyWith<$Res> {
factory $PictureEditTargetCopyWith(
PictureEditTarget value,
$Res Function(PictureEditTarget) _then,
) = _$PictureEditTargetCopyWithImpl;
@useResult
$Res call({TimelineVersion version, int tick});
}
/// @nodoc
class _$PictureEditTargetCopyWithImpl<$Res>
implements $PictureEditTargetCopyWith<$Res> {
_$PictureEditTargetCopyWithImpl(this._self, this._then);
final PictureEditTarget _self;
final $Res Function(PictureEditTarget) _then;
/// Create a copy of PictureEditTarget
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? version = null, Object? tick = null}) {
return _then(
PictureEditTarget(
version: null == version
? _self.version
: version // ignore: cast_nullable_to_non_nullable
as TimelineVersion,
tick: null == tick
? _self.tick
: tick // ignore: cast_nullable_to_non_nullable
as int,
),
);
}
}
/// Adds pattern-matching-related methods to [PictureEditTarget].
extension PictureEditTargetPatterns on PictureEditTarget {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>(
TResult Function(_PictureEditTarget value)? $default, {
required TResult orElse(),
}) {
final _that = this;
switch (_that) {
case _PictureEditTarget() when $default != null:
return $default(_that);
case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs
TResult map<TResult extends Object?>(
TResult Function(_PictureEditTarget value) $default,
) {
final _that = this;
switch (_that) {
case _PictureEditTarget():
return $default(_that);
case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>(
TResult? Function(_PictureEditTarget value)? $default,
) {
final _that = this;
switch (_that) {
case _PictureEditTarget() when $default != null:
return $default(_that);
case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
TResult Function(TimelineVersion version, int tick)? $default, {
required TResult orElse(),
}) {
final _that = this;
switch (_that) {
case _PictureEditTarget() when $default != null:
return $default(_that.version, _that.tick);
case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs
TResult when<TResult extends Object?>(
TResult Function(TimelineVersion version, int tick) $default,
) {
final _that = this;
switch (_that) {
case _PictureEditTarget():
return $default(_that.version, _that.tick);
case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>(
TResult? Function(TimelineVersion version, int tick)? $default,
) {
final _that = this;
switch (_that) {
case _PictureEditTarget() when $default != null:
return $default(_that.version, _that.tick);
case _:
return null;
}
}
}
/// @nodoc
class _PictureEditTarget implements PictureEditTarget {
const _PictureEditTarget({required this.version, required this.tick});
@override
final TimelineVersion version;
@override
final int tick;
/// Create a copy of PictureEditTarget
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$PictureEditTargetCopyWith<_PictureEditTarget> get copyWith =>
__$PictureEditTargetCopyWithImpl<_PictureEditTarget>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _PictureEditTarget &&
(identical(other.version, version) || other.version == version) &&
(identical(other.tick, tick) || other.tick == tick));
}
@override
int get hashCode {
return Object.hash(runtimeType, version, tick);
}
@override
String toString() {
return 'PictureEditTarget(version: $version, tick: $tick)';
}
}
/// @nodoc
abstract mixin class _$PictureEditTargetCopyWith<$Res>
implements $PictureEditTargetCopyWith<$Res> {
factory _$PictureEditTargetCopyWith(
_PictureEditTarget value,
$Res Function(_PictureEditTarget) _then,
) = __$PictureEditTargetCopyWithImpl;
@override
@useResult
$Res call({TimelineVersion version, int tick});
}
/// @nodoc
class __$PictureEditTargetCopyWithImpl<$Res>
implements _$PictureEditTargetCopyWith<$Res> {
__$PictureEditTargetCopyWithImpl(this._self, this._then);
final _PictureEditTarget _self;
final $Res Function(_PictureEditTarget) _then;
/// Create a copy of PictureEditTarget
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$Res call({Object? version = null, Object? tick = null}) {
return _then(
_PictureEditTarget(
version: null == version
? _self.version
: version // ignore: cast_nullable_to_non_nullable
as TimelineVersion,
tick: null == tick
? _self.tick
: tick // ignore: cast_nullable_to_non_nullable
as int,
),
);
}
}
/// @nodoc
mixin _$PictureEditException {
PictureEditFailure get failure;
+1 -1
View File
@@ -58,7 +58,7 @@ final class PictureEditsProvider
}
}
String _$pictureEditsHash() => r'6385f3bd53094d57ed054681d142591e059e8b08';
String _$pictureEditsHash() => r'b3166b6e97f6a711e6e92b67dfc44341a3fec4e2';
final class PictureEditsFamily extends $Family
with
+298 -82
View File
@@ -5,10 +5,10 @@ import 'package:cutdex/l10n/l10n.dart';
import 'dart:math' as math;
import 'package:cutdex/features/properties/animation_labels.dart';
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_sdk/preview.dart';
import 'package:cutdex_sdk/timeline/engine.dart';
import 'package:cutdex_sdk/timeline/model.dart';
import 'package:cutdex_core/editor.dart';
import 'package:cutdex_preview/cutdex_preview.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';
@@ -22,6 +22,10 @@ import '../../shared/state/operation_scope.dart';
import '../preview/preview_panel.dart';
import 'property_number_input.dart';
import 'picture_edits.dart';
import 'effect_properties.dart';
import 'stroke_properties.dart';
import 'distortion_properties.dart';
import 'effect_labels.dart';
class PictureProperties extends ConsumerStatefulWidget {
const PictureProperties({
@@ -57,6 +61,7 @@ class _PicturePropertiesState extends ConsumerState<PictureProperties> {
late final _operations = OperationScope<Object>(_operationContext);
late final _seeks = OperationScope<Object>(_operationContext);
bool _locked = true;
bool? _independentCorners;
bool _hasFocusedControl = false;
PictureEditsProvider get _editProvider =>
pictureEditsProvider(widget.session, widget.sequence, widget.clip.id);
@@ -87,6 +92,7 @@ class _PicturePropertiesState extends ConsumerState<PictureProperties> {
oldWidget.clip.id,
);
if (previousIdentity != _editIdentity) {
_independentCorners = null;
final edit = _clearScrub();
if (edit != null) scheduleMicrotask(edit.cancel);
}
@@ -204,7 +210,9 @@ class _PicturePropertiesState extends ConsumerState<PictureProperties> {
value.y == _scrubBase!.y &&
value.rotation == _scrubBase!.rotation &&
value.scale == _scrubBase!.scale &&
value.scaleY == _scrubBase!.scaleY)) {
value.scaleY == _scrubBase!.scaleY &&
value.sameCorners(_scrubBase!) &&
value.distortion.same(_scrubBase!.distortion))) {
_cancelScrub();
return;
}
@@ -267,6 +275,16 @@ class _PicturePropertiesState extends ConsumerState<PictureProperties> {
value.scale,
value.scaleY,
value.rotation,
value.distortion.topLeft,
value.distortion.topRight,
value.distortion.bottomRight,
value.distortion.bottomLeft,
value.cornerRadius,
value.topLeftRadius,
value.topRightRadius,
value.bottomRightRadius,
value.bottomLeftRadius,
_independentCorners,
_scrubValid,
_scrubBase != null,
_saving,
@@ -359,36 +377,46 @@ 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) {
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 axes(
TransformChannel channel,
Widget first,
Widget second, {
Widget? trailing,
}) => LayoutBuilder(
builder: (context, constraints) {
if (desktop) {
return AppPropertyRow(
trailing: channel == TransformChannel.position
? keyButton(channel)
: trailing,
children: [first, second],
);
}
final pair = constraints.maxWidth < 240
? Column(
children: [
first,
SizedBox(height: gap),
second,
],
)
: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(child: first),
SizedBox(width: gap),
Expanded(child: second),
],
);
return Row(
children: [
Expanded(child: pair),
SizedBox(width: gap),
keyButton(channel),
],
);
},
);
Widget keyTools(TransformChannel channel) {
if (animation == null || !animation.animated(channel)) {
@@ -488,17 +516,23 @@ class _PicturePropertiesState extends ConsumerState<PictureProperties> {
bool inlineLabel = false,
String? prefix,
IconData? prefixIcon,
int prefixQuarterTurns = 0,
String? valueText,
}) => PropertyNumberInput(
key: ValueKey(id),
label: label,
inlineLabel: inlineLabel,
prefix: prefix,
prefixIcon: prefixIcon,
prefixQuarterTurns: prefixQuarterTurns,
valueText: valueText,
unit: unit,
value: value,
enabled: !_saving,
readOnly: _scrubBase != null || preview?.transforms.hasPending == true,
submit: (v) => _commit(preview, (current) => change(current, v)),
submit: (v) => v < min || v > max
? Future.value(false)
: _commit(preview, (current) => change(current, v)),
onScrubStart: () => _startScrub(
preview,
id,
@@ -520,8 +554,7 @@ class _PicturePropertiesState extends ConsumerState<PictureProperties> {
widget.session.view(widget.sequence).playheadTick,
),
);
Widget section(List<Widget> children) => Padding(
padding: AppTheme.propertySectionPadding(context),
Widget section(List<Widget> children) => AppPropertySection(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: children,
@@ -555,7 +588,10 @@ class _PicturePropertiesState extends ConsumerState<PictureProperties> {
prefixIcon: desktop ? AppIcons.angle : null,
);
final rotation = desktop
? rotationInput
? AppPropertyRow(
trailing: keyButton(TransformChannel.rotation),
children: [rotationInput, const SizedBox.shrink()],
)
: Row(
children: [
Expanded(child: rotationInput),
@@ -563,7 +599,7 @@ class _PicturePropertiesState extends ConsumerState<PictureProperties> {
keyButton(TransformChannel.rotation),
],
);
final scale = axes(
Widget scaleControls({Widget? trailing}) => axes(
TransformChannel.scale,
number(
'picture-scale-x',
@@ -595,6 +631,7 @@ class _PicturePropertiesState extends ConsumerState<PictureProperties> {
: 10000,
inlineLabel: true,
),
trailing: trailing,
);
final lock = IconButton(
key: const Key('picture-lock'),
@@ -610,11 +647,10 @@ class _PicturePropertiesState extends ConsumerState<PictureProperties> {
}
: null,
);
final scale = scaleControls();
final alignmentControls = LayoutBuilder(
builder: (context, constraints) => Wrap(
spacing: AppSpacing.small,
runSpacing: AppSpacing.small,
children: [
builder: (context, constraints) {
final groups = <Widget>[
for (final group in [
[
(
@@ -648,7 +684,9 @@ class _PicturePropertiesState extends ConsumerState<PictureProperties> {
],
])
SizedBox(
width: constraints.maxWidth < 200
width: desktop
? null
: constraints.maxWidth < 200
? constraints.maxWidth
: (constraints.maxWidth - AppSpacing.small) / 2,
child: AppButtonGroup(
@@ -675,9 +713,89 @@ class _PicturePropertiesState extends ConsumerState<PictureProperties> {
],
),
),
],
),
];
if (desktop) return AppPropertyRow(children: groups);
return Wrap(
spacing: AppSpacing.small,
runSpacing: AppSpacing.small,
children: groups,
);
},
);
final radiusInput = number(
'picture-corner-radius',
context.l10n.cornerRadius,
value.topLeftRadius,
(c, v) => c.copyWith(cornerRadius: v),
min: 0,
max: 1000000,
inlineLabel: desktop,
prefix: desktop ? '' : null,
prefixIcon: desktop ? AppIcons.cornerRadius : null,
valueText: value.hasMixedCorners ? '—' : null,
);
final independent = _independentCorners ?? value.hasMixedCorners;
final cornerToggle = IconButton(
key: const ValueKey('picture-independent-corners'),
tooltip: context.l10n.independentCorners,
icon: const Icon(AppIcons.independentCorners),
isSelected: independent,
onPressed:
enabled &&
_scrubBase == null &&
preview?.transforms.hasPending != true
? () => setState(() => _independentCorners = !independent)
: null,
);
final cornerInputs = [
number(
'picture-corner-top-left',
context.l10n.cornerTopLeft,
value.topLeftRadius,
(c, v) => c.copyWith(topLeftRadius: v),
min: 0,
max: 1000000,
inlineLabel: true,
prefix: '',
prefixIcon: Icons.rounded_corner,
prefixQuarterTurns: 3,
),
number(
'picture-corner-top-right',
context.l10n.cornerTopRight,
value.topRightRadius,
(c, v) => c.copyWith(topRightRadius: v),
min: 0,
max: 1000000,
inlineLabel: true,
prefix: '',
prefixIcon: Icons.rounded_corner,
),
number(
'picture-corner-bottom-left',
context.l10n.cornerBottomLeft,
value.bottomLeftRadius,
(c, v) => c.copyWith(bottomLeftRadius: v),
min: 0,
max: 1000000,
inlineLabel: true,
prefix: '',
prefixIcon: Icons.rounded_corner,
prefixQuarterTurns: 2,
),
number(
'picture-corner-bottom-right',
context.l10n.cornerBottomRight,
value.bottomRightRadius,
(c, v) => c.copyWith(bottomRightRadius: v),
min: 0,
max: 1000000,
inlineLabel: true,
prefix: '',
prefixIcon: Icons.rounded_corner,
prefixQuarterTurns: 1,
),
];
final content = Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
@@ -690,46 +808,43 @@ class _PicturePropertiesState extends ConsumerState<PictureProperties> {
),
]),
],
if (!widget.animationView)
if (!widget.animationView && !desktop)
section([
if (desktop)
AppPropertyGroup(
label: context.l10n.alignment,
child: alignmentControls,
)
else ...[
Text(
context.l10n.alignment,
style: AppTheme.propertySectionTitleStyle(context),
),
SizedBox(height: gap),
alignmentControls,
],
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,
padChild: false,
child: Column(
children: [
if (!widget.animationView) alignmentControls,
position,
keyTools(TransformChannel.position),
rotation,
keyTools(TransformChannel.rotation),
],
),
),
keyTools(TransformChannel.position),
]),
section([
AppPropertyGroup(
label: context.l10n.scale,
actions: [lock, keyButton(TransformChannel.scale)],
child: scale,
actions: [keyButton(TransformChannel.scale)],
padChild: false,
child: Column(
children: [
scaleControls(trailing: lock),
keyTools(TransformChannel.scale),
],
),
),
keyTools(TransformChannel.scale),
]),
section([
AppPropertyGroup(
label: context.l10n.rotation,
actions: [keyButton(TransformChannel.rotation)],
child: rotation,
),
keyTools(TransformChannel.rotation),
]),
] else ...[
section([
@@ -759,6 +874,82 @@ class _PicturePropertiesState extends ConsumerState<PictureProperties> {
keyTools(TransformChannel.scale),
]),
],
DistortionProperties(
projectId: widget.projectId,
timelineId: widget.timelineId,
session: widget.session,
sequence: widget.sequence,
clip: widget.clip.id,
),
section([
if (desktop)
AppPropertyGroup(
label: context.l10n.cornerRadius,
padChild: false,
child: Column(
children: [
AppPropertyRow(
trailing: keyButton(TransformChannel.cornerRadius),
children: [
radiusInput,
Align(
alignment: Alignment.centerRight,
child: cornerToggle,
),
],
),
if (independent) ...[
AppPropertyRow(children: cornerInputs.sublist(0, 2)),
AppPropertyRow(children: cornerInputs.sublist(2, 4)),
],
keyTools(TransformChannel.cornerRadius),
],
),
)
else ...[
Row(
children: [
Expanded(child: radiusInput),
SizedBox(width: gap),
cornerToggle,
keyButton(TransformChannel.cornerRadius),
],
),
if (independent) ...[
SizedBox(height: gap),
Row(
children: [
Expanded(child: cornerInputs[0]),
SizedBox(width: gap),
Expanded(child: cornerInputs[1]),
],
),
SizedBox(height: gap),
Row(
children: [
Expanded(child: cornerInputs[2]),
SizedBox(width: gap),
Expanded(child: cornerInputs[3]),
],
),
],
keyTools(TransformChannel.cornerRadius),
],
]),
StrokeProperties(
projectId: widget.projectId,
timelineId: widget.timelineId,
session: widget.session,
sequence: widget.sequence,
clip: widget.clip.id,
),
EffectProperties(
projectId: widget.projectId,
timelineId: widget.timelineId,
session: widget.session,
sequence: widget.sequence,
clip: widget.clip.id,
),
if (_error != null)
section([
Text(
@@ -824,7 +1015,34 @@ class _KeyframeTimeline extends StatelessWidget {
],
),
const SizedBox(height: AppSpacing.small),
for (final channel in TransformChannel.values)
for (final (id, label, times) in [
for (final channel in TransformChannel.values)
(channel.name, channel.label(context), animation.keyTimes(channel)),
for (final layer in ClipStrokeStack(
animation.record,
animation.localTick,
).layers)
(
'stroke-${layer.id}',
context.l10n.stroke,
ClipStrokeStack(animation.record, animation.localTick)
.keyOffsets(layer.parameterIds)
.map((t) => animation.start + t)
.toList(),
),
for (final layer in ClipEffectStack(
animation.record,
animation.localTick,
).layers)
(
layer.id,
layer.type.label(context),
ClipEffectStack(animation.record, animation.localTick)
.keyOffsets(layer.parameterIds)
.map((t) => animation.start + t)
.toList(),
),
])
SizedBox(
height: 32,
child: Row(
@@ -832,7 +1050,7 @@ class _KeyframeTimeline extends StatelessWidget {
SizedBox(
width: 36,
child: Text(
channel.label(context),
label,
style: Theme.of(context).textTheme.bodySmall,
),
),
@@ -851,7 +1069,7 @@ class _KeyframeTimeline extends StatelessWidget {
) *
extent;
return GestureDetector(
key: ValueKey('picture-key-track-${channel.name}'),
key: ValueKey('picture-key-track-$id'),
behavior: HitTestBehavior.opaque,
onTapDown: !enabled
? null
@@ -883,18 +1101,16 @@ class _KeyframeTimeline extends StatelessWidget {
width: 1,
child: ColoredBox(color: colors.primary),
),
for (final tick in animation.keyTimes(channel))
for (final tick in times)
Positioned(
left: x(tick) - AppControlSize.compact / 2,
top: 4,
width: AppControlSize.compact,
height: AppControlSize.compact,
child: IconButton(
key: ValueKey(
'picture-key-marker-${channel.name}-$tick',
),
key: ValueKey('picture-key-marker-$id-$tick'),
tooltip:
'${channel.label(context)} ${((tick - animation.start) / TimelineClock.ticksPerSecond).toStringAsFixed(2)} s',
'$label ${((tick - animation.start) / TimelineClock.ticksPerSecond).toStringAsFixed(2)} s',
padding: EdgeInsets.zero,
onPressed: enabled
? () => onSeek(tick)
+19 -15
View File
@@ -1,7 +1,7 @@
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:cutdex_native_flutter/contracts.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:cutdex_core/timeline/engine.dart';
import 'package:flutter/material.dart';
import 'package:cutdex_ui/theme.dart';
@@ -39,7 +39,9 @@ class ProjectProperties extends StatelessWidget {
height: AppTheme.isDesktop(context) ? AppInspectorMetrics.input : null,
child: TextButton(
key: const ValueKey('project-settings-edit'),
style: AppTheme.isDesktop(context)
style:
AppTheme.isDesktop(context) &&
!AppTheme.isCompactInspector(context)
? AppTheme.toolbarButtonStyle(context)
: null,
onPressed: () => showAppDialog<void>(
@@ -50,14 +52,17 @@ class ProjectProperties extends StatelessWidget {
),
),
headerHeight: AppTheme.isDesktop(context)
? AppDesktopMetrics.panelHeader
? AppInspectorMetrics.sectionHeader
: AppControlSize.panelToolbar,
headerPadding: EdgeInsets.symmetric(
horizontal: AppTheme.isDesktop(context)
? AppInspectorMetrics.padding
: AppSpacing.panelContentHorizontal,
),
showHeaderDivider: false,
headerPadding: AppTheme.isDesktop(context)
? const EdgeInsets.only(
left: AppInspectorMetrics.padding,
right: AppInspectorMetrics.trailingPadding,
)
: const EdgeInsets.symmetric(
horizontal: AppSpacing.panelContentHorizontal,
),
showHeaderDivider: AppTheme.isCompactInspector(context),
child: ScrollEdgeFadeBuilder(
builder: (controller) => SingleChildScrollView(
controller: controller,
@@ -75,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',
@@ -133,8 +138,7 @@ class _Info extends StatelessWidget {
style: Theme.of(context).textTheme.bodyMedium,
),
);
return Padding(
padding: AppTheme.propertySectionPadding(context),
return AppPropertySection(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
spacing: AppSpacing.small,
@@ -14,9 +14,11 @@ class ProjectPropertyRow extends StatelessWidget {
@override
Widget build(BuildContext context) => Padding(
padding: const EdgeInsets.symmetric(
horizontal: AppInspectorMetrics.padding,
vertical: AppInspectorMetrics.rowGap,
padding: const EdgeInsets.fromLTRB(
AppInspectorMetrics.padding,
AppInspectorMetrics.rowPadding,
AppInspectorMetrics.trailingPadding,
AppInspectorMetrics.rowPadding,
),
child: ConstrainedBox(
constraints: const BoxConstraints(minHeight: AppInspectorMetrics.input),
@@ -35,13 +37,11 @@ class ProjectPropertyRow extends StatelessWidget {
label,
maxLines: 3,
overflow: TextOverflow.ellipsis,
style: AppTheme.toolbarTextStyle(context).copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
style: AppTheme.propertyLabelStyle(context),
),
),
),
const SizedBox(width: AppInspectorMetrics.rowGap * 2),
const SizedBox(width: AppInspectorMetrics.rowGap),
Expanded(
flex: 3,
child: Tooltip(
@@ -51,7 +51,7 @@ class ProjectPropertyRow extends StatelessWidget {
maxLines: 3,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.right,
style: AppTheme.toolbarTextStyle(context),
style: AppTheme.inputTextStyle(context),
),
),
),
@@ -20,8 +20,10 @@ Widget lightProjectSummaryPreview() => _preview(Brightness.light);
Widget _preview(Brightness brightness) => MaterialApp(
debugShowCheckedModeBanner: false,
theme: AppTheme.desktopWorkspaceTheme(
AppTheme.forPalette(AppPalette.graphite, brightness),
theme: AppTheme.propertiesPanelTheme(
AppTheme.desktopWorkspaceTheme(
AppTheme.forPalette(AppPalette.graphite, brightness),
),
),
home: const Scaffold(
body: SingleChildScrollView(
@@ -1,7 +1,7 @@
import 'package:cutdex/l10n/l10n.dart';
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_sdk/runtime/contracts.dart';
import 'package:cutdex_sdk/timeline/model.dart';
import 'package:cutdex_core/editor.dart';
import 'package:cutdex_native_flutter/contracts.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@@ -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(
+16 -17
View File
@@ -1,6 +1,6 @@
import 'package:cutdex/l10n/l10n.dart';
import 'package:cutdex_sdk/timeline/engine.dart';
import 'package:cutdex_sdk/timeline/model.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';
@@ -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],
@@ -1,6 +1,6 @@
import 'package:cutdex_sdk/timeline/engine.dart';
import 'package:cutdex_sdk/timeline/layout.dart';
import 'package:cutdex_sdk/timeline/model.dart';
import 'package:cutdex_core/timeline/engine.dart';
import 'package:cutdex_core/timeline/layout.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
@@ -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,
@@ -20,7 +20,7 @@ class EditorPropertiesPanel extends StatelessWidget {
projectId: projectId,
timelineId: timelineId,
categoryHeaderHeight: AppTheme.isDesktop(context)
? AppDesktopMetrics.panelHeader
? AppInspectorMetrics.sectionHeader
: CompactPanelTabs.height,
categoryControls: (context, categories, selected, onSelected) =>
CompactPanelTabs<PropertyCategory>(
@@ -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,
@@ -0,0 +1,152 @@
import 'package:cutdex/l10n/l10n.dart';
import 'package:cutdex_ui/widgets.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widget_previews.dart';
import 'package:cutdex_ui/theme.dart';
import '../../shared/state/operation_scope.dart';
import 'property_color_picker.dart';
class PropertyColorInput extends StatefulWidget {
const PropertyColorInput({
super.key,
required this.value,
required this.color,
required this.enabled,
required this.editContext,
required this.submit,
});
final String value;
final Color color;
final bool enabled;
final Object editContext;
final Future<bool> Function(int) submit;
@override
State<PropertyColorInput> createState() => _PropertyColorInputState();
}
class _PropertyColorInputState extends State<PropertyColorInput> {
late final _text = TextEditingController(text: widget.value);
final _focus = FocusNode();
bool _dirty = false;
String? _error;
late final _operations = OperationScope<Object>(widget.editContext);
@override
void initState() {
super.initState();
_focus.addListener(_blur);
}
void _blur() {
if (!_focus.hasFocus) _submit();
}
Future<void> _submit() async {
if (!_dirty || !widget.enabled) return;
final value = _text.text.replaceFirst('#', '');
if (!RegExp(r'^[A-Fa-f0-9]{6}$').hasMatch(value)) {
setState(() => _error = context.l10n.invalidNumber);
return;
}
_dirty = false;
final guard = _operations.begin();
final ok = await widget.submit(int.parse(value, radix: 16));
if (!mounted || !guard()) return;
setState(() {
_error = ok ? null : context.l10n.notApplied;
_text.text = widget.value;
});
}
@override
void didUpdateWidget(covariant PropertyColorInput oldWidget) {
super.didUpdateWidget(oldWidget);
_operations.bind(widget.editContext);
if (oldWidget.editContext != widget.editContext || !widget.enabled) {
_dirty = false;
_error = null;
}
if (!_dirty && _text.text != widget.value) _text.text = widget.value;
}
@override
void dispose() {
_operations.dispose();
_focus.removeListener(_blur);
_focus.dispose();
_text.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) => AppTextField(
controller: _text,
focusNode: _focus,
enabled: widget.enabled,
errorText: _error,
leading: AppPopover(
width: 240,
borderRadius: 8,
padding: const EdgeInsets.all(16),
backgroundColor: Theme.of(context).colorScheme.surfaceContainerLow,
builder: (context, toggle) => IconButton(
key: const ValueKey('effect-color-swatch'),
tooltip: context.l10n.color,
onPressed: widget.enabled ? toggle : null,
padding: EdgeInsets.zero,
icon: Container(
width: 14,
height: 14,
decoration: BoxDecoration(
color: widget.color,
borderRadius: BorderRadius.circular(2),
border: Border.all(
color: Theme.of(context).colorScheme.outlineVariant,
),
),
),
),
child: PropertyColorPicker(
color: widget.color,
enabled: widget.enabled,
submit: (color) => widget.submit(color.toARGB32() & 0xFFFFFF),
),
),
onChanged: (_) {
_operations.invalidate();
_dirty = true;
if (_error != null) setState(() => _error = null);
},
onEditingComplete: () {},
onSubmitted: (_) => _submit(),
);
}
@Preview(name: 'Property color input', size: Size(240, 80))
Widget propertyColorInputPreview() {
var rgb = 0x3366FF;
return MaterialApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
theme: AppTheme.propertiesPanelTheme(
AppTheme.desktopWorkspaceTheme(AppTheme.penDark),
),
home: Scaffold(
body: Padding(
padding: const EdgeInsets.all(16),
child: StatefulBuilder(
builder: (context, update) => PropertyColorInput(
value: rgb.toRadixString(16).padLeft(6, '0').toUpperCase(),
color: Color(0xFF000000 | rgb),
enabled: true,
editContext: 'preview',
submit: (value) async {
update(() => rgb = value);
return true;
},
),
),
),
),
);
}
@@ -0,0 +1,214 @@
import 'package:flutter/material.dart';
import 'package:cutdex/l10n/l10n.dart';
import 'package:cutdex_ui/theme.dart';
import 'package:flutter/widget_previews.dart';
class PropertyColorPicker extends StatefulWidget {
const PropertyColorPicker({
super.key,
required this.color,
required this.enabled,
required this.submit,
});
final Color color;
final bool enabled;
final Future<bool> Function(Color) submit;
@override
State<PropertyColorPicker> createState() => _PropertyColorPickerState();
}
class _PropertyColorPickerState extends State<PropertyColorPicker> {
late HSVColor _color = HSVColor.fromColor(widget.color);
@override
void didUpdateWidget(covariant PropertyColorPicker oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.color != oldWidget.color) {
_color = HSVColor.fromColor(widget.color);
}
}
Future<void> _commit() async {
if (!widget.enabled) return;
await widget.submit(_color.toColor());
if (mounted) setState(() => _color = HSVColor.fromColor(widget.color));
}
@override
Widget build(BuildContext context) => Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
context.l10n.color,
style: AppTheme.propertySectionTitleStyle(context),
),
const SizedBox(height: 12),
SizedBox(
height: 140,
child: LayoutBuilder(
builder: (context, constraints) {
final width = constraints.maxWidth;
const height = 140.0;
void update(Offset position) {
if (!widget.enabled) return;
setState(
() => _color = _color
.withSaturation((position.dx / width).clamp(0, 1))
.withValue((1 - position.dy / height).clamp(0, 1)),
);
}
return Semantics(
label: context.l10n.color,
child: GestureDetector(
key: const ValueKey('effect-color-plane'),
onTapDown: (details) => update(details.localPosition),
onTapUp: (_) => _commit(),
onPanStart: (details) => update(details.localPosition),
onPanUpdate: (details) => update(details.localPosition),
onPanEnd: (_) => _commit(),
child: ClipRRect(
borderRadius: BorderRadius.circular(5),
child: SizedBox(
height: height,
child: Stack(
children: [
Positioned.fill(
child: ColoredBox(
color: HSVColor.fromAHSV(
1,
_color.hue,
1,
1,
).toColor(),
),
),
const Positioned.fill(
child: DecoratedBox(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Colors.white, Color(0x00FFFFFF)],
),
),
),
),
const Positioned.fill(
child: DecoratedBox(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Colors.transparent, Colors.black],
),
),
),
),
Positioned(
left: (_color.saturation * width - 6).clamp(
0,
width - 12,
),
top: ((1 - _color.value) * height - 6).clamp(
0,
height - 12,
),
child: Container(
width: 12,
height: 12,
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(color: Colors.white, width: 2),
boxShadow: const [
BoxShadow(color: Colors.black54, blurRadius: 2),
],
),
),
),
],
),
),
),
),
);
},
),
),
const SizedBox(height: 8),
SizedBox(
height: 24,
child: Stack(
alignment: Alignment.center,
children: [
Container(
height: 12,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6),
gradient: const LinearGradient(
colors: [
Color(0xFFFF0000),
Color(0xFFFFFF00),
Color(0xFF00FF00),
Color(0xFF00FFFF),
Color(0xFF0000FF),
Color(0xFFFF00FF),
Color(0xFFFF0000),
],
),
),
),
SliderTheme(
data: SliderTheme.of(context).copyWith(
padding: EdgeInsets.zero,
trackHeight: 12,
activeTrackColor: Colors.transparent,
inactiveTrackColor: Colors.transparent,
thumbColor: Colors.white,
thumbShape: const RoundSliderThumbShape(enabledThumbRadius: 6),
overlayShape: SliderComponentShape.noOverlay,
),
child: Slider(
key: const ValueKey('effect-color-hue'),
min: 0,
max: 360,
value: _color.hue,
onChanged: widget.enabled
? (hue) => setState(() => _color = _color.withHue(hue))
: null,
onChangeEnd: (_) => _commit(),
),
),
],
),
),
],
);
}
@Preview(name: 'Property color picker', size: Size(240, 240))
Widget propertyColorPickerPreview() {
var color = const Color(0xFF3366FF);
return MaterialApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
theme: AppTheme.propertiesPanelTheme(
AppTheme.desktopWorkspaceTheme(AppTheme.penDark),
),
home: Scaffold(
body: Padding(
padding: const EdgeInsets.all(16),
child: StatefulBuilder(
builder: (context, update) => PropertyColorPicker(
color: color,
enabled: true,
submit: (value) async {
update(() => color = value);
return true;
},
),
),
),
),
);
}
@@ -0,0 +1,89 @@
import 'dart:async';
import 'package:cutdex_core/editor.dart';
import 'package:cutdex_preview/cutdex_preview.dart';
import 'package:cutdex_timeline_ui/cutdex_timeline_ui.dart';
import 'package:cutdex_core/timeline/engine.dart';
import 'package:cutdex_core/timeline/model.dart';
import '../../workspace/timeline_session.dart';
/// Shared pause, stale-context checks and diagnostics for inspector edits.
class PropertyEditBoundary {
PropertyEditBoundary(this.session, this.sequence, this.clip);
final EditorTimelineSession session;
final SequenceId sequence;
final ElementId clip;
bool _disposed = false;
bool _busy = false;
void dispose() => _disposed = true;
bool canRun(PreviewController? preview) =>
!_disposed &&
!_busy &&
session.activeSequenceId == sequence &&
preview?.transforms.hasPending != true;
Future<bool> run(
PreviewController? preview,
FutureOr<bool> Function(PropertyEditContext) action, {
required String operation,
bool Function()? isCurrent,
bool seek = false,
void Function()? started,
}) async {
if (!canRun(preview) || isCurrent?.call() == false) return false;
final view = session.view(sequence);
final target = PropertyEditContext._(
tick: view.playheadTick,
version: view.version.kernelVersion,
current: () =>
!_disposed &&
isCurrent?.call() != false &&
session.activeSequenceId == sequence &&
preview?.transforms.hasPending != true,
view: view,
);
_busy = true;
try {
started?.call();
await preview?.pauseForCanvasInteraction();
if (!target.isCurrent) return false;
if (seek) return await action(target);
return await session.runEditAsync(
operation,
sequence,
() async => action(target),
context: {
'clipIds': [clip.value],
'entryPoint': 'property',
'playheadTick': target.tick,
},
);
} finally {
_busy = false;
}
}
}
class PropertyEditContext {
PropertyEditContext._({
required this.tick,
required this._version,
required this._current,
required this._view,
});
final int tick;
final TimelineVersion _version;
final bool Function() _current;
final TimelineViewController _view;
/// Async operations check this again immediately before publication.
bool get isCurrent =>
_current() &&
_view.playheadTick == tick &&
identical(_view.version.kernelVersion, _version);
}
@@ -0,0 +1,84 @@
import 'package:cutdex_core/editor.dart';
import 'package:cutdex_preview/cutdex_preview.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:flutter/foundation.dart';
import 'property_edit_boundary.dart';
import '../../workspace/timeline_session.dart';
/// Owns the asynchronous edit boundary for one selected clip.
class PropertyEditController extends ChangeNotifier {
PropertyEditController({
required this.session,
required this.sequence,
required this.clip,
required this.projectId,
required this.timelineId,
required this.operation,
});
final EditorTimelineSession session;
final SequenceId sequence;
final ElementId clip;
final String projectId, timelineId, operation;
Object get identity => (session, sequence, clip, projectId, timelineId);
late final _boundary = PropertyEditBoundary(session, sequence, clip);
bool _disposed = false;
bool _saving = false;
bool _failed = false;
bool get saving => _saving;
bool get failed => _failed;
@override
void dispose() {
_disposed = true;
_boundary.dispose();
super.dispose();
}
ClipParameterAnimation? get animation {
final view = session.view(sequence);
final query = view.version.kernelVersion.query();
final handle = query.elementById(clip);
return handle == null
? null
: ClipParameterAnimation(
query.element(handle),
view.playheadTick - query.absoluteStart(handle),
);
}
Future<bool> run(
PreviewController? preview,
void Function(EditorCommandService, int) action, {
bool seek = false,
}) async {
if (_disposed || saving || !_boundary.canRun(preview)) return false;
try {
return await _boundary.run(
preview,
(target) {
action(session.commands, target.tick);
return true;
},
operation: operation,
seek: seek,
started: () {
_saving = true;
_failed = false;
notifyListeners();
},
);
} catch (_) {
if (!_disposed) {
_failed = true;
notifyListeners();
}
return false;
} finally {
if (!_disposed) {
_saving = false;
notifyListeners();
}
}
}
}
@@ -0,0 +1,105 @@
import 'dart:math' as math;
import 'package:cutdex/l10n/l10n.dart';
import 'package:cutdex_core/editor.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:cutdex_ui/icons.dart';
import 'package:cutdex_ui/widgets.dart';
import 'package:flutter/material.dart';
typedef PropertyKeyframeEdit = Future<bool> Function(
List<String> ids, {
KeyframeAction? action,
ParameterInterpolation? interpolation,
});
/// Keyframe controls share channel state and intent callbacks across property fields.
class PropertyKeyframeControls {
const PropertyKeyframeControls({
required this.stack,
required this.enabled,
required this.onEdit,
required this.onSeek,
});
final ClipParameterAnimation stack;
final bool enabled;
final PropertyKeyframeEdit onEdit;
final Future<bool> Function(int localTick) onSeek;
Widget button(
BuildContext context,
List<String> ids,
String label,
String id,
) => IconButton(
key: ValueKey(id),
tooltip: context.l10n.toggleKeyframe(
stack.keyed(ids) ? context.l10n.delete : context.l10n.addKeyframeAction,
label,
),
isSelected: stack.keyed(ids),
color: stack.animated(ids) ? Theme.of(context).colorScheme.primary : null,
icon: Transform.rotate(
angle: math.pi / 4,
child: Icon(
stack.keyed(ids) ? AppIcons.squareFilled : AppIcons.square,
size: 12,
),
),
onPressed: enabled && ids.isNotEmpty ? () => onEdit(ids) : null,
);
Widget menu(BuildContext context, List<String> ids, String label, String id) {
final offsets = stack.keyOffsets(ids);
final currentTick = stack.localTick;
final previous = offsets.where((t) => t < currentTick).lastOrNull;
final next = offsets.where((t) => t > currentTick).firstOrNull;
return AppDropdownMenu(
enabled: enabled,
builder: (context, toggle, focus) => IconButton(
key: ValueKey('$id-menu'),
focusNode: focus,
tooltip: context.l10n.keyframeSettings(label),
onPressed: enabled ? toggle : null,
icon: const Icon(AppIcons.more, size: 16),
),
items: [
AppMenuItem(
closeAncestors: false,
label: context.l10n.previousKeyframe(label),
onPressed: previous == null ? null : () => onSeek(previous),
),
AppMenuItem(
closeAncestors: false,
label: context.l10n.nextKeyframe(label),
onPressed: next == null ? null : () => onSeek(next),
),
for (final (mode, text) in [
(ParameterInterpolation.linear, context.l10n.linear),
(ParameterInterpolation.hold, context.l10n.hold),
(ParameterInterpolation.easeIn, context.l10n.easeIn),
(ParameterInterpolation.easeOut, context.l10n.easeOut),
(ParameterInterpolation.easeInOut, context.l10n.easeInOut),
])
AppMenuItem(
closeAncestors: false,
label: text,
onPressed: stack.keyed(ids)
? () => onEdit(
ids,
action: KeyframeAction.set,
interpolation: mode,
)
: null,
),
AppMenuItem(
closeAncestors: false,
label: context.l10n.removeAllKeyframes,
onPressed: stack.animated(ids)
? () => onEdit(ids, action: KeyframeAction.clear)
: null,
),
],
);
}
}
@@ -0,0 +1,288 @@
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';
import 'package:flutter/services.dart';
import 'package:flutter/widget_previews.dart';
class PropertyLayerRow extends StatefulWidget {
const PropertyLayerRow({
super.key,
required this.id,
required this.prefix,
required this.index,
required this.enabled,
required this.visible,
required this.label,
required this.tooltip,
required this.onVisibility,
required this.onRemove,
required this.menuItems,
required this.editor,
this.leading,
this.editorLabel,
});
final String id, prefix, label, tooltip;
final int index;
final bool enabled, visible;
final VoidCallback onVisibility, onRemove;
final List<AppMenuItem> menuItems;
final Widget editor;
final Widget? leading;
final String? editorLabel;
@override
State<PropertyLayerRow> createState() => _PropertyLayerRowState();
}
class _PropertyLayerRowState extends State<PropertyLayerRow> {
final _menu = MenuController();
final _focus = FocusNode();
bool _hovered = false;
@override
void dispose() {
_focus.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final colors = theme.colorScheme;
return MenuAnchor(
controller: _menu,
childFocusNode: _focus,
clipBehavior: Clip.none,
// Place the editor beside the inspector, as in Figma's effects panel.
alignmentOffset: Offset(
-240 - 8 - AppTheme.propertySectionPadding(context).left,
0,
),
style: const MenuStyle(
alignment: AlignmentDirectional.topStart,
padding: WidgetStatePropertyAll(EdgeInsets.zero),
backgroundColor: WidgetStatePropertyAll(Colors.transparent),
surfaceTintColor: WidgetStatePropertyAll(Colors.transparent),
elevation: WidgetStatePropertyAll(0),
side: WidgetStatePropertyAll(BorderSide.none),
shape: WidgetStatePropertyAll(
RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(8)),
),
),
),
onOpen: () => setState(() {}),
onClose: () => setState(() {}),
menuChildren: [
SizedBox(
key: ValueKey('${widget.prefix}-editor-${widget.id}'),
width: 240,
child: Material(
color: colors.surfaceContainerLow,
surfaceTintColor: Colors.transparent,
elevation: 8,
shadowColor: colors.shadow.withValues(alpha: .25),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
side: BorderSide(color: colors.outlineVariant),
),
clipBehavior: Clip.antiAlias,
child: Focus(
autofocus: true,
onKeyEvent: (_, event) {
if (event is KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.escape) {
_menu.close();
return KeyEventResult.handled;
}
return KeyEventResult.ignored;
},
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(
height: 40,
child: Padding(
padding: const EdgeInsets.only(left: 16, right: 8),
child: Row(
children: [
Expanded(
child: Text(
widget.editorLabel ?? widget.label,
style: AppTheme.propertySectionTitleStyle(
context,
),
),
),
AppDropdownMenu(
builder: (context, toggle, focus) => IconButton(
focusNode: focus,
tooltip: widget.tooltip,
icon: const Icon(AppIcons.more, size: 16),
onPressed: toggle,
),
items: widget.menuItems,
),
IconButton(
key: ValueKey(
'${widget.prefix}-editor-close-${widget.id}',
),
tooltip: context.l10n.close,
icon: const Icon(AppIcons.close, size: 16),
onPressed: _menu.close,
),
],
),
),
),
Divider(height: 1, color: theme.dividerColor),
Padding(
padding: const EdgeInsets.fromLTRB(16, 12, 16, 12),
child: ConstrainedBox(
constraints: BoxConstraints(
maxHeight: (MediaQuery.sizeOf(context).height - 120)
.clamp(80, 600),
),
child: SingleChildScrollView(
primary: false,
child: widget.editor,
),
),
),
],
),
),
),
),
],
builder: (context, controller, child) => MouseRegion(
onEnter: (_) => setState(() => _hovered = true),
onExit: (_) => setState(() => _hovered = false),
child: SizedBox(
height: AppInspectorMetrics.row,
child: Row(
children: [
ReorderableDragStartListener(
key: ValueKey('${widget.prefix}-drag-${widget.id}'),
index: widget.index,
enabled: widget.enabled,
child: MouseRegion(
cursor: widget.enabled
? SystemMouseCursors.grab
: SystemMouseCursors.basic,
child: SizedBox(
width: 16,
child: Icon(
AppIcons.dragHandle,
size: 12,
color: _hovered
? colors.onSurfaceVariant
: Colors.transparent,
),
),
),
),
Expanded(
child: TextButton(
key: ValueKey('${widget.prefix}-settings-${widget.id}'),
focusNode: _focus,
style: TextButton.styleFrom(
padding: const EdgeInsets.symmetric(horizontal: 4),
minimumSize: const Size(0, 24),
maximumSize: const Size(double.infinity, 24),
backgroundColor: controller.isOpen
? theme.inputDecorationTheme.fillColor
: null,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5),
),
foregroundColor: widget.visible
? colors.onSurface
: colors.onSurfaceVariant,
textStyle: AppTheme.inputTextStyle(context),
),
onPressed: () => controller.isOpen
? controller.close()
: controller.open(),
child: Row(
children: [
widget.leading ??
const Icon(PhosphorIconsRegular.sun, size: 16),
const SizedBox(width: 8),
Expanded(
child: Text(
widget.label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
],
),
),
),
IconButton(
key: ValueKey('${widget.prefix}-enabled-${widget.id}'),
tooltip: widget.visible
? context.l10n.disable
: context.l10n.enable,
icon: Icon(
widget.visible
? Icons.visibility_outlined
: Icons.visibility_off_outlined,
size: 16,
),
onPressed: widget.enabled ? widget.onVisibility : null,
),
IconButton(
key: ValueKey('${widget.prefix}-remove-${widget.id}'),
tooltip: context.l10n.delete,
icon: const Icon(AppIcons.remove, size: 16),
onPressed: widget.enabled ? widget.onRemove : null,
),
],
),
),
),
);
}
}
@Preview(name: 'Effect row / desktop', size: Size(560, 480))
Widget effectRowPreview() => MaterialApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
theme: AppTheme.propertiesPanelTheme(
AppTheme.desktopWorkspaceTheme(AppTheme.penDark),
),
home: Scaffold(
body: Align(
alignment: Alignment.topRight,
child: SizedBox(
width: 240,
child: ReorderableListView(
shrinkWrap: true,
onReorderItem: (_, _) {},
buildDefaultDragHandles: false,
children: [
PropertyLayerRow(
key: const ValueKey('preview-effect'),
id: 'preview',
prefix: 'effect',
index: 0,
enabled: true,
visible: true,
label: 'Drop shadow',
tooltip: 'Effects',
onVisibility: () {},
onRemove: () {},
menuItems: const [],
editor: const Text('X 0 Y 4 Blur 8'),
),
],
),
),
),
),
);
@@ -19,6 +19,8 @@ class PropertyNumberInput extends StatefulWidget {
this.inlineLabel = false,
this.prefix,
this.prefixIcon,
this.prefixQuarterTurns = 0,
this.valueText,
this.labelActions = const [],
this.decimalPlaces = 2,
this.onScrubStart,
@@ -33,6 +35,8 @@ class PropertyNumberInput extends StatefulWidget {
final bool inlineLabel;
final String? prefix;
final IconData? prefixIcon;
final int prefixQuarterTurns;
final String? valueText;
final List<Widget> labelActions;
final int decimalPlaces;
final bool Function()? onScrubStart;
@@ -50,11 +54,12 @@ class PropertyNumberInput extends StatefulWidget {
}
class _PropertyNumberInputState extends State<PropertyNumberInput> {
late final _text = TextEditingController(text: _format(widget.value));
late final _text = TextEditingController(text: _displayValue);
final _focus = FocusNode();
bool _dirty = false;
late final _operations = OperationScope<Object>(widget.editContext);
String? _error;
String get _displayValue => widget.valueText ?? _format(widget.value);
String _format(double value) {
var text = value.toStringAsFixed(widget.decimalPlaces);
if (text.contains('.')) text = text.replaceFirst(RegExp(r'\.?0+$'), '');
@@ -84,7 +89,7 @@ class _PropertyNumberInputState extends State<PropertyNumberInput> {
if (!mounted || !isCurrent()) return;
setState(() {
_error = accepted ? null : context.l10n.notApplied;
_text.text = _format(widget.value);
_text.text = _displayValue;
});
}
@@ -98,7 +103,7 @@ class _PropertyNumberInputState extends State<PropertyNumberInput> {
_dirty = false;
_error = null;
}
final text = _format(widget.value);
final text = _displayValue;
// A no-op assignment still resets selection and asks EditableText to
// reveal its caret, competing with the user's scroll on preview updates.
if (!_dirty && _text.text != text) _text.text = text;
@@ -115,8 +120,8 @@ class _PropertyNumberInputState extends State<PropertyNumberInput> {
@override
Widget build(BuildContext context) {
final labelAbove =
AppTheme.isCompactInspector(context) && !widget.inlineLabel;
final compact = AppTheme.isCompactInspector(context);
final labelAbove = compact && !widget.inlineLabel;
final label = widget.onScrubStart == null
? Text(widget.label ?? '', style: AppTheme.propertyLabelStyle(context))
: AppScrubLabel(
@@ -126,7 +131,7 @@ class _PropertyNumberInputState extends State<PropertyNumberInput> {
? AppTheme.propertySectionTitleStyle(context)
: null,
alignment: labelAbove ? Alignment.centerLeft : Alignment.center,
padding: labelAbove
padding: labelAbove || compact
? EdgeInsets.zero
: const EdgeInsets.symmetric(horizontal: AppSpacing.small),
enabled: widget.enabled && (!widget.readOnly || widget.scrubbing),
@@ -134,7 +139,7 @@ class _PropertyNumberInputState extends State<PropertyNumberInput> {
_operations.invalidate();
_dirty = false;
_error = null;
_text.text = _format(widget.value);
_text.text = _displayValue;
return widget.onScrubStart!();
},
onUpdate: widget.onScrubUpdate,
@@ -154,7 +159,17 @@ class _PropertyNumberInputState extends State<PropertyNumberInput> {
label: widget.label,
labelAbove: labelAbove,
labelActions: widget.labelActions,
leading: widget.onScrubStart == null ? null : label,
leading: widget.onScrubStart == null
? null
: compact && !labelAbove
? SizedBox(
width: AppInspectorMetrics.action,
child: RotatedBox(
quarterTurns: widget.prefixQuarterTurns,
child: label,
),
)
: label,
unit: widget.unit,
errorText: _error,
onChanged: (_) {
@@ -173,7 +188,7 @@ class _PropertyNumberInputState extends State<PropertyNumberInput> {
_operations.invalidate();
_dirty = false;
_error = null;
_text.text = _format(widget.value);
_text.text = _displayValue;
});
_focus.unfocus();
return KeyEventResult.handled;
@@ -4,10 +4,10 @@ import 'package:cutdex/shared/widgets/error_notification_host.dart';
import 'dart:math' as math;
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_sdk/timeline/engine.dart';
import 'package:cutdex_sdk/timeline/layout.dart';
import 'package:cutdex_sdk/timeline/model.dart';
import 'package:cutdex_core/editor.dart';
import 'package:cutdex_core/timeline/engine.dart';
import 'package:cutdex_core/timeline/layout.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:flutter/material.dart';
import '../../l10n/l10n.dart';
@@ -204,15 +204,14 @@ class _SpeedPropertiesState extends State<SpeedProperties> {
_version == null || identical(_version, view.version.kernelVersion)
? _timeline ?? saved ?? 1
: saved ?? 1;
return Padding(
padding: AppTheme.propertySectionPadding(context),
return AppPropertySection(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
ConstrainedBox(
constraints: BoxConstraints(
minHeight: AppTheme.isDesktop(context)
? AppInspectorMetrics.action
? AppInspectorMetrics.sectionHeader
: AppControlSize.propertyControl,
),
child: Row(
+136
View File
@@ -0,0 +1,136 @@
import 'package:cutdex/l10n/l10n.dart';
import 'package:cutdex_core/editor.dart';
import 'package:cutdex_ui/icons.dart';
import 'package:cutdex_ui/widgets.dart';
import 'package:flutter/material.dart';
import 'property_keyframe_controls.dart';
import 'property_layer_row.dart';
class StrokeList extends StatelessWidget {
const StrokeList({
super.key,
required this.stack,
required this.enabled,
required this.keyframes,
required this.onAdd,
required this.onReorder,
required this.onToggle,
required this.onRemove,
required this.editorBuilder,
this.error,
});
final ClipStrokeStack stack;
final bool enabled;
final PropertyKeyframeControls keyframes;
final VoidCallback onAdd;
final void Function(List<String>) onReorder;
final void Function(ClipStrokeLayer) onToggle, onRemove;
final Widget Function(ClipStrokeLayer) editorBuilder;
final String? error;
@override
Widget build(BuildContext context) {
final layers = stack.layers;
return AppPropertySection(
bottomSpacing: layers.isEmpty ? 0 : null,
child: AppPropertyGroup(
label: context.l10n.strokes,
padChild: false,
actions: [
keyframes.button(
context,
stack.parameterIds,
context.l10n.strokes,
'strokes-key',
),
IconButton(
key: const ValueKey('stroke-add'),
tooltip: context.l10n.addStroke,
onPressed: enabled && stack.canAdd ? onAdd : null,
icon: const Icon(AppIcons.add, size: 16),
),
],
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
ReorderableListView(
shrinkWrap: true,
primary: false,
padding: EdgeInsets.zero,
physics: const NeverScrollableScrollPhysics(),
buildDefaultDragHandles: false,
onReorderItem: (from, to) {
if (!enabled) return;
final order = layers.map((l) => l.id).toList();
order.insert(to, order.removeAt(from));
onReorder(order);
},
children: [
for (var i = 0; i < layers.length; i++)
PropertyLayerRow(
key: ValueKey('stroke-layer-${layers[i].id}'),
id: layers[i].id,
prefix: 'stroke',
index: i,
enabled: enabled,
visible: layers[i].enabled,
label:
'${layers[i].values['width']!.toStringAsFixed(layers[i].values['width']! % 1 == 0 ? 0 : 1)} · ${(layers[i].values['opacity']! * 100).round()}%',
editorLabel: context.l10n.stroke,
leading: Container(
width: 16,
height: 16,
decoration: BoxDecoration(
color: Color.from(
alpha: layers[i].values['opacity']!,
red: layers[i].values['color.r']!,
green: layers[i].values['color.g']!,
blue: layers[i].values['color.b']!,
),
borderRadius: BorderRadius.circular(3),
border: Border.all(
color: Theme.of(context).colorScheme.outlineVariant,
),
),
),
tooltip: context.l10n.strokes,
onVisibility: () => onToggle(layers[i]),
onRemove: () => onRemove(layers[i]),
menuItems: [
for (final (delta, label) in [
(-1, context.l10n.effectMoveUp),
(1, context.l10n.effectMoveDown),
])
AppMenuItem(
label: label,
closeAncestors: false,
onPressed:
!enabled ||
i + delta < 0 ||
i + delta >= layers.length
? null
: () {
final order = layers
.map((l) => l.id)
.toList();
order.insert(i + delta, order.removeAt(i));
onReorder(order);
},
),
],
editor: editorBuilder(layers[i]),
),
],
),
if (error != null)
Text(
error!,
style: TextStyle(color: Theme.of(context).colorScheme.error),
),
],
),
),
);
}
}
@@ -0,0 +1,226 @@
import 'package:cutdex/l10n/l10n.dart';
import 'package:cutdex_core/editor.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 'package:cutdex_core/timeline/model.dart';
import 'package:cutdex_core/timeline/engine.dart';
import 'property_keyframe_controls.dart';
import 'property_color_input.dart';
import 'property_number_input.dart';
class StrokeParameterEditor extends StatelessWidget {
const StrokeParameterEditor({
super.key,
required this.layer,
required this.stack,
required this.enabled,
required this.editContext,
required this.keyframes,
required this.onChange,
});
final ClipStrokeLayer layer;
final ClipStrokeStack stack;
final bool enabled;
final Object editContext;
final PropertyKeyframeControls keyframes;
final Future<bool> Function(Map<String, double>) onChange;
String _fieldLabel(BuildContext context, String field) => switch (field) {
'width' => context.l10n.strokeWidth,
'opacity' => context.l10n.shadowOpacity,
'dashLength' => context.l10n.strokeDashLength,
'dashGap' => context.l10n.strokeDashGap,
_ => field,
};
Widget _number(BuildContext context, String field) {
final label = _fieldLabel(context, field);
final structural = StrokeParameterTarget.structural.contains(field);
final percentage = {
'opacity',
'density',
'lightIntensity',
'splay',
}.contains(field);
final factor = percentage ? 100.0 : 1.0;
final definition = StrokeParameterTarget.definition(field);
return Padding(
padding: const EdgeInsets.only(bottom: 4),
child: Row(
children: [
Expanded(
child: PropertyNumberInput(
key: ValueKey('stroke-${layer.id}-$field'),
label: label,
value: layer.values[field]! * factor,
unit: percentage ? '%' : null,
enabled: enabled && layer.enabled,
readOnly: false,
scrubbing: false,
editContext: (editContext, layer.id),
onScrubUpdate: (_) {},
onScrubEnd: () {},
onScrubCancel: () {},
submit: (v) => !definition.accepts(v / factor)
? Future.value(false)
: onChange({field: v / factor}),
),
),
if (!structural) ...[
keyframes.button(
context,
[layer.target(field)],
label,
'stroke-${layer.id}-$field-key',
),
keyframes.menu(
context,
[layer.target(field)],
label,
'stroke-${layer.id}-$field',
),
] else
const SizedBox(width: 48),
],
),
);
}
Widget _color(BuildContext context, String prefix, String label) {
final fields = ['${prefix}r', '${prefix}g', '${prefix}b'];
final values = fields.map((f) => layer.values[f]!).toList();
final hex = values
.map((v) => (v * 255).round().toRadixString(16).padLeft(2, '0'))
.join()
.toUpperCase();
final ids = fields.map(layer.target).toList();
return Padding(
padding: const EdgeInsets.only(bottom: 4),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(label, style: AppTheme.propertyLabelStyle(context)),
Row(
children: [
Expanded(
child: PropertyColorInput(
key: ValueKey('stroke-${layer.id}-$prefix'),
value: hex,
color: Color.from(
alpha: 1,
red: values[0],
green: values[1],
blue: values[2],
),
enabled: enabled && layer.enabled,
editContext: (editContext, layer.id),
submit: (rgb) => onChange({
fields[0]: ((rgb >> 16) & 255) / 255,
fields[1]: ((rgb >> 8) & 255) / 255,
fields[2]: (rgb & 255) / 255,
}),
),
),
keyframes.button(
context,
ids,
label,
'stroke-${layer.id}-$prefix-key',
),
keyframes.menu(context, ids, label, 'stroke-${layer.id}-$prefix'),
],
),
],
),
);
}
Widget _mode(BuildContext context, String field, List<String> labels) =>
Padding(
padding: const EdgeInsets.only(bottom: 8),
child: SizedBox(
height: 24,
child: AppSelect<int>(
closeAncestors: false,
key: ValueKey('stroke-${layer.id}-$field'),
value: layer.values[field]!.round(),
label: field == 'alignment'
? context.l10n.alignment
: context.l10n.strokeStyle,
emptyLabel: context.l10n.strokes,
options: [
for (var i = 0; i < labels.length; i++)
AppSelectOption(i, labels[i]),
],
onChanged: enabled && layer.enabled
? (v) => onChange({field: v.toDouble()})
: null,
),
),
);
@override
Widget build(BuildContext context) => Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
_color(context, 'color.', context.l10n.color),
_number(context, 'opacity'),
_number(context, 'width'),
_mode(context, 'alignment', [
context.l10n.strokeInside,
context.l10n.strokeCenter,
context.l10n.strokeOutside,
]),
_mode(context, 'style', [
context.l10n.strokeSolid,
context.l10n.strokeDashed,
]),
if (layer.style == ClipStrokeStyle.dashed) ...[
_number(context, 'dashLength'),
_number(context, 'dashGap'),
],
],
);
}
@Preview(name: 'Stroke editor / desktop', size: Size(240, 360))
Widget strokeEditorPreview() {
final stack = ClipStrokeStack(
ElementRecord(
id: ElementId('preview'),
structure: ElementStructure.content,
duration: 1,
sourceStart: 0,
sourceDuration: 1,
enabled: true,
),
0,
);
return MaterialApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
theme: AppTheme.propertiesPanelTheme(
AppTheme.desktopWorkspaceTheme(AppTheme.penDark),
),
home: Scaffold(
body: Padding(
padding: const EdgeInsets.all(16),
child: StrokeParameterEditor(
layer: const ClipStrokeLayer(id: 'preview', values: strokeDefaults),
stack: stack,
enabled: true,
editContext: 'preview',
keyframes: PropertyKeyframeControls(
stack: stack,
enabled: true,
onEdit: (ids, {action, interpolation}) async => true,
onSeek: (_) async => true,
),
onChange: (_) async => true,
),
),
),
);
}
@@ -0,0 +1,162 @@
import 'package:cutdex/l10n/l10n.dart';
import 'package:cutdex_core/editor.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../workspace/timeline_session.dart';
import '../preview/preview_panel.dart';
import 'property_edit_controller.dart';
import 'property_keyframe_controls.dart';
import 'stroke_list.dart';
import 'stroke_parameter_editor.dart';
class StrokeProperties extends ConsumerStatefulWidget {
const StrokeProperties({
super.key,
required this.projectId,
required this.timelineId,
required this.session,
required this.sequence,
required this.clip,
});
final String projectId, timelineId;
final EditorTimelineSession session;
final SequenceId sequence;
final ElementId clip;
@override
ConsumerState<StrokeProperties> createState() => _StrokePropertiesState();
}
class _StrokePropertiesState extends ConsumerState<StrokeProperties> {
Object get _identity => (
widget.session,
widget.sequence,
widget.clip,
widget.projectId,
widget.timelineId,
);
PropertyEditController _createController() => PropertyEditController(
session: widget.session,
sequence: widget.sequence,
clip: widget.clip,
projectId: widget.projectId,
timelineId: widget.timelineId,
operation: 'editStroke',
);
late PropertyEditController _controller = _createController();
@override
void didUpdateWidget(covariant StrokeProperties oldWidget) {
super.didUpdateWidget(oldWidget);
if (_controller.identity != _identity) {
_controller.dispose();
_controller = _createController();
}
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final preview = ref
.watch(editorPreviewProvider(widget.projectId, widget.timelineId))
.asData
?.value;
final controller = _controller;
final view = widget.session.view(widget.sequence);
return ListenableBuilder(
listenable: Listenable.merge([controller, view]),
builder: (context, _) {
final animation = controller.animation;
if (animation == null) return const SizedBox.shrink();
final stack = ClipStrokeStack(animation.record, animation.localTick);
final enabled =
!controller.saving &&
stack.containsPlayhead &&
preview?.transforms.hasPending != true;
Future<bool> edit(void Function(EditorCommandService, int) action) =>
controller.run(preview, action);
final keyframes = PropertyKeyframeControls(
stack: stack,
enabled: enabled,
onEdit: (ids, {action, interpolation}) => edit(
(c, t) => c.editKeyframeChannel(
sequence: widget.sequence,
clip: widget.clip,
tick: t,
parameterIds: ids,
action: action,
interpolation: interpolation,
),
),
onSeek: (offset) => controller.run(
preview,
(_, tick) => view.seekTo(tick - stack.localTick + offset),
seek: true,
),
);
return StrokeList(
stack: stack,
enabled: enabled,
keyframes: keyframes,
error: controller.failed ? context.l10n.updateStrokeFailed : null,
onAdd: () => edit(
(c, t) => c.addStroke(
sequence: widget.sequence,
clip: widget.clip,
tick: t,
strokeId: c.newStrokeId(),
),
),
onReorder: (order) => edit(
(c, t) => c.configureStrokes(
sequence: widget.sequence,
clip: widget.clip,
tick: t,
order: order,
),
),
onToggle: (layer) => edit(
(c, t) => c.configureStrokes(
sequence: widget.sequence,
clip: widget.clip,
tick: t,
strokeId: layer.id,
enabled: !layer.enabled,
),
),
onRemove: (layer) => edit(
(c, t) => c.removeStroke(
sequence: widget.sequence,
clip: widget.clip,
tick: t,
strokeId: layer.id,
),
),
editorBuilder: (layer) => StrokeParameterEditor(
layer: layer,
stack: stack,
enabled: enabled,
editContext: controller.identity,
keyframes: keyframes,
onChange: (values) => edit(
(c, t) => c.setStroke(
sequence: widget.sequence,
clip: widget.clip,
tick: t,
strokeId: layer.id,
values: values,
),
),
),
);
},
);
}
}
@@ -27,8 +27,8 @@ class AppearanceSettings extends _$AppearanceSettings {
Future<void> setMode(AppAppearance appearance) => _writes.run(() async {
if (!ref.mounted) return;
await future;
if (!ref.mounted) return;
final current = await future;
if (!ref.mounted || current == appearance) return;
await ref.read(appearanceSettingsRepositoryProvider).save(appearance);
if (ref.mounted) state = AsyncData(appearance);
});
@@ -44,8 +44,8 @@ class PaletteSettings extends _$PaletteSettings {
Future<void> setPalette(AppPalette palette) => _writes.run(() async {
if (!ref.mounted) return;
await future;
if (!ref.mounted) return;
final current = await future;
if (!ref.mounted || current == palette) return;
await ref.read(paletteSettingsRepositoryProvider).save(palette);
if (ref.mounted) state = AsyncData(palette);
});
@@ -34,7 +34,7 @@ final class AppearanceSettingsProvider
}
String _$appearanceSettingsHash() =>
r'df889bcd3ec16a726ebc1bccd98b9e7033989a69';
r'c540755d69e4441b38db07394df144a0fc3544da';
abstract class _$AppearanceSettings extends $AsyncNotifier<AppAppearance> {
FutureOr<AppAppearance> build();
@@ -78,7 +78,7 @@ final class PaletteSettingsProvider
PaletteSettings create() => PaletteSettings();
}
String _$paletteSettingsHash() => r'95eecd4a35c8de3afbf6c94b1e13f282acb0f4ff';
String _$paletteSettingsHash() => r'8676c4ef0be0ce7132da7c53b9694da56e9c658d';
abstract class _$PaletteSettings extends $AsyncNotifier<AppPalette> {
FutureOr<AppPalette> build();
+2 -2
View File
@@ -89,8 +89,8 @@ class LanguageSettings extends _$LanguageSettings {
Future<void> setLanguage(AppLanguage language) => _writes.run(() async {
if (!ref.mounted) return;
await future;
if (!ref.mounted) return;
final current = await future;
if (!ref.mounted || current == language) return;
await ref.read(languageSettingsRepositoryProvider).save(language);
if (ref.mounted) state = AsyncData(language);
});
@@ -33,7 +33,7 @@ final class LanguageSettingsProvider
LanguageSettings create() => LanguageSettings();
}
String _$languageSettingsHash() => r'fcd5bb7f010ea5bb09f9743d9023cd1668214f43';
String _$languageSettingsHash() => r'6a1989abb393d00e262506572b1dfdd5b09be6c4';
abstract class _$LanguageSettings extends $AsyncNotifier<AppLanguage> {
FutureOr<AppLanguage> build();
@@ -1,10 +1,12 @@
import 'package:cutdex_sdk/timeline_ui.dart' show TimelineRulerTimecodeLayout;
import 'package:cutdex_timeline_ui/cutdex_timeline_ui.dart'
show TimelineRulerTimecodeLayout;
import 'package:riverpod_annotation/riverpod_annotation.dart';
import '../../persistence/settings/timeline_ruler_settings_repository.dart';
import '../../settings/settings_write_queue.dart';
export 'package:cutdex_sdk/timeline_ui.dart' show TimelineRulerTimecodeLayout;
export 'package:cutdex_timeline_ui/cutdex_timeline_ui.dart'
show TimelineRulerTimecodeLayout;
part 'timeline_ruler_settings.g.dart';
@@ -19,8 +21,8 @@ class TimelineRulerSettings extends _$TimelineRulerSettings {
Future<void> setLayout(TimelineRulerTimecodeLayout layout) =>
_writes.run(() async {
if (!ref.mounted) return;
await future;
if (!ref.mounted) return;
final current = await future;
if (!ref.mounted || current == layout) return;
await ref.read(timelineRulerSettingsRepositoryProvider).save(layout);
if (ref.mounted) state = AsyncData(layout);
});
@@ -38,7 +38,7 @@ final class TimelineRulerSettingsProvider
}
String _$timelineRulerSettingsHash() =>
r'26aef397f2aee8114b1d1229bb1c0b3f7a377f73';
r'4917c2ec4b2aa715c9e0e2a45cd05adb66ae6089';
abstract class _$TimelineRulerSettings
extends $AsyncNotifier<TimelineRulerTimecodeLayout> {
@@ -1,4 +1,4 @@
import 'package:cutdex_sdk/timeline_ui.dart';
import 'package:cutdex_timeline_ui/cutdex_timeline_ui.dart';
import 'package:cutdex_ui/theme.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
@@ -1,4 +1,4 @@
import 'package:cutdex_sdk/timeline/model.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
@@ -2,10 +2,10 @@ import 'package:cutdex/errors/app_failure.dart';
import 'dart:async';
import 'package:cutdex_sdk/project.dart';
import 'package:cutdex_core/project.dart';
import 'package:flutter/foundation.dart';
import 'package:cutdex_sdk/runtime.dart';
import 'package:cutdex_sdk/timeline/model.dart';
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
@@ -3,11 +3,11 @@ import 'package:cutdex/errors/app_failure.dart';
import 'dart:async';
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_sdk/project.dart';
import 'package:cutdex_sdk/timeline/layout.dart';
import 'package:cutdex_sdk/timeline/model.dart';
import 'package:cutdex_sdk/timeline_ui.dart';
import 'package:cutdex_core/editor.dart';
import 'package:cutdex_core/project.dart';
import 'package:cutdex_core/timeline/layout.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:cutdex_timeline_ui/cutdex_timeline_ui.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
+13 -11
View File
@@ -2,13 +2,13 @@ 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/timeline/engine.dart';
import 'package:cutdex_sdk/timeline/layout.dart';
import 'package:cutdex_sdk/timeline/model.dart';
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_sdk/project.dart';
import 'package:cutdex_core/timeline/engine.dart';
import 'package:cutdex_core/timeline/layout.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:cutdex_core/editor.dart';
import 'package:cutdex_core/project.dart';
import 'package:cutdex_sdk/timeline_ui.dart';
import 'package:cutdex_timeline_ui/cutdex_timeline_ui.dart';
import '../../shared/widgets/listenable_selector.dart';
import '../../workspace/timeline_provider.dart';
@@ -411,7 +411,7 @@ class _TimelineTabsBarState extends ConsumerState<_TimelineTabsBar> {
controller: _scrollController,
scrollDirection: Axis.horizontal,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.tiny),
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.small),
child: Row(
children: [
for (
@@ -419,7 +419,7 @@ class _TimelineTabsBarState extends ConsumerState<_TimelineTabsBar> {
index < widget.timelines.length;
index++
) ...[
if (index > 0) const SizedBox(width: AppSpacing.hairline),
if (index > 0) const SizedBox(width: AppSpacing.tiny),
_buildTab(context, widget.timelines[index]),
],
],
@@ -497,7 +497,7 @@ class _TimelineTabsBarState extends ConsumerState<_TimelineTabsBar> {
),
Padding(
padding: EdgeInsetsDirectional.only(
end: desktop ? AppSpacing.tiny : 0,
end: desktop ? AppSpacing.small : 0,
),
child: listButton,
),
@@ -538,7 +538,7 @@ class _TimelineTabsBarState extends ConsumerState<_TimelineTabsBar> {
),
],
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 3),
padding: const EdgeInsets.symmetric(vertical: 4),
child: Semantics(
selected: selected,
child: ConstrainedBox(
@@ -934,7 +934,9 @@ class _TimelineEditorState extends State<_TimelineEditor> {
? AppDesktopMetrics.timelineToolbar
: 32,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
padding: const EdgeInsets.symmetric(
horizontal: AppSpacing.medium,
),
child: AppCommandToolbar(
groups: [
[
@@ -1,7 +1,7 @@
import 'package:cutdex_sdk/timeline/engine.dart';
import 'package:cutdex_sdk/timeline/layout.dart';
import 'package:cutdex_sdk/timeline/model.dart';
import 'package:cutdex_sdk/timeline_ui.dart';
import 'package:cutdex_core/timeline/engine.dart';
import 'package:cutdex_core/timeline/layout.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:cutdex_timeline_ui/cutdex_timeline_ui.dart';
import 'package:cutdex_ui/icons.dart';
import 'package:cutdex_ui/theme.dart';
import 'package:flutter/material.dart';
@@ -4,11 +4,11 @@ import 'package:cutdex/shared/widgets/error_notification_host.dart';
import 'dart:math' as math;
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_sdk/timeline/engine.dart';
import 'package:cutdex_sdk/timeline/layout.dart';
import 'package:cutdex_sdk/timeline/model.dart';
import 'package:cutdex_sdk/timeline_ui.dart';
import 'package:cutdex_core/editor.dart';
import 'package:cutdex_core/timeline/engine.dart';
import 'package:cutdex_core/timeline/layout.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:cutdex_timeline_ui/cutdex_timeline_ui.dart';
import 'package:flutter/material.dart';
import '../../l10n/l10n.dart';
@@ -148,12 +148,9 @@ class TimelineSpeedEditor extends StatelessWidget {
}
for (var index = 0; index < frame.length; index++) {
if (frame.kindAt(index) == TimelineViewportItemKind.transition) {
continue;
}
final identity = frame.identityAt(index);
final handle = controller.elementForIdentity(identity);
final handle = controller.elementForFrameItem(frame, index);
if (handle == null) continue;
final identity = frame.identityAt(index);
final bodyId = identity is LayoutBodyId
? identity
: LayoutBodyId.element(handle);
@@ -1,8 +1,8 @@
import 'dart:math' as math;
import 'dart:ui';
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_sdk/timeline_ui.dart';
import 'package:cutdex_core/editor.dart';
import 'package:cutdex_timeline_ui/cutdex_timeline_ui.dart';
/// Speed segments in the clip's local coordinates. Paint and hit targets use
/// the same cells, including the minimum pixel width and clipping at low zoom.
@@ -1,6 +1,6 @@
import 'dart:convert';
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_core/editor.dart';
import 'package:cutdex_agent/cutdex_agent.dart';
/// Deterministic, read-only acceptance for explicitly declared editor outcomes.
@@ -1,9 +1,9 @@
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_core/editor.dart';
import 'dart:convert';
import 'package:cutdex_agent/cutdex_agent.dart';
import 'package:cutdex_sdk/tools.dart';
import 'package:cutdex_core/tools.dart';
/// Protocol adaptation only. The dispatchers belong to the open project.
List<AgentTool> editorAgentTools(
+2 -2
View File
@@ -1,7 +1,7 @@
import 'dart:io';
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_sdk/project.dart';
import 'package:cutdex_core/editor.dart';
import 'package:cutdex_core/project.dart';
import '../errors/app_failure.dart';
@@ -1,8 +1,8 @@
import 'dart:io';
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_sdk/timeline/model.dart';
import 'package:cutdex_sdk/tools.dart';
import 'package:cutdex_core/editor.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:cutdex_core/tools.dart';
import '../workspace/project_state.dart';
import 'application_command_dependencies.dart';
+5 -5
View File
@@ -1,10 +1,10 @@
import 'dart:async';
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_sdk/timeline/engine.dart';
import 'package:cutdex_sdk/timeline/layout.dart';
import 'package:cutdex_sdk/timeline/model.dart';
import 'package:cutdex_sdk/tools.dart';
import 'package:cutdex_core/editor.dart';
import 'package:cutdex_core/timeline/engine.dart';
import 'package:cutdex_core/timeline/layout.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:cutdex_core/tools.dart';
import '../workspace/timeline_session.dart';
+3 -3
View File
@@ -1,7 +1,7 @@
import 'package:cutdex_agent/cutdex_agent.dart';
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_sdk/mcp.dart';
import 'package:cutdex_sdk/tools.dart';
import 'package:cutdex_core/editor.dart';
import 'package:cutdex_core/mcp.dart';
import 'package:cutdex_core/tools.dart';
import 'agent/editor_agent_tools.dart';
import 'tool_workspace_registry.dart';
Loaded 100 of 452 files, more files were not shown because too many files have changed in this diff. Show more