summaryrefslogtreecommitdiffstats
path: root/src/declarative/fx/qfxitem.cpp
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-05-22 00:32:16 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-05-22 00:37:31 (GMT)
commit61943383ccff409d60d9837d58e4372dc6f22f23 (patch)
treeb030d569a1c4a31a20b87c3b0b80f4ee6d2fec7a /src/declarative/fx/qfxitem.cpp
parent942ea5202d4a329376c27015b07406c2018437ff (diff)
downloadQt-61943383ccff409d60d9837d58e4372dc6f22f23.zip
Qt-61943383ccff409d60d9837d58e4372dc6f22f23.tar.gz
Qt-61943383ccff409d60d9837d58e4372dc6f22f23.tar.bz2
Add support for baseline anchoring.
Diffstat (limited to 'src/declarative/fx/qfxitem.cpp')
-rw-r--r--src/declarative/fx/qfxitem.cpp55
1 files changed, 23 insertions, 32 deletions
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp
index 3cbcd6a..561a124 100644
--- a/src/declarative/fx/qfxitem.cpp
+++ b/src/declarative/fx/qfxitem.cpp
@@ -259,24 +259,10 @@ void QFxContents::setItem(QFxItem *item)
*/
/*!
- \fn void QFxItem::baselineChanged()
-
- This signal is emitted when the baseline of the item changes.
-
- The baseline may change in response to a change to the baselineOffset
- property or due to the geometry of the item changing.
-*/
-
-/*!
\fn void QFxItem::baselineOffsetChanged()
- This signal is emitted when the baseline of the item is changed
- via the baselineOffset property.
-
- The baseline corresponds to the baseline of the text contained in
- the item. It is useful for aligning the text in items placed
- beside each other. The default baseline is positioned at
- 2/3 of the height of the item.
+ This signal is emitted when the baseline offset of the item
+ is changed.
*/
/*!
@@ -286,24 +272,12 @@ void QFxContents::setItem(QFxItem *item)
*/
/*!
- \fn void QFxItem::rightChanged()
-
- This signal is emitted when the right coordinate of the item changes.
-*/
-
-/*!
\fn void QFxItem::topChanged()
This signal is emitted when the top coordinate of the item changes.
*/
/*!
- \fn void QFxItem::bottomChanged()
-
- This signal is emitted when the bottom coordinate of the item changes.
-*/
-
-/*!
\fn void QFxItem::widthChanged()
This signal is emitted when the width of the item changes.
@@ -1282,6 +1256,15 @@ QFxAnchorLine QFxItem::verticalCenter() const
}
/*!
+ \internal
+*/
+QFxAnchorLine QFxItem::baseline() const
+{
+ Q_D(const QFxItem);
+ return d->anchorLines()->baseline;
+}
+
+/*!
\property QFxItem::top
One of the anchor lines of the item.
@@ -1336,6 +1319,7 @@ QFxAnchorLine QFxItem::verticalCenter() const
\qmlproperty AnchorLine Item::right
\qmlproperty AnchorLine Item::horizontalCenter
\qmlproperty AnchorLine Item::verticalCenter
+ \qmlproperty AnchorLine Item::baseline
The anchor lines of the item.
@@ -1349,6 +1333,7 @@ QFxAnchorLine QFxItem::verticalCenter() const
\qmlproperty AnchorLine Item::anchors.right
\qmlproperty AnchorLine Item::anchors.horizontalCenter
\qmlproperty AnchorLine Item::anchors.verticalCenter
+ \qmlproperty AnchorLine Item::anchors.baseline
\qmlproperty Item Item::anchors.fill
@@ -1408,20 +1393,19 @@ QFxAnchorLine QFxItem::verticalCenter() const
/*!
\property QFxItem::baselineOffset
- \brief The position of the item's baseline in global (scene) coordinates.
+ \brief The position of the item's baseline in local coordinates.
The baseline of a Text item is the imaginary line on which the text
sits. Controls containing text usually set their baseline to the
baseline of their text.
- For non-text items, a default baseline offset of two-thirds of the
- item's height is used to determine the baseline.
+ For non-text items, a default baseline offset of 0 is used.
*/
int QFxItem::baselineOffset() const
{
Q_D(const QFxItem);
if (!d->_baselineOffset.isValid()) {
- return height()*2/3; //### default baseline is 2/3 of the way to the bottom of the item
+ return 0;
} else
return d->_baselineOffset;
}
@@ -1437,6 +1421,11 @@ void QFxItem::setBaselineOffset(int offset)
d->_baselineOffset = offset;
emit baselineOffsetChanged();
+
+ for(int ii = 0; ii < d->dependantAnchors.count(); ++ii) {
+ QFxAnchors *anchor = d->dependantAnchors.at(ii);
+ anchor->d_func()->updateVerticalAnchors();
+ }
}
/*!
@@ -2100,6 +2089,8 @@ QFxItemPrivate::AnchorLines::AnchorLines(QFxItem *q)
bottom.anchorLine = QFxAnchorLine::Bottom;
vCenter.item = q;
vCenter.anchorLine = QFxAnchorLine::VCenter;
+ baseline.item = q;
+ baseline.anchorLine = QFxAnchorLine::Baseline;
}
QT_END_NAMESPACE