| 1 | // Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QT3DRENDER_QPAINTEDTEXTURE_H |
| 5 | #define QT3DRENDER_QPAINTEDTEXTURE_H |
| 6 | |
| 7 | #include <Qt3DRender/qabstracttextureimage.h> |
| 8 | |
| 9 | QT_BEGIN_NAMESPACE |
| 10 | |
| 11 | class QPainter; |
| 12 | |
| 13 | namespace Qt3DRender { |
| 14 | |
| 15 | class QPaintedTextureImagePrivate; |
| 16 | |
| 17 | class Q_3DRENDERSHARED_EXPORT QPaintedTextureImage : public QAbstractTextureImage |
| 18 | { |
| 19 | Q_OBJECT |
| 20 | Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged) |
| 21 | Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged) |
| 22 | Q_PROPERTY(QSize size READ size WRITE setSize NOTIFY sizeChanged) |
| 23 | |
| 24 | public: |
| 25 | explicit QPaintedTextureImage(Qt3DCore::QNode *parent = nullptr); |
| 26 | ~QPaintedTextureImage(); |
| 27 | |
| 28 | int width() const; |
| 29 | int height() const; |
| 30 | QSize size() const; |
| 31 | |
| 32 | void update(const QRect &rect = QRect()); |
| 33 | |
| 34 | public Q_SLOTS: |
| 35 | void setWidth(int w); |
| 36 | void setHeight(int h); |
| 37 | void setSize(QSize size); |
| 38 | |
| 39 | Q_SIGNALS: |
| 40 | void widthChanged(int w); |
| 41 | void heightChanged(int w); |
| 42 | void sizeChanged(QSize size); |
| 43 | |
| 44 | protected: |
| 45 | virtual void paint(QPainter *painter) = 0; |
| 46 | |
| 47 | private: |
| 48 | Q_DECLARE_PRIVATE(QPaintedTextureImage) |
| 49 | |
| 50 | QTextureImageDataGeneratorPtr dataGenerator() const override; |
| 51 | }; |
| 52 | |
| 53 | } // namespace Qt3DRender |
| 54 | |
| 55 | QT_END_NAMESPACE |
| 56 | |
| 57 | #endif // QT3DRENDER_QPAINTEDTEXTURE_H |
| 58 |
