mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-31 00:32:48 +00:00
Refactor Cel::createCopy/Link() -> Cel::MakeCopy/Link() receiving the new frame position for the copy/link
This commit is contained in:
parent
c5b952173f
commit
b22903b326
@ -1,4 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -110,10 +111,8 @@ void CopyCel::onExecute()
|
||||
executeAndAdd(new cmd::RemoveCel(dstCel));
|
||||
|
||||
if (srcCel) {
|
||||
if (createLink) {
|
||||
dstCel = Cel::createLink(srcCel);
|
||||
dstCel->setFrame(m_dstFrame);
|
||||
}
|
||||
if (createLink)
|
||||
dstCel = Cel::MakeLink(m_dstFrame, srcCel);
|
||||
else
|
||||
dstCel = create_cel_copy(srcCel, dstSprite, dstLayer, m_dstFrame);
|
||||
|
||||
|
@ -348,8 +348,8 @@ void Doc::copyLayerContent(const Layer* sourceLayer0, Doc* destDoc, Layer* destL
|
||||
|
||||
auto it = linked.find(sourceCel->data()->id());
|
||||
if (it != linked.end()) {
|
||||
newCel.reset(Cel::createLink(it->second));
|
||||
newCel->setFrame(sourceCel->frame());
|
||||
newCel.reset(Cel::MakeLink(sourceCel->frame(),
|
||||
it->second));
|
||||
}
|
||||
else {
|
||||
newCel.reset(create_cel_copy(sourceCel,
|
||||
|
@ -138,8 +138,7 @@ bool FliFormat::onLoad(FileOp* fop)
|
||||
++frame_out;
|
||||
}
|
||||
else if (palChange) {
|
||||
Cel* cel = Cel::createLink(prevCel);
|
||||
cel->setFrame(frame_out);
|
||||
Cel* cel = Cel::MakeLink(frame_out, prevCel);
|
||||
layer->addCel(cel);
|
||||
|
||||
++frame_out;
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite Document IO Library
|
||||
// Copyright (c) 2018 Igara Studio S.A.
|
||||
// Copyright (c) 2018-2019 Igara Studio S.A.
|
||||
// Copyright (c) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -651,12 +651,10 @@ doc::Cel* AsepriteDecoder::readCelChunk(doc::Sprite* sprite,
|
||||
// different X, Y, or opacity per link, in that case we must
|
||||
// create a copy.
|
||||
if (link->x() == x && link->y() == y && link->opacity() == opacity) {
|
||||
cel.reset(doc::Cel::createLink(link));
|
||||
cel->setFrame(frame);
|
||||
cel.reset(doc::Cel::MakeLink(frame, link));
|
||||
}
|
||||
else {
|
||||
cel.reset(doc::Cel::createCopy(link));
|
||||
cel->setFrame(frame);
|
||||
cel.reset(doc::Cel::MakeCopy(frame, link));
|
||||
cel->setPosition(x, y);
|
||||
cel->setOpacity(opacity);
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (c) 2019 Igara Studio S.A.
|
||||
// Copyright (c) 2001-2016 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -34,10 +35,11 @@ Cel::Cel(frame_t frame, const CelDataRef& celData)
|
||||
}
|
||||
|
||||
// static
|
||||
Cel* Cel::createCopy(const Cel* other)
|
||||
Cel* Cel::MakeCopy(const frame_t newFrame,
|
||||
const Cel* other)
|
||||
{
|
||||
Cel* cel = new Cel(other->frame(),
|
||||
ImageRef(Image::createCopy(other->image())));
|
||||
Cel* cel = new Cel(newFrame,
|
||||
ImageRef(Image::createCopy(other->image())));
|
||||
|
||||
cel->setPosition(other->position());
|
||||
cel->setOpacity(other->opacity());
|
||||
@ -45,9 +47,10 @@ Cel* Cel::createCopy(const Cel* other)
|
||||
}
|
||||
|
||||
// static
|
||||
Cel* Cel::createLink(const Cel* other)
|
||||
Cel* Cel::MakeLink(const frame_t newFrame,
|
||||
const Cel* other)
|
||||
{
|
||||
return new Cel(other->frame(), other->dataRef());
|
||||
return new Cel(newFrame, other->dataRef());
|
||||
}
|
||||
|
||||
void Cel::setFrame(frame_t frame)
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (c) 2019 Igara Studio S.A.
|
||||
// Copyright (c) 2001-2016 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -27,8 +28,8 @@ namespace doc {
|
||||
Cel(frame_t frame, const ImageRef& image);
|
||||
Cel(frame_t frame, const CelDataRef& celData);
|
||||
|
||||
static Cel* createCopy(const Cel* other);
|
||||
static Cel* createLink(const Cel* other);
|
||||
static Cel* MakeCopy(const frame_t newFrame, const Cel* other);
|
||||
static Cel* MakeLink(const frame_t newFrame, const Cel* other);
|
||||
|
||||
frame_t frame() const { return m_frame; }
|
||||
int x() const { return m_data->position().x; }
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (c) 2018 Igara Studio S.A.
|
||||
// Copyright (c) 2018-2019 Igara Studio S.A.
|
||||
// Copyright (c) 2001-2016 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -104,17 +104,14 @@ TEST(Sprite, CelsRange)
|
||||
|
||||
ImageRef imgA(Image::create(IMAGE_RGB, 32, 32));
|
||||
Cel* celA = new Cel(frame_t(0), imgA);
|
||||
Cel* celB = Cel::createLink(celA);
|
||||
celB->setFrame(frame_t(2));
|
||||
Cel* celB = Cel::MakeLink(frame_t(2), celA);
|
||||
lay1->addCel(celA);
|
||||
lay1->addCel(celB);
|
||||
|
||||
ImageRef imgC(Image::create(IMAGE_RGB, 32, 32));
|
||||
Cel* celC = new Cel(frame_t(0), imgC);
|
||||
Cel* celD = Cel::createCopy(celC);
|
||||
Cel* celE = Cel::createLink(celD);
|
||||
celD->setFrame(frame_t(1));
|
||||
celE->setFrame(frame_t(2));
|
||||
Cel* celD = Cel::MakeCopy(frame_t(1), celC);
|
||||
Cel* celE = Cel::MakeLink(frame_t(2), celD);
|
||||
lay2->addCel(celC);
|
||||
lay2->addCel(celD);
|
||||
lay2->addCel(celE);
|
||||
@ -123,8 +120,7 @@ TEST(Sprite, CelsRange)
|
||||
ImageRef imgG(Image::create(IMAGE_RGB, 32, 32));
|
||||
Cel* celF = new Cel(frame_t(0), imgF);
|
||||
Cel* celG = new Cel(frame_t(1), imgG);
|
||||
Cel* celH = Cel::createLink(celG);
|
||||
celH->setFrame(frame_t(2));
|
||||
Cel* celH = Cel::MakeLink(frame_t(2), celG);
|
||||
lay3->addCel(celF);
|
||||
lay3->addCel(celG);
|
||||
lay3->addCel(celH);
|
||||
|
Loading…
x
Reference in New Issue
Block a user