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
@@ -214,8 +214,8 @@ namespace anm2ed::imgui::popup
|
||||
|
||||
if (addId != -1)
|
||||
{
|
||||
document.reference = {queuedAnimationIndex, (int)queuedType, addId};
|
||||
document.items.references = {document.reference};
|
||||
document.reference_set({queuedAnimationIndex, (int)queuedType, addId});
|
||||
document.selected_set(SelectionKind::TRACKS, {document.reference_get()});
|
||||
document.frame_references_clear();
|
||||
if (queuedType == LAYER)
|
||||
if (auto layer = document.anm2.element_get(ElementType::LAYER_ELEMENT, addId))
|
||||
|
||||
+10
-9
@@ -64,10 +64,10 @@ namespace anm2ed::imgui
|
||||
void Taskbar::update(Manager& manager, Settings& settings, Resources& resources, Dialog& dialog, bool& isQuitting)
|
||||
{
|
||||
auto document = manager.get();
|
||||
auto itemType = document ? (ItemType)document->reference.itemType : ItemType::NONE;
|
||||
auto animation =
|
||||
document ? document->anm2.element_get(ElementType::ANIMATION, document->reference.animationIndex) : nullptr;
|
||||
auto frames = document ? &document->frames : nullptr;
|
||||
auto itemType = document ? (ItemType)document->reference_get().itemType : ItemType::NONE;
|
||||
auto animation = document
|
||||
? document->anm2.element_get(ElementType::ANIMATION, document->reference_get().animationIndex)
|
||||
: nullptr;
|
||||
auto layerReferences = document ? document->layer_references_get() : std::vector<Reference>{};
|
||||
bool isGenerateAnimationFromGridAvailable = !layerReferences.empty();
|
||||
bool hasRegions = false;
|
||||
@@ -181,8 +181,9 @@ namespace anm2ed::imgui
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
bool isChangeAllFramesAvailable = frames && !frames->selection.empty() && itemType != ItemType::TRIGGER;
|
||||
bool isChangeAllAnimationsAvailable = document && !document->animation.selection.empty();
|
||||
bool isChangeAllFramesAvailable =
|
||||
document && !document->frame_references_get().empty() && itemType != ItemType::TRIGGER;
|
||||
bool isChangeAllAnimationsAvailable = document && !document->animations_selected_get().empty();
|
||||
if (ImGui::MenuItem(localize.get(LABEL_CHANGE_ALL_FRAME_PROPERTIES), nullptr, false,
|
||||
isChangeAllFramesAvailable || isChangeAllAnimationsAvailable))
|
||||
changePopup.open();
|
||||
@@ -272,9 +273,9 @@ namespace anm2ed::imgui
|
||||
}
|
||||
else
|
||||
{
|
||||
animationIndices.insert(document->animation.selection.begin(), document->animation.selection.end());
|
||||
if (animationIndices.empty() && document->reference.animationIndex >= 0)
|
||||
animationIndices.insert(document->reference.animationIndex);
|
||||
animationIndices = document->animations_selected_get();
|
||||
if (animationIndices.empty() && document->reference_get().animationIndex >= 0)
|
||||
animationIndices.insert(document->reference_get().animationIndex);
|
||||
}
|
||||
|
||||
auto queuedAnimationIndices = animationIndices;
|
||||
|
||||
@@ -416,7 +416,7 @@ namespace anm2ed::imgui
|
||||
|
||||
if (playback.isPlaying)
|
||||
{
|
||||
auto animation = anm2.element_get(ElementType::ANIMATION, document.reference.animationIndex);
|
||||
auto animation = anm2.element_get(ElementType::ANIMATION, document.reference_get().animationIndex);
|
||||
auto& isSound = settings.timelineIsSound;
|
||||
|
||||
if (!animation)
|
||||
@@ -453,7 +453,7 @@ namespace anm2ed::imgui
|
||||
auto& document = *manager.get();
|
||||
auto& anm2 = document.anm2;
|
||||
auto& playback = document.playback;
|
||||
auto& reference = document.reference;
|
||||
auto reference = document.reference_get();
|
||||
auto animation = anm2.element_get(ElementType::ANIMATION, reference.animationIndex);
|
||||
auto& pan = document.previewPan;
|
||||
auto& zoom = document.previewZoom;
|
||||
@@ -793,7 +793,7 @@ namespace anm2ed::imgui
|
||||
if (&sampleDocument != &document) return false;
|
||||
if (reference.animationIndex != -1 && referenceItemType == ItemType::LAYER && reference.itemID == id)
|
||||
return true;
|
||||
for (auto itemReference : document.items.references)
|
||||
for (auto itemReference : document.selected_get(SelectionKind::TRACKS))
|
||||
if (itemReference.animationIndex == reference.animationIndex && itemReference.itemType == LAYER &&
|
||||
itemReference.itemID == id)
|
||||
return true;
|
||||
|
||||
@@ -65,6 +65,30 @@ namespace anm2ed::imgui
|
||||
return insertIndex;
|
||||
}
|
||||
|
||||
// The list draws from Storage/Window mirrors of the document Selection: loaded each frame, written back on change.
|
||||
void animations_selection_set(Window& window, Document& document, const std::set<int>& indices,
|
||||
const std::set<int>& groupIds)
|
||||
{
|
||||
document.animations_selected_set(indices);
|
||||
auto& groupUids = document.selection.uids[SelectionKind::ANIMATION_GROUPS];
|
||||
groupUids.clear();
|
||||
if (auto animations = document.anm2.element_get(ElementType::ANIMATIONS))
|
||||
for (const auto& item : animations->children)
|
||||
if (item.type == ElementType::GROUP && groupIds.contains(item.id)) groupUids.insert(item.uid);
|
||||
document.animation.selection = indices;
|
||||
window.selection = groupIds;
|
||||
}
|
||||
|
||||
void animations_selection_load(Window& window, Document& document)
|
||||
{
|
||||
document.animation.selection = document.animations_selected_get();
|
||||
window.selection.clear();
|
||||
auto& groupUids = document.selection.uids[SelectionKind::ANIMATION_GROUPS];
|
||||
if (auto animations = document.anm2.element_get(ElementType::ANIMATIONS))
|
||||
for (const auto& item : animations->children)
|
||||
if (item.type == ElementType::GROUP && groupUids.contains(item.uid)) window.selection.insert(item.id);
|
||||
}
|
||||
|
||||
bool is_animation_grouped(const std::set<int>& groupIds, const Element& animation)
|
||||
{
|
||||
return animation.groupId != -1 && groupIds.contains(animation.groupId);
|
||||
@@ -126,10 +150,7 @@ namespace anm2ed::imgui
|
||||
[&](Anm2& anm2)
|
||||
{
|
||||
animation_overlay_reset(document, indices);
|
||||
if (indices.contains(document.reference.animationIndex))
|
||||
document.reference.animationIndex = -1;
|
||||
document.animation.selection.clear();
|
||||
window.selection.clear();
|
||||
animations_selection_set(window, document, {}, {});
|
||||
return edit::animations_remove(anm2, indices, groupIds);
|
||||
});
|
||||
}
|
||||
@@ -165,24 +186,23 @@ namespace anm2ed::imgui
|
||||
{
|
||||
std::set<int> groupIds{};
|
||||
std::string errorString{};
|
||||
auto uids = document.edit_apply(edit, window.changeType,
|
||||
[&](Anm2& anm2)
|
||||
{
|
||||
auto uids = edit::animations_paste(anm2, text, start, targetGroupId, groupIds,
|
||||
&errorString);
|
||||
if (uids.empty()) return uids;
|
||||
auto indices = animation_indices_get(document, uids);
|
||||
document.animation.selection = groupIds.empty() ? indices : std::set<int>{};
|
||||
window.selection = groupIds;
|
||||
document.reference = {};
|
||||
window.newElementId = -1;
|
||||
if (indices.empty()) return uids;
|
||||
window.scrollQueued = *indices.rbegin();
|
||||
if (!groupIds.empty()) return uids;
|
||||
document.reference = {*indices.rbegin()};
|
||||
if (indices.size() == 1) window.newElementId = *indices.rbegin();
|
||||
return uids;
|
||||
});
|
||||
auto uids = document.edit_apply(
|
||||
edit, window.changeType,
|
||||
[&](Anm2& anm2)
|
||||
{
|
||||
auto uids = edit::animations_paste(anm2, text, start, targetGroupId, groupIds, &errorString);
|
||||
if (uids.empty()) return uids;
|
||||
auto indices = animation_indices_get(document, uids);
|
||||
animations_selection_set(window, document, groupIds.empty() ? indices : std::set<int>{}, groupIds);
|
||||
document.reference_set({});
|
||||
window.newElementId = -1;
|
||||
if (indices.empty()) return uids;
|
||||
window.scrollQueued = *indices.rbegin();
|
||||
if (!groupIds.empty()) return uids;
|
||||
document.reference_set({*indices.rbegin()});
|
||||
if (indices.size() == 1) window.newElementId = *indices.rbegin();
|
||||
return uids;
|
||||
});
|
||||
if (!errorString.empty()) toast_log(Level::ERROR, TOAST_DESERIALIZE_ANIMATIONS_FAILED, errorString);
|
||||
}
|
||||
|
||||
@@ -219,8 +239,8 @@ namespace anm2ed::imgui
|
||||
auto indices = animation_indices_get(document, uids);
|
||||
if (indices.empty()) return uids;
|
||||
merged = *indices.begin();
|
||||
document.animation.selection = {merged};
|
||||
document.reference = {merged};
|
||||
document.animations_selected_set({merged});
|
||||
document.reference_set({merged});
|
||||
return uids;
|
||||
});
|
||||
return merged;
|
||||
@@ -244,8 +264,7 @@ namespace anm2ed::imgui
|
||||
(item.type == AnimationDragDropType::GROUP ? groupIds : indices).insert(item.id);
|
||||
auto uids = edit::animations_move(anm2, indices, groupIds, targetChildIndex, targetGroupId);
|
||||
if (uids.empty() && groupIds.empty()) return;
|
||||
document.animation.selection = animation_indices_get(document, uids);
|
||||
window.selection = groupIds;
|
||||
animations_selection_set(window, document, animation_indices_get(document, uids), groupIds);
|
||||
}
|
||||
|
||||
void animation_move_command_push(Window& window, Manager& manager, std::vector<AnimationDragDropItem> items,
|
||||
@@ -426,8 +445,8 @@ namespace anm2ed::imgui
|
||||
if (isDeselected ? selection.empty() && groupSelection.empty() : !isCtrl || selection.empty())
|
||||
{
|
||||
document.animation.reference = -1;
|
||||
document.reference = {};
|
||||
document.frames.clear();
|
||||
document.reference_set({});
|
||||
document.frame_references_clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -481,7 +500,7 @@ namespace anm2ed::imgui
|
||||
{
|
||||
auto animations = document.anm2.element_get(ElementType::ANIMATIONS);
|
||||
auto isDefault = animations && animations->defaultAnimation == animation.name;
|
||||
auto isReferenced = document.reference.animationIndex == index;
|
||||
auto isReferenced = document.reference_get().animationIndex == index;
|
||||
return isDefault && isReferenced ? font::BOLD_ITALICS
|
||||
: isDefault ? font::BOLD
|
||||
: isReferenced ? font::ITALICS
|
||||
@@ -491,8 +510,8 @@ namespace anm2ed::imgui
|
||||
{
|
||||
auto& io = ImGui::GetIO();
|
||||
if (!io.KeyCtrl && !io.KeyShift) window.selection.clear();
|
||||
document.reference = {index};
|
||||
document.frames.clear();
|
||||
document.reference_set({index});
|
||||
document.frame_references_clear();
|
||||
};
|
||||
window.rename_finish = [](Document& document, Element& animation, int, int count)
|
||||
{
|
||||
@@ -521,7 +540,7 @@ namespace anm2ed::imgui
|
||||
auto container = window_container_get(window, document);
|
||||
if (!container) return;
|
||||
auto groupIds = edit::animation_group_ids_get(*container);
|
||||
std::erase_if(window.selection, [&](int groupId) { return !groupIds.contains(groupId); });
|
||||
animations_selection_load(window, document);
|
||||
|
||||
std::vector<int> visibleIds{};
|
||||
window.order.clear();
|
||||
@@ -556,6 +575,9 @@ namespace anm2ed::imgui
|
||||
++animationIndex;
|
||||
}
|
||||
window_selection_finish(window, manager, settings, clipboard, document, arrowSelectionId);
|
||||
animations_selection_set(window, document,
|
||||
{document.animation.selection.begin(), document.animation.selection.end()},
|
||||
std::set<int>(window.selection));
|
||||
};
|
||||
window.add = [](Window& window, Manager&, Settings&, Document& document, Clipboard&)
|
||||
{
|
||||
@@ -581,11 +603,11 @@ namespace anm2ed::imgui
|
||||
document.edit_apply(EDIT_ADD_ANIMATION, window.changeType,
|
||||
[&](Anm2& anm2)
|
||||
{
|
||||
auto uids = edit::animation_add(anm2, index, groupId, document.reference.animationIndex,
|
||||
localize.get(TEXT_NEW_ANIMATION));
|
||||
selection = {index};
|
||||
window.selection.clear();
|
||||
document.reference = {index};
|
||||
auto uids =
|
||||
edit::animation_add(anm2, index, groupId, document.reference_get().animationIndex,
|
||||
localize.get(TEXT_NEW_ANIMATION));
|
||||
animations_selection_set(window, document, {index}, {});
|
||||
document.reference_set({index});
|
||||
window.newElementId = index;
|
||||
window.scrollQueued = index;
|
||||
return uids;
|
||||
@@ -675,9 +697,8 @@ namespace anm2ed::imgui
|
||||
[&](Anm2& anm2)
|
||||
{
|
||||
auto uids = edit::animations_group(anm2, targetSet, localize.get(TEXT_NEW_GROUP));
|
||||
document.animation.selection = targetSet;
|
||||
window.selection = {groupId};
|
||||
document.reference = {*targetSet.begin()};
|
||||
animations_selection_set(window, document, targetSet, {groupId});
|
||||
document.reference_set({*targetSet.begin()});
|
||||
window.scrollQueued = *targetSet.begin();
|
||||
return uids;
|
||||
});
|
||||
@@ -812,9 +833,10 @@ namespace anm2ed::imgui
|
||||
auto count = animations ? animations_count_get(*animations) : 0;
|
||||
if ((!isPrevious && !isNext) || count <= 0) return;
|
||||
|
||||
auto& reference = document.reference;
|
||||
auto reference = document.reference_get();
|
||||
reference.animationIndex = std::clamp(reference.animationIndex + (isNext ? 1 : -1), 0, count - 1);
|
||||
document.animation.selection = {reference.animationIndex};
|
||||
document.reference_set(reference);
|
||||
animations_selection_set(window, document, {reference.animationIndex}, std::set<int>(window.selection));
|
||||
window.scrollQueued = reference.animationIndex;
|
||||
};
|
||||
return window;
|
||||
|
||||
@@ -48,10 +48,10 @@ namespace anm2ed::imgui
|
||||
{
|
||||
auto& document = *manager.get();
|
||||
auto frameSelectionCount = document.frame_references_get(Document::FrameReferenceFallback::NONE).size();
|
||||
if (frameSelectionCount == 0 && document.reference.frameIndex >= 0) frameSelectionCount = 1;
|
||||
if (frameSelectionCount == 0 && document.reference_get().frameIndex >= 0) frameSelectionCount = 1;
|
||||
auto isSingleFrameSelection = frameSelectionCount == 1;
|
||||
auto isMultiFrameSelection = frameSelectionCount > 1;
|
||||
auto isSingleFrameBatchMode = isSingleFrameSelection && document.reference.itemType != TRIGGER && isBatchMode;
|
||||
auto isSingleFrameBatchMode = isSingleFrameSelection && document.reference_get().itemType != TRIGGER && isBatchMode;
|
||||
auto isBatchFrameProperties = isMultiFrameSelection || isSingleFrameBatchMode;
|
||||
auto windowLabel = std::string(
|
||||
localize.get(isBatchFrameProperties ? LABEL_CHANGE_ALL_FRAME_PROPERTIES : LABEL_FRAME_PROPERTIES_WINDOW));
|
||||
@@ -60,7 +60,7 @@ namespace anm2ed::imgui
|
||||
if (ImGui::Begin(windowLabel.c_str(), &settings.windowIsFrameProperties))
|
||||
{
|
||||
auto& anm2 = document.anm2;
|
||||
auto& reference = document.reference;
|
||||
auto reference = document.reference_get();
|
||||
auto& type = reference.itemType;
|
||||
auto frame = reference.frameIndex >= 0 ? anm2.element_get(reference) : nullptr;
|
||||
|
||||
@@ -138,8 +138,10 @@ namespace anm2ed::imgui
|
||||
frame.atFrame = atFrame;
|
||||
if (!item) return;
|
||||
frames_sort_by_at_frame(*item);
|
||||
document.reference.frameIndex = frame_index_from_at_frame_get(*item, atFrame);
|
||||
document.frame_references_set({document.reference});
|
||||
auto reference = document.reference_get();
|
||||
reference.frameIndex = frame_index_from_at_frame_get(*item, atFrame);
|
||||
document.reference_set(reference);
|
||||
document.frame_references_set({reference});
|
||||
});
|
||||
}
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_TRIGGER_AT_FRAME));
|
||||
|
||||
@@ -409,9 +409,8 @@ namespace anm2ed::imgui
|
||||
window.row_select = [](Window&, Document& document, int)
|
||||
{
|
||||
document.editTarget = Document::EditTarget::REGION;
|
||||
document.reference = {document.reference.animationIndex};
|
||||
document.frames.reference = -1;
|
||||
document.frames.selection.clear();
|
||||
document.reference_set({document.reference_get().animationIndex});
|
||||
document.frame_references_clear();
|
||||
};
|
||||
window.tooltip_draw = [](Document& document, Resources& resources, const Element& region)
|
||||
{
|
||||
@@ -464,9 +463,8 @@ namespace anm2ed::imgui
|
||||
if (!document.regions_trim(document.spritesheet.reference, region.selection)) return;
|
||||
if (region.reference != -1 && !region.selection.contains(region.reference))
|
||||
region.reference = *region.selection.begin();
|
||||
document.reference = {document.reference.animationIndex};
|
||||
document.frames.reference = -1;
|
||||
document.frames.selection.clear();
|
||||
document.reference_set({document.reference_get().animationIndex});
|
||||
document.frame_references_clear();
|
||||
});
|
||||
};
|
||||
window.paste = [](Window& window, Manager&, Settings&, Document& document, Clipboard& clipboard)
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace anm2ed::imgui
|
||||
|
||||
auto& document = *manager.get();
|
||||
auto& anm2 = document.anm2;
|
||||
auto& reference = document.reference;
|
||||
auto reference = document.reference_get();
|
||||
auto& referenceSpritesheet = document.spritesheet.reference;
|
||||
auto& pan = document.editorPan;
|
||||
auto& zoom = document.editorZoom;
|
||||
@@ -51,7 +51,7 @@ namespace anm2ed::imgui
|
||||
if (auto layer = anm2.element_get(ElementType::LAYER_ELEMENT, frameReference.itemID))
|
||||
return layer->spritesheetId;
|
||||
}
|
||||
if (document.is_frame_reference_valid(reference) && reference.itemType == LAYER)
|
||||
if (reference.frameIndex >= 0 && reference.itemType == LAYER)
|
||||
if (auto layer = anm2.element_get(ElementType::LAYER_ELEMENT, reference.itemID)) return layer->spritesheetId;
|
||||
return -1;
|
||||
};
|
||||
|
||||
@@ -162,8 +162,7 @@ namespace anm2ed::imgui
|
||||
Document& document;
|
||||
Anm2& anm2;
|
||||
Playback& playback;
|
||||
Reference& reference;
|
||||
Storage& frames;
|
||||
Reference reference;
|
||||
Storage& region;
|
||||
Element* animation{};
|
||||
float rowFrameChildHeight{};
|
||||
@@ -207,7 +206,6 @@ namespace anm2ed::imgui
|
||||
int group_items_count_get(int type, int groupId);
|
||||
Element* command_item_reference_get(Document& document, Reference itemReference);
|
||||
glm::vec4 color_get(TimelineColor, int);
|
||||
void frames_focus_sync_for(Document&);
|
||||
std::set<Reference> drag_frame_references_get(const Reference&);
|
||||
// Queues an edit on the document; its result is selected (frames by default).
|
||||
template <class Operation>
|
||||
@@ -222,6 +220,7 @@ namespace anm2ed::imgui
|
||||
});
|
||||
}
|
||||
void edit_begin_push(StringType);
|
||||
void reference_set(Reference);
|
||||
void frames_select_for(Document&, const edit::Uids&);
|
||||
Element* command_frame_get(Document& document, const Reference& targetReference);
|
||||
Reference item_reference_get(int type, int id, int groupType = NONE, int groupId = -1);
|
||||
@@ -229,7 +228,6 @@ namespace anm2ed::imgui
|
||||
bool is_same_item(const Reference& left, const Reference& right);
|
||||
void group_selection_reset_for(Document& targetDocument);
|
||||
std::set<Reference> item_references_for_current_get();
|
||||
void frames_selection_sync_for(Document& targetDocument);
|
||||
void item_selection_set_for(Document& targetDocument, Reference itemReference);
|
||||
void frame_selection_set_for(Document& targetDocument, Reference frameReference);
|
||||
void frame_selection_toggle_for(Document& targetDocument, Reference frameReference);
|
||||
@@ -239,7 +237,6 @@ namespace anm2ed::imgui
|
||||
std::set<Reference> copy_frame_references_get();
|
||||
void frames_selection_reset_for(Document& targetDocument);
|
||||
void frames_selection_set_reference_for(Document& targetDocument);
|
||||
void frames_reference_normalize_for(Document& targetDocument);
|
||||
void reference_clear_for(Document& targetDocument);
|
||||
void reference_set_item_reference_for(Document& targetDocument, Reference itemReference);
|
||||
void reference_set_timeline_item_reference_for(Document& targetDocument, Reference itemReference);
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ namespace anm2ed::imgui
|
||||
void TimelineContext::frame_move_drag_clear()
|
||||
{
|
||||
frameMoveDrag = {};
|
||||
frameSelectionLocked.clear();
|
||||
frameMoveDropType = NONE;
|
||||
frameMoveDropItemID = -1;
|
||||
frameMoveDropGroupType = NONE;
|
||||
@@ -189,9 +188,9 @@ namespace anm2ed::imgui
|
||||
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows) &&
|
||||
ImGui::Shortcut(ImGuiKey_Escape, ImGuiInputFlags_RouteFocused))
|
||||
{
|
||||
if (!frames.references.empty() || !frames.selection.empty())
|
||||
if (!document.selection.uids[SelectionKind::FRAMES].empty())
|
||||
{
|
||||
reference.frameIndex = -1;
|
||||
reference_set(item_reference_from_frame_get(reference));
|
||||
frames_selection_reset_for(document);
|
||||
}
|
||||
else if (reference.itemType != NONE || reference.itemID != -1)
|
||||
@@ -370,6 +369,7 @@ namespace anm2ed::imgui
|
||||
}
|
||||
|
||||
auto frameType = track_frame_type_get(*item);
|
||||
auto& selectedFrames = document.selection.uids[SelectionKind::FRAMES];
|
||||
int frameIndex{};
|
||||
for (int childIndex = 0; childIndex < (int)item->children.size(); ++childIndex)
|
||||
{
|
||||
@@ -380,10 +380,7 @@ namespace anm2ed::imgui
|
||||
auto frameReference = row_reference_make(frameIndex);
|
||||
auto isFrameVisible = isVisible && frame.isVisible;
|
||||
auto isReferenced = reference == frameReference;
|
||||
auto isSelected = frames.references.contains(frameReference) ||
|
||||
(frames.references.empty() && frames.selection.contains(frameIndex) &&
|
||||
reference.itemType == type && reference.itemID == id &&
|
||||
reference.groupType == row.rootGroupType && reference.groupId == row.rootGroupId);
|
||||
auto isSelected = selectedFrames.contains(frame.uid);
|
||||
|
||||
if (type == TRIGGER) frameTime = frame.atFrame;
|
||||
|
||||
@@ -399,9 +396,6 @@ namespace anm2ed::imgui
|
||||
}
|
||||
auto buttonPos = ImVec2(cursorPos.x + (frameTime * frameSize.x), cursorPos.y);
|
||||
|
||||
if (frameFocusRequested && frameFocusIndex == frameIndex && reference == frameReference)
|
||||
frameFocusRequested = false;
|
||||
|
||||
ImGui::SetCursorPos(buttonPos);
|
||||
|
||||
auto buttonScreenPos = ImGui::GetCursorScreenPos();
|
||||
@@ -419,7 +413,6 @@ namespace anm2ed::imgui
|
||||
ImGui::SetNextItemAllowOverlap();
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, FRAME_ROUNDING);
|
||||
ImGui::SetNextItemSelectionUserData(frameIndex);
|
||||
bool isDifferentItem = !is_same_item(reference, frameReference);
|
||||
if (ImGui::Selectable("##Frame Button", isSelected, ImGuiSelectableFlags_None, buttonSize))
|
||||
{
|
||||
if (type == LAYER)
|
||||
@@ -467,11 +460,10 @@ namespace anm2ed::imgui
|
||||
frameSelectionAnchor = frameReference;
|
||||
isFrameSelectionAnchorSet = true;
|
||||
}
|
||||
reference = frameReference;
|
||||
reference_set(frameReference);
|
||||
isReferenced = true;
|
||||
region.reference = -1;
|
||||
region.selection.clear();
|
||||
if (isDifferentItem) frames_selection_sync_for(document);
|
||||
}
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
@@ -563,22 +555,6 @@ namespace anm2ed::imgui
|
||||
(ImGui::IsMouseReleased(ImGuiMouseButton_Left) || ImGui::IsMouseReleased(ImGuiMouseButton_Right)) &&
|
||||
!ImGui::IsAnyItemHovered())
|
||||
row_selection_set(row);
|
||||
|
||||
if (isFrameSelectionLocked)
|
||||
{
|
||||
std::set<Reference> lockedSelection{};
|
||||
for (int idx : frameSelectionLocked)
|
||||
lockedSelection.insert(row_reference_make(idx));
|
||||
document.frame_references_set(std::move(lockedSelection));
|
||||
isFrameSelectionLocked = false;
|
||||
frameSelectionLocked.clear();
|
||||
}
|
||||
if (reference.itemType == type && reference.itemID == id && reference.groupType == row.rootGroupType &&
|
||||
reference.groupId == row.rootGroupId)
|
||||
{
|
||||
frameSelectionSnapshot.assign(frames.selection.begin(), frames.selection.end());
|
||||
frameSelectionSnapshotReference = reference;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -639,7 +615,6 @@ namespace anm2ed::imgui
|
||||
draggedFrameStartMouseX = 0.0f;
|
||||
draggedFrameWidth = 0.0f;
|
||||
isDraggedFrameSnapshot = false;
|
||||
frameSelectionLocked.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -692,7 +667,6 @@ namespace anm2ed::imgui
|
||||
{
|
||||
group_selection_reset_for(document);
|
||||
document.frame_references_set(document.selected_item_frame_references_get());
|
||||
if (!document.frames.references.empty()) frames_selection_sync_for(document);
|
||||
}
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2());
|
||||
@@ -809,7 +783,6 @@ namespace anm2ed::imgui
|
||||
}
|
||||
else
|
||||
document.frame_references_set(frameBoxSelection);
|
||||
frames_selection_sync_for(document);
|
||||
}
|
||||
isFrameBoxPending = false;
|
||||
isFrameBoxSelecting = false;
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace anm2ed::imgui
|
||||
{
|
||||
void TimelineContext::frame_begin()
|
||||
{
|
||||
frames_reference_normalize_for(document);
|
||||
iconTintDefault = isLightTheme ? ICON_TINT_DEFAULT_LIGHT : ICON_TINT_DEFAULT_DARK;
|
||||
itemIconTint = isLightTheme ? ICON_TINT_DEFAULT_LIGHT : iconTintDefault;
|
||||
frameBorderColor = isLightTheme ? FRAME_BORDER_COLOR_LIGHT : FRAME_BORDER_COLOR_DARK;
|
||||
|
||||
@@ -197,8 +197,10 @@ namespace anm2ed::imgui
|
||||
if (isPreviousFrame || isNextFrame)
|
||||
if (auto item = selected_item_get(); item && !item->children.empty())
|
||||
{
|
||||
reference.frameIndex = glm::clamp(reference.frameIndex + (int)isNextFrame - (int)isPreviousFrame, 0,
|
||||
(int)item->children.size() - 1);
|
||||
auto frameReference = reference;
|
||||
frameReference.frameIndex = glm::clamp(reference.frameIndex + (int)isNextFrame - (int)isPreviousFrame, 0,
|
||||
(int)item->children.size() - 1);
|
||||
reference_set(frameReference);
|
||||
frames_selection_set_reference_for(document);
|
||||
document.frameTime = frame_time_from_index_get(*item, reference.frameIndex);
|
||||
}
|
||||
|
||||
@@ -62,15 +62,6 @@ namespace anm2ed::imgui
|
||||
return isLightTheme ? colors.light[std::clamp(type, 0, TRIGGER)] : colors.dark[type];
|
||||
}
|
||||
|
||||
void TimelineContext::frames_focus_sync_for(Document& targetDocument)
|
||||
{
|
||||
frames_selection_sync_for(targetDocument);
|
||||
frameSelectionLocked.clear();
|
||||
isFrameSelectionLocked = false;
|
||||
frameFocusIndex = targetDocument.reference.frameIndex;
|
||||
frameFocusRequested = true;
|
||||
}
|
||||
|
||||
std::set<Reference> TimelineContext::drag_frame_references_get(const Reference& frameReference)
|
||||
{
|
||||
auto selectedReferences = document.frame_references_get(Document::FrameReferenceFallback::NONE);
|
||||
@@ -84,17 +75,22 @@ namespace anm2ed::imgui
|
||||
command_push([label](Manager&, Document& document) { document.edit_begin(label); });
|
||||
}
|
||||
|
||||
void TimelineContext::reference_set(Reference value)
|
||||
{
|
||||
reference = value;
|
||||
document.reference_set(value);
|
||||
}
|
||||
|
||||
void TimelineContext::frames_select_for(Document& targetDocument, const edit::Uids& uids)
|
||||
{
|
||||
auto references = targetDocument.references_get(uids);
|
||||
if (references.empty()) return;
|
||||
targetDocument.reference = references.front();
|
||||
auto focus = references.front();
|
||||
targetDocument.editTarget = Document::EditTarget::FRAME;
|
||||
targetDocument.frame_references_set({references.begin(), references.end()});
|
||||
if (auto item = command_item_reference_get(targetDocument, targetDocument.reference);
|
||||
item && targetDocument.reference.itemType != TRIGGER)
|
||||
targetDocument.frameTime = frame_time_from_index_get(*item, targetDocument.reference.frameIndex);
|
||||
frames_focus_sync_for(targetDocument);
|
||||
targetDocument.reference_set(focus);
|
||||
if (auto item = command_item_reference_get(targetDocument, focus); item && focus.itemType != TRIGGER)
|
||||
targetDocument.frameTime = frame_time_from_index_get(*item, focus.frameIndex);
|
||||
}
|
||||
|
||||
Reference TimelineContext::item_reference_get(int type, int id, int groupType, int groupId)
|
||||
@@ -116,34 +112,20 @@ namespace anm2ed::imgui
|
||||
|
||||
void TimelineContext::group_selection_reset_for(Document& targetDocument)
|
||||
{
|
||||
targetDocument.groupReferences.clear();
|
||||
targetDocument.selection.uids[SelectionKind::GROUPS].clear();
|
||||
isRowSelectionAnchorSet = false;
|
||||
}
|
||||
|
||||
std::set<Reference> TimelineContext::item_references_for_current_get()
|
||||
{
|
||||
std::set<Reference> result = document.items.references;
|
||||
if (result.empty() && reference.itemType != NONE)
|
||||
{
|
||||
auto itemReference = reference;
|
||||
itemReference.frameIndex = -1;
|
||||
result.insert(itemReference);
|
||||
}
|
||||
auto result = document.selected_get(SelectionKind::TRACKS);
|
||||
if (result.empty() && reference.itemType != NONE) result.insert(item_reference_from_frame_get(reference));
|
||||
return result;
|
||||
}
|
||||
|
||||
void TimelineContext::frames_selection_sync_for(Document& targetDocument)
|
||||
{
|
||||
auto selectedFrames = targetDocument.frame_references_get(Document::FrameReferenceFallback::NONE);
|
||||
targetDocument.frame_references_set(std::move(selectedFrames));
|
||||
frameSelectionSnapshot.assign(targetDocument.frames.selection.begin(), targetDocument.frames.selection.end());
|
||||
frameSelectionSnapshotReference = targetDocument.reference;
|
||||
}
|
||||
|
||||
void TimelineContext::item_selection_set_for(Document& targetDocument, Reference itemReference)
|
||||
{
|
||||
itemReference.frameIndex = -1;
|
||||
targetDocument.items.references = {itemReference};
|
||||
targetDocument.selected_set(SelectionKind::TRACKS, {item_reference_from_frame_get(itemReference)});
|
||||
}
|
||||
|
||||
void TimelineContext::frame_selection_set_for(Document& targetDocument, Reference frameReference)
|
||||
@@ -151,7 +133,7 @@ namespace anm2ed::imgui
|
||||
group_selection_reset_for(targetDocument);
|
||||
targetDocument.editTarget = Document::EditTarget::FRAME;
|
||||
targetDocument.frame_references_set({frameReference});
|
||||
frames_selection_sync_for(targetDocument);
|
||||
targetDocument.reference_set(frameReference);
|
||||
}
|
||||
|
||||
void TimelineContext::frame_selection_toggle_for(Document& targetDocument, Reference frameReference)
|
||||
@@ -159,24 +141,12 @@ namespace anm2ed::imgui
|
||||
group_selection_reset_for(targetDocument);
|
||||
targetDocument.editTarget = Document::EditTarget::FRAME;
|
||||
auto selection = targetDocument.frame_references_get(Document::FrameReferenceFallback::NONE);
|
||||
auto itemReference = item_reference_from_frame_get(frameReference);
|
||||
if (selection.contains(frameReference))
|
||||
{
|
||||
if (selection.size() > 1) selection.erase(frameReference);
|
||||
bool isItemStillSelected{};
|
||||
for (const auto& selectedFrame : selection)
|
||||
if (is_same_item(selectedFrame, itemReference)) isItemStillSelected = true;
|
||||
if (!isItemStillSelected && targetDocument.items.references.size() > 1)
|
||||
targetDocument.items.references.erase(itemReference);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!selection.contains(frameReference))
|
||||
selection.insert(frameReference);
|
||||
targetDocument.items.references.insert(itemReference);
|
||||
}
|
||||
targetDocument.reference = frameReference;
|
||||
targetDocument.frame_references_set(std::move(selection));
|
||||
frames_selection_sync_for(targetDocument);
|
||||
else if (selection.size() > 1)
|
||||
selection.erase(frameReference);
|
||||
targetDocument.frame_references_set(selection);
|
||||
targetDocument.reference_set(frameReference);
|
||||
}
|
||||
|
||||
bool TimelineContext::frame_selection_range_set_for(Document& targetDocument, Reference firstReference,
|
||||
@@ -188,17 +158,12 @@ namespace anm2ed::imgui
|
||||
return false;
|
||||
|
||||
auto item = command_item_reference_get(targetDocument, lastReference);
|
||||
if (!item) return false;
|
||||
if (firstReference.frameIndex >= (int)item->children.size() ||
|
||||
lastReference.frameIndex >= (int)item->children.size())
|
||||
if (!item || std::max(firstReference.frameIndex, lastReference.frameIndex) >= track_frames_count_get(*item))
|
||||
return false;
|
||||
|
||||
auto firstIndex = firstReference.frameIndex;
|
||||
auto lastIndex = lastReference.frameIndex;
|
||||
if (firstIndex > lastIndex) std::swap(firstIndex, lastIndex);
|
||||
auto [firstIndex, lastIndex] = std::minmax(firstReference.frameIndex, lastReference.frameIndex);
|
||||
auto selectedFrames = isAdditive ? targetDocument.frame_references_get(Document::FrameReferenceFallback::NONE)
|
||||
: std::set<Reference>{};
|
||||
|
||||
for (int i = firstIndex; i <= lastIndex; ++i)
|
||||
{
|
||||
auto frameReference = lastReference;
|
||||
@@ -206,9 +171,8 @@ namespace anm2ed::imgui
|
||||
selectedFrames.insert(frameReference);
|
||||
}
|
||||
|
||||
targetDocument.reference = lastReference;
|
||||
targetDocument.frame_references_set(std::move(selectedFrames));
|
||||
frames_selection_sync_for(targetDocument);
|
||||
targetDocument.frame_references_set(selectedFrames);
|
||||
targetDocument.reference_set(lastReference);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -222,13 +186,9 @@ namespace anm2ed::imgui
|
||||
auto selectedFrames = document.frame_references_get(Document::FrameReferenceFallback::NONE);
|
||||
if (!selectedFrames.empty()) return selectedFrames;
|
||||
|
||||
auto selectedItems = document.items.references;
|
||||
auto selectedItems = document.selected_get(SelectionKind::TRACKS);
|
||||
if (selectedItems.empty() && reference.itemType != NONE && reference.frameIndex < 0)
|
||||
{
|
||||
auto itemReference = reference;
|
||||
itemReference.frameIndex = -1;
|
||||
selectedItems.insert(itemReference);
|
||||
}
|
||||
selectedItems.insert(item_reference_from_frame_get(reference));
|
||||
|
||||
std::set<Reference> result{};
|
||||
for (auto itemReference : selectedItems)
|
||||
@@ -244,57 +204,27 @@ namespace anm2ed::imgui
|
||||
void TimelineContext::frames_selection_reset_for(Document& targetDocument)
|
||||
{
|
||||
targetDocument.frame_references_clear();
|
||||
frameSelectionSnapshot.clear();
|
||||
frameSelectionLocked.clear();
|
||||
isFrameSelectionLocked = false;
|
||||
frameFocusRequested = false;
|
||||
frameFocusIndex = -1;
|
||||
frameSelectionSnapshotReference = targetDocument.reference;
|
||||
}
|
||||
|
||||
void TimelineContext::frames_selection_set_reference_for(Document& targetDocument)
|
||||
{
|
||||
auto& targetReference = targetDocument.reference;
|
||||
if (targetReference.frameIndex >= 0)
|
||||
{
|
||||
targetDocument.editTarget = Document::EditTarget::FRAME;
|
||||
targetDocument.frame_references_set({targetReference});
|
||||
}
|
||||
else
|
||||
targetDocument.frame_references_clear();
|
||||
frameSelectionSnapshot.assign(targetDocument.frames.selection.begin(), targetDocument.frames.selection.end());
|
||||
frameSelectionSnapshotReference = targetReference;
|
||||
frameSelectionLocked.clear();
|
||||
isFrameSelectionLocked = false;
|
||||
frameFocusIndex = targetReference.frameIndex;
|
||||
frameFocusRequested = targetReference.frameIndex >= 0;
|
||||
}
|
||||
|
||||
void TimelineContext::frames_reference_normalize_for(Document& targetDocument)
|
||||
{
|
||||
auto selectedFrames = targetDocument.frame_references_get(Document::FrameReferenceFallback::NONE);
|
||||
if (!selectedFrames.empty())
|
||||
{
|
||||
targetDocument.frame_references_set(std::move(selectedFrames));
|
||||
frames_selection_sync_for(targetDocument);
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetDocument.reference.frameIndex >= 0 && !targetDocument.is_frame_reference_valid(targetDocument.reference))
|
||||
targetDocument.reference.frameIndex = -1;
|
||||
auto targetReference = targetDocument.reference_get();
|
||||
if (targetReference.frameIndex < 0) return targetDocument.frame_references_clear();
|
||||
targetDocument.editTarget = Document::EditTarget::FRAME;
|
||||
targetDocument.frame_references_set({targetReference});
|
||||
}
|
||||
|
||||
void TimelineContext::reference_clear_for(Document& targetDocument)
|
||||
{
|
||||
targetDocument.reference = {targetDocument.reference.animationIndex};
|
||||
targetDocument.reference_set({targetDocument.reference_get().animationIndex});
|
||||
frames_selection_reset_for(targetDocument);
|
||||
targetDocument.items.references.clear();
|
||||
targetDocument.selection.uids[SelectionKind::TRACKS].clear();
|
||||
}
|
||||
|
||||
void TimelineContext::reference_set_item_reference_for(Document& targetDocument, Reference itemReference)
|
||||
{
|
||||
itemReference.frameIndex = -1;
|
||||
targetDocument.reference = itemReference;
|
||||
targetDocument.reference_set(itemReference);
|
||||
frames_selection_reset_for(targetDocument);
|
||||
item_selection_set_for(targetDocument, itemReference);
|
||||
}
|
||||
@@ -429,49 +359,59 @@ namespace anm2ed::imgui
|
||||
|
||||
bool TimelineContext::is_group_selected(const TimelineItemRow& row)
|
||||
{
|
||||
return document.groupReferences.contains(group_reference_get(row));
|
||||
return document.selected_get(SelectionKind::GROUPS).contains(group_reference_get(row));
|
||||
}
|
||||
|
||||
bool TimelineContext::is_row_selected(const TimelineItemRow& row)
|
||||
{
|
||||
if (row.isGroup) return is_group_selected(row);
|
||||
auto itemReference = item_reference_get(row.type, row.id, row.rootGroupType, row.rootGroupId);
|
||||
auto isReferenced = is_same_item(reference, itemReference);
|
||||
return document.items.references.contains(itemReference) ||
|
||||
(document.items.references.empty() && document.groupReferences.empty() && isReferenced);
|
||||
auto tracks = document.selected_get(SelectionKind::TRACKS);
|
||||
return tracks.contains(itemReference) ||
|
||||
(tracks.empty() && document.selection.uids[SelectionKind::GROUPS].empty() &&
|
||||
is_same_item(reference, itemReference));
|
||||
}
|
||||
|
||||
SelectionKind row_kind_get(const TimelineRowReference& row)
|
||||
{
|
||||
return row.isGroup ? SelectionKind::GROUPS : SelectionKind::TRACKS;
|
||||
}
|
||||
|
||||
Reference row_selection_reference_get(const TimelineRowReference& row)
|
||||
{
|
||||
return row.isGroup ? Reference{row.animationIndex, row.type, row.id}
|
||||
: Reference{row.animationIndex, row.type, row.id, -1, row.groupType, row.groupId};
|
||||
}
|
||||
|
||||
void TimelineContext::row_selection_clear()
|
||||
{
|
||||
document.items.references.clear();
|
||||
document.groupReferences.clear();
|
||||
document.selection.uids[SelectionKind::TRACKS].clear();
|
||||
document.selection.uids[SelectionKind::GROUPS].clear();
|
||||
}
|
||||
|
||||
void TimelineContext::row_selection_insert(const TimelineRowReference& row)
|
||||
{
|
||||
if (row.isGroup)
|
||||
document.groupReferences.insert({row.animationIndex, row.type, row.id});
|
||||
else
|
||||
document.items.references.insert(row_item_reference_get(row));
|
||||
auto references = document.selected_get(row_kind_get(row));
|
||||
references.insert(row_selection_reference_get(row));
|
||||
document.selected_set(row_kind_get(row), references);
|
||||
}
|
||||
|
||||
void TimelineContext::row_selection_erase(const TimelineRowReference& row)
|
||||
{
|
||||
if (row.isGroup)
|
||||
document.groupReferences.erase({row.animationIndex, row.type, row.id});
|
||||
else
|
||||
document.items.references.erase(row_item_reference_get(row));
|
||||
auto references = document.selected_get(row_kind_get(row));
|
||||
references.erase(row_selection_reference_get(row));
|
||||
document.selected_set(row_kind_get(row), references);
|
||||
}
|
||||
|
||||
bool TimelineContext::is_row_reference_selected(const TimelineRowReference& row)
|
||||
{
|
||||
if (row.isGroup) return document.groupReferences.contains({row.animationIndex, row.type, row.id});
|
||||
return document.items.references.contains(row_item_reference_get(row));
|
||||
return document.selected_get(row_kind_get(row)).contains(row_selection_reference_get(row));
|
||||
}
|
||||
|
||||
std::size_t TimelineContext::row_selection_count_get()
|
||||
{
|
||||
return document.items.references.size() + document.groupReferences.size();
|
||||
return document.selection.uids[SelectionKind::TRACKS].size() +
|
||||
document.selection.uids[SelectionKind::GROUPS].size();
|
||||
}
|
||||
|
||||
void TimelineContext::row_selection_set(const TimelineItemRow& row)
|
||||
@@ -481,13 +421,13 @@ namespace anm2ed::imgui
|
||||
auto isShiftDown = ImGui::IsKeyDown(ImGuiMod_Shift);
|
||||
|
||||
if (row.isGroup)
|
||||
reference = {reference.animationIndex};
|
||||
reference_set({reference.animationIndex});
|
||||
else
|
||||
{
|
||||
if (row.type == LAYER)
|
||||
if (auto layer = anm2.element_get(ElementType::LAYER_ELEMENT, row.id))
|
||||
document.spritesheet.reference = layer->spritesheetId;
|
||||
reference = row_item_reference_get(rowReference);
|
||||
reference_set(row_item_reference_get(rowReference));
|
||||
}
|
||||
frames_selection_reset_for(document);
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace anm2ed::imgui
|
||||
Clipboard& clipboard)
|
||||
: TimelineState(std::move(state)), manager(manager), settings(settings), resources(resources),
|
||||
clipboard(clipboard), document(*manager.get()), anm2(document.anm2), playback(document.playback),
|
||||
reference(document.reference), frames(document.frames), region(document.region)
|
||||
reference(document.reference_get()), region(document.region)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -95,13 +95,7 @@ namespace anm2ed::imgui
|
||||
float draggedFrameStartMouseX{};
|
||||
float draggedFrameWidth{};
|
||||
bool isDraggedFrameSnapshot{};
|
||||
bool frameFocusRequested{};
|
||||
int frameFocusIndex{-1};
|
||||
FrameMoveDrag frameMoveDrag{};
|
||||
std::vector<int> frameSelectionSnapshot{};
|
||||
std::vector<int> frameSelectionLocked{};
|
||||
bool isFrameSelectionLocked{};
|
||||
Reference frameSelectionSnapshotReference{};
|
||||
Reference frameSelectionAnchor{};
|
||||
bool isFrameSelectionAnchorSet{};
|
||||
int animationLengthEditIndex{-1};
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace anm2ed::imgui::wizard
|
||||
isEnd = false;
|
||||
|
||||
auto& anm2 = document.anm2;
|
||||
auto& reference = document.reference;
|
||||
auto reference = document.reference_get();
|
||||
auto& startPosition = settings.generateStartPosition;
|
||||
auto& size = settings.generateSize;
|
||||
auto& pivot = settings.generatePivot;
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace anm2ed::imgui::wizard
|
||||
{
|
||||
void RenderAnimation::range_to_animation_set(Manager& manager, Document& document)
|
||||
{
|
||||
if (auto animation = document.anm2.element_get(ElementType::ANIMATION, document.reference.animationIndex))
|
||||
if (auto animation = document.anm2.element_get(ElementType::ANIMATION, document.reference_get().animationIndex))
|
||||
{
|
||||
manager.recordingStart = 0;
|
||||
manager.recordingEnd = animation->frameNum - 1;
|
||||
@@ -31,7 +31,7 @@ namespace anm2ed::imgui::wizard
|
||||
void RenderAnimation::range_to_frames_set(Manager& manager, Document& document)
|
||||
{
|
||||
auto frameReferences = document.frame_references_get(Document::FrameReferenceFallback::NONE);
|
||||
auto& reference = document.reference;
|
||||
auto reference = document.reference_get();
|
||||
std::erase_if(frameReferences,
|
||||
[&](const Reference& frameReference)
|
||||
{
|
||||
@@ -72,7 +72,7 @@ namespace anm2ed::imgui::wizard
|
||||
{
|
||||
isEnd = false;
|
||||
|
||||
auto animation = document.anm2.element_get(ElementType::ANIMATION, document.reference.animationIndex);
|
||||
auto animation = document.anm2.element_get(ElementType::ANIMATION, document.reference_get().animationIndex);
|
||||
if (!animation) return;
|
||||
|
||||
auto& ffmpegPath = settings.renderFFmpegPath;
|
||||
@@ -88,7 +88,7 @@ namespace anm2ed::imgui::wizard
|
||||
auto& rows = settings.renderRows;
|
||||
auto& columns = settings.renderColumns;
|
||||
auto& isRange = manager.isRecordingRange;
|
||||
auto& reference = document.reference;
|
||||
auto reference = document.reference_get();
|
||||
auto& frameNum = animation->frameNum;
|
||||
auto animationFrameNum = std::max(frameNum, 1);
|
||||
auto frameMax = animationFrameNum - 1;
|
||||
|
||||
Reference in new issue
Block a user