File indexing completed on 2024-05-19 04:28:58
0001 /* 0002 * SPDX-FileCopyrightText: 2006 Boudewijn Rempt <boud@valdyas.org> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 #ifndef KIS_LAYER_MANAGER 0007 #define KIS_LAYER_MANAGER 0008 0009 #include <QObject> 0010 #include <QPointer> 0011 #include <QList> 0012 0013 #include "kis_adjustment_layer.h" 0014 #include "kis_generator_layer.h" 0015 #include "kis_types.h" 0016 #include "KisView.h" 0017 #include <filter/kis_filter_configuration.h> 0018 0019 class KisViewManager; 0020 class KisNodeCommandsAdapter; 0021 class KisAction; 0022 class KisActionManager; 0023 class KisProcessingApplicator; 0024 0025 /** 0026 * KisLayerManager takes care of the gui around working with layers: 0027 * adding, removing, editing. It also keeps track of the active layer 0028 * for this view. 0029 */ 0030 class KisLayerManager : public QObject 0031 { 0032 0033 Q_OBJECT 0034 0035 public: 0036 0037 KisLayerManager(KisViewManager * view); 0038 ~KisLayerManager() override; 0039 void setView(QPointer<KisView>view); 0040 0041 Q_SIGNALS: 0042 0043 private: 0044 0045 friend class KisNodeManager; 0046 0047 /** 0048 * Activate the specified layer. The layer may be 0. 0049 */ 0050 void activateLayer(KisLayerSP layer); 0051 0052 KisLayerSP activeLayer(); 0053 KisPaintDeviceSP activeDevice(); 0054 0055 0056 void setup(KisActionManager *actionManager); 0057 0058 void updateGUI(); 0059 0060 private Q_SLOTS: 0061 0062 void mergeLayer(); 0063 0064 void imageResizeToActiveLayer(); 0065 void trimToImage(); 0066 0067 void layerProperties(); 0068 0069 void flattenImage(); 0070 0071 void flattenLayer(); 0072 0073 void layersUpdated(); 0074 0075 void saveGroupLayers(); 0076 bool activeLayerHasSelection(); 0077 0078 void convertNodeToPaintLayer(KisNodeSP source); 0079 void convertGroupToAnimated(); 0080 0081 void convertLayerToFileLayer(KisNodeSP source); 0082 0083 KisLayerSP addPaintLayer(KisNodeSP activeNode); 0084 KisNodeSP addGroupLayer(KisNodeSP activeNode); 0085 0086 KisNodeSP addCloneLayer(KisNodeList nodes); 0087 0088 KisNodeSP addShapeLayer(KisNodeSP activeNode); 0089 0090 KisNodeSP addAdjustmentLayer(KisNodeSP activeNode); 0091 KisAdjustmentLayerSP addAdjustmentLayer(KisNodeSP activeNode, const QString & name, KisFilterConfigurationSP filter, KisSelectionSP selection, KisProcessingApplicator *applicator); 0092 0093 KisNodeSP addGeneratorLayer(KisNodeSP activeNode); 0094 KisGeneratorLayerSP addGeneratorLayer(KisNodeSP activeNode, const QString &name, KisFilterConfigurationSP filter, KisSelectionSP selection, KisProcessingApplicator *applicator); 0095 0096 KisNodeSP addFileLayer(KisNodeSP activeNode); 0097 0098 void layerStyle(); 0099 0100 void changeCloneSource(); 0101 0102 void copyLayerStyle(); 0103 0104 void pasteLayerStyle(); 0105 0106 private: 0107 void adjustLayerPosition(KisNodeSP node, KisNodeSP activeNode, KisNodeSP &parent, KisNodeSP &above); 0108 void addLayerCommon(KisNodeSP activeNode, KisNodeSP layer, bool updateImage = true, KisProcessingApplicator *applicator = 0); 0109 0110 private: 0111 0112 KisViewManager * m_view; 0113 QPointer<KisView>m_imageView {0}; 0114 0115 KisAction *m_imageFlatten {0}; 0116 KisAction *m_imageMergeLayer {0}; 0117 KisAction *m_groupLayersSave {0}; 0118 KisAction *m_convertGroupAnimated {0}; 0119 KisAction *m_imageResizeToLayer {0}; 0120 KisAction *m_flattenLayer {0}; 0121 KisAction *m_rasterizeLayer {0}; 0122 KisNodeCommandsAdapter* m_commandsAdapter; 0123 0124 KisAction *m_layerStyle {0}; 0125 KisAction *m_copyLayerStyle {0}; 0126 KisAction *m_pasteLayerStyle {0}; 0127 }; 0128 0129 #endif