summaryrefslogtreecommitdiffstats
path: root/src/declarative/fx/qmlgraphicsanchors_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/fx/qmlgraphicsanchors_p.h')
-rw-r--r--src/declarative/fx/qmlgraphicsanchors_p.h234
1 files changed, 127 insertions, 107 deletions
diff --git a/src/declarative/fx/qmlgraphicsanchors_p.h b/src/declarative/fx/qmlgraphicsanchors_p.h
index 3986cd6..de7214d 100644
--- a/src/declarative/fx/qmlgraphicsanchors_p.h
+++ b/src/declarative/fx/qmlgraphicsanchors_p.h
@@ -39,122 +39,142 @@
**
****************************************************************************/
-#ifndef QMLGRAPHICSANCHORS_P_H
-#define QMLGRAPHICSANCHORS_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qmlgraphicsanchors.h"
-#include "private/qobject_p.h"
+#ifndef QMLGRAPHICSANCHORS_H
+#define QMLGRAPHICSANCHORS_H
+
+#include <QtCore/QObject>
+#include <QtDeclarative/qfxglobal.h>
+#include <QtDeclarative/qml.h>
+#include <QtDeclarative/qmlgraphicsitem.h>
+
+QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-class QmlGraphicsAnchorLine
+QT_MODULE(Declarative)
+
+class QmlGraphicsAnchorsPrivate;
+class QmlGraphicsAnchorLine;
+class Q_DECLARATIVE_EXPORT QmlGraphicsAnchors : public QObject
{
+ Q_OBJECT
+
+ Q_PROPERTY(QmlGraphicsAnchorLine left READ left WRITE setLeft RESET resetLeft)
+ Q_PROPERTY(QmlGraphicsAnchorLine right READ right WRITE setRight RESET resetRight)
+ Q_PROPERTY(QmlGraphicsAnchorLine horizontalCenter READ horizontalCenter WRITE setHorizontalCenter RESET resetHorizontalCenter)
+ Q_PROPERTY(QmlGraphicsAnchorLine top READ top WRITE setTop RESET resetTop)
+ Q_PROPERTY(QmlGraphicsAnchorLine bottom READ bottom WRITE setBottom RESET resetBottom)
+ Q_PROPERTY(QmlGraphicsAnchorLine verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter)
+ Q_PROPERTY(QmlGraphicsAnchorLine baseline READ baseline WRITE setBaseline RESET resetBaseline)
+ Q_PROPERTY(qreal leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged)
+ Q_PROPERTY(qreal rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged)
+ Q_PROPERTY(qreal horizontalCenterOffset READ horizontalCenterOffset WRITE setHorizontalCenterOffset NOTIFY horizontalCenterOffsetChanged())
+ Q_PROPERTY(qreal topMargin READ topMargin WRITE setTopMargin NOTIFY topMarginChanged)
+ Q_PROPERTY(qreal bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged)
+ Q_PROPERTY(qreal verticalCenterOffset READ verticalCenterOffset WRITE setVerticalCenterOffset NOTIFY verticalCenterOffsetChanged())
+ Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged())
+ Q_PROPERTY(QmlGraphicsItem *fill READ fill WRITE setFill)
+ Q_PROPERTY(QmlGraphicsItem *centerIn READ centerIn WRITE setCenterIn)
+
public:
- QmlGraphicsAnchorLine() : item(0), anchorLine(Invalid)
- {
- }
-
- enum AnchorLine {
- Invalid = 0x0,
- Left = 0x01,
- Right = 0x02,
- Top = 0x04,
- Bottom = 0x08,
- HCenter = 0x10,
- VCenter = 0x20,
- Baseline = 0x40,
- Horizontal_Mask = Left | Right | HCenter,
- Vertical_Mask = Top | Bottom | VCenter | Baseline
+ QmlGraphicsAnchors(QObject *parent=0);
+ virtual ~QmlGraphicsAnchors();
+
+ enum UsedAnchor {
+ HasLeftAnchor = 0x01,
+ HasRightAnchor = 0x02,
+ HasTopAnchor = 0x04,
+ HasBottomAnchor = 0x08,
+ HasHCenterAnchor = 0x10,
+ HasVCenterAnchor = 0x20,
+ HasBaselineAnchor = 0x40,
+ Horizontal_Mask = HasLeftAnchor | HasRightAnchor | HasHCenterAnchor,
+ Vertical_Mask = HasTopAnchor | HasBottomAnchor | HasVCenterAnchor | HasBaselineAnchor
};
+ Q_DECLARE_FLAGS(UsedAnchors, UsedAnchor)
- QmlGraphicsItem *item;
- AnchorLine anchorLine;
-};
-Q_DECLARE_METATYPE(QmlGraphicsAnchorLine)
+ QmlGraphicsAnchorLine left() const;
+ void setLeft(const QmlGraphicsAnchorLine &edge);
+ void resetLeft();
-class QmlGraphicsAnchorsPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QmlGraphicsAnchors)
-public:
- QmlGraphicsAnchorsPrivate()
- : updatingMe(false), updatingHorizontalAnchor(0),
- updatingVerticalAnchor(0), item(0), usedAnchors(0), fill(0),
- centerIn(0), leftMargin(0), rightMargin(0), topMargin(0),
- bottomMargin(0), vCenterOffset(0), hCenterOffset(0), baselineOffset(0),
- componentComplete(true)
- {
- }
-
- void init()
- {
- }
-
- void clearItem(QmlGraphicsItem *);
-
- void addDepend(QmlGraphicsItem *);
- void remDepend(QmlGraphicsItem *);
- bool isItemComplete() const;
-
- bool updatingMe;
- int updatingHorizontalAnchor;
- int updatingVerticalAnchor;
-
- void setItemHeight(qreal);
- void setItemWidth(qreal);
- void setItemX(qreal);
- void setItemY(qreal);
- void setItemPos(const QPointF &);
-
- void updateOnComplete();
- void updateMe();
- void update(QmlGraphicsItem *, const QRectF &, const QRectF &);
-
- bool checkHValid() const;
- bool checkVValid() const;
- bool checkHAnchorValid(QmlGraphicsAnchorLine anchor) const;
- bool checkVAnchorValid(QmlGraphicsAnchorLine anchor) const;
- bool calcStretch(const QmlGraphicsAnchorLine &edge1, const QmlGraphicsAnchorLine &edge2, int offset1, int offset2, QmlGraphicsAnchorLine::AnchorLine line, int &stretch);
-
- void updateHorizontalAnchors();
- void updateVerticalAnchors();
- void fillChanged();
- void centerInChanged();
-
- QmlGraphicsItem *item;
- QmlGraphicsAnchors::UsedAnchors usedAnchors;
-
- QmlGraphicsItem *fill;
- QmlGraphicsItem *centerIn;
-
- QmlGraphicsAnchorLine left;
- QmlGraphicsAnchorLine right;
- QmlGraphicsAnchorLine top;
- QmlGraphicsAnchorLine bottom;
- QmlGraphicsAnchorLine vCenter;
- QmlGraphicsAnchorLine hCenter;
- QmlGraphicsAnchorLine baseline;
-
- qreal leftMargin;
- qreal rightMargin;
- qreal topMargin;
- qreal bottomMargin;
- qreal vCenterOffset;
- qreal hCenterOffset;
- qreal baselineOffset;
-
- bool componentComplete;
+ QmlGraphicsAnchorLine right() const;
+ void setRight(const QmlGraphicsAnchorLine &edge);
+ void resetRight();
+
+ QmlGraphicsAnchorLine horizontalCenter() const;
+ void setHorizontalCenter(const QmlGraphicsAnchorLine &edge);
+ void resetHorizontalCenter();
+
+ QmlGraphicsAnchorLine top() const;
+ void setTop(const QmlGraphicsAnchorLine &edge);
+ void resetTop();
+
+ QmlGraphicsAnchorLine bottom() const;
+ void setBottom(const QmlGraphicsAnchorLine &edge);
+ void resetBottom();
+
+ QmlGraphicsAnchorLine verticalCenter() const;
+ void setVerticalCenter(const QmlGraphicsAnchorLine &edge);
+ void resetVerticalCenter();
+
+ QmlGraphicsAnchorLine baseline() const;
+ void setBaseline(const QmlGraphicsAnchorLine &edge);
+ void resetBaseline();
+
+ qreal leftMargin() const;
+ void setLeftMargin(qreal);
+
+ qreal rightMargin() const;
+ void setRightMargin(qreal);
+
+ qreal horizontalCenterOffset() const;
+ void setHorizontalCenterOffset(qreal);
+
+ qreal topMargin() const;
+ void setTopMargin(qreal);
+
+ qreal bottomMargin() const;
+ void setBottomMargin(qreal);
+
+ qreal verticalCenterOffset() const;
+ void setVerticalCenterOffset(qreal);
+
+ qreal baselineOffset() const;
+ void setBaselineOffset(qreal);
+
+ QmlGraphicsItem *fill() const;
+ void setFill(QmlGraphicsItem *);
+
+ QmlGraphicsItem *centerIn() const;
+ void setCenterIn(QmlGraphicsItem *);
+
+ UsedAnchors usedAnchors() const;
+
+ void setItem(QmlGraphicsItem *item);
+
+ void classBegin();
+ void componentComplete();
+
+Q_SIGNALS:
+ void leftMarginChanged();
+ void rightMarginChanged();
+ void topMarginChanged();
+ void bottomMarginChanged();
+ void verticalCenterOffsetChanged();
+ void horizontalCenterOffsetChanged();
+ void baselineOffsetChanged();
+
+private:
+ friend class QmlGraphicsItem;
+ Q_DISABLE_COPY(QmlGraphicsAnchors)
+ Q_DECLARE_PRIVATE(QmlGraphicsAnchors)
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(QmlGraphicsAnchors::UsedAnchors)
QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QmlGraphicsAnchors)
+
+QT_END_HEADER
+
#endif