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

@@ -97,18 +97,19 @@ namespace anm2ed::imgui::wizard
{
isChanged = false;
auto& animations = document.animation.selection;
auto animations = document.animations_selected_get();
auto& destination = settings.changeDestination;
auto& regionId = document.changeAllFramePropertiesRegionId;
auto& shaderId = document.changeAllFramePropertiesShaderId;
auto selectedFrameReferences = document.frame_references_get(Document::FrameReferenceFallback::NONE);
std::erase_if(selectedFrameReferences, [](const Reference& reference) { return reference.itemType == TRIGGER; });
auto selectedItemReferences = document.items.references;
if (selectedItemReferences.empty() && document.reference.itemType != NONE)
selectedItemReferences.insert({document.reference.animationIndex, document.reference.itemType,
document.reference.itemID, -1, document.reference.groupType,
document.reference.groupId});
auto selectedItemReferences = document.selected_get(SelectionKind::TRACKS);
if (auto reference = document.reference_get(); selectedItemReferences.empty() && reference.itemType != NONE)
{
reference.frameIndex = -1;
selectedItemReferences.insert(reference);
}
std::erase_if(selectedItemReferences, [](const Reference& reference) { return reference.itemType == TRIGGER; });
bool isSelectedFramesAvailable = !selectedFrameReferences.empty();
@@ -196,7 +197,8 @@ namespace anm2ed::imgui::wizard
interpolationIds.push_back(i);
interpolationLabels.push_back(localize.get(INTERPOLATION_LABELS[i]));
}
auto regions = document.layer_regions_get(document.reference.itemType == LAYER ? document.reference.itemID : -1);
auto regions =
document.layer_regions_get(document.reference_get().itemType == LAYER ? document.reference_get().itemID : -1);
if (!isLayerPropertyAvailable) regionId = shaderId = -1;
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImGui::GetStyle().ItemInnerSpacing);