Skip to content

Commit

Permalink
Fixing bug aseprite#1644: Combination of parameters results in jumble…
Browse files Browse the repository at this point in the history
…d layer order.

This fix iterates over layers, no matter if are visible or not
  • Loading branch information
dncampo committed Nov 10, 2018
1 parent c657038 commit d955374
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/app/cli/cli_processor.cpp
Expand Up @@ -540,7 +540,7 @@ bool CliProcessor::openFile(Context* ctx, CliOpenFile& cof)
filter_layers(doc->sprite()->allLayers(), cof, filteredLayers);

if (cof.splitLayers) {
for (Layer* layer : filteredLayers) {
for (Layer* layer : filteredLayers.toAllLayersList()) {
SelectedLayers oneLayer;
oneLayer.insert(layer);

Expand Down
20 changes: 20 additions & 0 deletions src/doc/selected_layers.cpp
Expand Up @@ -58,6 +58,26 @@ bool SelectedLayers::hasSameParent() const
return true;
}

LayerList SelectedLayers::toAllLayersList() const
{
LayerList output;

if (empty())
return output;

ASSERT(*begin());
ASSERT((*begin())->sprite());

for (Layer* layer = (*begin())->sprite()->firstLayer();
layer != nullptr;
layer = layer->getNext()) {
if (contains(layer))
output.push_back(layer);
}

return output;
}

LayerList SelectedLayers::toLayerList() const
{
LayerList output;
Expand Down
1 change: 1 addition & 0 deletions src/doc/selected_layers.h
Expand Up @@ -39,6 +39,7 @@ namespace doc {
bool contains(Layer* layer) const;
bool hasSameParent() const;
LayerList toLayerList() const;
LayerList toAllLayersList() const;

void removeChildrenIfParentIsSelected();
void expandCollapsedGroups();
Expand Down
8 changes: 8 additions & 0 deletions src/doc/sprite.cpp
Expand Up @@ -215,6 +215,14 @@ LayerImage* Sprite::backgroundLayer() const
return NULL;
}

Layer* Sprite::firstLayer() const
{
Layer* layer = root()->firstLayer();
while (layer->isGroup())
layer = static_cast<LayerGroup*>(layer)->firstLayer();
return layer;
}

Layer* Sprite::firstBrowsableLayer() const
{
Layer* layer = root()->firstLayer();
Expand Down
1 change: 1 addition & 0 deletions src/doc/sprite.h
Expand Up @@ -104,6 +104,7 @@ namespace doc {
LayerGroup* root() const { return m_root; }
LayerImage* backgroundLayer() const;
Layer* firstBrowsableLayer() const;
Layer* firstLayer() const;
layer_t allLayersCount() const;
bool hasVisibleReferenceLayers() const;

Expand Down

0 comments on commit d955374

Please sign in to comment.