File indexing completed on 2024-05-12 15:58:44

0001 /*
0002  *  SPDX-FileCopyrightText: 2015 Dmitry Kazakov <dimula73@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef __KIS_SWITCH_TIME_STROKE_STRATEGY_H
0008 #define __KIS_SWITCH_TIME_STROKE_STRATEGY_H
0009 
0010 #include <kis_simple_stroke_strategy.h>
0011 
0012 #include <QScopedPointer>
0013 
0014 class KisImageAnimationInterface;
0015 class KisPostExecutionUndoAdapter;
0016 
0017 
0018 class KisSwitchTimeStrokeStrategy : public KisSimpleStrokeStrategy
0019 {
0020 public:
0021     struct SharedToken {
0022         SharedToken(int initialTime, bool needsRegeneration);
0023         ~SharedToken();
0024 
0025         bool tryResetDestinationTime(int time, bool needsRegeneration);
0026         int fetchTime() const;
0027 
0028     private:
0029         struct Private;
0030         QScopedPointer<Private> m_d;
0031     };
0032 
0033     typedef QSharedPointer<SharedToken> SharedTokenSP;
0034     typedef QWeakPointer<SharedToken> SharedTokenWSP;
0035 
0036 public:
0037     /**
0038      * Switches current time to \p frameId
0039      *
0040      * NOTE: switching time *does* end all the running stroke, because it is
0041      *       not a background action, but a distinct user action.
0042      */
0043     KisSwitchTimeStrokeStrategy(int frameId,
0044                                 bool needsRegeneration,
0045                                 KisImageAnimationInterface *interface,
0046                                 KisPostExecutionUndoAdapter *undoAdapter);
0047     ~KisSwitchTimeStrokeStrategy() override;
0048 
0049     void initStrokeCallback() override;
0050     KisStrokeStrategy* createLodClone(int levelOfDetail) override;
0051 
0052     SharedTokenSP token() const;
0053 
0054 
0055 private:
0056     struct Private;
0057     const QScopedPointer<Private> m_d;
0058 };
0059 
0060 #endif /* __KIS_SWITCH_TIME_STROKE_STRATEGY_H */