mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-28 16:20:50 +00:00
Add support to create layers inside groups
This commit is contained in:
parent
f6fa39ba52
commit
64c1ecf555
@ -378,7 +378,7 @@ void ImportSpriteSheetCommand::onExecute(Context* context)
|
||||
DocumentApi api = document->getApi(transaction);
|
||||
|
||||
// Add the layer in the sprite.
|
||||
LayerImage* resultLayer = api.newLayer(sprite, "Sprite Sheet");
|
||||
LayerImage* resultLayer = api.newLayer(sprite->root(), "Sprite Sheet");
|
||||
|
||||
// Add all frames+cels to the new layer
|
||||
for (size_t i=0; i<animation.size(); ++i) {
|
||||
|
@ -105,7 +105,20 @@ void NewLayerCommand::onExecute(Context* context)
|
||||
name = window.name()->text();
|
||||
}
|
||||
|
||||
LayerGroup* parent = sprite->root();
|
||||
Layer* activeLayer = writer.layer();
|
||||
if (activeLayer) {
|
||||
if (activeLayer->isGroup() &&
|
||||
activeLayer->isExpanded() &&
|
||||
!m_group) {
|
||||
parent = static_cast<LayerGroup*>(activeLayer);
|
||||
activeLayer = nullptr;
|
||||
}
|
||||
else {
|
||||
parent = activeLayer->parent();
|
||||
}
|
||||
}
|
||||
|
||||
Layer* layer;
|
||||
{
|
||||
Transaction transaction(
|
||||
@ -114,9 +127,9 @@ void NewLayerCommand::onExecute(Context* context)
|
||||
DocumentApi api = document->getApi(transaction);
|
||||
|
||||
if (m_group)
|
||||
layer = api.newGroup(sprite, name);
|
||||
layer = api.newGroup(parent, name);
|
||||
else
|
||||
layer = api.newLayer(sprite, name);
|
||||
layer = api.newLayer(parent, name);
|
||||
|
||||
// If "top" parameter is false, create the layer above the active
|
||||
// one.
|
||||
|
@ -396,31 +396,27 @@ void DocumentApi::swapCel(
|
||||
if (cel2) setCelFramePosition(cel2, frame1);
|
||||
}
|
||||
|
||||
LayerImage* DocumentApi::newLayer(Sprite* sprite, const std::string& name)
|
||||
LayerImage* DocumentApi::newLayer(LayerGroup* parent, const std::string& name)
|
||||
{
|
||||
LayerImage* layer = new LayerImage(sprite);
|
||||
LayerImage* layer = new LayerImage(parent->sprite());
|
||||
layer->setName(name);
|
||||
|
||||
addLayer(sprite->root(), layer,
|
||||
sprite->root()->lastLayer());
|
||||
|
||||
addLayer(parent, layer, parent->lastLayer());
|
||||
return layer;
|
||||
}
|
||||
|
||||
LayerGroup* DocumentApi::newGroup(Sprite* sprite, const std::string& name)
|
||||
LayerGroup* DocumentApi::newGroup(LayerGroup* parent, const std::string& name)
|
||||
{
|
||||
LayerGroup* layer = new LayerGroup(sprite);
|
||||
LayerGroup* layer = new LayerGroup(parent->sprite());
|
||||
layer->setName(name);
|
||||
|
||||
addLayer(sprite->root(), layer,
|
||||
sprite->root()->lastLayer());
|
||||
|
||||
addLayer(parent, layer, parent->lastLayer());
|
||||
return layer;
|
||||
}
|
||||
|
||||
void DocumentApi::addLayer(LayerGroup* folder, Layer* newLayer, Layer* afterThis)
|
||||
void DocumentApi::addLayer(LayerGroup* parent, Layer* newLayer, Layer* afterThis)
|
||||
{
|
||||
m_transaction.execute(new cmd::AddLayer(folder, newLayer, afterThis));
|
||||
m_transaction.execute(new cmd::AddLayer(parent, newLayer, afterThis));
|
||||
}
|
||||
|
||||
void DocumentApi::removeLayer(Layer* layer)
|
||||
|
@ -80,9 +80,9 @@ namespace app {
|
||||
LayerImage* layer, frame_t frame1, frame_t frame2);
|
||||
|
||||
// Layers API
|
||||
LayerImage* newLayer(Sprite* sprite, const std::string& name);
|
||||
LayerGroup* newGroup(Sprite* sprite, const std::string& name);
|
||||
void addLayer(LayerGroup* folder, Layer* newLayer, Layer* afterThis);
|
||||
LayerImage* newLayer(LayerGroup* parent, const std::string& name);
|
||||
LayerGroup* newGroup(LayerGroup* parent, const std::string& name);
|
||||
void addLayer(LayerGroup* parent, Layer* newLayer, Layer* afterThis);
|
||||
void removeLayer(Layer* layer);
|
||||
void restackLayerAfter(Layer* layer, Layer* afterThis);
|
||||
void restackLayerBefore(Layer* layer, Layer* beforeThis);
|
||||
|
Loading…
x
Reference in New Issue
Block a user