Stage 4: one uid-based Selection for the timeline and animations list

- Selection { map<kind, set<uid>> uids; Handle focus; } (src/selection.*, core)
  replaces Document::reference, the frames/items/animation Storages,
  groupReferences, and the timeline's selection snapshot/lock/focus state.
- Because selection is by uid it follows elements through edits by itself;
  after an edit or undo, selection_follow only drops removed uids and moves a
  removed focus to its nearest survivor. The Stage 2 handle capture/re-resolve,
  frames_reference_normalize_for, frames_selection_sync_for and the index-based
  frame validity repair are gone.
- Document keeps a UidIndex (rebuilt on every change) and exposes
  reference_get/reference_set, selected_get/selected_set(kind),
  frame_references_get/set and animations_selected_get/set.
- UidIndex records each uid's element type.
- The animations list keeps its ImGui multi-select Storage as a per-frame mirror
  of the Selection; content windows are unchanged until Stage 8.
- tests/selection.cpp and tests/undo.cpp cover selection through inserts,
  reverses, deletes, item and animation removal, regrouping and undo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shweetandClaude Opus 5.5 committed 2026-10-03 15:46:47 -04:00
1 parent 700b613c62
commit 65a3546c3b
29 files changed
+484 -608

No files matched your search

+12 -8
View File
@@ -109,18 +109,22 @@ TEST_CASE("undo and redo restore every state of a random edit walk")
TEST_CASE("selection follows its frame through an edit and its undo")
{
Snapshots snapshots{};
snapshots.current.anm2 = anm2_load(file_load(CORPUS_DIR / "02_items.anm2"));
snapshots.current.reference = {0, LAYER, 0, 1};
snapshots.current.frames.references = {{0, LAYER, 0, 1}};
auto& current = snapshots.current;
current.anm2 = anm2_load(file_load(CORPUS_DIR / "02_items.anm2"));
current.anm2.uids_repair();
selection_focus_set(current.selection, current.anm2, {0, LAYER, 0, 1});
selection_references_set(current.selection, current.anm2, SelectionKind::FRAMES, {{0, LAYER, 0, 1}});
snapshots.push("Insert");
edit::frame_insert(snapshots.current.anm2, {0, LAYER, 0, -1}, 0);
auto& track = *snapshots.current.anm2.element_get(Reference{0, LAYER, 0});
edit::frame_insert(current.anm2, {0, LAYER, 0, -1}, 0);
auto& track = *current.anm2.element_get(Reference{0, LAYER, 0});
std::rotate(track.children.begin(), track.children.end() - 1, track.children.end());
snapshots.commit();
CHECK(snapshots.current.reference == Reference{0, LAYER, 0, 2});
CHECK(snapshots.current.frames.references == std::set<Reference>{{0, LAYER, 0, 2}});
UidIndex index(current.anm2);
CHECK(selection_focus_get(current.selection, index) == Reference{0, LAYER, 0, 2});
CHECK(selection_references_get(current.selection, index, SelectionKind::FRAMES) ==
std::set<Reference>{{0, LAYER, 0, 2}});
REQUIRE(snapshots.undo());
CHECK(snapshots.current.reference == Reference{0, LAYER, 0, 1});
CHECK(selection_focus_get(current.selection, UidIndex(current.anm2)) == Reference{0, LAYER, 0, 1});
}