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
96 lines
2.9 KiB
Dart
96 lines
2.9 KiB
Dart
import 'dart:math' as math;
|
|
import 'dart:ui';
|
|
|
|
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.
|
|
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;
|
|
}
|