Skip to content

Commit

Permalink
Fixed bug, that made first frame untracable
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlamhauge committed Jul 29, 2023
1 parent 9a9a8ae commit db802b4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
7 changes: 4 additions & 3 deletions app/src/bitmapcoloring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ GNU General Public License for more details.
#include "ui_bitmapcoloringwidget.h"
#include "layermanager.h"
#include "toolmanager.h"
#include "selectionmanager.h"
#include "app_util.h"


Expand Down Expand Up @@ -523,7 +522,7 @@ void BitmapColoring::prepareAndTraceLines()

if (ui->cb3TraceAllKeyframes->isChecked())
{
for (int i = sourceLayer->firstKeyFramePosition(); i <= sourceLayer->getMaxKeyFramePosition(); i++ )
for (int i = sourceLayer->firstKeyFramePosition(); i <= sourceLayer->getMaxKeyFramePosition(); i++)
{
if (sourceLayer->keyExists(i))
{
Expand Down Expand Up @@ -584,6 +583,7 @@ void BitmapColoring::prepareLines()
{
return;
}

LayerManager* lMgr = mEditor->layers();
LayerBitmap* colorLayer = nullptr;
bool black;
Expand All @@ -593,6 +593,7 @@ void BitmapColoring::prepareLines()
{
colorLayer = mLayerBitmap;
}

// Method selector 2 = Coloring on separate layer
else
{
Expand Down Expand Up @@ -627,7 +628,7 @@ void BitmapColoring::prepareLines()
return;
}

mBitmapImage->traceLine(colorLayer->getBitmapImageAtFrame(mEditor->currentFrame()),
mBitmapImage->traceLine(mBitmapImage,
black,
mRedChecked,
mGreenChecked,
Expand Down
2 changes: 2 additions & 0 deletions core_lib/src/graphics/bitmap/bitmapimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,9 @@ void BitmapImage::traceLine(BitmapImage* img, bool blackEnabled, bool redEnabled
else
{
if (blackEnabled && alphaValue > TRANSP_THRESHOLD)
{
img->scanLine(x, y, blackline);
}
else if (blackEnabled)
img->scanLine(x, y, transp);
}
Expand Down
20 changes: 18 additions & 2 deletions core_lib/src/structure/layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,25 @@ void Layer::copyFrame(Layer *fromLayer, Layer *toLayer, int frame)
mObject->updateActiveFrames(frame);
KeyFrame* keyframe = fromLayer->getKeyFrameAt(frame);
KeyFrame* dupKey = keyframe->clone();
if (toLayer->keyExists(frame))
if (toLayer->keyExists(frame) && toLayer->keyFrameCount() == 1)
{
int i = toLayer->firstKeyFramePosition();
if (i == frame)
{
toLayer->addKeyFrame(frame + 1, dupKey);
toLayer->removeKeyFrame(frame);
toLayer->moveKeyFrame(frame + 1, -1);
} else
{
toLayer->addKeyFrame(frame, dupKey);
toLayer->removeKeyFrame(i);
}
}
else
{
toLayer->removeKeyFrame(frame);
toLayer->addKeyFrame(frame, dupKey);
toLayer->addKeyFrame(frame, dupKey);
}
toLayer->setModified(frame, true);
toLayer->getKeyFrameAt(frame)->modification();
}
Expand Down

0 comments on commit db802b4

Please sign in to comment.