File indexing completed on 2024-12-22 04:10:01
0001 /* 0002 * SPDX-FileCopyrightText: 2002 Patrick Julien <freak@codepimps.org> 0003 * SPDX-FileCopyrightText: 2007 Sven Langkamp <sven.langkamp@gmail.com> 0004 * 0005 * SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef KIS_IMAGE_COMMAND_H_ 0009 #define KIS_IMAGE_COMMAND_H_ 0010 0011 #include <kritaimage_export.h> 0012 0013 #include <kundo2command.h> 0014 0015 #include <QSize> 0016 #include <QRect> 0017 #include "kis_types.h" 0018 #include "kis_paint_device.h" 0019 0020 0021 /// the base command for commands altering a KisImage 0022 class KRITAIMAGE_EXPORT KisImageCommand : public KUndo2Command 0023 { 0024 0025 public: 0026 /** 0027 * Constructor 0028 * @param name The name that will be shown in the ui 0029 * @param image The image the command will be working on. 0030 * @param parent The parent command. 0031 */ 0032 KisImageCommand(const KUndo2MagicString& name, KisImageWSP image, KUndo2Command *parent = 0); 0033 ~KisImageCommand() override; 0034 0035 protected: 0036 0037 /** 0038 * Used for performing the smallest update 0039 * after a node has been removed from stack. 0040 * First tries to setDirty() node's siblings. 0041 * If it doesn't help, performs full refresh. 0042 */ 0043 class UpdateTarget 0044 { 0045 public: 0046 UpdateTarget(KisImageWSP image, KisNodeSP removedNode, const QRect &updateRect); 0047 void update(); 0048 0049 private: 0050 KisImageWSP m_image; 0051 QRect m_updateRect; 0052 int m_removedNodeIndex; 0053 KisNodeSP m_removedNodeParent; 0054 }; 0055 0056 protected: 0057 KisImageWSP m_image; 0058 }; 0059 0060 #endif // KIS_IMAGE_COMMAND_H_