File indexing completed on 2024-05-19 04:26:11

0001 /*
0002  *  SPDX-FileCopyrightText: 2010 Boudewijn Rempt <boud@valdyas.org>
0003  *  SPDX-FileCopyrightText: 2010 Dmitry Kazakov <dimula73@gmail.com>
0004  *
0005  *  SPDX-License-Identifier: GPL-2.0-or-later
0006  */
0007 #ifndef KIS_DEFAULT_BOUNDS_H
0008 #define KIS_DEFAULT_BOUNDS_H
0009 
0010 #include <QRect>
0011 #include "kis_types.h"
0012 #include "kis_default_bounds_base.h"
0013 
0014 class KisDefaultBounds;
0015 class KisSelectionDefaultBounds;
0016 class KisSelectionEmptyBounds;
0017 class KisWrapAroundBoundsWrapper;
0018 typedef KisSharedPtr<KisDefaultBounds> KisDefaultBoundsSP;
0019 typedef KisSharedPtr<KisSelectionDefaultBounds> KisSelectionDefaultBoundsSP;
0020 typedef KisSharedPtr<KisSelectionEmptyBounds> KisSelectionEmptyBoundsSP;
0021 typedef KisSharedPtr<KisWrapAroundBoundsWrapper> KisWrapAroundBoundsWrapperSP;
0022 
0023 class KRITAIMAGE_EXPORT KisDefaultBounds :  public KisDefaultBoundsBase
0024 {
0025 public:
0026     KisDefaultBounds();
0027     KisDefaultBounds(KisImageWSP image);
0028     ~KisDefaultBounds() override;
0029 
0030     QRect bounds() const override;
0031     bool wrapAroundMode() const override;
0032     WrapAroundAxis wrapAroundModeAxis() const override;
0033     int currentLevelOfDetail() const override;
0034     int currentTime() const override;
0035     bool externalFrameActive() const override;
0036     void * sourceCookie() const override;
0037 
0038 protected:
0039     friend class KisPaintDeviceTest;
0040     static const QRect infiniteRect;
0041 
0042 private:
0043     Q_DISABLE_COPY(KisDefaultBounds)
0044 
0045     struct Private;
0046     Private * const m_d;
0047 };
0048 
0049 class KRITAIMAGE_EXPORT KisSelectionDefaultBounds : public KisDefaultBoundsBase
0050 {
0051 public:
0052     KisSelectionDefaultBounds(KisPaintDeviceSP parentPaintDevice);
0053     ~KisSelectionDefaultBounds() override;
0054 
0055     QRect bounds() const override;
0056     QRect imageBorderRect() const override;
0057     bool wrapAroundMode() const override;
0058     WrapAroundAxis wrapAroundModeAxis() const override;
0059     int currentLevelOfDetail() const override;
0060     int currentTime() const override;
0061     bool externalFrameActive() const override;
0062     void * sourceCookie() const override;
0063 
0064 private:
0065     Q_DISABLE_COPY(KisSelectionDefaultBounds)
0066 
0067     struct Private;
0068     Private * const m_d;
0069 };
0070 
0071 class KRITAIMAGE_EXPORT KisSelectionEmptyBounds : public KisDefaultBounds
0072 {
0073 public:
0074     KisSelectionEmptyBounds();
0075     KisSelectionEmptyBounds(KisImageWSP image);
0076     ~KisSelectionEmptyBounds() override;
0077     QRect bounds() const override;
0078 };
0079 
0080 /**
0081  * @brief The KisWrapAroundBoundsWrapper class
0082  * wrapper around a KisDefaultBoundsBaseSP to enable
0083  * wraparound. Used for patterns.
0084  */
0085 class KRITAIMAGE_EXPORT KisWrapAroundBoundsWrapper :  public KisDefaultBoundsBase
0086 {
0087 public:
0088     KisWrapAroundBoundsWrapper(KisDefaultBoundsBaseSP base, QRect bounds);
0089     ~KisWrapAroundBoundsWrapper() override;
0090 
0091     QRect bounds() const override;
0092     bool wrapAroundMode() const override;
0093     WrapAroundAxis wrapAroundModeAxis() const override;
0094     int currentLevelOfDetail() const override;
0095     int currentTime() const override;
0096     bool externalFrameActive() const override;
0097     void * sourceCookie() const override;
0098 
0099 protected:
0100     friend class KisPaintDeviceTest;
0101 
0102 private:
0103     Q_DISABLE_COPY(KisWrapAroundBoundsWrapper)
0104 
0105     struct Private;
0106     const QScopedPointer<Private> m_d;
0107 };
0108 
0109 #endif // KIS_DEFAULT_BOUNDS_H