| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
| 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 QQUICKBORDERIMAGE_P_H |
| 5 | #define QQUICKBORDERIMAGE_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include "qquickimagebase_p.h" |
| 19 | |
| 20 | QT_BEGIN_NAMESPACE |
| 21 | |
| 22 | class QQuickScaleGrid; |
| 23 | class QQuickGridScaledImage; |
| 24 | class QQuickBorderImagePrivate; |
| 25 | class Q_QUICK_EXPORT QQuickBorderImage : public QQuickImageBase |
| 26 | { |
| 27 | Q_OBJECT |
| 28 | |
| 29 | Q_PROPERTY(QQuickScaleGrid *border READ border CONSTANT) |
| 30 | Q_PROPERTY(TileMode horizontalTileMode READ horizontalTileMode WRITE setHorizontalTileMode NOTIFY horizontalTileModeChanged) |
| 31 | Q_PROPERTY(TileMode verticalTileMode READ verticalTileMode WRITE setVerticalTileMode NOTIFY verticalTileModeChanged) |
| 32 | // read-only for BorderImage |
| 33 | Q_PROPERTY(QSize sourceSize READ sourceSize NOTIFY sourceSizeChanged) |
| 34 | QML_NAMED_ELEMENT(BorderImage) |
| 35 | QML_ADDED_IN_VERSION(2, 0) |
| 36 | |
| 37 | public: |
| 38 | QQuickBorderImage(QQuickItem *parent=nullptr); |
| 39 | ~QQuickBorderImage(); |
| 40 | |
| 41 | QQuickScaleGrid *border(); |
| 42 | |
| 43 | enum TileMode { Stretch = Qt::StretchTile, Repeat = Qt::RepeatTile, Round = Qt::RoundTile }; |
| 44 | Q_ENUM(TileMode) |
| 45 | |
| 46 | TileMode horizontalTileMode() const; |
| 47 | void setHorizontalTileMode(TileMode); |
| 48 | |
| 49 | TileMode verticalTileMode() const; |
| 50 | void setVerticalTileMode(TileMode); |
| 51 | |
| 52 | void setSource(const QUrl &url) override; |
| 53 | |
| 54 | Q_SIGNALS: |
| 55 | void horizontalTileModeChanged(); |
| 56 | void verticalTileModeChanged(); |
| 57 | void sourceSizeChanged(); |
| 58 | |
| 59 | protected: |
| 60 | void load() override; |
| 61 | void pixmapChange() override; |
| 62 | QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override; |
| 63 | |
| 64 | private: |
| 65 | void setGridScaledImage(const QQuickGridScaledImage& sci); |
| 66 | |
| 67 | private Q_SLOTS: |
| 68 | void doUpdate(); |
| 69 | void requestFinished() override; |
| 70 | #if QT_CONFIG(qml_network) |
| 71 | void sciRequestFinished(); |
| 72 | #endif |
| 73 | |
| 74 | private: |
| 75 | Q_DISABLE_COPY(QQuickBorderImage) |
| 76 | Q_DECLARE_PRIVATE(QQuickBorderImage) |
| 77 | }; |
| 78 | |
| 79 | QT_END_NAMESPACE |
| 80 | |
| 81 | #endif // QQUICKBORDERIMAGE_P_H |
| 82 | |