Name row drops, merge sources, playback looping and spritesheet merge options

items_move takes a DropZone, animations_merge MergeSources, Playback::tick PlaybackLoop, and spritesheets_merge SpritesheetMergeOptions.
This commit is contained in:
shweet committed 2026-11-22 18:58:37 -05:00
1 parent 228a15b5b3
commit ada48aefdd
19 files changed
+78 -53

No files matched your search

+2 -1
View File
@@ -70,7 +70,8 @@ inline std::vector<Variant> variants_get(const Model& model)
{
auto merged = model;
std::set<int> sources = {0, 1, 2};
animations_merge(merged, 0, sources, type, type == MERGE_PREPEND || type == MERGE_REPLACE, {});
animations_merge(merged, 0, sources, type,
type == MERGE_PREPEND || type == MERGE_REPLACE ? SOURCES_DELETED : SOURCES_KEPT, {});
variants.emplace_back(name, model_serialize(merged, SAVE_EDITOR));
}
return variants;
+10 -10
View File
@@ -35,7 +35,7 @@ TEST_CASE("animations_merge keeps one group per name")
{
INFO("merge: ", std::string(name));
auto model = fixture_load("03a_groups_nested.anm2");
animations_merge(model, 0, {0, 1}, type, false, {});
animations_merge(model, 0, {0, 1}, type, SOURCES_KEPT, {});
CHECK(groups_named_count(*model.animation_get(0), "Main") == 1);
}
}
@@ -190,7 +190,7 @@ TEST_CASE("edit layer operations")
[&](Model& anm2) { return items_group(anm2, 0, LAYER, {2}, "New"); }, 1},
{"items_move", "03b_groups_legacy_flat.anm2",
[&](Model& anm2) {
items_move(anm2, 0, LAYER, {2}, {}, {true, LAYER, 0, -1}, false, true);
items_move(anm2, 0, LAYER, {2}, {}, {true, LAYER, 0, -1}, DROP_INSIDE);
return Uids{};
},
0},
@@ -244,7 +244,7 @@ TEST_CASE("edit layer operations")
},
0},
{"animations_merge", "03a_groups_nested.anm2",
[&](Model& anm2) { return animations_merge(anm2, 0, {1}, MERGE_APPEND, true, {0}); }, 1},
[&](Model& anm2) { return animations_merge(anm2, 0, {1}, MERGE_APPEND, SOURCES_DELETED, {0}); }, 1},
};
for (auto& entry : CASES)
@@ -299,7 +299,7 @@ TEST_CASE("spritesheet pixel edits")
auto image_get = [&](int id) {
return id == 0 ? &sheet : &other;
};
auto merged = spritesheets_merge(model, {0, 1}, image_get, true, true, false, Origin::TOP_LEFT);
auto merged = spritesheets_merge(model, {0, 1}, image_get, {true, true, false, Origin::TOP_LEFT});
REQUIRE(merged);
CHECK(merged->size == IVec2(80, 64));
CHECK(model.content.spritesheets.size() == 1);
@@ -326,9 +326,9 @@ TEST_CASE("markers stay in the editor's copy and bound playback")
Playback playback = {};
playback.isPlaying = true;
playback.tick(10, 2, 6, true, 0.1f);
playback.tick(10, 2, 6, PLAYBACK_LOOP, 0.1f);
CHECK(playback.time == doctest::Approx(3.0f));
playback.tick(10, 2, 6, true, 0.5f);
playback.tick(10, 2, 6, PLAYBACK_LOOP, 0.5f);
CHECK(playback.time == doctest::Approx(4.0f));
}
@@ -435,11 +435,11 @@ TEST_CASE("animations_merge moves triggers past the animation placed before them
};
auto appended = model_make();
animations_merge(appended, 0, {0, 1}, MERGE_APPEND, false, {});
animations_merge(appended, 0, {0, 1}, MERGE_APPEND, SOURCES_KEPT, {});
CHECK(appended.animation_get(0)->triggers.frames.at(0).atFrame == 15);
auto prepended = model_make();
animations_merge(prepended, 1, {0, 1}, MERGE_PREPEND, false, {});
animations_merge(prepended, 1, {0, 1}, MERGE_PREPEND, SOURCES_KEPT, {});
CHECK(prepended.animation_get(1)->triggers.frames.at(0).atFrame == 15);
}
@@ -489,7 +489,7 @@ TEST_CASE("SVG spritesheets pack and merge into SVGs")
return images.at(id);
};
auto mixed = model;
auto merged = spritesheets_merge(mixed, {0, 1}, image_get, true, false, false, Origin::TOP_LEFT);
auto merged = spritesheets_merge(mixed, {0, 1}, image_get, {true, false, false, Origin::TOP_LEFT});
REQUIRE(merged);
CHECK(merged->is_vector());
CHECK(merged->size == IVec2(36, 16));
@@ -498,7 +498,7 @@ TEST_CASE("SVG spritesheets pack and merge into SVGs")
std::swap(model.content.spritesheets.front().id, model.content.spritesheets.back().id);
images = {{1, &vector}, {0, &raster}};
REQUIRE(spritesheets_merge(model, {0, 1}, image_get, true, false, false, Origin::TOP_LEFT));
REQUIRE(spritesheets_merge(model, {0, 1}, image_get, {true, false, false, Origin::TOP_LEFT}));
CHECK(item_get(model.content.spritesheets, 0)->path == "white.svg");
}
+1 -1
View File
@@ -81,7 +81,7 @@ TEST_CASE("track and group selection follow regrouping")
selection_references_set(selection, anm2, SelectionKind::TRACKS, {{0, LAYER, 0, -1, LAYER, groupId}});
selection_references_set(selection, anm2, SelectionKind::GROUPS, {{0, LAYER, groupId}});
selection_edit(anm2, selection, [&] { items_move(anm2, 0, LAYER, {0}, {}, {false, LAYER, 2, -1}, false, false); });
selection_edit(anm2, selection, [&] { items_move(anm2, 0, LAYER, {0}, {}, {false, LAYER, 2, -1}, DROP_BEFORE); });
UidIndex index(anm2);
CHECK(selection_references_get(selection, index, SelectionKind::TRACKS) == std::set<Reference>{{0, LAYER, 0}});