Krita Source Code Documentation
Loading...
Searching...
No Matches
KisBrushEnclosingProducer.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<KisToolBasicBrushBase>(canvas, KisToolBasicBrushBase::PAINT, KisCursor::load("tool_freehand_cursor.xpm", 2, 2))
17{
18 setObjectName("enclosing_tool_brush");
19
20 KisCanvas2 *kritaCanvas = dynamic_cast<KisCanvas2*>(canvas);
21
22 connect(kritaCanvas->viewManager()->canvasResourceProvider(), SIGNAL(sigEffectiveCompositeOpChanged()), SLOT(resetCursorStyle()));
23}
24
27
29{
30 if (isEraser()) {
31 useCursor(KisCursor::load("cursor-eraser.xpm", 2, 2));
32 } else {
33 KisDynamicDelegateTool::resetCursorStyle();
34 }
35
37}
38
39void KisBrushEnclosingProducer::finishStroke(const QPainterPath &stroke)
40{
41 if (stroke.isEmpty()) {
42 return;
43 }
44
45 KisPixelSelectionSP enclosingMask = new KisPixelSelection();
46
47 KisPainter painter(enclosingMask);
48 painter.setPaintColor(KoColor(Qt::white, enclosingMask->colorSpace()));
49 painter.setAntiAliasPolygonFill(false);
52
53 painter.fillPainterPath(stroke);
54
55 Q_EMIT enclosingMaskProduced(enclosingMask);
56}
57
62
67
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
KisBrushEnclosingProducer(KoCanvasBase *canvas)
void enclosingMaskProduced(KisPixelSelectionSP enclosingMask)
void finishStroke(const QPainterPath &stroke) override
KisViewManager * viewManager() const
static QCursor load(const QString &cursorName, int hotspotX=-1, int hotspotY=-1)
const KoColorSpace * colorSpace() const
@ FillStyleForegroundColor
void setStrokeStyle(StrokeStyle strokeStyle)
Set the current brush stroke style.
void setFillStyle(FillStyle fillStyle)
Set the current style with which to fill.
void fillPainterPath(const QPainterPath &path)
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.
bool isEraser() const
KisCanvasResourceProvider * canvasResourceProvider()
void useCursor(const QCursor &cursor)
bool overrideCursorIfNotEditable()
Override the cursor appropriately if current node is not editable.
Definition kis_tool.cc:618
KisCanvas2 * canvas