C++ / fmt (pull_request) Failing after 6s
C++ / build (pull_request) Failing after 12s
C++ / clang-tidy (pull_request) Failing after 10s
JS/TS / fmt (pull_request) Successful in 9s
JS/TS / lint (pull_request) Successful in 9s
Python / static (pull_request) Successful in 28s
Python / verify (pull_request) Failing after 1m41s
Rust / build (pull_request) Successful in 1m15s
Rust / fmt (pull_request) Successful in 42s
Rust / clippy (pull_request) Successful in 1m6s
59 lines
1.3 KiB
C++
59 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <QCanvasCustomBrush>
|
|
#include <QCanvasPainterItemRenderer>
|
|
#include <QHash>
|
|
#include <QRectF>
|
|
#include <QVector4D>
|
|
#include <qcontainerfwd.h>
|
|
#include "stroke.hpp"
|
|
|
|
namespace ZShell::internal {
|
|
|
|
struct BrushEntry {
|
|
QCanvasCustomBrush brush;
|
|
qint64 holeToken = -1; // hole generation this brush was built with
|
|
};
|
|
|
|
class StrokeCanvasRenderer final : public QCanvasPainterItemRenderer {
|
|
public:
|
|
void synchronizeData(QCanvasPainterItem* item) override;
|
|
void paint(QCanvasPainter* painter) override;
|
|
|
|
private:
|
|
QCanvasCustomBrush& brushFor(const QColor& color);
|
|
void updateBrushHole();
|
|
void drawStroke(
|
|
QCanvasPainter* painter,
|
|
const QVector<QPointF>& points,
|
|
const QColor& color,
|
|
qreal width,
|
|
bool polyline);
|
|
void drawHoverCursor(
|
|
QCanvasPainter* painter,
|
|
const QPointF& point,
|
|
qreal penWidth,
|
|
QColor penColor,
|
|
bool isDrawing);
|
|
|
|
QColor m_penColor;
|
|
qreal m_penWidth = 4.0;
|
|
bool m_hoverVisible = false;
|
|
QPointF m_hoverPoint;
|
|
bool m_isDrawing = false;
|
|
QRectF m_hole;
|
|
qreal m_holeRadius = 0.0;
|
|
qreal m_devicePixelRatio = 1.0;
|
|
|
|
QVector4D m_lastHoleData1;
|
|
QVector4D m_lastHoleData3;
|
|
QVector4D m_lastHoleData4;
|
|
qint64 m_holeToken = 0;
|
|
QVector<Stroke> m_strokes;
|
|
Stroke m_currentStroke;
|
|
QVector<int> m_pendingGroupRemovals;
|
|
QHash<QRgb, BrushEntry> m_brushes;
|
|
};
|
|
|
|
}; // namespace ZShell::internal
|