Copy frame tags when we duplicate a sprite

This commit is contained in:
David Capello 2015-03-16 18:21:08 -03:00
parent dae3a0dd81
commit b3232311ff
3 changed files with 19 additions and 1 deletions

View File

@ -28,6 +28,7 @@
#include "doc/context.h"
#include "doc/document_event.h"
#include "doc/document_observer.h"
#include "doc/frame_tag.h"
#include "doc/layer.h"
#include "doc/mask.h"
#include "doc/palette.h"
@ -446,6 +447,10 @@ Document* Document::duplicate(DuplicateType type) const
for (frame_t i(0); i < sourceSprite->totalFrames(); ++i)
spriteCopy->setFrameDuration(i, sourceSprite->frameDuration(i));
// Copy frame tags
for (const FrameTag* tag : sourceSprite->frameTags())
spriteCopy->frameTags().add(new FrameTag(*tag));
// Copy color palettes
{
PalettesList::const_iterator it = sourceSprite->getPalettes().begin();

View File

@ -25,6 +25,17 @@ FrameTag::FrameTag(frame_t from, frame_t to)
{
}
FrameTag::FrameTag(const FrameTag& other)
: Object(ObjectType::FrameTag)
, m_owner(nullptr)
, m_from(other.m_from)
, m_to(other.m_to)
, m_color(other.m_color)
, m_name(other.m_name)
, m_aniDir(other.m_aniDir)
{
}
FrameTag::~FrameTag()
{
ASSERT(!m_owner);

View File

@ -22,6 +22,7 @@ namespace doc {
class FrameTag : public Object {
public:
FrameTag(frame_t from, frame_t to);
FrameTag(const FrameTag& other);
~FrameTag();
FrameTags* owner() const { return m_owner; }
@ -45,7 +46,8 @@ namespace doc {
std::string m_name;
AniDir m_aniDir;
DISABLE_COPYING(FrameTag);
// Disable operator=
FrameTag& operator=(FrameTag&);
};
} // namespace doc