diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-07-31 03:33:24 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-07-31 03:33:24 (GMT) |
commit | 5c9f8288cf642a51bdce46f2833b37e4f94d43d9 (patch) | |
tree | 85e57f9c561477a3706c5f8fb32d4abf3c428919 /src | |
parent | 3359564d5628af68eb19598d1c0d19e5d1abb272 (diff) | |
download | Qt-5c9f8288cf642a51bdce46f2833b37e4f94d43d9.zip Qt-5c9f8288cf642a51bdce46f2833b37e4f94d43d9.tar.gz Qt-5c9f8288cf642a51bdce46f2833b37e4f94d43d9.tar.bz2 |
Add baselineOffset to anchors.
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/fx/qfxanchors.cpp | 18 | ||||
-rw-r--r-- | src/declarative/fx/qfxanchors.h | 5 | ||||
-rw-r--r-- | src/declarative/fx/qfxanchors_p.h | 3 | ||||
-rw-r--r-- | src/declarative/fx/qfxitem.cpp | 3 |
4 files changed, 26 insertions, 3 deletions
diff --git a/src/declarative/fx/qfxanchors.cpp b/src/declarative/fx/qfxanchors.cpp index a22aeb3..1595f57 100644 --- a/src/declarative/fx/qfxanchors.cpp +++ b/src/declarative/fx/qfxanchors.cpp @@ -468,7 +468,7 @@ void QFxAnchorsPrivate::updateVerticalAnchors() } else if (usedAnchors & QFxAnchors::HasBaselineAnchor) { //Handle baseline if (baseline.item->parentItem() == item->parentItem()) { - setItemY(position(baseline.item, baseline.anchorLine) - item->baselineOffset()); + setItemY(position(baseline.item, baseline.anchorLine) - item->baselineOffset() + baselineOffset); } } --updatingVerticalAnchor; @@ -872,6 +872,22 @@ void QFxAnchors::setVerticalCenterOffset(qreal offset) emit verticalCenterOffsetChanged(); } +qreal QFxAnchors::baselineOffset() const +{ + Q_D(const QFxAnchors); + return d->baselineOffset; +} + +void QFxAnchors::setBaselineOffset(qreal offset) +{ + Q_D(QFxAnchors); + if (d->baselineOffset == offset) + return; + d->baselineOffset = offset; + d->updateVerticalAnchors(); + emit baselineOffsetChanged(); +} + QFxAnchors::UsedAnchors QFxAnchors::usedAnchors() const { Q_D(const QFxAnchors); diff --git a/src/declarative/fx/qfxanchors.h b/src/declarative/fx/qfxanchors.h index 7ff4c35..70217d6 100644 --- a/src/declarative/fx/qfxanchors.h +++ b/src/declarative/fx/qfxanchors.h @@ -71,6 +71,7 @@ class Q_DECLARATIVE_EXPORT QFxAnchors : public QObject 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(QFxItem *fill READ fill WRITE setFill) Q_PROPERTY(QFxItem *centerIn READ centerIn WRITE setCenterIn) @@ -137,6 +138,9 @@ public: qreal verticalCenterOffset() const; void setVerticalCenterOffset(qreal); + qreal baselineOffset() const; + void setBaselineOffset(qreal); + QFxItem *fill() const; void setFill(QFxItem *); @@ -157,6 +161,7 @@ Q_SIGNALS: void bottomMarginChanged(); void verticalCenterOffsetChanged(); void horizontalCenterOffsetChanged(); + void baselineOffsetChanged(); private: friend class QFxItem; diff --git a/src/declarative/fx/qfxanchors_p.h b/src/declarative/fx/qfxanchors_p.h index 1827324..ca42966 100644 --- a/src/declarative/fx/qfxanchors_p.h +++ b/src/declarative/fx/qfxanchors_p.h @@ -66,7 +66,7 @@ public: : 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), + bottomMargin(0), vCenterOffset(0), hCenterOffset(0), baselineOffset(0), componentComplete(true) { } @@ -126,6 +126,7 @@ public: qreal bottomMargin; qreal vCenterOffset; qreal hCenterOffset; + qreal baselineOffset; bool componentComplete; }; diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 617e479..71d4ce2 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -1087,13 +1087,14 @@ QFxAnchorLine QFxItem::baseline() const \qmlproperty real Item::anchors.rightMargin \qmlproperty real Item::anchors.horizontalCenterOffset \qmlproperty real Item::anchors.verticalCenterOffset + \qmlproperty real Item::anchors.baselineOffset Anchors provide a way to position an item by specifying its relationship with other items. Margins apply to top, bottom, left, right, and fill anchors. - Offsets apply for horizontal and vertical center anchors. + Offsets apply for horizontal center, vertical center, and baseline anchors. \table \row |