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
296 lines
17 KiB
Markdown
296 lines
17 KiB
Markdown
# Cutdex Timeline UI
|
|
|
|
This is an application-owned internal package. Timeline semantics come from `cutdex_core`; Flutter views and interaction state remain here. Run its tests from the application workspace.
|
|
|
|
[简体中文](README.zh-CN.md)
|
|
|
|
Flutter presentation for the Cutdex timeline. The package renders immutable
|
|
Kernel/Layout publications without owning timeline semantics.
|
|
|
|
## Timecode ruler layouts
|
|
|
|
Choose full project timecode independently of its visual arrangement:
|
|
|
|
```dart
|
|
TimelineViewport(
|
|
controller: controller,
|
|
rulerStyle: TimelineRulerStyle.timecode,
|
|
rulerTimecodeLayout: TimelineRulerTimecodeLayout.centered,
|
|
child: TimelineView(controller: controller),
|
|
)
|
|
```
|
|
|
|
`TimelineRulerTimecodeLayout.inline` (default) places labels to the right of
|
|
their major marks in the same band as subdivisions. `centered` centers labels
|
|
over their major marks, keeping that anchor at the viewport edges.
|
|
Both omit subdivisions in the text's horizontal span. `overlay` retains faint
|
|
marks behind the text and uses a glyph halo rather than a rectangular mask.
|
|
Edge labels clip progressively and remain visible until their text leaves the
|
|
viewport. All three share the adaptive frame-grid density, project timecode formatting,
|
|
camera and playhead interaction. Changing the layout only repaints the ruler.
|
|
|
|
Standalone `TimelineRuler` accepts the same enum through `timecodeLayout`.
|
|
These parameters affect only `TimelineRulerStyle.timecode`; the default elapsed
|
|
ruler keeps its existing appearance.
|
|
|
|
The initial `TimelineView` uses one `CustomPainter` and Layout's reusable
|
|
structure-of-arrays viewport frame. Its work is `O(V)`, where `V` is the
|
|
resident viewport population rather than the full project size.
|
|
|
|
The bulk painter distinguishes visual content, audio content, structural gaps,
|
|
containers, and transitions. Hover and selection are presentation-only states
|
|
on `TimelineViewController`. `hitTest` scans the exact frame in reverse paint
|
|
order and returns a copied result without retaining Layout's transient buffer.
|
|
|
|
Every clip body, including drag ghosts, paints its Kernel `name` in an internal
|
|
header (blank names fall back to the element ID). Long names use one-line
|
|
ellipsis; extremely narrow clips clip/omit unreadable text. Names stay anchored
|
|
to the clip's left edge plus header padding; horizontal panning clips text at
|
|
the viewport without repositioning it or changing its ellipsis. Transition boundaries are
|
|
not clip bodies and do not acquire a separate name header.
|
|
Headers have no separate background fill.
|
|
Hosts may supply `TimelineWaveforms` to render source audio envelopes beneath
|
|
the header. The painter requests visible sources and maps each screen interval
|
|
through Kernel source time, including trimming, retiming and reverse playback.
|
|
Waveform providers load asynchronously and notify the painter when ready; no
|
|
per-clip widget or project state is introduced. Without a provider, audio retains
|
|
its decorative accent line. With a provider, unavailable data is left blank.
|
|
For visual clips, `TimelineWaveforms.hasAudioFor` reports a bound audio source
|
|
without waiting for decoding. Clips with enough height reserve a 16 px audio
|
|
strip below the filmstrip, leaving at least 20 px for thumbnails. Source loading
|
|
does not resize these regions. Silent videos, images and clips whose audio
|
|
binding has been removed keep the full filmstrip; compact clips omit the strip.
|
|
Video and standalone audio share source-time and gain mapping.
|
|
`clipHeaderHeight` (18 px), `clipHeaderPadding` (2 px horizontally),
|
|
and `clipNameTextStyle` belong to the shared theme. Text honors
|
|
ambient direction, locale and scaling and is clipped inside existing geometry;
|
|
the header does not change lanes. One TextPainter is reused for visible labels
|
|
within a paint pass and disposed afterward; no per-clip widgets or document-wide
|
|
name cache are introduced.
|
|
|
|
Gaps can be dragged but only dropped on the opened scene's Primary axis. An
|
|
off-axis pointer retains the original Primary reservation; a valid Primary
|
|
boundary preview replaces it with the new reservation. Dropping off-axis cancels
|
|
the edit. Gap reservations remain visible alongside the pointer ghost, unlike
|
|
ordinary clip landing bodies. Reordering uses the existing boundary splice and
|
|
never splits another clip or creates a connected gap.
|
|
|
|
Primary clips with connected descendants share this Primary-only reservation
|
|
behavior: the whole group follows the pointer freely above or below the axis,
|
|
while the original Primary occupancy remains until a valid new Primary preview
|
|
replaces it. Off-axis release restores the original state without history. The
|
|
placement restriction never hides the pointer ghost or ends the gesture.
|
|
|
|
An eligible audio-only Primary clip dragged above the axis keeps its pointer
|
|
ghost there, but releases below at the requested time, outside overlapping
|
|
incumbents. Primary detach uses the same outside-overlap resolver as connected
|
|
audio; it does not create an above-axis audio connection.
|
|
|
|
All Primary sources, including clips without connections, show a pointer ghost
|
|
with an opaque default fill and an outline. Reservations are hollow outlined
|
|
rectangles; both outlines use the theme's selection outline color and width.
|
|
This ghost and serial reservation appear as soon as dragging moves within Primary,
|
|
even before crossing an insertion boundary. Unconnected clips still support a
|
|
legal off-axis detach; its prepared result closes the original Primary interval.
|
|
|
|
Primary detach and cross-side dragging use the same latest-preview incumbent
|
|
geometry as same-side dragging. Displaced clips refill only after the pointer
|
|
crosses their current top threshold, not their pre-drag top. Previous previews
|
|
are read-only interaction history tied to the exact published base; every edit
|
|
is still prepared from that base and only the latest result can be committed.
|
|
|
|
Below-axis audio can follow the pointer above Primary. Releasing there retains
|
|
the requested time interval and places it below, outside all overlapping
|
|
incumbents (lane 1 if none overlap). Only the ghost is above; canonical audio
|
|
ownership stays below. Primary-band drops retain their ordinary insertion rule.
|
|
Outside-viewport release remains invalid. This fallback currently requires an
|
|
all-audio below-side carried group; it does not silently migrate mixed groups.
|
|
|
|
Cross-side targeting uses the pointer position, not whether the entire ghost
|
|
rectangle has cleared Primary. A ghost may straddle the axis during crossing;
|
|
the canonical solver still keeps the final connected body outside Primary.
|
|
|
|
Ordinary drag into/out of Primary rejects roots with connected clips, including
|
|
when those children are also selected. Primary reordering still carries children;
|
|
internal compound contents are not external connections. Lift/overwrite commands
|
|
remain separate from drag transfer. See the [Apple drag-transfer rule](https://support.apple.com/guide/final-cut-pro/verc147f195/mac).
|
|
|
|
Kernel payloads remain opaque. The host passes the same `LayoutMediaClassifier`
|
|
to `classifyContent` that it uses for Layout's media index. Primary content is
|
|
then classified without a second policy; connected media class comes directly
|
|
from Layout's resolved `LayoutPlacementClass`.
|
|
|
|
See [the architecture contract](ARCHITECTURE.md).
|
|
|
|
## Runnable example
|
|
|
|
See the [macOS example](example/README.md) for a mixed timeline, theme switching,
|
|
pan, zoom, hover, selection, connected-clip group dragging and undo/redo.
|
|
|
|
```sh
|
|
cd packages/cutdex_timeline_ui/example
|
|
flutter pub get
|
|
flutter run -d macos
|
|
```
|
|
|
|
Run these commands from the repository root.
|
|
|
|
## Usage
|
|
|
|
```dart
|
|
final controller = TimelineViewController(
|
|
version: layoutVersion,
|
|
storyline: primaryStoryline,
|
|
geometry: TimelineViewportGeometry(primaryTop: 80, primaryHeight: 48),
|
|
camera: TimelineCamera(
|
|
baseTick: 0,
|
|
pixelsPerTick: pixelsPerSecond / TimelineClock.ticksPerSecond,
|
|
),
|
|
);
|
|
|
|
TimelineView(controller: controller);
|
|
```
|
|
|
|
The application owns and disposes the controller. Publish adjacent Layout
|
|
results with `applyLayout`; use `replaceLayout` only for an explicit open,
|
|
history jump, or global rebuild.
|
|
|
|
The optional `TimelineThumbnails` host receives each tile's desired source tick,
|
|
approximate source-span ticks, logical size, and device-pixel ratio. The painter
|
|
keeps tile centers stable for a fixed tile-count level, registers visible demand
|
|
before two tiles of bidirectional prefetch, and never paints prefetched tiles
|
|
outside the viewport. Hosts should quantize nearby source ticks onto a bounded
|
|
sampling pyramid and return a nearby cached frame while a finer level loads.
|
|
|
|
For editing, construct `TimelineViewController.editable(engine: ..., geometry: ...,
|
|
camera: ..., createConnectionId: ..., createElementId: ...)` from an engine initialized with
|
|
`buildComponents`. The component root may have an empty `expanded` set. It
|
|
retains the canonical projection for coordinated history; no UI history is added.
|
|
Wrap `TimelineView` in `TimelineInteractionRegion(controller: controller, child: ...)`.
|
|
Use `controller.undo()` / `redo()` for coordinated history. See the example for
|
|
a complete setup and the architecture contract for supported drag sources.
|
|
|
|
## Explicit editing commands
|
|
|
|
`cutSelectionAtPlayhead()` cuts selected clip interiors at the definition-local
|
|
playhead; `deleteSelection()` deletes whole selected owners and their connected
|
|
descendants, closing Primary magnetically. Each command is one coordinated
|
|
Kernel/Layout history entry. A connected right half anchors to the Primary member
|
|
at the cut, resolved by Kernel. Host ID factories must return fresh IDs, including
|
|
after undo; `createElementId` is used only by explicit blade, never by dragging.
|
|
`canCutSelection`/`canDeleteSelection` expose selection eligibility; Kernel still
|
|
validates the command and `commandRejection` explains rejected edits. While the
|
|
timeline or ruler has focus: Ctrl/Cmd+B cuts, Delete/Backspace deletes,
|
|
Ctrl/Cmd+Z undoes, and Ctrl/Cmd+Shift+Z redoes. Active pointer edits ignore these
|
|
shortcuts. No implicit blade is added to drag/drop.
|
|
|
|
## Ruler and navigation
|
|
|
|
Wrap the interaction region and `TimelineView` in `TimelineViewport`. It provides
|
|
a ruler with the same effective width and horizontal origin. The ruler displays definition-local elapsed time (not
|
|
SMPTE/drop-frame timecode), with adaptive second/millisecond ticks. Click or drag
|
|
the ruler to move the presentation-only playhead. Negative seek clamps to zero;
|
|
seeking beyond the tail is allowed. No playback or media decoding is started.
|
|
|
|
`TimelineInteractionRegion` supports:
|
|
|
|
- Wheel/trackpad scrolling: two-axis pan; Shift+wheel: horizontal pan.
|
|
- Hold a dragged clip at an edge to auto-pan; corners pan both axes. Configure
|
|
`edgeScrollExtent` (48 px) and `edgeScrollMaxSpeed` (600 px/s) on the region;
|
|
zero disables it. Cancel stops without editing and retains the scrolled Camera.
|
|
- Ctrl/Cmd+wheel: zoom around the pointer, up to 32 px/frame. The minimum
|
|
scale fits the sequence duration plus 25%, rounded up to 10/30 minutes,
|
|
1/2/4 hours, then doubled as needed. Connected clips count toward the duration.
|
|
Edits update the limits without applying a new zoom; `fitTimeline()` explicitly
|
|
shows the whole sequence with tail space.
|
|
- Middle-button drag or Space+primary-button drag: pan. A single touch on blank space also pans.
|
|
- Primary mouse drag on blank space: marquee-select intersecting visible items.
|
|
Release keeps the selection; Escape, cancellation or camera navigation restores
|
|
the previous selection. A changed document root cannot restore stale identities.
|
|
Drag a selected connected member to move the whole connected selection and
|
|
carried descendants. Into Primary, independent roots without connected children are inserted consecutively
|
|
in time order, with no automatic container; one undo restores the group.
|
|
- Touch pinch or native trackpad pan/zoom: one combined focal-point transform.
|
|
A second finger cancels any active clip edit before navigation; lifting one
|
|
finger does not resume that edit.
|
|
|
|
Ruler navigation is horizontal only. Its click/drag changes the playhead, not
|
|
selection. Camera and playhead changes create no Kernel history. Ruler colors,
|
|
height, typography and playhead appearance use `TimelineThemeData`.
|
|
|
|
## Scrollbars
|
|
|
|
Use `TimelineViewport(controller: controller, child: ...)` around the clip surface
|
|
and `TimelineInteractionRegion`. The viewport owns the ruler and reserves space
|
|
for horizontal and vertical scrollbars, so painting and pointer hit testing use
|
|
the same unobscured content rectangle. Use `showRuler: false` for a surface-only
|
|
host. `TimelineScrollbars` is now a rendering component requiring explicit viewport
|
|
dimensions and bounds; it no longer configures the camera. Drag a thumb or click its track to page. Wheel, pinch,
|
|
toolbar and scrollbar navigation all use the same Camera; none creates history.
|
|
Content bounds include connected clips. Horizontal navigation starts at zero;
|
|
scrollbars appear only on overflowing axes. The navigation range includes half
|
|
a viewport beyond the content tail without extending the authored duration.
|
|
An initially empty viewport fits twenty seconds once. Subsequent zooms, resizes,
|
|
and deleting all clips preserve the chosen scale. Thumb
|
|
mapping stays fixed during a drag. Thickness and colors use theme tokens.
|
|
|
|
The wrapper registers viewport and content bounds with the controller and applies
|
|
them after layout. Initial layout calls `focusPrimary()` to center the primary
|
|
lane by moving the whole viewport. Call `focusPrimary(resetHorizontal: true)`
|
|
for a reset-position command; omit the option to preserve horizontal position.
|
|
Resizing and editing reconcile content bounds without recentering the primary.
|
|
Custom hosts can use `configureViewport` and `reconcileViewport` for the same
|
|
behavior. Positioning does not edit the timeline or create history.
|
|
|
|
The ruler draws nonnegative elapsed time, with labels beside top-aligned ticks.
|
|
Minor ticks beneath labels are omitted. `primaryLaneBackgroundColor` controls
|
|
the full-width primary lane background independently from the canvas.
|
|
|
|
## Theme
|
|
|
|
Basic edge trimming is available through `TimelineInteractionRegion`: drag the
|
|
inner left/right edge to adjust source in/out, with magnetic serial ripple and
|
|
Layout avoidance. It shares preview, cancellation, edge scrolling and history
|
|
with moves. `trimHandleWidth` (3 px) and `trimHitExtent` (6 px) are theme tokens;
|
|
zero hit extent disables edge gestures. Apply custom edge tokens above both
|
|
the input region and painter. See the architecture contract for constraints.
|
|
|
|
Finite source limits come from Kernel's `constrainMediaTrimDuration`; dragging
|
|
beyond a known media edge stops at its exact rate-adjusted boundary. Supply full
|
|
`mediaRange` for video/audio, or explicitly set `sourceExtendable` for stills and
|
|
generators. Missing bounds do not imply unlimited media. Other edit constraints
|
|
still reject through Kernel. Media availability and trim rules are maintained by core in `packages/timeline/docs/model/MEDIA_AVAILABILITY.md`.
|
|
|
|
Every timeline painter resolves the same `TimelineThemeData`. Install it once
|
|
through Flutter's extension mechanism, or pass the same type directly to one
|
|
`TimelineView` for a local override:
|
|
|
|
```dart
|
|
ThemeData(
|
|
extensions: const [TimelineThemeData.dark()],
|
|
);
|
|
|
|
TimelineView(
|
|
controller: controller,
|
|
theme: const TimelineThemeData.dark(),
|
|
);
|
|
```
|
|
|
|
The theme is resolved once during widget build, never once per painted item.
|
|
|
|
`TimelineView.thumbnails` accepts an optional host-owned `TimelineThumbnails`. The painter declares visible frame demand through `beginFrame`, `aspectRatioFor`, resolution-aware `imageFor`, and `endFrame`, and repaints when that provider notifies. Providers receive the painted logical tile size plus device pixel ratio, then own resolution bucketing, asynchronous I/O, bounded decoded-image retention, and image disposal. Timeline UI has no runtime or file-access dependency. Filmstrip tiles follow the source display aspect ratio once the provider knows it and use Kernel source-time mapping beneath clip headers, including implicit and piecewise retiming; contextual nested occurrences currently retain their ordinary fill until an occurrence-specific source mapping is supplied.
|
|
|
|
### Frame-budget subscriptions
|
|
|
|
The controller's default `Listenable` includes every view update. Use
|
|
`contentChanges` for retained clip/ruler painters that do not draw the playhead,
|
|
and `editingChanges` for inspectors and native preview synchronization. The
|
|
latter includes selection, playhead, authored changes and keyframe previews;
|
|
camera/hover changes and private clip-placement/trim geometry stay within the
|
|
viewport. Committing or cancelling a gesture still notifies editing consumers.
|
|
|
|
Pointer-driven ripple trim coalesces updates to the latest position per display
|
|
frame. Release synchronously resolves the final pointer before publication;
|
|
cancellation, view replacement and disposal discard queued callbacks. Clip
|
|
labels retain a bounded cache of shaped text across panning and rebuilds.
|