Fix setting opacity or user data of linked cels when the first cel isn't included in the active range

This commit is contained in:
David Capello 2016-02-01 18:05:40 -03:00
parent 99d504a3aa
commit be57d0332f
3 changed files with 17 additions and 9 deletions

View File

@ -106,10 +106,11 @@ private:
return 1; return 1;
} }
else if (m_range.enabled()) { else if (m_range.enabled()) {
Sprite* sprite = m_document->sprite();
int count = 0; int count = 0;
for (Cel* cel : m_document->sprite()->uniqueCels()) { for (Cel* cel : sprite->uniqueCels(m_range.frameBegin(),
if (m_range.inRange(cel->sprite()->layerToIndex(cel->layer()), m_range.frameEnd())) {
cel->frame())) { if (m_range.inRange(sprite->layerToIndex(cel->layer()))) {
if (backgroundCount && cel->layer()->isBackground()) if (backgroundCount && cel->layer()->isBackground())
++(*backgroundCount); ++(*backgroundCount);
++count; ++count;
@ -183,11 +184,12 @@ private:
App::instance()->getMainWindow()->getTimeline()->invalidate(); App::instance()->getMainWindow()->getTimeline()->invalidate();
} }
} }
else { else if (m_range.enabled()) {
for (Cel* cel : m_document->sprite()->uniqueCels()) { Sprite* sprite = m_document->sprite();
if (m_range.inRange(cel->sprite()->layerToIndex(cel->layer()), cel->frame())) { for (Cel* cel : sprite->uniqueCels(m_range.frameBegin(),
if (!cel->layer()->isBackground() && m_range.frameEnd())) {
newOpacity != cel->opacity()) { if (m_range.inRange(sprite->layerToIndex(cel->layer()))) {
if (!cel->layer()->isBackground() && newOpacity != cel->opacity()) {
transaction.execute(new cmd::SetCelOpacity(cel, newOpacity)); transaction.execute(new cmd::SetCelOpacity(cel, newOpacity));
} }

View File

@ -555,6 +555,11 @@ CelsRange Sprite::uniqueCels() const
return CelsRange(this, frame_t(0), lastFrame(), CelsRange::UNIQUE); return CelsRange(this, frame_t(0), lastFrame(), CelsRange::UNIQUE);
} }
CelsRange Sprite::uniqueCels(frame_t from, frame_t to) const
{
return CelsRange(this, from, to, CelsRange::UNIQUE);
}
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
static Layer* index2layer(const Layer* layer, const LayerIndex& index, int* index_count) static Layer* index2layer(const Layer* layer, const LayerIndex& index, int* index_count)

View File

@ -1,5 +1,5 @@
// Aseprite Document Library // Aseprite Document Library
// Copyright (c) 2001-2015 David Capello // Copyright (c) 2001-2016 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -151,6 +151,7 @@ namespace doc {
CelsRange cels() const; CelsRange cels() const;
CelsRange cels(frame_t frame) const; CelsRange cels(frame_t frame) const;
CelsRange uniqueCels() const; CelsRange uniqueCels() const;
CelsRange uniqueCels(frame_t from, frame_t to) const;
private: private:
Document* m_document; Document* m_document;