File indexing completed on 2024-05-19 04:28:59

0001 /* This file is part of the KDE project
0002  * SPDX-FileCopyrightText: 2006 Boudewijn Rempt <boud@valdyas.org>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 #ifndef KIS_MASK_MANAGER
0007 #define KIS_MASK_MANAGER
0008 
0009 #include <QObject>
0010 #include <QPointer>
0011 
0012 #include "kis_types.h"
0013 #include "KisView.h"
0014 
0015 class KisViewManager;
0016 class KisKActionCollection;
0017 class KisNodeCommandsAdapter;
0018 class KisActionManager;
0019 
0020 #include "kis_mask.h"
0021 
0022 /**
0023  * Handle the gui for manipulating masks.
0024  */
0025 class KisMaskManager : public QObject
0026 {
0027 
0028     Q_OBJECT
0029 
0030 public:
0031 
0032 
0033     KisMaskManager(KisViewManager * view);
0034     ~KisMaskManager() override {}
0035     void setView(QPointer<KisView>view);
0036 
0037 private:
0038     
0039     friend class KisNodeManager;
0040     
0041     void setup(KisKActionCollection * actionCollection, KisActionManager *actionManager);
0042 
0043     void updateGUI();
0044     
0045     /**
0046      * @return the paint device associated with the currently
0047      *         active mask, if there is one.
0048      */
0049     KisPaintDeviceSP activeDevice();
0050 
0051     /**
0052      * @return the active mask, if there is one
0053      */
0054     KisMaskSP activeMask();
0055 
0056     /**
0057      * Show the mask properties dialog
0058      */
0059     void maskProperties();
0060 
0061     /**
0062      * called whenever the mask stack is updated to enable/disable all
0063      * menu items
0064      */
0065     void masksUpdated();
0066 
0067     /**
0068      * Activate a new mask. There can be only one mask active per
0069      * view; and if the mask is active, it becomes the paint device.
0070      */
0071     void activateMask(KisMaskSP mask);
0072 
0073     void adjustMaskPosition(KisNodeSP node, KisNodeSP activeNode, bool avoidActiveNode, KisNodeSP &parent, KisNodeSP &above);
0074     void createMaskCommon(KisMaskSP mask, KisNodeSP activeNode, KisPaintDeviceSP copyFrom, const KUndo2MagicString &macroName, const QString &nodeType, const QString &nodeName, bool suppressSelection, bool avoidActiveNode, bool updateImage = true);
0075     QString createMaskNameCommon(KisNodeSP targetNode, const QString& nodeType, const QString &desiredName);
0076 
0077     KisNodeSP createSelectionMask(KisNodeSP activeNode, KisPaintDeviceSP copyFrom, bool convertActiveNode);
0078     KisNodeSP createFilterMask(KisNodeSP activeNode, KisPaintDeviceSP copyFrom, bool quiet, bool convertActiveNode);
0079     KisNodeSP createColorizeMask(KisNodeSP activeNode);
0080     KisNodeSP createTransformMask(KisNodeSP activeNode);
0081     KisNodeSP createTransparencyMask(KisNodeSP activeNode, KisPaintDeviceSP copyFrom, bool convertActiveNode);
0082 
0083     KisViewManager * m_view;
0084     QPointer<KisView>m_imageView;
0085     KisNodeCommandsAdapter* m_commandsAdapter;
0086 
0087 };
0088 
0089 #endif // KIS_MASK_MANAGER