Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_tool_rectangle_base.h
Go to the documentation of this file.
1/* This file is part of the KDE project
2 * SPDX-FileCopyrightText: 2009 Boudewijn Rempt <boud@valdyas.org>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7#ifndef KIS_TOOL_RECTANGLE_BASE_H
8#define KIS_TOOL_RECTANGLE_BASE_H
9
10#include <kis_tool_shape.h>
11#include <kis_cursor.h>
12
13class KRITAUI_EXPORT KisToolRectangleBase : public KisToolShape
14{
15Q_OBJECT
16
17Q_SIGNALS:
18 void rectangleChanged(const QRectF &newRect);
20
21public Q_SLOTS:
22 void constraintsChanged(bool forceRatio, bool forceWidth, bool forceHeight, float ratio, float width, float height);
23 void roundCornersChanged(int rx, int ry);
24
25 void requestStrokeEnd() override;
26 void requestStrokeCancellation() override;
27
28public:
29 enum ToolType {
31 SELECT
32 };
33
34 explicit KisToolRectangleBase(KoCanvasBase * canvas, KisToolRectangleBase::ToolType type, const QCursor & cursor=KisCursor::load("tool_rectangle_cursor.png", 6, 6));
35
36 void keyPressEvent(QKeyEvent *event) override;
37 void keyReleaseEvent(QKeyEvent *event) override;
38 void beginPrimaryAction(KoPointerEvent *event) override;
39 void continuePrimaryAction(KoPointerEvent *event) override;
40 void endPrimaryAction(KoPointerEvent *event) override;
41
42 void paint(QPainter& gc, const KoViewConverter &converter) override;
43 void activate(const QSet<KoShape*> &shapes) override;
44 void deactivate() override;
45
47 void showSize();
48
49protected:
50 virtual void finishRect(const QRectF &rect, qreal roundCornersX, qreal roundCornersY) = 0;
51
52 QPointF m_dragCenter;
53 QPointF m_dragStart;
54 QPointF m_dragEnd;
56
67 qreal m_angle;
69 Qt::KeyboardModifiers m_currentModifiers;
70
71 bool isFixedSize();
72 qreal getRotationAngle();
73 QPainterPath drawX(const QPointF &pt);
74 void applyConstraints(QSizeF& area, bool overrideRatio);
75 void getRotatedPath(QPainterPath &path, const QPointF &center, const qreal &angle);
76
77 void updateArea();
78 virtual void paintRectangle(QPainter &gc, const QRectF &imageRect);
79 virtual QRectF createRect(const QPointF &start, const QPointF &end);
80 virtual bool showRoundCornersGUI() const;
81
82 void endStroke();
83 void cancelStroke();
84};
85
86#endif // KIS_TOOL_RECTANGLE_BASE_H
static QCursor load(const QString &cursorName, int hotspotX=-1, int hotspotY=-1)
void deactivate() override
void paint(QPainter &gc, const KoViewConverter &converter) override
void rectangleChanged(const QRectF &newRect)
Qt::KeyboardModifiers m_currentModifiers
virtual void finishRect(const QRectF &rect, qreal roundCornersX, qreal roundCornersY)=0
void activate(const QSet< KoShape * > &shapes) override
virtual void requestStrokeCancellation()
virtual QList< QPointer< QWidget > > createOptionWidgets()
virtual void keyReleaseEvent(QKeyEvent *event)
virtual void keyPressEvent(QKeyEvent *event)
virtual void requestStrokeEnd()
virtual void beginPrimaryAction(KoPointerEvent *event)
Definition kis_tool.cc:431
virtual void endPrimaryAction(KoPointerEvent *event)
Definition kis_tool.cc:446
virtual void continuePrimaryAction(KoPointerEvent *event)
Definition kis_tool.cc:441