1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtQml module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #ifndef QQUICKIMAGE_P_H
43 #define QQUICKIMAGE_P_H
45 #include "qquickimagebase_p.h"
46 #include <QtQuick/qsgtextureprovider.h>
52 class QQuickImagePrivate;
53 class Q_AUTOTEST_EXPORT QQuickImage : public QQuickImageBase
60 Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged)
61 Q_PROPERTY(qreal paintedWidth READ paintedWidth NOTIFY paintedGeometryChanged)
62 Q_PROPERTY(qreal paintedHeight READ paintedHeight NOTIFY paintedGeometryChanged)
63 Q_PROPERTY(HAlignment horizontalAlignment READ horizontalAlignment WRITE setHorizontalAlignment NOTIFY horizontalAlignmentChanged)
64 Q_PROPERTY(VAlignment verticalAlignment READ verticalAlignment WRITE setVerticalAlignment NOTIFY verticalAlignmentChanged)
67 QQuickImage(QQuickItem *parent=0);
70 enum HAlignment { AlignLeft = Qt::AlignLeft,
71 AlignRight = Qt::AlignRight,
72 AlignHCenter = Qt::AlignHCenter };
73 enum VAlignment { AlignTop = Qt::AlignTop,
74 AlignBottom = Qt::AlignBottom,
75 AlignVCenter = Qt::AlignVCenter };
77 enum FillMode { Stretch, PreserveAspectFit, PreserveAspectCrop, Tile, TileVertically, TileHorizontally, Pad };
79 FillMode fillMode() const;
80 void setFillMode(FillMode);
82 qreal paintedWidth() const;
83 qreal paintedHeight() const;
85 QRectF boundingRect() const;
87 HAlignment horizontalAlignment() const;
88 void setHorizontalAlignment(HAlignment align);
90 VAlignment verticalAlignment() const;
91 void setVerticalAlignment(VAlignment align);
93 bool isTextureProvider() const { return true; }
94 QSGTextureProvider *textureProvider() const;
97 void fillModeChanged();
98 void paintedGeometryChanged();
99 void horizontalAlignmentChanged(HAlignment alignment);
100 void verticalAlignmentChanged(VAlignment alignment);
103 QQuickImage(QQuickImagePrivate &dd, QQuickItem *parent);
105 void updatePaintedGeometry();
107 virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
108 virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
111 Q_DISABLE_COPY(QQuickImage)
112 Q_DECLARE_PRIVATE(QQuickImage)
116 QML_DECLARE_TYPE(QQuickImage)
119 #endif // QQUICKIMAGE_P_H