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:
1 parent
700b613c62
commit
65a3546c3b
29 files changed
+484
-608
No files matched your search
+4
-24
@@ -10,6 +10,7 @@
|
||||
#include "audio_data.hpp"
|
||||
#include "image.hpp"
|
||||
#include "playback.hpp"
|
||||
#include "selection.hpp"
|
||||
#include "storage.hpp"
|
||||
|
||||
namespace anm2ed::snapshots
|
||||
@@ -52,10 +53,7 @@ namespace anm2ed
|
||||
{
|
||||
public:
|
||||
Playback playback{};
|
||||
Storage animation{};
|
||||
Storage event{};
|
||||
Storage frames{};
|
||||
Storage items{};
|
||||
Storage layer{};
|
||||
Storage merge{};
|
||||
Storage null{};
|
||||
@@ -66,8 +64,7 @@ namespace anm2ed
|
||||
std::map<int, resource::Image> textures{};
|
||||
std::map<int, resource::AudioData> sounds{};
|
||||
Anm2 anm2{};
|
||||
Reference reference{};
|
||||
std::set<Reference> groupReferences{};
|
||||
Selection selection{};
|
||||
float frameTime{};
|
||||
std::string message = snapshots::ACTION;
|
||||
};
|
||||
@@ -77,10 +74,7 @@ namespace anm2ed
|
||||
|
||||
#define SNAPSHOT_STEP_STATE_FIELDS \
|
||||
X(Playback, playback) \
|
||||
X(Storage, animation) \
|
||||
X(Storage, event) \
|
||||
X(Storage, frames) \
|
||||
X(Storage, items) \
|
||||
X(Storage, layer) \
|
||||
X(Storage, merge) \
|
||||
X(Storage, null) \
|
||||
@@ -88,8 +82,7 @@ namespace anm2ed
|
||||
X(Storage, shader) \
|
||||
X(Storage, sound) \
|
||||
X(Storage, spritesheet) \
|
||||
X(Reference, reference) \
|
||||
X(std::set<Reference>, groupReferences) \
|
||||
X(Selection, selection) \
|
||||
X(float, frameTime)
|
||||
|
||||
#define SNAPSHOT_STEP_RESOURCE_FIELDS \
|
||||
@@ -110,19 +103,6 @@ namespace anm2ed
|
||||
void apply(Snapshot&, SnapshotStepDirection) const;
|
||||
};
|
||||
|
||||
// The selection as it was before a change, with the uids that let it follow elements through the change.
|
||||
struct SnapshotSelection
|
||||
{
|
||||
Reference reference{};
|
||||
std::set<Reference> frameReferences{};
|
||||
std::set<Reference> itemReferences{};
|
||||
std::set<Reference> groupReferences{};
|
||||
std::set<int> frameIndices{};
|
||||
std::set<int> animationIndices{};
|
||||
std::map<Reference, Handle> handles{};
|
||||
std::map<Reference, Handle> groupHandles{};
|
||||
};
|
||||
|
||||
class SnapshotStack
|
||||
{
|
||||
public:
|
||||
@@ -149,7 +129,7 @@ namespace anm2ed
|
||||
SnapshotStack redoStack{};
|
||||
Snapshot current{};
|
||||
std::optional<SnapshotStep> pendingStep{};
|
||||
std::optional<SnapshotSelection> pendingSelection{};
|
||||
std::optional<Reference> pendingFocus{};
|
||||
|
||||
void push(const std::string&, bool = false);
|
||||
void step_push(const std::string&, SnapshotStep);
|
||||
|
||||
Reference in new issue
Block a user