Skip to content

Commit

Permalink
Simplify cursor paint methods
Browse files Browse the repository at this point in the history
  • Loading branch information
MrStevns committed Jan 9, 2024
1 parent cb53144 commit ebe30ee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
20 changes: 10 additions & 10 deletions core_lib/src/canvascursorpainter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

CanvasCursorPainter::CanvasCursorPainter()
{
setupPen();
}

void CanvasCursorPainter::setupPen()
{
mCursorPen = Qt::gray;
mCursorPen.setWidthF(1);
mCursorPen.setCosmetic(true);
}

void CanvasCursorPainter::paint(QPainter& painter, const QRect& blitRect)
Expand Down Expand Up @@ -40,12 +48,8 @@ void CanvasCursorPainter::paintFeatherCursor(QPainter& painter, const QRect& bli

painter.save();

QPen cursorPen = QPen(Qt::gray);
painter.setClipRect(blitRect);
cursorPen.setWidthF(1);
cursorPen.setCosmetic(true);

painter.setPen(cursorPen);
painter.setPen(mCursorPen);
painter.setCompositionMode(QPainter::RasterOp_SourceXorDestination);
painter.drawEllipse(featherCircleBounds);

Expand All @@ -56,12 +60,8 @@ void CanvasCursorPainter::paintWidthCursor(QPainter& painter, const QRect& blitR
{
painter.save();

QPen cursorPen = QPen(Qt::gray);
painter.setClipRect(blitRect);
cursorPen.setWidthF(1);
cursorPen.setCosmetic(true);

painter.setPen(cursorPen);
painter.setPen(mCursorPen);

painter.setCompositionMode(QPainter::RasterOp_SourceXorDestination);

Expand Down
3 changes: 3 additions & 0 deletions core_lib/src/canvascursorpainter.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class CanvasCursorPainter
const QRectF dirtyRect() { return mDirtyRect; }
private:

void setupPen();
void mapToView(QRectF& widthRect, QRectF& featherRect);

/// @brief precision circular cursor: used for drawing a cursor on the canvas.
Expand All @@ -33,6 +34,8 @@ class CanvasCursorPainter
CanvasCursorPainterOptions mOptions;
QRectF mDirtyRect;
QTransform mViewTransform;

QPen mCursorPen;
};

#endif // CANVASCURSORPAINTER_H

0 comments on commit ebe30ee

Please sign in to comment.