refactor(core): own editor UI and pin verified native releases
Gitea CI / Check code and tests (pull_request) Failing after 8s
Gitea CI / Build Android APK (pull_request) Skipped
Gitea CI / Build Windows x64 app (pull_request) Skipped
Gitea CI / Audit and package Windows x64 (pull_request) Skipped
Gitea CI / Assemble and validate CI artifacts (pull_request) Skipped
Gitea CI / Gitea CI passed (pull_request) Failing after 1s

This commit is contained in:
lingjhf committed 2026-10-12 03:20:29 +08:00
1 parent 796a3852a2
commit 38ca180cf7
354 files changed
+29841 -642

No files matched your search

@@ -0,0 +1,174 @@
part of 'timeline_view_controller.dart';
final class TimelineKeyframeHit {
const TimelineKeyframeHit({
required this.identity,
required this.element,
required this.offset,
required this.start,
});
final Object identity;
final ElementHandle element;
final int offset;
final int start;
}
extension _KeyframeHitGeometry on TimelineViewController {
TimelineKeyframeHit? _keyframeAt({
required TimelineViewportRect viewport,
required Offset position,
required double headerHeight,
}) {
final hit = hitTest(viewport: viewport, position: position);
if (hit == null ||
!canTrim(hit.identity) ||
hit.bounds.height < headerHeight + 14) {
return null;
}
final element = switch (hit.identity) {
ElementHandle id => id,
LayoutBodyId id when id.context == null && id.isSemantic => id.owner,
_ => null,
};
if (element == null) return null;
final layout = clipLayout(
hit.bounds,
owner: element,
nameHeight: headerHeight,
);
if (layout.body.height < headerHeight + 14) return null;
final markerY = layout.bounds.top + layout.keyframeCenter.dy;
final q = _version.kernelVersion.query();
final record = q.element(element);
if (record.duration <= 0 || hit.bounds.width < 2) return null;
final curves = <ParameterCurveRecord>[];
record.parameters?.forEach((_, curve) => curves.add(curve));
final ticksPerPixel = record.duration / hit.bounds.width;
final local = (position.dx - hit.bounds.left) * ticksPerPixel;
final offsets = TimelineSourceClock(record).keyframeOffsets(
curves,
start: (local - 10 * ticksPerPixel).floor(),
end: (local + 10 * ticksPerPixel).ceil() + 1,
);
int? nearest;
var distance = double.infinity;
for (final offset in offsets) {
final x = hit.bounds.left + offset / ticksPerPixel;
final d = (position.dx - x).abs() + (position.dy - markerY).abs();
if (d <= 10 && d < distance) {
nearest = offset;
distance = d;
}
}
return nearest == null
? null
: TimelineKeyframeHit(
identity: hit.identity,
element: element,
offset: nearest,
start: q.localContext(element).start,
);
}
}
final class _TimelineKeyframeDrag {
_TimelineKeyframeDrag({
required this.engine,
required TimelineKeyframeHit hit,
required TimelineCamera camera,
required this.viewport,
required this.position,
}) : base = engine.current!,
move = LayoutKeyframeMove.capture(
projection: engine.currentComponents!.semanticProjection,
element: hit.element,
offset: hit.offset,
),
anchor = TimelineViewportDragAnchor.capture(
camera: camera,
viewport: viewport,
screenX: position.dx,
screenY: position.dy,
sourceStart: hit.start + hit.offset,
sourceTop: 0,
),
displayOffset = hit.offset;
final TimelineLayoutEngine engine;
final LayoutVersion base;
final LayoutKeyframeMove move;
final TimelineViewportDragAnchor anchor;
TimelineViewportRect viewport;
Offset position;
LayoutConnectionEditPreview? _prepared;
int displayOffset;
String? rejection;
({Object error, StackTrace stack})? failure;
TimelineCamera? _lastCamera;
LayoutPreviewMode get mode => rejection == null
? LayoutPreviewMode.connected
: LayoutPreviewMode.invalid;
LayoutVersion get displayVersion => _prepared?.result.version ?? base;
void update({
required TimelineCamera camera,
required TimelineViewportRect viewport,
required Offset position,
required int frameTicks,
}) {
if (_lastCamera case final last?) {
if (_sameCamera(last, camera) &&
this.position == position &&
this.viewport.left == viewport.left &&
this.viewport.top == viewport.top &&
this.viewport.width == viewport.width &&
this.viewport.height == viewport.height) {
return;
}
}
_lastCamera = camera;
this.viewport = viewport;
this.position = position;
cancel();
rejection = null;
failure = null;
displayOffset = move.offset;
try {
final delta = anchor
.resolve(
camera: camera,
viewport: viewport,
screenX: position.dx,
screenY: position.dy,
timeRounding: TimelineTickRounding.nearest,
verticalRounding: TimelineTickRounding.nearest,
)
.timeDelta;
if (delta == 0) return;
final target = move.constrainOffset(
checkedLayoutAdd(move.offset, delta, 'keyframe drag'),
frameTicks: frameTicks,
);
_prepared = move.preview(engine: engine, targetOffset: target);
displayOffset = target;
} on LayoutException catch (error, stack) {
failure = (error: error, stack: stack);
rejection = error.toString();
} on ArgumentError catch (error, stack) {
failure = (error: error, stack: stack);
rejection = error.toString();
}
}
LayoutApplyResult? commit() {
final prepared = _prepared;
if (prepared == null) return null;
final result = prepared.commit();
_prepared = null;
return result;
}
void cancel() {
_prepared?.cancel();
_prepared = null;
}
}