feat: initial Cutdex application
Add the Flutter video editing application with project management, media import, timeline editing, preview, AI assistance, diagnostics and settings. Include shared UI and native host packages, platform runners, application tests and release tooling. Provide usage and contribution guides, the MIT license and third-party notices. Exclude local credentials, build outputs and validation data.
This commit is contained in:
commit
27e77fff39
718 files changed
+183958
No files matched your search
@@ -0,0 +1,95 @@
|
||||
import 'dart:math' as math;
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:cutdex_sdk/editor.dart';
|
||||
import 'package:cutdex_sdk/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.
|
||||
final class TimelineSpeedLayout {
|
||||
TimelineSpeedLayout({
|
||||
required TimelineClipLayout clip,
|
||||
required Iterable<ClipSpeedSegment> segments,
|
||||
required double pixelsPerTick,
|
||||
}) {
|
||||
bounds = Rect.fromLTWH(
|
||||
clip.header.left,
|
||||
clip.header.top,
|
||||
clip.header.width,
|
||||
math.min(
|
||||
clip.header.height,
|
||||
EditorLayoutConfiguration.speedSectionHeight.toDouble(),
|
||||
),
|
||||
);
|
||||
var left = bounds.left;
|
||||
final cells = <TimelineSpeedSegmentLayout>[];
|
||||
for (final segment in segments) {
|
||||
final width = math.max(1.0, segment.projectDuration * pixelsPerTick);
|
||||
final right = math.min(bounds.right, left + width);
|
||||
final cell = Rect.fromLTWH(
|
||||
math.min(left, bounds.right),
|
||||
bounds.top,
|
||||
math.max(0, right - left),
|
||||
bounds.height,
|
||||
);
|
||||
cells.add(TimelineSpeedSegmentLayout(segment, cell));
|
||||
left += width;
|
||||
}
|
||||
this.segments = List.unmodifiable(cells);
|
||||
}
|
||||
|
||||
late final Rect bounds;
|
||||
late final List<TimelineSpeedSegmentLayout> segments;
|
||||
}
|
||||
|
||||
final class TimelineSpeedSegmentLayout {
|
||||
TimelineSpeedSegmentLayout(this.segment, this.cell) {
|
||||
bar = Rect.fromLTWH(
|
||||
cell.left,
|
||||
cell.top,
|
||||
math.max(0, cell.width - segmentGap),
|
||||
cell.height,
|
||||
);
|
||||
label = Rect.fromLTWH(
|
||||
bar.left + math.min(labelPadding, bar.width / 2),
|
||||
bar.top + 1,
|
||||
math.max(0, bar.width - labelPadding * 2),
|
||||
math.max(0, bar.height - 2),
|
||||
);
|
||||
final horizontalInset = math.min(handleInset, bar.width / 2);
|
||||
final verticalInset = math.min(handleInset, bar.height / 2);
|
||||
final handleRight = bar.right - horizontalInset;
|
||||
final availableWidth = math.max(0.0, bar.width - horizontalInset * 2);
|
||||
final handleTop = bar.top + verticalInset;
|
||||
final handleHeight = math.max(0.0, bar.height - verticalInset * 2);
|
||||
handle = Rect.fromLTWH(
|
||||
handleRight - math.min(handleWidth, availableWidth),
|
||||
handleTop,
|
||||
math.min(handleWidth, availableWidth),
|
||||
handleHeight,
|
||||
);
|
||||
final hitWidth = math.min(handleHitWidth, bar.width);
|
||||
handleHit = Rect.fromLTWH(
|
||||
(handle.center.dx - hitWidth / 2).clamp(bar.left, bar.right - hitWidth),
|
||||
bar.top,
|
||||
hitWidth,
|
||||
bar.height,
|
||||
);
|
||||
}
|
||||
|
||||
static const segmentGap = 2.0;
|
||||
static const labelPadding = 8.0;
|
||||
static const handleInset = 3.0;
|
||||
static const handleWidth = 2.0;
|
||||
static const handleHitWidth = 10.0;
|
||||
static const handleRadius = 1.0;
|
||||
|
||||
final ClipSpeedSegment segment;
|
||||
final Rect cell;
|
||||
late final Rect bar;
|
||||
late final Rect label;
|
||||
late final Rect handle;
|
||||
late final Rect handleHit;
|
||||
|
||||
double get speed => segment.speed;
|
||||
}
|
||||
Reference in new issue
Block a user