File indexing completed on 2024-10-27 04:07:33
0001 /* 0002 * SPDX-FileCopyrightText: 2011 Dmitry Kazakov <dimula73@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef __KIS_DUMMIES_FACADE_BASE_H 0008 #define __KIS_DUMMIES_FACADE_BASE_H 0009 0010 #include <QObject> 0011 0012 #include "kis_types.h" 0013 #include "kritaui_export.h" 0014 0015 class KisNodeDummy; 0016 0017 /** 0018 * Keeps track of the node stack and manages local (UI-wide) representation 0019 * of the node stack. It uses KisNodeDummy objects to represent the stack. 0020 * This is done to break synchronization tie between UI and Image threads, 0021 * caused by the fact that KisNodeModel must be synchronously notified 0022 * when a node is removed/deleted. 0023 */ 0024 0025 class KRITAUI_EXPORT KisDummiesFacadeBase : public QObject 0026 { 0027 Q_OBJECT 0028 0029 public: 0030 KisDummiesFacadeBase(QObject *parent = 0); 0031 ~KisDummiesFacadeBase() override; 0032 0033 virtual void setImage(KisImageWSP image); 0034 0035 virtual bool hasDummyForNode(KisNodeSP node) const = 0; 0036 virtual KisNodeDummy* dummyForNode(KisNodeSP node) const = 0; 0037 0038 /** 0039 * Return the root dummy of the graph. Since the call to setImage() causes 0040 * an **asynchronous** update of the dummies graph, it may cause 0041 * rootDummy() to be null at some moments, which is a valid state. 0042 */ 0043 virtual KisNodeDummy* rootDummy() const = 0; 0044 virtual int dummiesCount() const = 0; 0045 0046 protected: 0047 KisImageWSP image() const; 0048 0049 virtual void addNodeImpl(KisNodeSP node, KisNodeSP parent, KisNodeSP aboveThis) = 0; 0050 virtual void removeNodeImpl(KisNodeSP node) = 0; 0051 0052 Q_SIGNALS: 0053 /** 0054 * The signals for controlling the node model 0055 */ 0056 0057 void sigBeginInsertDummy(KisNodeDummy *parent, int index, const QString &metaObjectType); 0058 void sigEndInsertDummy(KisNodeDummy *dummy); 0059 0060 void sigBeginRemoveDummy(KisNodeDummy *dummy); 0061 void sigEndRemoveDummy(); 0062 0063 void sigDummyChanged(KisNodeDummy *dummy); 0064 0065 /** 0066 * This signal is emitted when the shape controller wants to request 0067 * the change of an active layer. E.g. when a new layer is added or 0068 * when the root layer of the image is changed. It should be forwarded 0069 * through a signal to allow queueing and synchronization of threads. 0070 */ 0071 void sigActivateNode(KisNodeSP node); 0072 0073 private Q_SLOTS: 0074 void slotLayersChanged(); 0075 void slotNodeChanged(KisNodeSP node); 0076 0077 void slotNodeActivationRequested(KisNodeSP node); 0078 0079 void slotNodeAdded(KisNodeSP node); 0080 void slotRemoveNode(KisNodeSP node); 0081 0082 void slotContinueAddNode(KisNodeSP node, KisNodeSP parent, KisNodeSP aboveThis); 0083 void slotContinueRemoveNode(KisNodeSP node); 0084 0085 private: 0086 static KisNodeSP findFirstLayer(KisNodeSP root); 0087 0088 private: 0089 struct Private; 0090 Private * const m_d; 0091 }; 0092 0093 #endif /* __KIS_DUMMIES_FACADE_BASE_H */