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
@@ -74,14 +74,11 @@ namespace anm2ed::imgui
|
||||
bool isLayers, bool isNulls)
|
||||
{
|
||||
std::set<Reference> result{};
|
||||
auto animationIndex = targetDocument.reference.animationIndex;
|
||||
auto animationIndex = targetDocument.reference_get().animationIndex;
|
||||
if (target == BakeIntoOtherFramesTarget::CURRENT_SELECTION)
|
||||
{
|
||||
for (auto itemReference : targetDocument.items.references)
|
||||
{
|
||||
itemReference.frameIndex = -1;
|
||||
for (auto itemReference : targetDocument.selected_get(SelectionKind::TRACKS))
|
||||
if (itemReference.itemType == LAYER || itemReference.itemType == NULL_) result.insert(itemReference);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -93,8 +90,8 @@ namespace anm2ed::imgui
|
||||
[&](const Element& track)
|
||||
{
|
||||
auto itemType = (int)row.itemType;
|
||||
result.insert({animationIndex, itemType, anm2ed::track_id_get(track), -1,
|
||||
track.groupId == -1 ? NONE : itemType, track.groupId});
|
||||
result.insert(Reference{animationIndex, itemType, anm2ed::track_id_get(track), -1,
|
||||
track.groupId == -1 ? NONE : itemType, track.groupId});
|
||||
});
|
||||
}
|
||||
return result;
|
||||
@@ -150,7 +147,7 @@ namespace anm2ed::imgui
|
||||
|
||||
std::vector<Reference> TimelineContext::item_references_groupable_get()
|
||||
{
|
||||
if (!document.groupReferences.empty()) return std::vector<Reference>{};
|
||||
if (!document.selection.uids[SelectionKind::GROUPS].empty()) return std::vector<Reference>{};
|
||||
auto selectedItems = item_references_for_current_get();
|
||||
std::erase_if(selectedItems, [](const Reference& itemReference)
|
||||
{ return itemReference.itemType != LAYER && itemReference.itemType != NULL_; });
|
||||
@@ -186,8 +183,8 @@ namespace anm2ed::imgui
|
||||
[=, this](Document& document, const edit::Uids& uids)
|
||||
{
|
||||
if (uids.empty()) return;
|
||||
document.items.references = {targetReferences.begin(), targetReferences.end()};
|
||||
document.reference = targetReferences.front();
|
||||
document.selected_set(SelectionKind::TRACKS, {targetReferences.begin(), targetReferences.end()});
|
||||
document.reference_set(targetReferences.front());
|
||||
frames_selection_reset_for(document);
|
||||
});
|
||||
}
|
||||
@@ -210,6 +207,15 @@ namespace anm2ed::imgui
|
||||
(row.isGroup ? groupIds : ids).insert(row.id);
|
||||
edit::RowTarget target{targetRow.isGroup, targetRow.type, targetRow.id, targetRow.groupId};
|
||||
auto animationIndex = reference.animationIndex;
|
||||
std::set<Reference> tracks{};
|
||||
std::set<Reference> groups{};
|
||||
for (const auto& row : draggedRows)
|
||||
(row.isGroup ? groups : tracks)
|
||||
.insert(row.isGroup ? Reference{row.animationIndex, row.type, row.id} : row_item_reference_get(row));
|
||||
Selection moved{};
|
||||
selection_references_set(moved, anm2, SelectionKind::TRACKS, tracks);
|
||||
selection_references_set(moved, anm2, SelectionKind::GROUPS, groups);
|
||||
if (!tracks.empty()) selection_focus_set(moved, anm2, *tracks.begin());
|
||||
|
||||
edit_push(
|
||||
EDIT_MOVE_ITEMS, Document::ITEMS,
|
||||
@@ -220,15 +226,12 @@ namespace anm2ed::imgui
|
||||
},
|
||||
[=, this](Document& document, const edit::Uids&)
|
||||
{
|
||||
document.items.references.clear();
|
||||
document.groupReferences.clear();
|
||||
for (const auto& row : draggedRows)
|
||||
if (row.isGroup)
|
||||
document.groupReferences.insert({row.animationIndex, row.type, row.id});
|
||||
else
|
||||
document.items.references.insert(row_item_reference_get(row));
|
||||
document.reference =
|
||||
document.items.references.empty() ? Reference{animationIndex} : *document.items.references.begin();
|
||||
document.selection.uids[SelectionKind::TRACKS] = moved.uids.at(SelectionKind::TRACKS);
|
||||
document.selection.uids[SelectionKind::GROUPS] = moved.uids.at(SelectionKind::GROUPS);
|
||||
if (tracks.empty())
|
||||
document.reference_set({document.reference_get().animationIndex});
|
||||
else
|
||||
document.selection.focus = moved.focus;
|
||||
frames_selection_reset_for(document);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user