这是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
68 changes: 15 additions & 53 deletions core_lib/src/interface/scribblearea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,32 +572,11 @@ void ScribbleArea::handleDoubleClick()
}

bool ScribbleArea::isLayerPaintable() const
{
if (!areLayersSane())
return false;

Layer* layer = mEditor->layers()->currentLayer();
return layer->type() == Layer::BITMAP || layer->type() == Layer::VECTOR;
}

bool ScribbleArea::areLayersSane() const
{
Layer* layer = mEditor->layers()->currentLayer();
// ---- checks ------
if (layer == nullptr) { return false; }
if (layer->type() == Layer::VECTOR)
{
VectorImage* vectorImage = currentVectorImage(layer);
if (vectorImage == nullptr) { return false; }
}
if (layer->type() == Layer::BITMAP)
{
BitmapImage* bitmapImage = currentBitmapImage(layer);
if (bitmapImage == nullptr) { return false; }
}
// ---- end checks ------

return true;
return layer->type() == Layer::BITMAP || layer->type() == Layer::VECTOR;
}

bool ScribbleArea::allowSmudging()
Expand Down Expand Up @@ -923,47 +902,30 @@ void ScribbleArea::handleDrawingOnEmptyFrame()

switch (action)
{
case CREATE_NEW_KEY:
mEditor->addNewKey();
mEditor->scrubTo(frameNumber); // Refresh timeline.

// Hack to clear previous frame's content.
if (layer->type() == Layer::BITMAP && previousKeyFrame)
{
auto asBitmapImage = dynamic_cast<BitmapImage *> (previousKeyFrame);

if (asBitmapImage)
{
drawCanvas(frameNumber, asBitmapImage->bounds());
}
}

if (layer->type() == Layer::VECTOR)
{
auto asVectorImage = dynamic_cast<VectorImage *> (previousKeyFrame);

if (asVectorImage)
{
auto copy(*asVectorImage);
copy.selectAll();

drawCanvas(frameNumber, copy.getSelectionRect().toRect());
}
case KEEP_DRAWING_ON_PREVIOUS_KEY:
{
if (previousKeyFrame == nullptr) {
mEditor->addNewKey();
}

break;
}
case DUPLICATE_PREVIOUS_KEY:
{
if (previousKeyFrame)
{
KeyFrame* dupKey = previousKeyFrame->clone();
layer->addKeyFrame(frameNumber, dupKey);
mEditor->scrubTo(frameNumber); // Refresh timeline.
mEditor->scrubTo(frameNumber);
break;
}
break;
// if the previous keyframe doesn't exist,
// fallthrough and create empty keyframe
}
case KEEP_DRAWING_ON_PREVIOUS_KEY:
// No action needed.
case CREATE_NEW_KEY:
mEditor->addNewKey();

// Refresh canvas
drawCanvas(frameNumber, mCanvas.rect());
break;
default:
break;
Expand Down
1 change: 0 additions & 1 deletion core_lib/src/interface/scribblearea.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ class ScribbleArea : public QWidget
qreal myRotatedAngle = 0.0;
QList<int> mClosestCurves;

bool areLayersSane() const;
bool isLayerPaintable() const;
bool allowSmudging();

Expand Down
10 changes: 0 additions & 10 deletions core_lib/src/tool/polylinetool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,6 @@ bool PolylineTool::keyPressEvent(QKeyEvent* event)

void PolylineTool::drawPolyline(QList<QPointF> points, QPointF endPoint)
{
if (!mScribbleArea->areLayersSane())
{
return;
}

if (points.size() > 0)
{
QPen pen(mEditor->color()->frontColor(),
Expand Down Expand Up @@ -238,11 +233,6 @@ void PolylineTool::cancelPolyline()

void PolylineTool::endPolyline(QList<QPointF> points)
{
if (!mScribbleArea->areLayersSane())
{
return;
}

Layer* layer = mEditor->layers()->currentLayer();

if (layer->type() == Layer::VECTOR)
Expand Down