1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
/*
* SPDX-FileCopyrightText: 2000 John Califf <jcaliff@compuzone.net>
* SPDX-FileCopyrightText: 2002 Patrick Julien <freak@codepimps.org>
* SPDX-FileCopyrightText: 2004 Boudewijn Rempt <boud@valdyas.org>
* SPDX-FileCopyrightText: 2015 Michael Abrahams <miabraha@gmail.com>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef KISTOOLOUTLINEBASE_H
#define KISTOOLOUTLINEBASE_H
#include <kis_tool_shape.h>
#include <kis_cursor.h>
class KisInputActionGroupsMaskGuard;
class KRITAUI_EXPORT KisToolOutlineBase : public KisToolShape
{
Q_OBJECT
public:
enum ToolType {
PAINT,
SELECT
};
KisToolOutlineBase(KoCanvasBase *canvas,
ToolType type,
const QCursor & cursor=KisCursor::load("tool_outline_selection_cursor.png", 6, 6));
~KisToolOutlineBase() override;
void beginPrimaryAction(KoPointerEvent *event) override;
void continuePrimaryAction(KoPointerEvent *event) override;
void endPrimaryAction(KoPointerEvent *event) override;
void paint(QPainter& gc, const KoViewConverter &converter) override;
void keyPressEvent(QKeyEvent *event) override;
void keyReleaseEvent(QKeyEvent *event) override;
void mouseMoveEvent(KoPointerEvent *event) override;
bool eventFilter(QObject *obj, QEvent *event) override;
KisPopupWidgetInterface* popupWidget() override;
bool hasUserInteractionRunning() const;
public Q_SLOTS:
void activate(const QSet<KoShape*> &shapes) override;
void deactivate() override;
void requestStrokeEnd() override;
void requestStrokeCancellation() override;
void undoLastPoint();
protected:
virtual void finishOutline(const QVector<QPointF>& points) = 0;
private:
static constexpr int FEEDBACK_LINE_WIDTH{2};
QPainterPath m_paintPath;
QVector<QPointF> m_points;
bool m_continuedMode;
QPointF m_lastCursorPos;
ToolType m_type;
int m_numberOfContinuedModePoints;
bool m_hasUserInteractionRunning;
QScopedPointer<KisInputActionGroupsMaskGuard> m_blockModifyingActionsGuard;
void updateFeedback();
void updateContinuedMode();
void updateCanvas();
void endStroke();
void cancelStroke();
QRectF dragBoundingRect();
void installBlockActionGuard();
void uninstallBlockActionGuard();
};
#endif
|