Share one set of group operations between tracks and animations
model/group.h walks, finds, takes, wraps, unwraps and expands lists of items and groups. Track and animation groups both keep their members in items, and the edits, bakes, merges and writers use it.
This commit is contained in:
1 parent
03bbb93ba6
commit
7e3c5cfeb5
19 files changed
+395
-460
No files matched your search
@@ -66,7 +66,7 @@ template <class Callback> static void animation_entries_each(const Model& model,
|
||||
{
|
||||
auto& group = std::get<AnimationGroup>(entry);
|
||||
callback(index, (const Animation*)nullptr, &group);
|
||||
index += (int)group.animations.size();
|
||||
index += (int)group.items.size();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -439,7 +439,7 @@ static bool animation_group_draw(Panel& panel, std::set<int>& selection, std::se
|
||||
|
||||
if (tree.isOpen)
|
||||
{
|
||||
for (int i = 0; i < (int)group.animations.size() && !isRowsDone; ++i)
|
||||
for (int i = 0; i < (int)group.items.size() && !isRowsDone; ++i)
|
||||
isRowsDone = row_draw(panel, selection, focus, rows, firstIndex + i, firstIndex + i, arrowKey);
|
||||
ImGui::TreePop();
|
||||
}
|
||||
@@ -472,13 +472,13 @@ static void animations_merge_popup_update(Panel& panel, AnimationsPanel& animati
|
||||
animation_entries_each(document.model, [&](int index, const Animation* animation, const AnimationGroup* group) {
|
||||
if (animation)
|
||||
return candidate_animation_push(*animation, index, false);
|
||||
auto isReferenceOnly = group->animations.size() == 1 && index == mergeReference;
|
||||
if (group->animations.empty() || isReferenceOnly)
|
||||
auto isReferenceOnly = group->items.size() == 1 && index == mergeReference;
|
||||
if (group->items.empty() || isReferenceOnly)
|
||||
return;
|
||||
candidates.push_back(
|
||||
{group_key_get(group->id), group->name.empty() ? std::string(localize.get(TEXT_NEW_GROUP)) : group->name});
|
||||
for (int i = 0; i < (int)group->animations.size(); ++i)
|
||||
candidate_animation_push(*group->animations[i], index + i, true);
|
||||
for (int i = 0; i < (int)group->items.size(); ++i)
|
||||
candidate_animation_push(*group->items[i], index + i, true);
|
||||
});
|
||||
|
||||
auto footerSize = footer_size_get();
|
||||
@@ -751,7 +751,7 @@ void animations_update(Panel& panel, AnimationsPanel& animations)
|
||||
if (animation)
|
||||
visibleKeys.push_back(index);
|
||||
if (group && group->isExpanded)
|
||||
for (int i = 0; i < (int)group->animations.size(); ++i)
|
||||
for (int i = 0; i < (int)group->items.size(); ++i)
|
||||
visibleKeys.push_back(index + i);
|
||||
});
|
||||
|
||||
|
||||
@@ -24,10 +24,10 @@ std::vector<PeekRow> TimelineContext::peek_rows_get(const TimelineRow& row)
|
||||
};
|
||||
row_add(child->root);
|
||||
std::vector<const Track*> layers;
|
||||
tracks_each(child->layers, [&](const Track& childTrack, auto*) { layers.push_back(&childTrack); });
|
||||
items_each(child->layers, [&](const Track& childTrack, auto*) { layers.push_back(&childTrack); });
|
||||
for (auto it = layers.rbegin(); it != layers.rend(); ++it)
|
||||
row_add(**it);
|
||||
tracks_each(child->nulls, [&](const Track& childTrack, auto*) { row_add(childTrack); });
|
||||
items_each(child->nulls, [&](const Track& childTrack, auto*) { row_add(childTrack); });
|
||||
row_add(child->triggers);
|
||||
return rows;
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ std::set<Reference> TimelineContext::item_references_for_bake_into_other_frames_
|
||||
{
|
||||
if (!(itemType == LAYER ? isLayers : isNulls))
|
||||
continue;
|
||||
tracks_each(animation_entries_get(targetAnimation, itemType), [&](const Track& track, const TrackGroup* group) {
|
||||
items_each(animation_entries_get(targetAnimation, itemType), [&](const Track& track, const TrackGroup* group) {
|
||||
result.insert(
|
||||
Reference{animationIndex, itemType, track.id, -1, group ? itemType : NONE, group ? group->id : -1});
|
||||
});
|
||||
|
||||
@@ -153,8 +153,8 @@ std::vector<TimelineRow> TimelineContext::timeline_item_rows_get()
|
||||
if (!group.isExpanded)
|
||||
continue;
|
||||
rows.push_back({.type = ROOT, .groupType = type, .groupId = group.id, .depth = 1});
|
||||
for (auto trackIndex : order_get((int)group.tracks.size(), isReversed))
|
||||
if (auto& track = group.tracks[trackIndex]; is_track_shown(track))
|
||||
for (auto trackIndex : order_get((int)group.items.size(), isReversed))
|
||||
if (auto& track = group.items[trackIndex]; is_track_shown(track))
|
||||
rows.push_back({.type = type,
|
||||
.id = track.id,
|
||||
.index = trackIndex,
|
||||
|
||||
@@ -159,7 +159,7 @@ void TimelineContext::item_child(const TimelineRow& row, int index)
|
||||
ImGui::TextUnformatted(label.c_str());
|
||||
ImGui::PopFont();
|
||||
ImGui::TextUnformatted(std::vformat(localize.get(FORMAT_ID), std::make_format_args(group->id)).c_str());
|
||||
auto groupItemsCount = (int)group->tracks.size();
|
||||
auto groupItemsCount = (int)group->items.size();
|
||||
ImGui::TextUnformatted(
|
||||
std::vformat(localize.get(FORMAT_ITEMS_COUNT), std::make_format_args(groupItemsCount)).c_str());
|
||||
ImGui::EndTooltip();
|
||||
|
||||
Reference in new issue
Block a user