File indexing completed on 2024-12-22 04:16:48
0001 /* 0002 * KDE. Krita Project. 0003 * 0004 * SPDX-FileCopyrightText: 2022 Deif Lou <ginoba@gmail.com> 0005 * 0006 * SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 #ifndef KISPATHENCLOSINGPRODUCER 0010 #define KISPATHENCLOSINGPRODUCER 0011 0012 #include <KoCreatePathTool.h> 0013 #include <kis_pixel_selection.h> 0014 #include <kis_delegated_tool.h> 0015 #include <kis_tool_shape.h> 0016 0017 #include "KisDynamicDelegatedTool.h" 0018 0019 class KisPathEnclosingProducer; 0020 0021 class KisToolPathLocalTool : public KoCreatePathTool { 0022 public: 0023 KisToolPathLocalTool(KoCanvasBase * canvas, KisPathEnclosingProducer* parentTool); 0024 0025 void paintPath(KoPathShape &pathShape, QPainter &painter, const KoViewConverter &converter) override; 0026 void addPathShape(KoPathShape* pathShape) override; 0027 void beginShape() override; 0028 void endShape() override; 0029 0030 using KoCreatePathTool::createOptionWidgets; 0031 using KoCreatePathTool::endPathWithoutLastPoint; 0032 using KoCreatePathTool::endPath; 0033 using KoCreatePathTool::cancelPath; 0034 using KoCreatePathTool::removeLastPoint; 0035 0036 private: 0037 KisPathEnclosingProducer* const m_parentTool; 0038 }; 0039 0040 typedef KisDelegatedTool<KisToolShape, KisToolPathLocalTool, DeselectShapesActivationPolicy> DelegatedPathTool; 0041 0042 class KisPathEnclosingProducer : public KisDynamicDelegateTool<DelegatedPathTool> 0043 { 0044 Q_OBJECT 0045 0046 public: 0047 KisPathEnclosingProducer(KoCanvasBase *canvas); 0048 ~KisPathEnclosingProducer() override; 0049 0050 bool hasUserInteractionRunning() const; 0051 0052 void mousePressEvent(KoPointerEvent *event) override; 0053 bool eventFilter(QObject *obj, QEvent *event) override; 0054 void beginPrimaryAction(KoPointerEvent* event) override; 0055 void continuePrimaryAction(KoPointerEvent *event) override; 0056 void endPrimaryAction(KoPointerEvent *event) override; 0057 void beginAlternateAction(KoPointerEvent *event, AlternateAction action) override; 0058 // reimplementing KisTool's method because that method calls beginPrimaryAction 0059 // which now is used to start the path tool. 0060 void beginPrimaryDoubleClickAction(KoPointerEvent* event) override; 0061 0062 KisPopupWidgetInterface* popupWidget() override; 0063 0064 protected: 0065 void requestStrokeCancellation() override; 0066 void requestStrokeEnd() override; 0067 0068 void addPathShape(KoPathShape* pathShape); 0069 void beginShape() override; 0070 void endShape() override; 0071 0072 friend class KisToolPathLocalTool; 0073 0074 Q_SIGNALS: 0075 void enclosingMaskProduced(KisPixelSelectionSP enclosingMask); 0076 0077 private: 0078 bool m_hasUserInteractionRunning {false}; 0079 0080 protected Q_SLOTS: 0081 void resetCursorStyle() override; 0082 }; 0083 0084 #endif