Seperating the sequencer into multiple widgets.

This commit is contained in:
Johannes Findeisen 2026-11-06 21:39:38 +01:00
commit e664414796
23 changed files with 1455 additions and 914 deletions

View file

@ -65,6 +65,63 @@ commands and publish independent compiled snapshots. See GUI.md.
---
## Sequencer Widget Ownership
`SequencerWidget` is the master FLTK group. It owns the timeline coordinate
system, grid/background, selection, zoom, scrolling extent, expansion state,
shared edit hooks and gestures that cross tracks. Drawing and local input belong
to child widgets:
```mermaid
flowchart TD
S[SequencerWidget] --> R[SequencerRulerWidget]
S --> T[SequencerTrackWidget per track]
T --> H[SequencerTrackHeader]
H --> I[Fl_Choice instrument selector]
T --> C[SequencerClipWidget per clip]
T --> V[SequencerVelocityWidget]
```
FLTK groups own and destroy their children. The master's track index and each
track's clip index contain borrowed pointers; they do not independently delete
children. Views reconcile copied C metadata by stable IDs when edits, project
installation or drawing refresh the timeline. Surviving track views retain their
identity through reorder and undo; clips moved between tracks acquire a view
under their destination group. No child keeps a borrowed pointer into a C
project snapshot. Removed views are detached, hidden and scheduled with
`Fl::delete_widget`, allowing the current event handler to return safely.
A project replacement cancels captured gestures before refreshing the hierarchy.
The ruler handles seeking and loop selection. Track groups manage row layout;
headers handle disclosure/selection and own instrument controls. Clip widgets
draw notes or cached waveforms and start selection/move/trim gestures; the
master completes cross-track edits. Velocity children own MIDI/audio previews
and local point/bar hit testing. All mutations still use the master's
before-edit and changed callbacks, preserving C history, transport stopping and
plan publication. Instrument keyboard focus is handled before timeline shortcuts.
Implementation map:
| Files in `src/gui/` | Responsibility |
| --- | --- |
| `sequencer_widget.hpp/.cpp` | Master API, layout/reconciliation, shared selection, gestures and timeline overlays |
| `sequencer_track_widget.hpp/.cpp` | Track groups, pinned header groups and nested instrument selectors |
| `sequencer_clip_widget.hpp/.cpp` | Clip drawing and local selection/gesture initiation |
| `sequencer_velocity_widget.hpp/.cpp` | MIDI velocity bars and continuous audio gain envelopes, including preview state |
| `sequencer_ruler_widget.hpp/.cpp` | Bar/marker labels, loop display, seeking and loop gestures |
| `sequencer_commands.cpp` | Editing commands and dialogs exposed by the master |
| `sequencer_instruments.cpp` | Instrument catalog and selector callbacks |
| `sequencer_waveforms.cpp` | Shared control-thread waveform cache and waveform drawing |
| `sequencer_group_scope.hpp` | Restore FLTK's implicit parent around dynamic child construction |
`cmake/Gui.cmake` lists all implementation files explicitly in `xtc-gui`.
The hierarchy adds no dependency, C API, project format or audio-thread work.
GUI integration checks cover actual parent relationships, stable track views,
FLTK window-dispatched clip/velocity drags, cross-track movement, deferred
removal, project replacement during a captured gesture and undo/redo.
---
## Editable Graph and Canvas
Read-only C snapshots, monotonic node IDs, and a small set of C edit commands