Item Properties shares Layer Properties' source fields
New layers added from the timeline can play an animation too: both popups draw the source with layer_source_draw and build the item from the same ItemEdit, and edit::item_add takes the new layer or null whole. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
af60cdc11c
commit
6b6cd671f7
7 files changed
+91
-94
No files matched your search
+1
-1
@@ -110,7 +110,7 @@ namespace anm2ed::edit
|
||||
Uids items_group(model::Model&, int, int, const std::set<int>&, const std::string&);
|
||||
Uids items_move(model::Model&, int, int, const std::set<int>&, const std::set<int>&, RowTarget, bool, bool);
|
||||
Uids animation_length_fit(model::Model&, int);
|
||||
int item_add(model::Model&, ItemType, int, int, const std::string&, int, bool, int, types::destination::Type);
|
||||
int item_add(model::Model&, ItemType, int, int, model::Layer, model::Null, int, types::destination::Type);
|
||||
|
||||
std::set<int> animation_group_ids_get(const model::Model&);
|
||||
std::set<int> animation_group_indices_get(const model::Model&, int);
|
||||
|
||||
+13
-16
@@ -159,26 +159,23 @@ namespace anm2ed::edit
|
||||
}
|
||||
|
||||
// Adds a layer or null (or updates the one with the item's id) and gives it a track in one or every animation.
|
||||
int item_add(Model& model, ItemType type, int animationIndex, int id, const std::string& name, int spritesheetId,
|
||||
bool isShowRect, int insertBeforeId, types::destination::Type destination)
|
||||
// Adds track `id` (a new item, from `layer` or `null`, at -1) to an animation or all of them.
|
||||
int item_add(Model& model, ItemType type, int animationIndex, int id, Layer layer, Null null, int insertBeforeId,
|
||||
types::destination::Type destination)
|
||||
{
|
||||
auto& content = model.content;
|
||||
auto item_insert = [&](auto& items, auto item)
|
||||
{
|
||||
if (id == -1) id = item_next_id_get(items);
|
||||
if (item_get(items, id)) return;
|
||||
item.id = id;
|
||||
items.push_back(item);
|
||||
};
|
||||
if (!item_get(content.spritesheets, layer.spritesheetId)) layer.spritesheetId = 0;
|
||||
if (type == ItemType::LAYER)
|
||||
{
|
||||
if (id == -1) id = item_next_id_get(content.layers);
|
||||
auto layer = item_get(content.layers, id);
|
||||
if (!layer) layer = &content.layers.emplace_back(Layer{.id = id});
|
||||
if (!name.empty()) layer->name = name;
|
||||
layer->spritesheetId = item_get(content.spritesheets, spritesheetId) ? spritesheetId : 0;
|
||||
}
|
||||
item_insert(content.layers, layer);
|
||||
else if (type == ItemType::NULL_)
|
||||
{
|
||||
if (id == -1) id = item_next_id_get(content.nulls);
|
||||
auto null = item_get(content.nulls, id);
|
||||
if (!null) null = &content.nulls.emplace_back(Null{.id = id});
|
||||
if (!name.empty()) null->name = name;
|
||||
null->isShowRect = isShowRect;
|
||||
}
|
||||
item_insert(content.nulls, null);
|
||||
else
|
||||
return -1;
|
||||
|
||||
|
||||
Reference in new issue
Block a user