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 QQUICKIMAGE_P_H |
5 | #define QQUICKIMAGE_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 | #include <QtQuick/qsgtextureprovider.h> |
20 | |
21 | QT_BEGIN_NAMESPACE |
22 | |
23 | class QQuickImagePrivate; |
24 | class Q_QUICK_PRIVATE_EXPORT QQuickImage : public QQuickImageBase |
25 | { |
26 | Q_OBJECT |
27 | |
28 | Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged FINAL) |
29 | Q_PROPERTY(qreal paintedWidth READ paintedWidth NOTIFY paintedGeometryChanged FINAL) |
30 | Q_PROPERTY(qreal paintedHeight READ paintedHeight NOTIFY paintedGeometryChanged FINAL) |
31 | Q_PROPERTY(HAlignment horizontalAlignment READ horizontalAlignment WRITE setHorizontalAlignment NOTIFY horizontalAlignmentChanged FINAL) |
32 | Q_PROPERTY(VAlignment verticalAlignment READ verticalAlignment WRITE setVerticalAlignment NOTIFY verticalAlignmentChanged FINAL) |
33 | Q_PROPERTY(QSize sourceSize READ sourceSize WRITE setSourceSize RESET resetSourceSize NOTIFY sourceSizeChanged FINAL) |
34 | Q_PROPERTY(bool mipmap READ mipmap WRITE setMipmap NOTIFY mipmapChanged REVISION(2, 3) FINAL) |
35 | Q_PROPERTY(bool autoTransform READ autoTransform WRITE setAutoTransform NOTIFY autoTransformChanged REVISION(2, 5) FINAL) |
36 | Q_PROPERTY(QRectF sourceClipRect READ sourceClipRect WRITE setSourceClipRect RESET resetSourceClipRect NOTIFY sourceClipRectChanged REVISION(2, 15) FINAL) |
37 | QML_NAMED_ELEMENT(Image) |
38 | QML_ADDED_IN_VERSION(2, 0) |
39 | |
40 | public: |
41 | QQuickImage(QQuickItem *parent=nullptr); |
42 | ~QQuickImage(); |
43 | |
44 | enum HAlignment { AlignLeft = Qt::AlignLeft, |
45 | AlignRight = Qt::AlignRight, |
46 | AlignHCenter = Qt::AlignHCenter }; |
47 | Q_ENUM(HAlignment) |
48 | enum VAlignment { AlignTop = Qt::AlignTop, |
49 | AlignBottom = Qt::AlignBottom, |
50 | AlignVCenter = Qt::AlignVCenter }; |
51 | Q_ENUM(VAlignment) |
52 | |
53 | enum FillMode { Stretch, PreserveAspectFit, PreserveAspectCrop, Tile, TileVertically, TileHorizontally, Pad }; |
54 | Q_ENUM(FillMode) |
55 | |
56 | FillMode fillMode() const; |
57 | void setFillMode(FillMode); |
58 | |
59 | qreal paintedWidth() const; |
60 | qreal paintedHeight() const; |
61 | |
62 | QRectF boundingRect() const override; |
63 | |
64 | HAlignment horizontalAlignment() const; |
65 | void setHorizontalAlignment(HAlignment align); |
66 | |
67 | VAlignment verticalAlignment() const; |
68 | void setVerticalAlignment(VAlignment align); |
69 | |
70 | bool isTextureProvider() const override { return true; } |
71 | QSGTextureProvider *textureProvider() const override; |
72 | |
73 | bool mipmap() const; |
74 | void setMipmap(bool use); |
75 | |
76 | void emitAutoTransformBaseChanged() override { Q_EMIT autoTransformChanged(); } |
77 | |
78 | Q_SIGNALS: |
79 | void fillModeChanged(); |
80 | void paintedGeometryChanged(); |
81 | void horizontalAlignmentChanged(HAlignment alignment); |
82 | void verticalAlignmentChanged(VAlignment alignment); |
83 | Q_REVISION(2, 3) void mipmapChanged(bool); |
84 | Q_REVISION(2, 5) void autoTransformChanged(); |
85 | |
86 | private Q_SLOTS: |
87 | void invalidateSceneGraph(); |
88 | |
89 | protected: |
90 | QQuickImage(QQuickImagePrivate &dd, QQuickItem *parent); |
91 | void pixmapChange() override; |
92 | void updatePaintedGeometry(); |
93 | void releaseResources() override; |
94 | |
95 | void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override; |
96 | QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override; |
97 | |
98 | private: |
99 | Q_DISABLE_COPY(QQuickImage) |
100 | Q_DECLARE_PRIVATE(QQuickImage) |
101 | }; |
102 | |
103 | QT_END_NAMESPACE |
104 | QML_DECLARE_TYPE(QQuickImage) |
105 | #endif // QQUICKIMAGE_P_H |
106 | |