Krita Source Code Documentation
Loading...
Searching...
No Matches
KisRectangleEnclosingProducer.cpp
Go to the documentation of this file.
1/*
2 * KDE. Krita Project.
3 *
4 * SPDX-FileCopyrightText: 2022 Deif Lou <ginoba@gmail.com>
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8
9#include <KisViewManager.h>
10#include <canvas/kis_canvas2.h>
12
14
16 : KisDynamicDelegateTool<KisToolRectangleBase>(canvas, KisToolRectangleBase::PAINT, KisCursor::load("tool_rectangular_selection_cursor.png", 6, 6))
17{
18 setObjectName("enclosing_tool_rectangle");
20 setOutlineEnabled(false);
21
22 KisCanvas2 *kritaCanvas = dynamic_cast<KisCanvas2*>(canvas);
23
24 connect(kritaCanvas->viewManager()->canvasResourceProvider(), SIGNAL(sigEffectiveCompositeOpChanged()), SLOT(resetCursorStyle()));
25}
26
29
31{
32 if (isEraser()) {
33 useCursor(KisCursor::load("tool_rectangular_selection_enclose_eraser_cursor.png", 6, 6));
34 } else {
35 KisDynamicDelegateTool::resetCursorStyle();
36 }
37
39}
40
41void KisRectangleEnclosingProducer::finishRect(const QRectF& rect, qreal roundCornersX, qreal roundCornersY)
42{
43 QRect rc(rect.normalized().toRect());
44 if (!rc.isValid()) {
45 return;
46 }
47
49 QPainterPath path;
50
51 if (roundCornersX > 0 || roundCornersY > 0) {
52 path.addRoundedRect(rc, roundCornersX, roundCornersY);
53 } else {
54 path.addRect(rc);
55 }
56 getRotatedPath(path, rc.center(), getRotationAngle());
57
58 KisPainter painter(enclosingMask);
59 painter.setPaintColor(KoColor(Qt::white, enclosingMask->colorSpace()));
60 painter.setAntiAliasPolygonFill(false);
63
64 painter.paintPainterPath(path);
65
66 Q_EMIT enclosingMaskProduced(enclosingMask);
67}
68
73
78
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
KisViewManager * viewManager() const
static QCursor load(const QString &cursorName, int hotspotX=-1, int hotspotY=-1)
const KoColorSpace * colorSpace() const
@ FillStyleForegroundColor
void paintPainterPath(const QPainterPath &path)
void setStrokeStyle(StrokeStyle strokeStyle)
Set the current brush stroke style.
void setFillStyle(FillStyle fillStyle)
Set the current style with which to fill.
void setPaintColor(const KoColor &color)
void setAntiAliasPolygonFill(bool antiAliasPolygonFill)
Set whether a polygon's filled area should be anti-aliased or not. The default is true.
void enclosingMaskProduced(KisPixelSelectionSP enclosingMask)
void finishRect(const QRectF &rect, qreal roundCornersX, qreal roundCornersY) override
void setSupportOutline(bool supportOutline)
bool isEraser() const
void setOutlineEnabled(bool enabled)
void getRotatedPath(QPainterPath &path, const QPointF &center, const qreal &angle)
KisCanvasResourceProvider * canvasResourceProvider()
void useCursor(const QCursor &cursor)
KisSharedPtr< KisPixelSelection > KisPixelSelectionSP
Definition kis_types.h:159
bool overrideCursorIfNotEditable()
Override the cursor appropriately if current node is not editable.
Definition kis_tool.cc:618
KisCanvas2 * canvas