Skip to content

Commit

Permalink
Remove various dead code from ScribbleArea
Browse files Browse the repository at this point in the history
  • Loading branch information
J5lx committed Sep 17, 2023
1 parent adcb3c1 commit 3566a5a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 47 deletions.
29 changes: 7 additions & 22 deletions core_lib/src/interface/scribblearea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ bool ScribbleArea::init()
mQuickSizing = mPrefs->isOn(SETTING::QUICK_SIZING);
mMakeInvisible = false;

mIsSimplified = mPrefs->isOn(SETTING::OUTLINES);
mMultiLayerOnionSkin = mPrefs->isOn(SETTING::MULTILAYER_ONION);

mLayerVisibility = static_cast<LayerVisibility>(mPrefs->getInt(SETTING::LAYER_VISIBILITY));
Expand Down Expand Up @@ -415,8 +414,6 @@ void ScribbleArea::keyPressEvent(QKeyEvent *event)
// Don't handle this event on auto repeat
if (event->isAutoRepeat()) { return; }

mKeyboardInUse = true;

if (isPointerInUse()) { return; } // prevents shortcuts calls while drawing

if (currentTool()->keyPressEvent(event))
Expand Down Expand Up @@ -530,8 +527,6 @@ void ScribbleArea::keyReleaseEvent(QKeyEvent *event)
return;
}

mKeyboardInUse = false;

if (event->key() == 0)
{
editor()->tools()->tryClearTemporaryTool(Qt::Key_unknown);
Expand All @@ -554,7 +549,7 @@ void ScribbleArea::keyReleaseEvent(QKeyEvent *event)
// mouse and tablet event handlers
void ScribbleArea::wheelEvent(QWheelEvent* event)
{
// Don't change view if tool is in use
// Don't change view if the tool is in use
if (isPointerInUse()) return;

static const bool isX11 = QGuiApplication::platformName() == "xcb";
Expand Down Expand Up @@ -693,7 +688,6 @@ void ScribbleArea::pointerPressEvent(PointerEvent* event)
const bool isPressed = event->buttons() & Qt::LeftButton;
if (isPressed && mQuickSizing)
{
//qDebug() << "Start Adjusting" << event->buttons();
if (currentTool()->startAdjusting(event->modifiers(), 1))
{
return;
Expand Down Expand Up @@ -733,13 +727,6 @@ void ScribbleArea::pointerReleaseEvent(PointerEvent* event)
return; // [SHIFT]+drag OR [CTRL]+drag
}

if (event->buttons() & (Qt::RightButton | Qt::MiddleButton))
{
mMouseRightButtonInUse = false;
return;
}

//qDebug() << "release event";
currentTool()->pointerReleaseEvent(event);

editor()->tools()->tryClearTemporaryTool(event->button());
Expand All @@ -759,11 +746,11 @@ void ScribbleArea::handleDoubleClick()

void ScribbleArea::tabletReleaseEventFired()
{
// Under certain circumstances a mouse press event will fire after a tablet release event.
// This causes unexpected behaviours for some of the tools, eg. the bucket.
// The problem only seems to occur on windows and only when tapping.
// prior to this fix, the event queue would look like this:
// eg: TabletPress -> TabletRelease -> MousePress
// Under certain circumstances, a mouse press event will fire after a tablet release event.
// This causes unexpected behaviors for some tools, e.g., the bucket tool.
// The problem only seems to occur on Windows and only when tapping.
// Prior to this fix, the event queue would look like this:
// e.g.: TabletPress -> TabletRelease -> MousePress
// The following will filter mouse events created after a tablet release event.
mTabletReleaseMillisAgo += 50;

Expand Down Expand Up @@ -1048,10 +1035,9 @@ void ScribbleArea::paintEvent(QPaintEvent* event)

currentTool()->paint(painter);

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

if (!editor()->playback()->isPlaying()) // we don't need to display the following when the animation is playing
{
Layer* layer = mEditor->layers()->currentLayer();
if (layer->type() == Layer::VECTOR)
{
VectorImage* vectorImage = currentVectorImage(layer);
Expand Down Expand Up @@ -1128,7 +1114,6 @@ void ScribbleArea::paintEvent(QPaintEvent* event)

mOverlayPainter.paint(painter);


// paints the selection outline
if (mEditor->select()->somethingSelected())
{
Expand Down
24 changes: 1 addition & 23 deletions core_lib/src/interface/scribblearea.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class ScribbleArea : public QWidget
Q_OBJECT

friend class MoveTool;
friend class EditTool;
friend class SmudgeTool;
friend class BucketTool;

Expand All @@ -74,16 +73,12 @@ class ScribbleArea : public QWidget

bool isLayerPaintable() const;

QVector<QPoint> calcSelectionCenterPoints();

void setEffect(SETTING e, bool isOn);

LayerVisibility getLayerVisibility() const { return mLayerVisibility; }
qreal getCurveSmoothing() const { return mCurveSmoothingLevel; }
bool usePressure() const { return mUsePressure; }
bool makeInvisible() const { return mMakeInvisible; }

QRect getCameraRect();
QPointF getCentralPoint();

/** Update frame.
Expand Down Expand Up @@ -124,10 +119,6 @@ class ScribbleArea : public QWidget
/** Tool changed, invalidate cache and frame if needed */
void onToolChanged(ToolType);

/** Set frame on layer to modified and invalidate current frame cache */
void setModified(int layerNumber, int frameNumber);
void setModified(const Layer* layer, int frameNumber);

void endStroke();

void flipSelection(bool flipVertical);
Expand All @@ -143,7 +134,6 @@ class ScribbleArea : public QWidget

signals:
void multiLayerOnionSkinChanged(bool);
void refreshPreview();
void selectionUpdated();

public slots:
Expand Down Expand Up @@ -233,27 +223,17 @@ public slots:
BitmapImage* currentBitmapImage(Layer* layer) const;
VectorImage* currentVectorImage(Layer* layer) const;

MoveMode mMoveMode = MoveMode::NONE;

std::unique_ptr<StrokeManager> mStrokeManager;

Editor* mEditor = nullptr;


bool mIsSimplified = false;
bool mShowThinLines = false;
bool mQuickSizing = true;
LayerVisibility mLayerVisibility = LayerVisibility::ALL;
bool mUsePressure = true;
bool mMakeInvisible = false;
bool mToolCursors = true;
qreal mCurveSmoothingLevel = 0.0;
bool mMultiLayerOnionSkin = false; // future use. If required, just add a checkbox to updated it.
QColor mOnionColor;
bool mMultiLayerOnionSkin = false; // Future use. If required, just add a checkbox to update it.
int mDeltaFactor = 1;

private:

/* Under certain circumstances a mouse press event will fire after a tablet release event.
This causes unexpected behaviours for some of the tools, eg. the bucket.
The problem only seems to occur on windows and only when tapping.
Expand All @@ -262,9 +242,7 @@ public slots:
The following will filter mouse events created after a tablet release event.
*/
void tabletReleaseEventFired();
bool mKeyboardInUse = false;
bool mMouseInUse = false;
bool mMouseRightButtonInUse = false;
bool mTabletInUse = false;
qreal mDevicePixelRatio = 1.;

Expand Down
2 changes: 1 addition & 1 deletion core_lib/src/managers/toolmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ void ToolManager::tabletSwitchToEraser()
}

void ToolManager::tabletRestorePrevTool()
{
{
if (mTemporaryTool == nullptr && mTabletEraserTool != nullptr)
{
mTabletEraserTool = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion core_lib/src/tool/stroketool.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class StrokeTool : public BaseTool
virtual bool emptyFrameActionEnabled();

private:
QPointF mLastPixel { 0, 0 };
QPointF mLastPixel { 0, 0 };
};

#endif // STROKETOOL_H

0 comments on commit 3566a5a

Please sign in to comment.