这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions app/src/actioncommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ GNU General Public License for more details.
#include "aboutdialog.h"
#include "doubleprogressdialog.h"
#include "checkupdatesdialog.h"
#include "layeropacitydialog.h"
#include "errordialog.h"


Expand Down Expand Up @@ -703,10 +702,9 @@ void ActionCommands::duplicateLayer()
int currFrame = mEditor->currentFrame();

Layer* toLayer = layerMgr->createLayer(fromLayer->type(), tr("%1 (copy)", "Default duplicate layer name").arg(fromLayer->name()));
toLayer->removeKeyFrame(1);
fromLayer->foreachKeyFrame([&] (KeyFrame* key) {
key = key->clone();
toLayer->addKeyFrame(key->pos(), key);
toLayer->addOrReplaceKeyFrame(key->pos(), key);
if (toLayer->type() == Layer::SOUND)
{
mEditor->sound()->processSound(static_cast<SoundClip*>(key));
Expand All @@ -716,6 +714,9 @@ void ActionCommands::duplicateLayer()
key->modification();
}
});
if (!fromLayer->keyExists(1)) {
toLayer->removeKeyFrame(1);
}
mEditor->scrubTo(currFrame);
}

Expand Down
16 changes: 10 additions & 6 deletions core_lib/src/structure/layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,20 +184,24 @@ bool Layer::addNewKeyFrameAt(int position)
return addKeyFrame(position, key);
}

bool Layer::addKeyFrame(int position, KeyFrame* pKeyFrame)
void Layer::addOrReplaceKeyFrame(int position, KeyFrame* pKeyFrame)
{
Q_ASSERT(position > 0);
auto it = mKeyFrames.find(position);
if (it != mKeyFrames.end())
pKeyFrame->setPos(position);
loadKey(pKeyFrame);
markFrameAsDirty(position);
}

bool Layer::addKeyFrame(int position, KeyFrame* pKeyFrame)
{
if (keyExists(position))
{
return false;
}

pKeyFrame->setPos(position);
mKeyFrames.insert(std::make_pair(position, pKeyFrame));

mKeyFrames.emplace(position, pKeyFrame);
markFrameAsDirty(position);

return true;
}

Expand Down
6 changes: 3 additions & 3 deletions core_lib/src/structure/layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ GNU General Public License for more details.
#include <QString>
#include <QDomElement>
#include "pencilerror.h"
#include "pencildef.h"

class QMouseEvent;
class QPainter;
Expand Down Expand Up @@ -99,11 +98,11 @@ class Layer : public QObject
bool insertExposureAt(int position);

bool addNewKeyFrameAt(int position);
virtual bool addKeyFrame(int position, KeyFrame*);
void addOrReplaceKeyFrame(int position, KeyFrame* pKeyFrame);
virtual bool addKeyFrame(int position, KeyFrame* pKeyFrame);
virtual bool removeKeyFrame(int position);
bool swapKeyFrames(int position1, int position2);
bool moveKeyFrame(int position, int offset);
bool loadKey(KeyFrame*);
KeyFrame* getKeyFrameAt(int position) const;
KeyFrame* getLastKeyFrameAtPosition(int position) const;
bool keyExistsWhichCovers(int frameNumber);
Expand Down Expand Up @@ -171,6 +170,7 @@ class Layer : public QObject
protected:
void setId(int LayerId) { mId = LayerId; }
virtual KeyFrame* createKeyFrame(int position, Object*) = 0;
bool loadKey(KeyFrame*);

private:
void removeFromSelectionList(int position);
Expand Down
2 changes: 2 additions & 0 deletions core_lib/src/structure/layerbitmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ BitmapImage* LayerBitmap::getLastBitmapImageAtFrame(int frameNumber, int increme
void LayerBitmap::repositionFrame(QPoint point, int frame)
{
BitmapImage* image = getBitmapImageAtFrame(frame);
Q_ASSERT(image);
image->moveTopLeft(point);
}

QRect LayerBitmap::getFrameBounds(int frame)
{
BitmapImage* image = getBitmapImageAtFrame(frame);
Q_ASSERT(image);
return image->bounds();
}

Expand Down
1 change: 1 addition & 0 deletions core_lib/src/structure/layercamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ GNU General Public License for more details.
#include "layer.h"
#include "camerafieldoption.h"
#include "cameraeasingtype.h"
#include "pencildef.h"

class Camera;

Expand Down