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

+9 -2
View File
@@ -10,6 +10,7 @@
#include <vector>
#include "edit/edit.hpp"
#include "selection.hpp"
#include "snapshots.hpp"
#include "strings.hpp"
@@ -30,6 +31,7 @@ namespace anm2ed
uint64_t tabId{};
Snapshots snapshots{};
std::map<int, Storage> regionBySpritesheet{};
Storage animation{};
int changeAllFramePropertiesRegionId{-1};
int changeAllFramePropertiesShaderId{-1};
@@ -100,6 +102,7 @@ namespace anm2ed
Anm2& anm2 = current.anm2;
std::string& message = current.message;
EditTarget editTarget{EditTarget::NONE};
UidIndex index{};
Document(const std::filesystem::path&, bool = false, std::string* = nullptr);
Document(const Document&) = delete;
@@ -152,7 +155,12 @@ namespace anm2ed
bool spritesheet_any_dirty();
void spritesheet_hashes_reset();
void spritesheet_hashes_sync();
bool is_frame_reference_valid(Reference) const;
Reference reference_get() const;
void reference_set(Reference);
std::set<Reference> selected_get(SelectionKind) const;
void selected_set(SelectionKind, const std::set<Reference>&);
std::set<int> animations_selected_get() const;
void animations_selected_set(const std::set<int>&);
std::set<Reference> item_frame_references_get(Reference) const;
std::set<Reference> selected_item_frame_references_get() const;
std::set<Reference> frame_references_get(FrameReferenceFallback = FrameReferenceFallback::CURRENT) const;
@@ -164,7 +172,6 @@ namespace anm2ed
Element* frame_get();
Element* item_get();
Element* spritesheet_get();
Element* animation_get();
void spritesheets_add(const std::vector<std::filesystem::path>&);
void sounds_add(const std::vector<std::filesystem::path>&);