summaryrefslogtreecommitdiffstats
path: root/src/declarative/fx
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-05-20 04:51:29 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-05-20 04:51:29 (GMT)
commite484ee27f929aca738a269947237d834dab89b39 (patch)
tree216f95598411eb4c72141308973695d5e0d8b372 /src/declarative/fx
parentded29009f766a8373193d94bcb8309270f66a266 (diff)
parentd1f1f2c91f63609ca1ffad32efdd6590f9f0ce6a (diff)
downloadQt-e484ee27f929aca738a269947237d834dab89b39.zip
Qt-e484ee27f929aca738a269947237d834dab89b39.tar.gz
Qt-e484ee27f929aca738a269947237d834dab89b39.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative/fx')
-rw-r--r--src/declarative/fx/qfxanchors.cpp718
-rw-r--r--src/declarative/fx/qfxanchors.h18
-rw-r--r--src/declarative/fx/qfxanchors_p.h36
-rw-r--r--src/declarative/fx/qfxanimatedimageitem.h2
-rw-r--r--src/declarative/fx/qfxblendedimage.h4
-rw-r--r--src/declarative/fx/qfxblurfilter.h4
-rw-r--r--src/declarative/fx/qfxcomponentinstance.h2
-rw-r--r--src/declarative/fx/qfxcontentwrapper.h2
-rw-r--r--src/declarative/fx/qfxevents_p.h4
-rw-r--r--src/declarative/fx/qfxflickable.h2
-rw-r--r--src/declarative/fx/qfxflipable.cpp7
-rw-r--r--src/declarative/fx/qfxflipable.h6
-rw-r--r--src/declarative/fx/qfxfocuspanel.h2
-rw-r--r--src/declarative/fx/qfxfocusrealm.h2
-rw-r--r--src/declarative/fx/qfxgridview.h2
-rw-r--r--src/declarative/fx/qfxhighlightfilter.h4
-rw-r--r--src/declarative/fx/qfximage.cpp36
-rw-r--r--src/declarative/fx/qfximage.h2
-rw-r--r--src/declarative/fx/qfxitem.cpp105
-rw-r--r--src/declarative/fx/qfxitem.h9
-rw-r--r--src/declarative/fx/qfxitem_p.h10
-rw-r--r--src/declarative/fx/qfxkeyactions.h8
-rw-r--r--src/declarative/fx/qfxkeyproxy.h2
-rw-r--r--src/declarative/fx/qfxlayouts.h8
-rw-r--r--src/declarative/fx/qfxlayouts_p.h10
-rw-r--r--src/declarative/fx/qfxlistview.h2
-rw-r--r--src/declarative/fx/qfxmouseregion.h2
-rw-r--r--src/declarative/fx/qfxpainteditem.h4
-rw-r--r--src/declarative/fx/qfxpainteditem_p.h4
-rw-r--r--src/declarative/fx/qfxparticles.cpp98
-rw-r--r--src/declarative/fx/qfxparticles.h10
-rw-r--r--src/declarative/fx/qfxpath.h8
-rw-r--r--src/declarative/fx/qfxpathview.h4
-rw-r--r--src/declarative/fx/qfxpixmap.h8
-rw-r--r--src/declarative/fx/qfxrect.cpp282
-rw-r--r--src/declarative/fx/qfxrect.h6
-rw-r--r--src/declarative/fx/qfxreflectionfilter.h4
-rw-r--r--src/declarative/fx/qfxrepeater.h2
-rw-r--r--src/declarative/fx/qfxscalegrid.h14
-rw-r--r--src/declarative/fx/qfxshadowfilter.h4
-rw-r--r--src/declarative/fx/qfxtext.cpp27
-rw-r--r--src/declarative/fx/qfxtext.h4
-rw-r--r--src/declarative/fx/qfxtext_p.h7
-rw-r--r--src/declarative/fx/qfxtextedit.cpp39
-rw-r--r--src/declarative/fx/qfxtextedit.h4
-rw-r--r--src/declarative/fx/qfxtransform.cpp32
-rw-r--r--src/declarative/fx/qfxtransform.h11
-rw-r--r--src/declarative/fx/qfxvisualitemmodel.h4
-rw-r--r--src/declarative/fx/qfxwebview.h10
-rw-r--r--src/declarative/fx/qfxwidgetcontainer.h2
50 files changed, 790 insertions, 807 deletions
diff --git a/src/declarative/fx/qfxanchors.cpp b/src/declarative/fx/qfxanchors.cpp
index 53d0187..235511f 100644
--- a/src/declarative/fx/qfxanchors.cpp
+++ b/src/declarative/fx/qfxanchors.cpp
@@ -41,6 +41,7 @@
#include "qfxanchors_p.h"
#include "qfxitem.h"
+#include "qfxitem_p.h"
#include <QDebug>
#include <QtDeclarative/qmlinfo.h>
#include <QtDeclarative/qmlbindablevalue.h>
@@ -132,22 +133,175 @@ static qreal adjustedPosition(QFxItem *item, QFxAnchorLine::AnchorLine anchorLin
QFxAnchors::QFxAnchors(QObject *parent)
: QObject(*new QFxAnchorsPrivate(), parent)
{
-
}
-void QFxAnchors::fillChanged()
+QFxAnchors::~QFxAnchors()
{
Q_D(QFxAnchors);
- if (!d->fill)
+ d->remDepend(d->fill);
+ d->remDepend(d->centeredIn);
+ d->remDepend(d->left.item);
+ d->remDepend(d->right.item);
+ d->remDepend(d->top.item);
+ d->remDepend(d->bottom.item);
+ d->remDepend(d->vCenter.item);
+ d->remDepend(d->hCenter.item);
+}
+
+void QFxAnchorsPrivate::fillChanged()
+{
+ if (!fill || !isItemComplete())
+ return;
+
+ if (fill == item->itemParent()) { //child-parent
+ setItemPos(QPointF(leftMargin, topMargin));
+ } else if (fill->itemParent() == item->itemParent()) { //siblings
+ setItemPos(QPointF(fill->x()+leftMargin, fill->y()+topMargin));
+ }
+ setItemWidth(fill->width()-leftMargin-rightMargin);
+ setItemHeight(fill->height()-topMargin-bottomMargin);
+}
+
+void QFxAnchorsPrivate::centeredInChanged()
+{
+ if (!centeredIn || fill || !isItemComplete())
return;
- if (d->fill == d->item->itemParent()) { //child-parent
- d->item->setPos(QPointF(leftMargin(), topMargin()));
- } else if (d->fill->itemParent() == d->item->itemParent()) { //siblings
- d->item->setPos(QPointF(d->fill->x()+leftMargin(), d->fill->y()+topMargin()));
+ if (centeredIn == item->itemParent()) {
+ QPointF p((item->itemParent()->width() - item->width()) / 2.,
+ (item->itemParent()->height() - item->height()) / 2.);
+ setItemPos(p);
+
+ } else if (centeredIn->itemParent() == item->itemParent()) {
+
+ QPointF p(centeredIn->x() + (centeredIn->width() - item->width()) / 2.,
+ centeredIn->y() + (centeredIn->height() - item->height()) / 2.);
+ setItemPos(p);
+ }
+}
+
+void QFxAnchorsPrivate::clearItem(QFxItem *item)
+{
+ if (fill == item)
+ fill = 0;
+ if (centeredIn == item)
+ centeredIn = 0;
+ if (left.item == item) {
+ left.item = 0;
+ usedAnchors &= ~QFxAnchors::HasLeftAnchor;
+ }
+ if (right.item == item) {
+ right.item = 0;
+ usedAnchors &= ~QFxAnchors::HasRightAnchor;
+ }
+ if (top.item == item) {
+ top.item = 0;
+ usedAnchors &= ~QFxAnchors::HasTopAnchor;
+ }
+ if (bottom.item == item) {
+ bottom.item = 0;
+ usedAnchors &= ~QFxAnchors::HasBottomAnchor;
+ }
+ if (vCenter.item == item) {
+ vCenter.item = 0;
+ usedAnchors &= ~QFxAnchors::HasVCenterAnchor;
+ }
+ if (hCenter.item == item) {
+ hCenter.item = 0;
+ usedAnchors &= ~QFxAnchors::HasHCenterAnchor;
+ }
+}
+
+void QFxAnchorsPrivate::addDepend(QFxItem *item)
+{
+ Q_Q(QFxAnchors);
+ if (!item)
+ return;
+ QFxItemPrivate *p =
+ static_cast<QFxItemPrivate *>(QObjectPrivate::get(item));
+ p->dependantAnchors.append(q);
+}
+
+void QFxAnchorsPrivate::remDepend(QFxItem *item)
+{
+ Q_Q(QFxAnchors);
+ if (!item)
+ return;
+ QFxItemPrivate *p =
+ static_cast<QFxItemPrivate *>(QObjectPrivate::get(item));
+ p->dependantAnchors.removeAll(q);
+}
+
+bool QFxAnchorsPrivate::isItemComplete() const
+{
+ return item->isComponentComplete();
+}
+
+void QFxAnchorsPrivate::setItemHeight(qreal v)
+{
+ updatingMe = true;
+ item->setHeight(v);
+ updatingMe = false;
+}
+
+void QFxAnchorsPrivate::setItemWidth(qreal v)
+{
+ updatingMe = true;
+ item->setWidth(v);
+ updatingMe = false;
+}
+
+void QFxAnchorsPrivate::setItemX(qreal v)
+{
+ updatingMe = true;
+ item->setX(v);
+ updatingMe = false;
+}
+
+void QFxAnchorsPrivate::setItemY(qreal v)
+{
+ updatingMe = true;
+ item->setY(v);
+ updatingMe = false;
+}
+
+void QFxAnchorsPrivate::setItemPos(const QPointF &v)
+{
+ updatingMe = true;
+ item->setPos(v);
+ updatingMe = false;
+}
+
+void QFxAnchorsPrivate::updateMe()
+{
+ if (updatingMe) {
+ updatingMe = false;
+ return;
}
- d->item->setWidth(d->fill->width()-leftMargin()-rightMargin());
- d->item->setHeight(d->fill->height()-topMargin()-bottomMargin());
+
+ fillChanged();
+ centeredInChanged();
+ updateHorizontalAnchors();
+ updateVerticalAnchors();
+}
+
+void QFxAnchorsPrivate::updateOnComplete()
+{
+ fillChanged();
+ centeredInChanged();
+ updateHorizontalAnchors();
+ updateVerticalAnchors();
+}
+
+void QFxAnchorsPrivate::update(QFxItem *, const QRectF &newG, const QRectF &oldG)
+{
+ fillChanged();
+ centeredInChanged();
+
+ if (newG.x() != oldG.x() || newG.width() != oldG.width())
+ updateHorizontalAnchors();
+ if (newG.y() != oldG.y() || newG.height() != oldG.height())
+ updateVerticalAnchors();
}
/*!
@@ -166,37 +320,11 @@ QFxItem *QFxAnchors::fill() const
void QFxAnchors::setFill(QFxItem *f)
{
Q_D(QFxAnchors);
- if (d->fill) {
- QObject::disconnect(d->fill, SIGNAL(leftChanged()), this, SLOT(fillChanged()));
- QObject::disconnect(d->fill, SIGNAL(topChanged()), this, SLOT(fillChanged()));
- QObject::disconnect(d->fill, SIGNAL(widthChanged()), this, SLOT(fillChanged()));
- QObject::disconnect(d->fill, SIGNAL(heightChanged()), this, SLOT(fillChanged()));
- QObject::disconnect(this, SIGNAL(leftMarginChanged()), this, SLOT(fillChanged()));
- QObject::disconnect(this, SIGNAL(topMarginChanged()), this, SLOT(fillChanged()));
- QObject::disconnect(this, SIGNAL(rightMarginChanged()), this, SLOT(fillChanged()));
- QObject::disconnect(this, SIGNAL(bottomMarginChanged()), this, SLOT(fillChanged()));
- }
-
+ d->remDepend(d->fill);
d->fill = f;
+ d->addDepend(d->fill);
- if (d->fill) {
- if (d->fill == d->item->itemParent()) { //child-parent
- QObject::connect(d->fill, SIGNAL(widthChanged()), this, SLOT(fillChanged()));
- QObject::connect(d->fill, SIGNAL(heightChanged()), this, SLOT(fillChanged()));
- } else if (f->itemParent() == d->item->itemParent()) { //siblings
- QObject::connect(d->fill, SIGNAL(leftChanged()), this, SLOT(fillChanged()));
- QObject::connect(d->fill, SIGNAL(topChanged()), this, SLOT(fillChanged()));
- QObject::connect(d->fill, SIGNAL(widthChanged()), this, SLOT(fillChanged()));
- QObject::connect(d->fill, SIGNAL(heightChanged()), this, SLOT(fillChanged()));
- } else {
- qmlInfo(d->item) << "Can't anchor to an item that isn't a parent or sibling.";
- }
- }
- QObject::connect(this, SIGNAL(leftMarginChanged()), this, SLOT(fillChanged()));
- QObject::connect(this, SIGNAL(topMarginChanged()), this, SLOT(fillChanged()));
- QObject::connect(this, SIGNAL(rightMarginChanged()), this, SLOT(fillChanged()));
- QObject::connect(this, SIGNAL(bottomMarginChanged()), this, SLOT(fillChanged()));
- fillChanged(); //### can/should we defer until component completion?
+ d->fillChanged();
}
/*!
@@ -223,163 +351,12 @@ void QFxAnchors::setCenteredIn(QFxItem* c)
qmlInfo(d->item) << "Can't anchor to an item that isn't a parent or sibling.";
return;
}
- d->centeredIn = c;
- setHorizontalCenter(c->horizontalCenter());
- setVerticalCenter(c->verticalCenter());
-}
-
-void QFxAnchorsPrivate::connectVHelper(const QFxAnchorLine &edge)
-{
- //### should we do disconnects first? (will it be called more than once?)
- Q_Q(QFxAnchors);
- if (edge.item == item->itemParent()) { //child-parent
- switch(edge.anchorLine) {
- case QFxAnchorLine::Bottom:
- case QFxAnchorLine::VCenter:
- QObject::connect(edge.item, SIGNAL(heightChanged()), q, SLOT(updateVerticalAnchors()));
- break;
- case QFxAnchorLine::Top: //no connection needed
- default:
- break;
- }
- } else if (edge.item->itemParent() == item->itemParent()) { //siblings
- switch(edge.anchorLine) {
- case QFxAnchorLine::Top:
- QObject::connect(edge.item, SIGNAL(topChanged()), q, SLOT(updateVerticalAnchors()));
- break;
- case QFxAnchorLine::Bottom:
- QObject::connect(edge.item, SIGNAL(bottomChanged()), q, SLOT(updateVerticalAnchors()));
- break;
- case QFxAnchorLine::VCenter:
- QObject::connect(edge.item, SIGNAL(vcenterChanged()), q, SLOT(updateVerticalAnchors()));
- break;
- default:
- break;
- }
- } else {
- qmlInfo(item) << "Can't anchor to an item that isn't a parent or sibling.";
- }
-}
-
-void QFxAnchors::connectVAnchors()
-{
- Q_D(QFxAnchors);
- if (!d->checkVValid())
- return;
-
- if (d->usedAnchors & HasTopAnchor) {
- //Handle stretching connections (if we have multiple horizontal anchors)
- QFxAnchorLine *edge = 0;
- if (d->usedAnchors & HasBottomAnchor) {
- edge = &d->bottom;
- connect(this, SIGNAL(bottomMarginChanged()), this, SLOT(updateVerticalAnchors()));
- } else if (d->usedAnchors & HasVCenterAnchor) {
- edge = &d->vCenter;
- connect(this, SIGNAL(verticalCenterOffsetChanged()), this, SLOT(updateVerticalAnchors()));
- }
- if (edge) {
- //we need to stretch
- d->connectVHelper(*edge);
- }
-
- //Handle top
- d->connectVHelper(d->top);
- connect(this, SIGNAL(topMarginChanged()), this, SLOT(updateVerticalAnchors()));
- updateVerticalAnchors();
- } else if (d->usedAnchors & HasBottomAnchor) {
- //Handle stretching connections (if we have multiple horizontal anchors)
- if (d->usedAnchors & HasVCenterAnchor) {
- d->connectVHelper(d->vCenter);
- connect(this, SIGNAL(verticalCenterOffsetChanged()), this, SLOT(updateVerticalAnchors()));
- }
-
- //Handle bottom
- d->connectVHelper(d->bottom);
- connect(this, SIGNAL(bottomMarginChanged()), this, SLOT(updateVerticalAnchors()));
- updateVerticalAnchors();
- } else if (d->usedAnchors & HasVCenterAnchor) {
- //Handle vCenter
- d->connectVHelper(d->vCenter);
- connect(this, SIGNAL(verticalCenterOffsetChanged()), this, SLOT(updateVerticalAnchors()));
- updateVerticalAnchors();
- }
-}
-
-void QFxAnchorsPrivate::connectHHelper(const QFxAnchorLine &edge)
-{
- //### should we do disconnects first? (will it be called more than once?)
- Q_Q(QFxAnchors);
- if (edge.item == item->itemParent()) { //child-parent
- switch(edge.anchorLine) {
- case QFxAnchorLine::Right:
- case QFxAnchorLine::HCenter:
- QObject::connect(edge.item, SIGNAL(widthChanged()), q, SLOT(updateHorizontalAnchors()));
- break;
- case QFxAnchorLine::Left: //no connection needed
- default:
- break;
- }
- } else if (edge.item->itemParent() == item->itemParent()) { //siblings
- switch(edge.anchorLine) {
- case QFxAnchorLine::Left:
- QObject::connect(edge.item, SIGNAL(leftChanged()), q, SLOT(updateHorizontalAnchors()));
- break;
- case QFxAnchorLine::Right:
- QObject::connect(edge.item, SIGNAL(rightChanged()), q, SLOT(updateHorizontalAnchors()));
- break;
- case QFxAnchorLine::HCenter:
- QObject::connect(edge.item, SIGNAL(hcenterChanged()), q, SLOT(updateHorizontalAnchors()));
- break;
- default:
- break;
- }
- } else {
- qmlInfo(item) << "Can't anchor to an item that isn't a parent or sibling.";
- }
-}
-
-void QFxAnchors::connectHAnchors()
-{
- Q_D(QFxAnchors);
- if (!d->checkHValid())
- return;
-
- if (d->usedAnchors & HasLeftAnchor) {
- //Handle stretching connections (if we have multiple horizontal anchors)
- QFxAnchorLine *edge = 0;
- if (d->usedAnchors & HasRightAnchor) {
- edge = &d->right;
- connect(this, SIGNAL(rightMarginChanged()), this, SLOT(updateHorizontalAnchors()));
- } else if (d->usedAnchors & HasHCenterAnchor) {
- edge = &d->hCenter;
- connect(this, SIGNAL(horizontalCenterOffsetChanged()), this, SLOT(updateHorizontalAnchors()));
- }
- if (edge) {
- //we need to stretch
- d->connectHHelper(*edge);
- }
- //Handle left
- d->connectHHelper(d->left);
- connect(this, SIGNAL(leftMarginChanged()), this, SLOT(updateHorizontalAnchors()));
- updateHorizontalAnchors();
- } else if (d->usedAnchors & HasRightAnchor) {
- //Handle stretching connections (if we have multiple horizontal anchors)
- if (d->usedAnchors & HasHCenterAnchor) {
- d->connectHHelper(d->hCenter);
- connect(this, SIGNAL(horizontalCenterOffsetChanged()), this, SLOT(updateHorizontalAnchors()));
- }
+ d->remDepend(d->centeredIn);
+ d->centeredIn = c;
+ d->addDepend(d->centeredIn);
- //Handle right
- d->connectHHelper(d->right);
- connect(this, SIGNAL(rightMarginChanged()), this, SLOT(updateHorizontalAnchors()));
- updateHorizontalAnchors();
- } else if (d->usedAnchors & HasHCenterAnchor) {
- //Handle hCenter
- d->connectHHelper(d->hCenter);
- connect(this, SIGNAL(horizontalCenterOffsetChanged()), this, SLOT(updateHorizontalAnchors()));
- updateHorizontalAnchors();
- }
+ d->centeredInChanged();
}
bool QFxAnchorsPrivate::calcStretch(const QFxAnchorLine &edge1,
@@ -411,168 +388,124 @@ bool QFxAnchorsPrivate::calcStretch(const QFxAnchorLine &edge1,
return invalid;
}
-void QFxAnchors::updateVerticalAnchors()
+void QFxAnchorsPrivate::updateVerticalAnchors()
{
- Q_D(QFxAnchors);
- if (!d->updatingVerticalAnchor) {
- d->updatingVerticalAnchor = true;
- if (d->usedAnchors & HasTopAnchor) {
+ if (fill || centeredIn || !isItemComplete())
+ return;
+
+ if (!updatingVerticalAnchor) {
+ updatingVerticalAnchor = true;
+ if (usedAnchors & QFxAnchors::HasTopAnchor) {
//Handle stretching
bool invalid = true;
int height = 0;
- if (d->usedAnchors & HasBottomAnchor) {
- invalid = d->calcStretch(d->top, d->bottom, d->topMargin, -d->bottomMargin, QFxAnchorLine::Top, height);
- } else if (d->usedAnchors & HasVCenterAnchor) {
- invalid = d->calcStretch(d->top, d->vCenter, d->topMargin, d->vCenterOffset, QFxAnchorLine::Top, height);
+ if (usedAnchors & QFxAnchors::HasBottomAnchor) {
+ invalid = calcStretch(top, bottom, topMargin, -bottomMargin, QFxAnchorLine::Top, height);
+ } else if (usedAnchors & QFxAnchors::HasVCenterAnchor) {
+ invalid = calcStretch(top, vCenter, topMargin, vCenterOffset, QFxAnchorLine::Top, height);
height *= 2;
}
if (!invalid)
- d->item->setHeight(height);
+ setItemHeight(height);
//Handle top
- if (d->top.item == d->item->itemParent()) {
- d->item->setY(adjustedPosition(d->top.item, d->top.anchorLine) + d->topMargin);
- } else if (d->top.item->itemParent() == d->item->itemParent()) {
- d->item->setY(position(d->top.item, d->top.anchorLine) + d->topMargin);
+ if (top.item == item->itemParent()) {
+ setItemY(adjustedPosition(top.item, top.anchorLine) + topMargin);
+ } else if (top.item->itemParent() == item->itemParent()) {
+ setItemY(position(top.item, top.anchorLine) + topMargin);
}
- } else if (d->usedAnchors & HasBottomAnchor) {
+ } else if (usedAnchors & QFxAnchors::HasBottomAnchor) {
//Handle stretching (top + bottom case is handled above)
- if (d->usedAnchors & HasVCenterAnchor) {
+ if (usedAnchors & QFxAnchors::HasVCenterAnchor) {
int height = 0;
- bool invalid = d->calcStretch(d->vCenter, d->bottom, d->vCenterOffset, -d->bottomMargin,
+ bool invalid = calcStretch(vCenter, bottom, vCenterOffset, -bottomMargin,
QFxAnchorLine::Top, height);
if (!invalid)
- d->item->setHeight(height*2);
+ setItemHeight(height*2);
}
//Handle bottom
- if (d->bottom.item == d->item->itemParent()) {
- d->item->setY(adjustedPosition(d->bottom.item, d->bottom.anchorLine) - d->item->height() - d->bottomMargin);
- } else if (d->bottom.item->itemParent() == d->item->itemParent()) {
- d->item->setY(position(d->bottom.item, d->bottom.anchorLine) - d->item->height() - d->bottomMargin);
+ if (bottom.item == item->itemParent()) {
+ setItemY(adjustedPosition(bottom.item, bottom.anchorLine) - item->height() - bottomMargin);
+ } else if (bottom.item->itemParent() == item->itemParent()) {
+ setItemY(position(bottom.item, bottom.anchorLine) - item->height() - bottomMargin);
}
- } else if (d->usedAnchors & HasVCenterAnchor) {
+ } else if (usedAnchors & QFxAnchors::HasVCenterAnchor) {
//(stetching handled above)
//Handle vCenter
- if (d->vCenter.item == d->item->itemParent()) {
- d->item->setY(adjustedPosition(d->vCenter.item, d->vCenter.anchorLine)
- - d->item->height()/2 + d->vCenterOffset);
- } else if (d->vCenter.item->itemParent() == d->item->itemParent()) {
- d->item->setY(position(d->vCenter.item, d->vCenter.anchorLine) - d->item->height()/2 + d->vCenterOffset);
+ if (vCenter.item == item->itemParent()) {
+ setItemY(adjustedPosition(vCenter.item, vCenter.anchorLine)
+ - item->height()/2 + vCenterOffset);
+ } else if (vCenter.item->itemParent() == item->itemParent()) {
+ setItemY(position(vCenter.item, vCenter.anchorLine) - item->height()/2 + vCenterOffset);
}
}
- d->updatingVerticalAnchor = false;
+ updatingVerticalAnchor = false;
} else {
- qmlInfo(d->item) << "Anchor loop detected on vertical anchor.";
+ // ### Make this certain :)
+ qmlInfo(item) << "Possible anchor loop detected on vertical anchor.";
}
}
-void QFxAnchors::updateHorizontalAnchors()
+void QFxAnchorsPrivate::updateHorizontalAnchors()
{
- Q_D(QFxAnchors);
- if (!d->updatingHorizontalAnchor) {
- d->updatingHorizontalAnchor = true;
+ if (fill || centeredIn || !isItemComplete())
+ return;
- //alternate implementation (needs performance testing)
- /*switch(d->usedAnchors & QFxAnchors::Horizontal_Mask) {
- case 0x03: //(HasLeftAnchor | HasRightAnchor)
- {
- int width = 0;
- if (!d->calcStretch(d->left, d->right, d->leftMargin, -d->rightMargin, QFxAnchorLine::Left, width))
- d->item->setWidth(width);
- //fall though
- }
- case 0x11: //(HasLeftAnchor | HasHCenterAnchor)
- {
- if (d->usedAnchors & HasHCenterAnchor) {
- int width = 0;
- if (!d->calcStretch(d->left, d->hCenter, d->leftMargin, d->hCenterOffset, QFxAnchorLine::Left, width))
- d->item->setWidth(width*2);
- }
- //fall though
- }
- case HasLeftAnchor:
- if (d->left.item == d->item->itemParent()) {
- d->item->setX(adjustedPosition(d->left.item, d->left.anchorLine) + d->leftMargin);
- } else if (d->left.item->itemParent() == d->item->itemParent()) {
- d->item->setX(position(d->left.item, d->left.anchorLine) + d->leftMargin);
- }
- break;
- case 0x12: //(HasRightAnchor | HasHCenterAnchor)
- {
- int width = 0;
- if (!d->calcStretch(d->hCenter, d->right, d->hCenterOffset, -d->rightMargin, QFxAnchorLine::Left, width))
- d->item->setWidth(width*2);
- //fall though
- }
- case HasRightAnchor:
- if (d->right.item == d->item->itemParent()) {
- d->item->setX(adjustedPosition(d->right.item, d->right.anchorLine) - d->item->width() - d->rightMargin);
- } else if (d->right.item->itemParent() == d->item->itemParent()) {
- d->item->setX(position(d->right.item, d->right.anchorLine) - d->item->width() - d->rightMargin);
- }
- break;
- case HasHCenterAnchor:
- if (d->hCenter.item == d->item->itemParent()) {
- d->item->setX(adjustedPosition(d->hCenter.item, d->hCenter.anchorLine) - d->item->width()/2 + d->hCenterOffset);
- } else if (d->hCenter.item->itemParent() == d->item->itemParent()) {
- d->item->setX(position(d->hCenter.item, d->hCenter.anchorLine) - d->item->width()/2 + d->hCenterOffset);
- }
- break;
- default:
- break;
- }*/
+ if (!updatingHorizontalAnchor) {
+ updatingHorizontalAnchor = true;
- if (d->usedAnchors & HasLeftAnchor) {
+ if (usedAnchors & QFxAnchors::HasLeftAnchor) {
//Handle stretching
bool invalid = true;
int width = 0;
- if (d->usedAnchors & HasRightAnchor) {
- invalid = d->calcStretch(d->left, d->right, d->leftMargin, -d->rightMargin, QFxAnchorLine::Left, width);
- } else if (d->usedAnchors & HasHCenterAnchor) {
- invalid = d->calcStretch(d->left, d->hCenter, d->leftMargin, d->hCenterOffset, QFxAnchorLine::Left, width);
+ if (usedAnchors & QFxAnchors::HasRightAnchor) {
+ invalid = calcStretch(left, right, leftMargin, -rightMargin, QFxAnchorLine::Left, width);
+ } else if (usedAnchors & QFxAnchors::HasHCenterAnchor) {
+ invalid = calcStretch(left, hCenter, leftMargin, hCenterOffset, QFxAnchorLine::Left, width);
width *= 2;
}
if (!invalid)
- d->item->setWidth(width);
+ setItemWidth(width);
//Handle left
- if (d->left.item == d->item->itemParent()) {
- d->item->setX(adjustedPosition(d->left.item, d->left.anchorLine) + d->leftMargin);
- } else if (d->left.item->itemParent() == d->item->itemParent()) {
- d->item->setX(position(d->left.item, d->left.anchorLine) + d->leftMargin);
+ if (left.item == item->itemParent()) {
+ setItemX(adjustedPosition(left.item, left.anchorLine) + leftMargin);
+ } else if (left.item->itemParent() == item->itemParent()) {
+ setItemX(position(left.item, left.anchorLine) + leftMargin);
}
- } else if (d->usedAnchors & HasRightAnchor) {
+ } else if (usedAnchors & QFxAnchors::HasRightAnchor) {
//Handle stretching (left + right case is handled in updateLeftAnchor)
- if (d->usedAnchors & HasHCenterAnchor) {
+ if (usedAnchors & QFxAnchors::HasHCenterAnchor) {
int width = 0;
- bool invalid = d->calcStretch(d->hCenter, d->right, d->hCenterOffset, -d->rightMargin,
+ bool invalid = calcStretch(hCenter, right, hCenterOffset, -rightMargin,
QFxAnchorLine::Left, width);
if (!invalid)
- d->item->setWidth(width*2);
+ setItemWidth(width*2);
}
//Handle right
- if (d->right.item == d->item->itemParent()) {
- d->item->setX(adjustedPosition(d->right.item, d->right.anchorLine) - d->item->width() - d->rightMargin);
- } else if (d->right.item->itemParent() == d->item->itemParent()) {
- d->item->setX(position(d->right.item, d->right.anchorLine) - d->item->width() - d->rightMargin);
+ if (right.item == item->itemParent()) {
+ setItemX(adjustedPosition(right.item, right.anchorLine) - item->width() - rightMargin);
+ } else if (right.item->itemParent() == item->itemParent()) {
+ setItemX(position(right.item, right.anchorLine) - item->width() - rightMargin);
}
- } else if (d->usedAnchors & HasHCenterAnchor) {
+ } else if (usedAnchors & QFxAnchors::HasHCenterAnchor) {
//Handle hCenter
- if (d->hCenter.item == d->item->itemParent()) {
- d->item->setX(adjustedPosition(d->hCenter.item, d->hCenter.anchorLine) - d->item->width()/2 + d->hCenterOffset);
- } else if (d->hCenter.item->itemParent() == d->item->itemParent()) {
- d->item->setX(position(d->hCenter.item, d->hCenter.anchorLine) - d->item->width()/2 + d->hCenterOffset);
+ if (hCenter.item == item->itemParent()) {
+ setItemX(adjustedPosition(hCenter.item, hCenter.anchorLine) - item->width()/2 + hCenterOffset);
+ } else if (hCenter.item->itemParent() == item->itemParent()) {
+ setItemX(position(hCenter.item, hCenter.anchorLine) - item->width()/2 + hCenterOffset);
}
}
- d->updatingHorizontalAnchor = false;
+ updatingHorizontalAnchor = false;
} else {
- qmlInfo(d->item) << "Anchor loop detected on horizontal anchor.";
+ // ### Make this certain :)
+ qmlInfo(item) << "Possible anchor loop detected on horizontal anchor.";
}
}
@@ -588,29 +521,22 @@ void QFxAnchors::setTop(const QFxAnchorLine &edge)
if (!d->checkVAnchorValid(edge))
return;
- d->usedAnchors |= HasTopAnchor;
+ if (edge.item)
+ d->usedAnchors |= HasTopAnchor;
+ else
+ d->usedAnchors &= ~HasTopAnchor;
d->checkVValid();
+ d->remDepend(d->top.item);
d->top = edge;
+ d->addDepend(d->top.item);
+ d->updateVerticalAnchors();
}
void QFxAnchors::resetTop()
{
- Q_D(QFxAnchors);
-
- //update flags
- d->usedAnchors &= ~HasTopAnchor;
-
- //clear binding
- QmlMetaProperty prop(this, "top");
- prop.binding()->clearExpression();
-
- //disconnect signal/slot connections as needed
- disconnect(this, SIGNAL(topMarginChanged()), this, SLOT(updateVerticalAnchors()));
- disconnect(d->top.item, 0, this, 0);
-
- updateVerticalAnchors();
+ setTop(QFxAnchorLine());
}
QFxAnchorLine QFxAnchors::bottom() const
@@ -625,29 +551,22 @@ void QFxAnchors::setBottom(const QFxAnchorLine &edge)
if (!d->checkVAnchorValid(edge))
return;
- d->usedAnchors |= HasBottomAnchor;
+ if (edge.item)
+ d->usedAnchors |= HasBottomAnchor;
+ else
+ d->usedAnchors &= ~HasBottomAnchor;
d->checkVValid();
+ d->remDepend(d->bottom.item);
d->bottom = edge;
+ d->addDepend(d->bottom.item);
+ d->updateVerticalAnchors();
}
void QFxAnchors::resetBottom()
{
- Q_D(QFxAnchors);
-
- //update flags
- d->usedAnchors &= ~HasBottomAnchor;
-
- //clear binding
- QmlMetaProperty prop(this, "bottom");
- prop.binding()->clearExpression();
-
- //disconnect signal/slot connections as needed
- disconnect(this, SIGNAL(bottomMarginChanged()), this, SLOT(updateVerticalAnchors()));
- disconnect(d->bottom.item, 0, this, 0);
-
- updateVerticalAnchors();
+ setBottom(QFxAnchorLine());
}
QFxAnchorLine QFxAnchors::verticalCenter() const
@@ -662,29 +581,22 @@ void QFxAnchors::setVerticalCenter(const QFxAnchorLine &edge)
if (!d->checkVAnchorValid(edge))
return;
- d->usedAnchors |= HasVCenterAnchor;
+ if (edge.item)
+ d->usedAnchors |= HasVCenterAnchor;
+ else
+ d->usedAnchors &= ~HasVCenterAnchor;
d->checkVValid();
+ d->remDepend(d->vCenter.item);
d->vCenter = edge;
+ d->addDepend(d->vCenter.item);
+ d->updateVerticalAnchors();
}
void QFxAnchors::resetVerticalCenter()
{
- Q_D(QFxAnchors);
-
- //update flags
- d->usedAnchors &= ~HasVCenterAnchor;
-
- //clear binding
- QmlMetaProperty prop(this, "verticalCenter");
- prop.binding()->clearExpression();
-
- //disconnect signal/slot connections as needed
- disconnect(this, SIGNAL(verticalCenterOffsetChanged()), this, SLOT(updateVerticalAnchors()));
- disconnect(d->vCenter.item, 0, this, 0);
-
- updateVerticalAnchors();
+ setVerticalCenter(QFxAnchorLine());
}
QFxAnchorLine QFxAnchors::left() const
@@ -699,29 +611,22 @@ void QFxAnchors::setLeft(const QFxAnchorLine &edge)
if (!d->checkHAnchorValid(edge))
return;
- d->usedAnchors |= HasLeftAnchor;
+ if (edge.item)
+ d->usedAnchors |= HasLeftAnchor;
+ else
+ d->usedAnchors &= ~HasLeftAnchor;
d->checkHValid();
+ d->remDepend(d->left.item);
d->left = edge;
+ d->addDepend(d->left.item);
+ d->updateHorizontalAnchors();
}
void QFxAnchors::resetLeft()
{
- Q_D(QFxAnchors);
-
- //update flags
- d->usedAnchors &= ~HasLeftAnchor;
-
- //clear binding
- QmlMetaProperty prop(this, "left");
- prop.binding()->clearExpression();
-
- //disconnect signal/slot connections as needed
- disconnect(this, SIGNAL(leftMarginChanged()), this, SLOT(updateHorizontalAnchors()));
- disconnect(d->left.item, 0, this, 0);
-
- updateHorizontalAnchors();
+ setLeft(QFxAnchorLine());
}
QFxAnchorLine QFxAnchors::right() const
@@ -736,29 +641,23 @@ void QFxAnchors::setRight(const QFxAnchorLine &edge)
if (!d->checkHAnchorValid(edge))
return;
- d->usedAnchors |= HasRightAnchor;
+ if (edge.item)
+ d->usedAnchors |= HasRightAnchor;
+ else
+ d->usedAnchors &= ~HasRightAnchor;
d->checkHValid();
+ d->remDepend(d->right.item);
d->right = edge;
+ d->addDepend(d->right.item);
+
+ d->updateHorizontalAnchors();
}
void QFxAnchors::resetRight()
{
- Q_D(QFxAnchors);
-
- //update flags
- d->usedAnchors &= ~HasRightAnchor;
-
- //clear binding
- QmlMetaProperty prop(this, "right");
- prop.binding()->clearExpression();
-
- //disconnect signal/slot connections as needed
- disconnect(this, SIGNAL(rightMarginChanged()), this, SLOT(updateHorizontalAnchors()));
- disconnect(d->right.item, 0, this, 0);
-
- updateHorizontalAnchors();
+ setRight(QFxAnchorLine());
}
QFxAnchorLine QFxAnchors::horizontalCenter() const
@@ -773,29 +672,22 @@ void QFxAnchors::setHorizontalCenter(const QFxAnchorLine &edge)
if (!d->checkHAnchorValid(edge))
return;
- d->usedAnchors |= HasHCenterAnchor;
+ if (edge.item)
+ d->usedAnchors |= HasHCenterAnchor;
+ else
+ d->usedAnchors &= ~HasHCenterAnchor;
d->checkHValid();
+ d->remDepend(d->hCenter.item);
d->hCenter = edge;
+ d->addDepend(d->hCenter.item);
+ d->updateHorizontalAnchors();
}
void QFxAnchors::resetHorizontalCenter()
{
- Q_D(QFxAnchors);
-
- //update flags
- d->usedAnchors &= ~HasHCenterAnchor;
-
- //clear binding
- QmlMetaProperty prop(this, "horizontalCenter");
- prop.binding()->clearExpression();
-
- //disconnect signal/slot connections as needed
- disconnect(this, SIGNAL(horizontalCenterOffsetChanged()), this, SLOT(updateHorizontalAnchors()));
- disconnect(d->hCenter.item, 0, this, 0);
-
- updateHorizontalAnchors();
+ setHorizontalCenter(QFxAnchorLine());
}
int QFxAnchors::leftMargin() const
@@ -888,50 +780,6 @@ void QFxAnchors::setVerticalCenterOffset(int offset)
emit verticalCenterOffsetChanged();
}
-#if 0
-/*!
- \property QFxAnchors::baseline
- \brief what the baseline of the item should be anchored to (aligned with).
-
- 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.
-*/
-int QFxAnchors::baseline() const
-{
- return d->item->baseline();
-}
-
-void QFxAnchors::setBaseline(int baseline)
-{
- d->usedAnchors |= HasBaselineAnchor;
-
- if (d->usedAnchors & HasTopAnchor && d->usedAnchors & HasBottomAnchor) {
- qmlInfo(d->item) << "Can't specify top, bottom, and baseline anchors";
- return;
- }
-
- if (d->usedAnchors & HasTopAnchor) {
- int hoffset = baseline - d->item->baseline();
- d->item->setHeight(d->item->height() + hoffset);
- } else {
- if (d->usedAnchors & HasBottomAnchor) {
- int hoffset = d->item->baseline() - baseline;
- d->item->setHeight(d->item->height() + hoffset);
- }
-
- int boffset = d->item->baseline() - d->item->top();
- QFxItem *parentItem = d->item->itemParent();
- if (parentItem)
- d->item->setY(baseline - boffset - parentItem->top());
- else
- d->item->setY(baseline - boffset);
- }
-}
-#endif
-
QFxAnchors::UsedAnchors QFxAnchors::usedAnchors() const
{
Q_D(const QFxAnchors);
diff --git a/src/declarative/fx/qfxanchors.h b/src/declarative/fx/qfxanchors.h
index 5a8cc1a..9d776ab 100644
--- a/src/declarative/fx/qfxanchors.h
+++ b/src/declarative/fx/qfxanchors.h
@@ -42,9 +42,9 @@
#ifndef QFXANCHORS_H
#define QFXANCHORS_H
-#include <qfxglobal.h>
-#include <QObject>
-#include <qml.h>
+#include <QtCore/QObject>
+#include <QtDeclarative/qfxglobal.h>
+#include <QtDeclarative/qml.h>
QT_BEGIN_HEADER
@@ -80,6 +80,7 @@ public:
Q_DECLARE_METATYPE(QFxAnchorLine);
+class QFxAnchorsPrivate;
class Q_DECLARATIVE_EXPORT QFxAnchors : public QObject
{
Q_OBJECT
@@ -101,6 +102,7 @@ class Q_DECLARATIVE_EXPORT QFxAnchors : public QObject
public:
QFxAnchors(QObject *parent=0);
+ virtual ~QFxAnchors();
enum UsedAnchor {
HasLeftAnchor = 0x01,
@@ -167,9 +169,6 @@ public:
void setItem(QFxItem *item);
- void connectHAnchors();
- void connectVAnchors();
-
Q_SIGNALS:
void leftMarginChanged();
void rightMarginChanged();
@@ -178,13 +177,8 @@ Q_SIGNALS:
void verticalCenterOffsetChanged();
void horizontalCenterOffsetChanged();
-private Q_SLOTS:
- void fillChanged();
- void updateHorizontalAnchors();
- void updateVerticalAnchors();
-
private:
- //### should item be a friend? (and make some of the public methods private or protected)
+ friend class QFxItem;
Q_DISABLE_COPY(QFxAnchors)
Q_DECLARE_PRIVATE(QFxAnchors)
};
diff --git a/src/declarative/fx/qfxanchors_p.h b/src/declarative/fx/qfxanchors_p.h
index 82c2086..b90380a 100644
--- a/src/declarative/fx/qfxanchors_p.h
+++ b/src/declarative/fx/qfxanchors_p.h
@@ -63,9 +63,10 @@ class QFxAnchorsPrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QFxAnchors)
public:
QFxAnchorsPrivate()
- : item(0), usedAnchors(0), fill(0), centeredIn(0), leftMargin(0), rightMargin(0),
- topMargin(0), bottomMargin(0), vCenterOffset(0), hCenterOffset(0),
- updatingHorizontalAnchor(false), updatingVerticalAnchor(false)
+ : updatingMe(false), updatingHorizontalAnchor(false),
+ updatingVerticalAnchor(false), item(0), usedAnchors(0), fill(0),
+ centeredIn(0), leftMargin(0), rightMargin(0), topMargin(0),
+ bottomMargin(0), vCenterOffset(0), hCenterOffset(0)
{
}
@@ -73,14 +74,37 @@ public:
{
}
+ void clearItem(QFxItem *);
+
+ void addDepend(QFxItem *);
+ void remDepend(QFxItem *);
+ bool isItemComplete() const;
+
+ bool updatingMe:1;
+ bool updatingHorizontalAnchor:1;
+ bool updatingVerticalAnchor:1;
+
+ void setItemHeight(qreal);
+ void setItemWidth(qreal);
+ void setItemX(qreal);
+ void setItemY(qreal);
+ void setItemPos(const QPointF &);
+
+ void updateOnComplete();
+ void updateMe();
+ void update(QFxItem *, const QRectF &, const QRectF &);
+
bool checkHValid() const;
bool checkVValid() const;
bool checkHAnchorValid(QFxAnchorLine anchor) const;
bool checkVAnchorValid(QFxAnchorLine anchor) const;
- void connectHHelper(const QFxAnchorLine &anchorLine);
- void connectVHelper(const QFxAnchorLine &anchorLine);
bool calcStretch(const QFxAnchorLine &edge1, const QFxAnchorLine &edge2, int offset1, int offset2, QFxAnchorLine::AnchorLine line, int &stretch);
+ void updateHorizontalAnchors();
+ void updateVerticalAnchors();
+ void fillChanged();
+ void centeredInChanged();
+
QFxItem *item;
QFxAnchors::UsedAnchors usedAnchors;
@@ -101,8 +125,6 @@ public:
int vCenterOffset;
int hCenterOffset;
- bool updatingHorizontalAnchor;
- bool updatingVerticalAnchor;
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxanimatedimageitem.h b/src/declarative/fx/qfxanimatedimageitem.h
index 121fe62..a332c8b 100644
--- a/src/declarative/fx/qfxanimatedimageitem.h
+++ b/src/declarative/fx/qfxanimatedimageitem.h
@@ -42,7 +42,7 @@
#ifndef QFXANIMATEDIMAGEITEM_H
#define QFXANIMATEDIMAGEITEM_H
-#include <qfximage.h>
+#include <QtDeclarative/qfximage.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/fx/qfxblendedimage.h b/src/declarative/fx/qfxblendedimage.h
index 5cc0238..2fdf15b 100644
--- a/src/declarative/fx/qfxblendedimage.h
+++ b/src/declarative/fx/qfxblendedimage.h
@@ -42,7 +42,7 @@
#ifndef QFXBLENDEDIMAGE_H
#define QFXBLENDEDIMAGE_H
-#include <qfxitem.h>
+#include <QtDeclarative/qfxitem.h>
#if defined(QFX_RENDER_OPENGL2)
#include <gltexture.h>
#endif
@@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class QFxBlendedImage : public QFxItem
+class Q_DECLARATIVE_EXPORT QFxBlendedImage : public QFxItem
{
Q_OBJECT
diff --git a/src/declarative/fx/qfxblurfilter.h b/src/declarative/fx/qfxblurfilter.h
index 7a2b5b9..576debf 100644
--- a/src/declarative/fx/qfxblurfilter.h
+++ b/src/declarative/fx/qfxblurfilter.h
@@ -42,8 +42,8 @@
#ifndef QFXBLURFILTER_H
#define QFXBLURFILTER_H
-#include <qsimplecanvasfilter.h>
-#include <qml.h>
+#include <QtDeclarative/qsimplecanvasfilter.h>
+#include <QtDeclarative/qml.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/fx/qfxcomponentinstance.h b/src/declarative/fx/qfxcomponentinstance.h
index 64af355..9f84043 100644
--- a/src/declarative/fx/qfxcomponentinstance.h
+++ b/src/declarative/fx/qfxcomponentinstance.h
@@ -42,7 +42,7 @@
#ifndef QFXCOMPONENTINSTANCE_H
#define QFXCOMPONENTINSTANCE_H
-#include <qfxitem.h>
+#include <QtDeclarative/qfxitem.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/fx/qfxcontentwrapper.h b/src/declarative/fx/qfxcontentwrapper.h
index 5d5a7e1..0b7253e 100644
--- a/src/declarative/fx/qfxcontentwrapper.h
+++ b/src/declarative/fx/qfxcontentwrapper.h
@@ -42,7 +42,7 @@
#ifndef QFXCONTENTWRAPPER_H
#define QFXCONTENTWRAPPER_H
-#include <qfxitem.h>
+#include <QtDeclarative/qfxitem.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/fx/qfxevents_p.h b/src/declarative/fx/qfxevents_p.h
index 30717ef..bcd9f2d 100644
--- a/src/declarative/fx/qfxevents_p.h
+++ b/src/declarative/fx/qfxevents_p.h
@@ -42,8 +42,8 @@
#ifndef QFXEVENTS_P_H
#define QFXEVENTS_P_H
-#include <qfxglobal.h>
-#include <qml.h>
+#include <QtDeclarative/qfxglobal.h>
+#include <QtDeclarative/qml.h>
#include <QtCore/qobject.h>
#include <QtGui/qevent.h>
diff --git a/src/declarative/fx/qfxflickable.h b/src/declarative/fx/qfxflickable.h
index c5a0593..3857017 100644
--- a/src/declarative/fx/qfxflickable.h
+++ b/src/declarative/fx/qfxflickable.h
@@ -42,7 +42,7 @@
#ifndef QFXFLICKABLE_H
#define QFXFLICKABLE_H
-#include <qfxitem.h>
+#include <QtDeclarative/qfxitem.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/fx/qfxflipable.cpp b/src/declarative/fx/qfxflipable.cpp
index 24ae428..edcc7cb 100644
--- a/src/declarative/fx/qfxflipable.cpp
+++ b/src/declarative/fx/qfxflipable.cpp
@@ -169,7 +169,6 @@ void QFxFlipable::setBack(QFxItem *back)
children()->append(d->back);
if (Front == d->current)
d->back->setOpacity(0.);
- d->setBackTransform();
}
/*!
@@ -203,8 +202,6 @@ void QFxFlipablePrivate::_q_updateAxis()
axisRotation.axis()->setEndX(axis->endX());
axisRotation.axis()->setEndY(axis->endY());
axisRotation.axis()->setEndZ(axis->endZ());
-
- setBackTransform();
}
void QFxFlipablePrivate::setBackTransform()
@@ -273,8 +270,10 @@ void QFxFlipable::setRotation(qreal angle)
d->current = newSide;
if (d->front)
d->front->setOpacity((d->current==Front)?1.:0.);
- if (d->back)
+ if (d->back) {
+ d->setBackTransform();
d->back->setOpacity((d->current==Back)?1.:0.);
+ }
emit sideChanged();
}
}
diff --git a/src/declarative/fx/qfxflipable.h b/src/declarative/fx/qfxflipable.h
index ef1832e..62b62a5 100644
--- a/src/declarative/fx/qfxflipable.h
+++ b/src/declarative/fx/qfxflipable.h
@@ -42,12 +42,12 @@
#ifndef QFXFLIPABLE_H
#define QFXFLIPABLE_H
-#include <QObject>
-#include <QTransform>
+#include <QtCore/QObject>
+#include <QtGui/QTransform>
#if defined(QFX_RENDER_OPENGL)
#include <QtGui/qmatrix4x4.h>
#endif
-#include <qfxitem.h>
+#include <QtDeclarative/qfxitem.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/fx/qfxfocuspanel.h b/src/declarative/fx/qfxfocuspanel.h
index 38f7a15..cec12a1 100644
--- a/src/declarative/fx/qfxfocuspanel.h
+++ b/src/declarative/fx/qfxfocuspanel.h
@@ -42,7 +42,7 @@
#ifndef QFXFOCUSPANEL_H
#define QFXFOCUSPANEL_H
-#include <qfxitem.h>
+#include <QtDeclarative/qfxitem.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/fx/qfxfocusrealm.h b/src/declarative/fx/qfxfocusrealm.h
index 6c35405..fdf1525 100644
--- a/src/declarative/fx/qfxfocusrealm.h
+++ b/src/declarative/fx/qfxfocusrealm.h
@@ -42,7 +42,7 @@
#ifndef QFXFOCUSREALM_H
#define QFXFOCUSREALM_H
-#include <qfxitem.h>
+#include <QtDeclarative/qfxitem.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/fx/qfxgridview.h b/src/declarative/fx/qfxgridview.h
index 90bf1ce..99c7cff 100644
--- a/src/declarative/fx/qfxgridview.h
+++ b/src/declarative/fx/qfxgridview.h
@@ -42,7 +42,7 @@
#ifndef QFXGRIDVIEW_H
#define QFXGRIDVIEW_H
-#include <qfxflickable.h>
+#include <QtDeclarative/qfxflickable.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/fx/qfxhighlightfilter.h b/src/declarative/fx/qfxhighlightfilter.h
index 218f4e1..92a3dc7 100644
--- a/src/declarative/fx/qfxhighlightfilter.h
+++ b/src/declarative/fx/qfxhighlightfilter.h
@@ -42,8 +42,8 @@
#ifndef QFXHIGHLIGHTFILTER_H
#define QFXHIGHLIGHTFILTER_H
-#include <qsimplecanvasfilter.h>
-#include <qml.h>
+#include <QtDeclarative/qsimplecanvasfilter.h>
+#include <QtDeclarative/qml.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp
index 9d7a36a..4197a80 100644
--- a/src/declarative/fx/qfximage.cpp
+++ b/src/declarative/fx/qfximage.cpp
@@ -361,49 +361,57 @@ void QFxImage::paintContents(QPainter &p)
p.drawImage(0, 0, pix);
}
} else {
- const int sgl = d->_scaleGrid->left();
- const int sgr = d->_scaleGrid->right();
- const int sgt = d->_scaleGrid->top();
- const int sgb = d->_scaleGrid->bottom();
- const int xSide = qMin(sgl + sgr, int(width()));
- const int ySide = qMin(sgt + sgb, int(height()));
+ int sgl = d->_scaleGrid->left();
+ int sgr = d->_scaleGrid->right();
+ int sgt = d->_scaleGrid->top();
+ int sgb = d->_scaleGrid->bottom();
+
+ int w = width();
+ int h = height();
+ if (sgt + sgb > h)
+ sgt = sgb = h/2;
+ if (sgl + sgr > w)
+ sgl = sgr = w/2;
+
+ const int xSide = sgl + sgr;
+ const int ySide = sgt + sgb;
// Upper left
if (sgt && sgl)
p.drawImage(QRect(0, 0, sgl, sgt), pix, QRect(0, 0, sgl, sgt));
// Upper middle
if (pix.width() - xSide && sgt)
- p.drawImage(QRect(sgl, 0, width() - xSide, sgt), pix,
+ p.drawImage(QRect(sgl, 0, w - xSide, sgt), pix,
QRect(sgl, 0, pix.width() - xSide, sgt));
// Upper right
if (sgt && pix.width() - sgr)
- p.drawImage(QPoint(width()-sgr, 0), pix,
+ p.drawImage(QPoint(w-sgr, 0), pix,
QRect(pix.width()-sgr, 0, sgr, sgt));
// Middle left
if (sgl && pix.height() - ySide)
- p.drawImage(QRect(0, sgt, sgl, height() - ySide), pix,
+ p.drawImage(QRect(0, sgt, sgl, h - ySide), pix,
QRect(0, sgt, sgl, pix.height() - ySide));
// Middle
if (pix.width() - xSide && pix.height() - ySide)
- p.drawImage(QRect(sgl, sgt, width() - xSide, height() - ySide),
+ p.drawImage(QRect(sgl, sgt, w - xSide, h - ySide),
pix,
QRect(sgl, sgt, pix.width() - xSide, pix.height() - ySide));
// Middle right
if (sgr && pix.height() - ySide)
- p.drawImage(QRect(width()-sgr, sgt, sgr, height() - ySide), pix,
+ p.drawImage(QRect(w-sgr, sgt, sgr, h - ySide), pix,
QRect(pix.width()-sgr, sgt, sgr, pix.height() - ySide));
// Lower left
if (sgl && sgr)
- p.drawImage(QPoint(0, height() - sgb), pix,
+ p.drawImage(QPoint(0, h - sgb), pix,
QRect(0, pix.height() - sgb, sgl, sgb));
// Lower Middle
if (pix.width() - xSide && sgb)
- p.drawImage(QRect(sgl, height() - sgb, width() - xSide, sgb), pix,
+ p.drawImage(QRect(sgl, h - sgb, w - xSide, sgb), pix,
QRect(sgl, pix.height() - sgb, pix.width() - xSide, sgb));
// Lower Right
if (sgr && sgb)
- p.drawImage(QPoint(width()-sgr, height() - sgb), pix,
+ p.drawImage(QPoint(w-sgr, h - sgb), pix,
QRect(pix.width()-sgr, pix.height() - sgb, sgr, sgb));
}
diff --git a/src/declarative/fx/qfximage.h b/src/declarative/fx/qfximage.h
index dc13a97..1436551 100644
--- a/src/declarative/fx/qfximage.h
+++ b/src/declarative/fx/qfximage.h
@@ -42,7 +42,7 @@
#ifndef QFXIMAGE_H
#define QFXIMAGE_H
-#include <qfxitem.h>
+#include <QtDeclarative/qfxitem.h>
#include <QtNetwork/qnetworkreply.h>
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp
index b737615..3cbcd6a 100644
--- a/src/declarative/fx/qfxitem.cpp
+++ b/src/declarative/fx/qfxitem.cpp
@@ -52,6 +52,7 @@
#include "qmlengine.h"
#include "qmlstate.h"
#include "qlistmodelinterface.h"
+#include "qfxanchors_p.h"
#include "qfxtransform.h"
#include "qfxscalegrid.h"
@@ -434,6 +435,14 @@ void QFxItem::doUpdate()
QFxItem::~QFxItem()
{
Q_D(QFxItem);
+ for (int ii = 0; ii < d->dependantAnchors.count(); ++ii) {
+ QFxAnchors *anchor = d->dependantAnchors.at(ii);
+ anchor->d_func()->clearItem(this);
+ }
+ for (int ii = 0; ii < d->dependantAnchors.count(); ++ii) {
+ QFxAnchors *anchor = d->dependantAnchors.at(ii);
+ anchor->d_func()->updateOnComplete();
+ }
delete d->_anchorLines; d->_anchorLines = 0;
}
@@ -1062,85 +1071,30 @@ void QFxItem::geometryChanged(const QRectF &newGeometry,
const QRectF &oldGeometry)
{
Q_D(QFxItem);
- if (newGeometry.width() != oldGeometry.width()) {
- int xoffset = oldGeometry.width() - newGeometry.width();
- d->handleWidthChange(xoffset);
- }
- if (newGeometry.height() != oldGeometry.height()) {
- int yoffset = oldGeometry.height() - newGeometry.height();
- d->handleHeightChange(yoffset);
- }
+ if (d->_anchors)
+ d->_anchors->d_func()->updateMe();
- if (newGeometry.x() != oldGeometry.x()) {
- emit leftChanged();
- emit hcenterChanged();
- emit rightChanged();
+ if (newGeometry.size() != oldGeometry.size()) {
+ if (rotation() && transformOrigin() != QFxItem::TopLeft)
+ setRotation(rotation());
+ if (scale() && transformOrigin() != QFxItem::TopLeft)
+ setScale(scale());
}
- if (newGeometry.y() != oldGeometry.y()) {
+ if (newGeometry.x() != oldGeometry.x())
+ emit leftChanged();
+ if (newGeometry.width() != oldGeometry.width())
+ emit widthChanged();
+ if (newGeometry.y() != oldGeometry.y())
emit topChanged();
- emit vcenterChanged();
- emit bottomChanged();
- }
-}
-
-void QFxItemPrivate::handleWidthChange(int xoffset)
-{
- Q_Q(QFxItem);
- if (!_anchors) {
- emit q->hcenterChanged();
- emit q->rightChanged();
- } else {
- QFxAnchors::UsedAnchors used = anchors()->usedAnchors();
- if (used & QFxAnchors::HasHCenterAnchor) {
- q->setX(q->x() + xoffset/2);
- emit q->rightChanged();
- } else if ((used & QFxAnchors::HasRightAnchor) && !(used & QFxAnchors::HasLeftAnchor)) {
- q->setX(q->x() + xoffset);
- emit q->hcenterChanged();
- } else {
- emit q->hcenterChanged();
- emit q->rightChanged();
- }
- }
- if (q->rotation() && q->transformOrigin() != QFxItem::TopLeft)
- q->setRotation(q->rotation());
- if (q->scale() && q->transformOrigin() != QFxItem::TopLeft)
- q->setScale(q->scale());
- emit q->widthChanged();
-}
+ if (newGeometry.height() != oldGeometry.height())
+ emit heightChanged();
-void QFxItemPrivate::handleHeightChange(int yoffset)
-{
- Q_Q(QFxItem);
- if (!_anchors) {
- emit q->vcenterChanged();
- emit q->bottomChanged();
- emit q->baselineChanged();
- } else {
- QFxAnchors::UsedAnchors used = anchors()->usedAnchors();
- if (used & QFxAnchors::HasBaselineAnchor) {
- q->setY(q->y() + yoffset - q->baselineOffset());
- emit q->bottomChanged();
- emit q->vcenterChanged();
- } else if (used & QFxAnchors::HasVCenterAnchor) {
- q->setY(q->y() + yoffset/2);
- emit q->bottomChanged();
- } else if ((used & QFxAnchors::HasBottomAnchor) && !(used & QFxAnchors::HasTopAnchor)) {
- q->setY(q->y() + yoffset);
- emit q->vcenterChanged();
- } else {
- emit q->vcenterChanged();
- emit q->bottomChanged();
- emit q->baselineChanged();
- }
+ for(int ii = 0; ii < d->dependantAnchors.count(); ++ii) {
+ QFxAnchors *anchor = d->dependantAnchors.at(ii);
+ anchor->d_func()->update(this, newGeometry, oldGeometry);
}
- if (q->rotation() && q->transformOrigin() != QFxItem::TopLeft)
- q->setRotation(q->rotation());
- if (q->scale() && q->transformOrigin() != QFxItem::TopLeft)
- q->setScale(q->scale());
- emit q->heightChanged();
}
/*!
@@ -1483,7 +1437,6 @@ void QFxItem::setBaselineOffset(int offset)
d->_baselineOffset = offset;
emit baselineOffsetChanged();
- emit baselineChanged();
}
/*!
@@ -2075,10 +2028,8 @@ void QFxItem::componentComplete()
d->_componentComplete = true;
if (d->_stateGroup)
d->_stateGroup->componentComplete();
- if (d->_anchors) {
- d->anchors()->connectHAnchors();
- d->anchors()->connectVAnchors();
- }
+ if (d->_anchors)
+ d->anchors()->d_func()->updateOnComplete();
if (!d->_transform.isEmpty())
updateTransform();
}
diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h
index 549c9c2..d34a9fb 100644
--- a/src/declarative/fx/qfxitem.h
+++ b/src/declarative/fx/qfxitem.h
@@ -42,9 +42,9 @@
#ifndef QFXITEM_H
#define QFXITEM_H
-#include <QObject>
+#include <QtCore/QObject>
#include <QtScript/qscriptvalue.h>
-#include <QList>
+#include <QtCore/QList>
#include <QtDeclarative/qfxanchors.h>
#include <QtDeclarative/qfxglobal.h>
#include <QtDeclarative/qml.h>
@@ -213,14 +213,9 @@ public Q_SLOTS:
Q_SIGNALS:
void leftChanged();
- void rightChanged();
void widthChanged();
void heightChanged();
void topChanged();
- void bottomChanged();
- void hcenterChanged();
- void vcenterChanged();
- void baselineChanged();
void baselineOffsetChanged();
void stateChanged(const QString &);
void focusChanged();
diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h
index f2da3ba..85ce171 100644
--- a/src/declarative/fx/qfxitem_p.h
+++ b/src/declarative/fx/qfxitem_p.h
@@ -53,11 +53,11 @@
// We mean it.
//
-#include "qfxitem.h"
+#include <QtDeclarative/qfxitem.h>
#include <private/qsimplecanvasitem_p.h>
#include <private/qmlnullablevalue_p.h>
-#include <qml.h>
-#include <qmlcontext.h>
+#include <QtDeclarative/qml.h>
+#include <QtDeclarative/qmlcontext.h>
#include <QtCore/qlist.h>
QT_BEGIN_NAMESPACE
@@ -129,6 +129,7 @@ public:
}
return _anchors;
}
+ QList<QFxAnchors *> dependantAnchors;
QFxAnchors *_anchors;
QFxContents *_contents;
QFxItem *qmlItem;
@@ -171,9 +172,6 @@ public:
QmlStateGroup *states();
QmlStateGroup *_stateGroup;
-
- void handleWidthChange(int xoffset);
- void handleHeightChange(int xoffset);
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxkeyactions.h b/src/declarative/fx/qfxkeyactions.h
index 7ad323a..a5aec2e 100644
--- a/src/declarative/fx/qfxkeyactions.h
+++ b/src/declarative/fx/qfxkeyactions.h
@@ -42,10 +42,10 @@
#ifndef QFXKEYACTIONS_H
#define QFXKEYACTIONS_H
-#include <qfxglobal.h>
-#include <QObject>
-#include <qml.h>
-#include <qfxitem.h>
+#include <QtCore/QObject>
+#include <QtDeclarative/qfxglobal.h>
+#include <QtDeclarative/qml.h>
+#include <QtDeclarative/qfxitem.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/fx/qfxkeyproxy.h b/src/declarative/fx/qfxkeyproxy.h
index ae5fce4..6cf0c0d 100644
--- a/src/declarative/fx/qfxkeyproxy.h
+++ b/src/declarative/fx/qfxkeyproxy.h
@@ -42,7 +42,7 @@
#ifndef QFXKEYPROXY_H
#define QFXKEYPROXY_H
-#include <qfxitem.h>
+#include <QtDeclarative/qfxitem.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/fx/qfxlayouts.h b/src/declarative/fx/qfxlayouts.h
index acfc0c4..35e41d8 100644
--- a/src/declarative/fx/qfxlayouts.h
+++ b/src/declarative/fx/qfxlayouts.h
@@ -42,10 +42,10 @@
#ifndef QFXLAYOUTS_H
#define QFXLAYOUTS_H
-#include <qfxitem.h>
-#include <QObject>
-#include <QString>
-#include <qmlstate.h>
+#include <QtCore/QObject>
+#include <QtCore/QString>
+#include <QtDeclarative/qfxitem.h>
+#include <QtDeclarative/qmlstate.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/fx/qfxlayouts_p.h b/src/declarative/fx/qfxlayouts_p.h
index 859482f..77b0ea1 100644
--- a/src/declarative/fx/qfxlayouts_p.h
+++ b/src/declarative/fx/qfxlayouts_p.h
@@ -53,11 +53,11 @@
// We mean it.
//
-#include "qfxlayouts.h"
-#include "qfxitem_p.h"
-#include <QObject>
-#include <QString>
-#include <qmlstate.h>
+#include <private/qfxitem_p.h>
+#include <QtCore/QObject>
+#include <QtCore/QString>
+#include <QtDeclarative/qfxlayouts.h>
+#include <QtDeclarative/qmlstate.h>
QT_BEGIN_NAMESPACE
diff --git a/src/declarative/fx/qfxlistview.h b/src/declarative/fx/qfxlistview.h
index 42f7773..87a851b 100644
--- a/src/declarative/fx/qfxlistview.h
+++ b/src/declarative/fx/qfxlistview.h
@@ -42,7 +42,7 @@
#ifndef QFXLISTVIEW_H
#define QFXLISTVIEW_H
-#include <qfxflickable.h>
+#include <QtDeclarative/qfxflickable.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/fx/qfxmouseregion.h b/src/declarative/fx/qfxmouseregion.h
index 2ba4a50..1d1ec93 100644
--- a/src/declarative/fx/qfxmouseregion.h
+++ b/src/declarative/fx/qfxmouseregion.h
@@ -42,7 +42,7 @@
#ifndef QFXMOUSEREGION_H
#define QFXMOUSEREGION_H
-#include <qfxitem.h>
+#include <QtDeclarative/qfxitem.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/fx/qfxpainteditem.h b/src/declarative/fx/qfxpainteditem.h
index 015a035..6cd21e6 100644
--- a/src/declarative/fx/qfxpainteditem.h
+++ b/src/declarative/fx/qfxpainteditem.h
@@ -42,8 +42,8 @@
#ifndef QFXIMAGEITEM_H
#define QFXIMAGEITEM_H
-#include <qfxglobal.h>
-#include <qfxitem.h>
+#include <QtDeclarative/qfxglobal.h>
+#include <QtDeclarative/qfxitem.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/fx/qfxpainteditem_p.h b/src/declarative/fx/qfxpainteditem_p.h
index b0432ac..5d5da6b 100644
--- a/src/declarative/fx/qfxpainteditem_p.h
+++ b/src/declarative/fx/qfxpainteditem_p.h
@@ -53,8 +53,8 @@
// We mean it.
//
-#include "qfxitem_p.h"
-#include <qsimplecanvas.h>
+#include <private/qfxitem_p.h>
+#include <QtDeclarative/qsimplecanvas.h>
#if defined(QFX_RENDER_OPENGL)
#include "gltexture.h"
diff --git a/src/declarative/fx/qfxparticles.cpp b/src/declarative/fx/qfxparticles.cpp
index 1aaf256..67c1208 100644
--- a/src/declarative/fx/qfxparticles.cpp
+++ b/src/declarative/fx/qfxparticles.cpp
@@ -340,6 +340,32 @@ void QFxParticleMotionWander::destroy(QFxParticle &p)
}
//---------------------------------------------------------------------------
+class QFxParticlesPainter : public QFxItem
+{
+public:
+ QFxParticlesPainter(QFxParticlesPrivate *p, QFxItem* parent)
+ : QFxItem(parent), d(p)
+ {
+ setOptions(HasContents);
+ maxX = minX = maxY = minY = 0;
+ }
+
+#if defined(QFX_RENDER_QPAINTER)
+ void paintContents(QPainter &p);
+#elif defined(QFX_RENDER_OPENGL2)
+ void paintGLContents(GLPainter &);
+#endif
+
+ void updateSize();
+
+ qreal maxX;
+ qreal minX;
+ qreal maxY;
+ qreal minY;
+ QFxParticlesPrivate* d;
+};
+
+//---------------------------------------------------------------------------
class QFxParticlesPrivate : public QFxItemPrivate
{
Q_DECLARE_PUBLIC(QFxParticles)
@@ -359,7 +385,12 @@ public:
{
}
- void init() {}
+ void init()
+ {
+ Q_Q(QFxParticles);
+ paintItem = new QFxParticlesPainter(this, q);
+ }
+
void tick(int time);
void createParticle(int time);
void updateOpacity(QFxParticle &p, int age);
@@ -383,6 +414,7 @@ public:
int streamDelay;
bool emitting;
QFxParticleMotion *motion;
+ QFxParticlesPainter *paintItem;
QList<QFxParticle> particles;
QTickAnimationProxy<QFxParticlesPrivate, &QFxParticlesPrivate::tick> clock;
@@ -1040,28 +1072,76 @@ QString QFxParticles::propertyInfo() const
return d->url.toString();
}
+void QFxParticlesPainter::updateSize(){
+ setX(-500);
+ setY(-500);
+ setWidth(1000);
+ setHeight(1000);
+ return ;
+ const int parentX = parent()->x();
+ const int parentY = parent()->y();
+ //Have to use statistical approach to needed size as arbitrary particle
+ //motions make it impossible to calculate.
+ //max/min vars stored to give a never shrinking rect
+ for (int i = 0; i < d->particles.count(); ++i) {
+ const QFxParticle &particle = d->particles.at(i);
+ if(particle.x > maxX)
+ maxX = particle.x;
+ if(particle.x < minX)
+ minX = particle.x;
+ if(particle.y > maxY)
+ maxY = particle.y;
+ if(particle.y < minY)
+ minY = particle.y;
+ }
+
+ int myWidth = (int)(maxX-minX+0.5)+d->image.width();
+ int myX = (int)(minX - parentX);
+ int myHeight = (int)(maxY-minY+0.5)+d->image.height();
+ int myY = (int)(minY - parentY);
+ setWidth(myWidth);
+ setHeight(myHeight);
+ setX(myX);
+ setY(myY);
+}
+
#if defined(QFX_RENDER_QPAINTER)
void QFxParticles::paintContents(QPainter &p)
{
- Q_D(QFxParticles);
+ Q_UNUSED(p);
+ //painting is done by the ParticlesPainter, so it can have the right size
+}
+
+void QFxParticlesPainter::paintContents(QPainter &p)
+{
if (d->image.isNull())
return;
- const int myX = x();
- const int myY = y();
+ updateSize();
+ const int myX = x() + parent()->x();
+ const int myY = y() + parent()->y();
+
for (int i = 0; i < d->particles.count(); ++i) {
const QFxParticle &particle = d->particles.at(i);
p.setOpacity(particle.opacity);
- p.drawImage(particle.x-myX, particle.y-myY, d->image);
+ p.drawImage(particle.x - myX, particle.y - myY, d->image);
}
+ update();//Should I need this? (GV does)
}
#elif defined(QFX_RENDER_OPENGL2)
-void QFxParticles::paintGLContents(GLPainter &p)
+void QFxParticles::paintGLContents(GLPainter &)
{
- Q_D(QFxParticles);
+ //painting is done by the ParticlesPainter, so it can have the right size
+}
+
+void QFxParticlesPainter::paintGLContents(GLPainter &p)
+{
+
if (d->image.isNull())
return;
+ updateSize();
+
if (d->texDirty && !d->image.isNull()) {
d->tex.setImage(d->image);
d->tex.setHorizontalWrap(GLTexture::Repeat);
@@ -1075,8 +1155,8 @@ void QFxParticles::paintGLContents(GLPainter &p)
glBindTexture(GL_TEXTURE_2D, d->tex.texture());
- const int myX = (int)x();
- const int myY = (int)y();
+ const int myX = (int)(x() + parent()->x());
+ const int myY = (int)(y() + parent()->y());
float widthV = d->image.width();
float heightV = d->image.height();
for (int i = 0; i < d->particles.count(); ++i) {
diff --git a/src/declarative/fx/qfxparticles.h b/src/declarative/fx/qfxparticles.h
index 0696e60..31a00fb 100644
--- a/src/declarative/fx/qfxparticles.h
+++ b/src/declarative/fx/qfxparticles.h
@@ -42,7 +42,7 @@
#ifndef QFXPARTICLES_H
#define QFXPARTICLES_H
-#include <qfxitem.h>
+#include <QtDeclarative/qfxitem.h>
#if defined(QFX_RENDER_OPENGL)
#include "gltexture.h"
@@ -56,7 +56,7 @@ QT_MODULE(Declarative)
class QFxParticle;
class QFxParticles;
-class QFxParticleMotion : public QObject
+class Q_DECLARATIVE_EXPORT QFxParticleMotion : public QObject
{
Q_OBJECT
public:
@@ -68,7 +68,7 @@ public:
};
QML_DECLARE_TYPE(QFxParticleMotion);
-class QFxParticleMotionLinear : public QFxParticleMotion
+class Q_DECLARATIVE_EXPORT QFxParticleMotionLinear : public QFxParticleMotion
{
Q_OBJECT
public:
@@ -79,7 +79,7 @@ public:
};
QML_DECLARE_TYPE(QFxParticleMotionLinear);
-class QFxParticleMotionGravity : public QFxParticleMotion
+class Q_DECLARATIVE_EXPORT QFxParticleMotionGravity : public QFxParticleMotion
{
Q_OBJECT
@@ -108,7 +108,7 @@ private:
};
QML_DECLARE_TYPE(QFxParticleMotionGravity);
-class QFxParticleMotionWander : public QFxParticleMotion
+class Q_DECLARATIVE_EXPORT QFxParticleMotionWander : public QFxParticleMotion
{
Q_OBJECT
public:
diff --git a/src/declarative/fx/qfxpath.h b/src/declarative/fx/qfxpath.h
index c594793..10cf252 100644
--- a/src/declarative/fx/qfxpath.h
+++ b/src/declarative/fx/qfxpath.h
@@ -42,10 +42,10 @@
#ifndef QFXPATH_H
#define QFXPATH_H
-#include <QObject>
-#include <QPainterPath>
-#include <qml.h>
-#include <qfxitem.h>
+#include <QtCore/QObject>
+#include <QtGui/QPainterPath>
+#include <QtDeclarative/qml.h>
+#include <QtDeclarative/qfxitem.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/fx/qfxpathview.h b/src/declarative/fx/qfxpathview.h
index 04804b7..33db566 100644
--- a/src/declarative/fx/qfxpathview.h
+++ b/src/declarative/fx/qfxpathview.h
@@ -42,8 +42,8 @@
#ifndef QFXPATHVIEW_H
#define QFXPATHVIEW_H
-#include <qfxitem.h>
-#include <qfxpath.h>
+#include <QtDeclarative/qfxitem.h>
+#include <QtDeclarative/qfxpath.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/fx/qfxpixmap.h b/src/declarative/fx/qfxpixmap.h
index 297dba7..fd56ee4 100644
--- a/src/declarative/fx/qfxpixmap.h
+++ b/src/declarative/fx/qfxpixmap.h
@@ -42,10 +42,10 @@
#ifndef QFXPIXMAP_H
#define QFXPIXMAP_H
-#include <QString>
-#include <qsimplecanvas.h>
-#include <qfxglobal.h>
-#include <QPixmap>
+#include <QtCore/QString>
+#include <QtGui/QPixmap>
+#include <QtDeclarative/qsimplecanvas.h>
+#include <QtDeclarative/qfxglobal.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp
index dafd8a2..f1cbb58 100644
--- a/src/declarative/fx/qfxrect.cpp
+++ b/src/declarative/fx/qfxrect.cpp
@@ -52,6 +52,11 @@ QML_DEFINE_TYPE(QFxPen,Pen);
\ingroup group_utility
\brief The QFxPen class provides a pen used for drawing rect borders on a QFxView.
+ By default, the pen is invalid and nothing is drawn. You must either set a color (then the default
+ width is 0) or a width (then the default color is black).
+
+ A width of 0 is a single-pixel line on the border of the item being painted.
+
Example:
\qml
Rect { pen.width: 2; pen.color: "red" ... }
@@ -61,8 +66,9 @@ QML_DEFINE_TYPE(QFxPen,Pen);
/*! \property QFxPen::width
\brief the width of the pen.
- The default width is 1. If the width is less than 1 the pen is considered invalid
- and won't be used.
+ A width of 0 is a single-pixel line on the border of the item being painted.
+
+ If the width is less than 0 the pen is considered invalid and won't be used.
*/
/*!
@@ -86,8 +92,28 @@ QML_DEFINE_TYPE(QFxPen,Pen);
void QFxPen::setColor(const QColor &c)
{
_color = c;
- emit updated();
_valid = _color.alpha() ? true : false;
+ emit updated();
+}
+
+/*!
+ \property QFxPen::width
+ \brief the width of the pen.
+
+ \qml
+ // rect with green border using hexidecimal notation
+ Rect { pen.width: 4 }
+ \endqml
+
+ A width of 0 creates a thin line. For no line, use a negative width or a transparent color.
+
+ Odd pen widths generally lead to half-pixel painting.
+*/
+void QFxPen::setWidth(int w)
+{
+ _width = w;
+ _valid = (_width < 0) ? false : true;
+ emit updated();
}
@@ -167,6 +193,8 @@ void QFxRect::doUpdate()
Q_D(QFxRect);
d->_rectTexture.clear();
#endif
+ const int pw = d->_pen && d->_pen->isValid() ? d->_pen->width() : 0;
+ setPaintMargin((pw+1)/2);
update();
}
@@ -372,14 +400,19 @@ void QFxRect::generateRoundedRect()
{
Q_D(QFxRect);
if (d->_rectImage.isNull()) {
- d->_rectImage = QImage(d->_radius*2 + 1, d->_radius*2 + 1, QImage::Format_ARGB32_Premultiplied);
+ const int pw = d->_pen && d->_pen->isValid() ? d->_pen->width() : 0;
+ d->_rectImage = QImage(d->_radius*2 + 1 + pw*2, d->_radius*2 + 1 + pw*2, QImage::Format_ARGB32_Premultiplied);
d->_rectImage.fill(0);
QPainter p(&(d->_rectImage));
- QPen pn(QColor(pen()->color()), pen()->width());
p.setRenderHint(QPainter::Antialiasing);
- p.setPen(pn);
+ if (d->_pen && d->_pen->isValid()) {
+ QPen pn(QColor(pen()->color()), pen()->width());
+ p.setPen(pn);
+ } else {
+ p.setPen(Qt::NoPen);
+ }
p.setBrush(d->_color);
- p.drawRoundedRect(0, 0, d->_rectImage.width(), d->_rectImage.height(), d->_radius, d->_radius);
+ p.drawRoundedRect((pw+1)/2, (pw+1)/2, d->_rectImage.width()-(pw+1)/2*2, d->_rectImage.height()-(pw+1)/2*2, d->_radius, d->_radius);
}
}
@@ -387,14 +420,19 @@ void QFxRect::generateBorderedRect()
{
Q_D(QFxRect);
if (d->_rectImage.isNull()) {
- d->_rectImage = QImage(d->pen()->width()*2 + 1, d->pen()->width()*2 + 1, QImage::Format_ARGB32_Premultiplied);
+ const int pw = d->_pen && d->_pen->isValid() ? d->_pen->width() : 0;
+ d->_rectImage = QImage(d->pen()->width()*2 + 1 + pw*2, d->pen()->width()*2 + 1 + pw*2, QImage::Format_ARGB32_Premultiplied);
d->_rectImage.fill(0);
QPainter p(&(d->_rectImage));
- QPen pn(QColor(pen()->color()), pen()->width());
p.setRenderHint(QPainter::Antialiasing);
- p.setPen(pn);
+ if (d->_pen && d->_pen->isValid()) {
+ QPen pn(QColor(pen()->color()), pen()->width());
+ p.setPen(pn);
+ } else {
+ p.setPen(Qt::NoPen);
+ }
p.setBrush(d->_color);
- p.drawRect(0, 0, d->_rectImage.width(), d->_rectImage.height());
+ p.drawRect(qreal(pw+1)/2, qreal(pw+1)/2, d->_rectImage.width()-(pw+1)/2*2, d->_rectImage.height()-(pw+1)/2*2);
}
}
#elif defined(QFX_RENDER_OPENGL)
@@ -402,14 +440,19 @@ void QFxRect::generateRoundedRect()
{
Q_D(QFxRect);
if (d->_rectTexture.isNull()) {
- QImage roundRect(int(d->_radius*2 + 1), int(d->_radius*2 + 1), QImage::Format_ARGB32);
+ const int pw = d->_pen && d->_pen->isValid() ? d->_pen->width() : 0;
+ QImage roundRect(d->_radius*2 + 4 + pw*2, d->_radius*2 + 4 + pw*2, QImage::Format_ARGB32_Premultiplied);
roundRect.fill(0);
QPainter p(&roundRect);
- QPen pn(QColor(pen()->color()), pen()->width());
p.setRenderHint(QPainter::Antialiasing);
- p.setPen(pn);
+ if (d->_pen && d->_pen->isValid()) {
+ QPen pn(QColor(pen()->color()), pen()->width());
+ p.setPen(pn);
+ } else {
+ p.setPen(Qt::NoPen);
+ }
p.setBrush(d->_color);
- p.drawRoundedRect(0, 0, roundRect.width(), roundRect.height(), d->_radius, d->_radius);
+ p.drawRoundedRect((pw+1)/2, (pw+1)/2, roundRect.width()-(pw+1)/2*2, roundRect.height()-(pw+1)/2*2, d->_radius, d->_radius);
d->_rectTexture.setImage(roundRect);
}
}
@@ -418,14 +461,19 @@ void QFxRect::generateBorderedRect()
{
Q_D(QFxRect);
if (d->_rectTexture.isNull()) {
- QImage borderedRect(d->pen()->width()*2 + 1, d->pen()->width()*2 + 1, QImage::Format_ARGB32_Premultiplied);
+ const int pw = d->_pen && d->_pen->isValid() ? d->_pen->width() : 0;
+ QImage borderedRect(pw*2 + 4, pw*2 + 4, QImage::Format_ARGB32_Premultiplied);
borderedRect.fill(0);
QPainter p(&(borderedRect));
- QPen pn(QColor(pen()->color()), pen()->width());
p.setRenderHint(QPainter::Antialiasing);
- p.setPen(pn);
+ if (d->_pen && d->_pen->isValid()) {
+ QPen pn(QColor(pen()->color()), pen()->width());
+ p.setPen(pn);
+ } else {
+ p.setPen(Qt::NoPen);
+ }
p.setBrush(d->_color);
- p.drawRect(0, 0, borderedRect.width(), borderedRect.height());
+ p.drawRect(qreal(pw+1)/2, qreal(pw+1)/2, borderedRect.width()-(pw+1)/2*2, borderedRect.height()-(pw+1)/2*2);
d->_rectTexture.setImage(borderedRect);
}
}
@@ -458,9 +506,13 @@ void QFxRect::drawRect(QPainter &p)
// XXX This path is still slower than the image path
// Image path won't work for gradients though
p.save();
- QPen pn(QColor(pen()->color()), pen()->width());
p.setRenderHint(QPainter::Antialiasing);
- p.setPen(pn);
+ if (d->_pen && d->_pen->isValid()) {
+ QPen pn(QColor(pen()->color()), pen()->width());
+ p.setPen(pn);
+ } else {
+ p.setPen(Qt::NoPen);
+ }
if (d->_gradcolor.isValid()){
QLinearGradient grad(0, 0, 0, height());
grad.setColorAt(0, d->_color);
@@ -476,55 +528,72 @@ void QFxRect::drawRect(QPainter &p)
p.restore();
} else {
int offset = 0;
+ const int pw = d->_pen && d->_pen->isValid() ? (d->_pen->width()+1)/2*2 : 0;
+
if (d->_radius > 0) {
generateRoundedRect();
//### implicit conversion to int
- offset = d->_radius;
+ offset = int(d->_radius+0.5+pw);
} else {
generateBorderedRect();
- offset = d->pen()->width();
+ offset = pw;
}
//basically same code as QFxImage uses to paint sci images
- int xSide = qMin(offset * 2, int(width()));
- int ySide = qMin(offset * 2, int(height()));;
+ int w = width()+pw;
+ int h = height()+pw;
+ int xOffset = offset;
+ int xSide = xOffset * 2;
+ bool xMiddles=true;
+ if (xSide > w) {
+ xMiddles=false;
+ xOffset = w/2 + 1;
+ xSide = xOffset * 2;
+ }
+ int yOffset = offset;
+ int ySide = yOffset * 2;
+ bool yMiddles=true;
+ if (ySide > h) {
+ yMiddles = false;
+ yOffset = h/2 + 1;
+ ySide = yOffset * 2;
+ }
// Upper left
- p.drawImage(QRect(0, 0, offset, offset), d->_rectImage, QRect(0, 0, offset, offset));
+ p.drawImage(QRect(-pw/2, -pw/2, xOffset, yOffset), d->_rectImage, QRect(0, 0, xOffset, yOffset));
// Upper middle
- if (d->_rectImage.width() - xSide)
- p.drawImage(QRect(offset, 0, width() - xSide, offset), d->_rectImage,
- QRect(offset, 0, d->_rectImage.width() - xSide, offset));
+ if (xMiddles)
+ p.drawImage(QRect(xOffset-pw/2, -pw/2, width() - xSide + pw, yOffset), d->_rectImage,
+ QRect(d->_rectImage.width()/2, 0, 1, yOffset));
// Upper right
- if (d->_rectImage.width() - offset) {
- p.drawImage(QPoint(width()-offset, 0), d->_rectImage,
- QRect(d->_rectImage.width()-offset, 0, offset, offset));
- }
+ p.drawImage(QPoint(width()-xOffset+pw/2, -pw/2), d->_rectImage,
+ QRect(d->_rectImage.width()-xOffset, 0, xOffset, yOffset));
// Middle left
- if (d->_rectImage.height() - ySide)
- p.drawImage(QRect(0, offset, offset, height() - ySide), d->_rectImage,
- QRect(0, offset, offset, d->_rectImage.height() - ySide));
+ if (yMiddles)
+ p.drawImage(QRect(-pw/2, yOffset-pw/2, xOffset, height() - ySide + pw), d->_rectImage,
+ QRect(0, d->_rectImage.height()/2, xOffset, 1));
// Middle
- if (d->_rectImage.width() - xSide && d->_rectImage.height() - ySide)
- p.drawImage(QRect(offset, offset, width() - xSide, height() - ySide), d->_rectImage,
- QRect(offset, offset, d->_rectImage.width() - xSide, d->_rectImage.height() - ySide));
- // Midlle right
- if (d->_rectImage.height() - ySide)
- p.drawImage(QRect(width()-offset, offset, offset, height() - ySide), d->_rectImage,
- QRect(d->_rectImage.width()-offset, offset, offset, d->_rectImage.height() - ySide));
+ if (xMiddles && yMiddles)
+ // XXX paint errors in animation example
+ //p.fillRect(xOffset-pw/2, yOffset-pw/2, width() - xSide + pw, height() - ySide + pw, d->getColor());
+ p.drawImage(QRect(xOffset-pw/2, yOffset-pw/2, width() - xSide + pw, height() - ySide + pw), d->_rectImage,
+ QRect(d->_rectImage.width()/2, d->_rectImage.height()/2, 1, 1));
+ // Middle right
+ if (yMiddles)
+ p.drawImage(QRect(width()-xOffset+pw/2, yOffset-pw/2, xOffset, height() - ySide + pw), d->_rectImage,
+ QRect(d->_rectImage.width()-xOffset, d->_rectImage.height()/2, xOffset, 1));
// Lower left
- p.drawImage(QPoint(0, height() - offset), d->_rectImage, QRect(0, d->_rectImage.height() - offset, offset, offset));
+ p.drawImage(QPoint(-pw/2, height() - yOffset + pw/2), d->_rectImage, QRect(0, d->_rectImage.height() - yOffset, xOffset, yOffset));
// Lower Middle
- if (d->_rectImage.width() - xSide)
- p.drawImage(QRect(offset, height() - offset, width() - xSide, offset), d->_rectImage,
- QRect(offset, d->_rectImage.height() - offset, d->_rectImage.width() - xSide, offset));
+ if (xMiddles)
+ p.drawImage(QRect(xOffset-pw/2, height() - yOffset +pw/2, width() - xSide + pw, yOffset), d->_rectImage,
+ QRect(d->_rectImage.width()/2, d->_rectImage.height() - yOffset, 1, yOffset));
// Lower Right
- if (d->_rectImage.width() - offset)
- p.drawImage(QPoint(width()-offset, height() - offset), d->_rectImage,
- QRect(d->_rectImage.width()-offset, d->_rectImage.height() - offset, offset, offset));
+ p.drawImage(QPoint(width()-xOffset+pw/2, height() - yOffset+pw/2), d->_rectImage,
+ QRect(d->_rectImage.width()-xOffset, d->_rectImage.height() - yOffset, xOffset, yOffset));
}
}
#endif
@@ -586,53 +655,60 @@ void QFxRect::paintGLContents(GLPainter &p)
}
} else {
qreal offset = 0;
+ qreal pw = d->_pen && d->_pen->isValid() ? d->_pen->width() : 0.0;
+
if (d->_radius > 0) {
generateRoundedRect();
- offset = d->_radius;
+ offset = d->_radius + pw+1.5;
} else {
generateBorderedRect();
- offset = d->pen()->width();
+ offset = pw+1.5;
}
QGLShaderProgram *shader = p.useTextureShader();
- float imgWidth = d->_rectTexture.width();
- float imgHeight = d->_rectTexture.height();
- if (!imgWidth || !imgHeight)
+ float texWidth = d->_rectTexture.width();
+ float texHeight = d->_rectTexture.height();
+ if (!texWidth || !texHeight)
return;
- float widthV = width();
- float heightV = height();
+ float widthV = qreal(width())+pw/2;
+ float heightV = qreal(height())+pw/2;
- float texleft = 0;
- float texright = 1;
- float textop = 1;
- float texbottom = 0;
- float imgleft = 0;
- float imgright = widthV;
- float imgtop = 0;
- float imgbottom = heightV;
+ float xOffset = offset;
+ bool xMiddles = true;
+ if (xOffset*2 > width()+pw) {
+ xMiddles = false;
+ xOffset = (width()+pw)/2;
+ }
+ float yOffset = offset;
+ bool yMiddles = true;
+ if (yOffset*2 > height()+pw) {
+ yMiddles = false;
+ yOffset = (height()+pw)/2;
+ }
- texleft = float(offset) / imgWidth;
- imgleft = offset;
- texright = 1. - float(offset) / imgWidth;
- imgright = widthV - offset;
- textop = 1. - float(offset) / imgHeight;
- imgtop = offset;
- texbottom = float(offset) / imgHeight;
- imgbottom = heightV - offset;
+ float texleft = xOffset / texWidth;
+ float imgleft = xOffset-pw/2;
+ float texright = (texWidth-xOffset) / texWidth;
+ float imgright = widthV - xOffset;
+
+ float textop = yOffset / texHeight;
+ float imgtop = yOffset-pw/2;
+ float texbottom = (texHeight-yOffset) / texHeight;
+ float imgbottom = heightV - yOffset;
//Bug 231768: Inappropriate interpolation was occuring on 3x3 textures
if (offset==1)
texleft=texright=textop=texbottom=0.5;
- float vert1[] = { 0, 0,
- 0, imgtop,
- imgleft, 0,
+ float vert1[] = { -pw/2, -pw/2,
+ -pw/2, imgtop,
+ imgleft, -pw/2,
imgleft, imgtop,
- imgright, 0,
+ imgright, -pw/2,
imgright, imgtop,
- widthV, 0,
+ widthV, -pw/2,
widthV, imgtop };
float tex1[] = { 0, 0,
0, textop,
@@ -642,8 +718,8 @@ void QFxRect::paintGLContents(GLPainter &p)
texright, textop,
1, 0,
1, textop };
- float vert2[] = { 0, imgtop,
- 0, imgbottom,
+ float vert2[] = { -pw/2, imgtop,
+ -pw/2, imgbottom,
imgleft, imgtop,
imgleft, imgbottom,
imgright, imgtop,
@@ -658,31 +734,33 @@ void QFxRect::paintGLContents(GLPainter &p)
texright, texbottom,
1, textop,
1, texbottom };
- float vert3[] = { 0, imgbottom,
- 0, heightV,
- imgleft, imgbottom,
+ float vert3[] = { -pw/2, heightV,
+ -pw/2, imgbottom,
imgleft, heightV,
- imgright, imgbottom,
+ imgleft, imgbottom,
imgright, heightV,
- widthV, imgbottom,
- widthV, heightV };
- float tex3[] = { 0, texbottom,
- 0, 0,
+ imgright, imgbottom,
+ widthV, heightV,
+ widthV, imgbottom };
+ float tex3[] = { 0, 1,
+ 0, texbottom,
+ texleft, 1,
texleft, texbottom,
- texleft, 0,
+ texright, 1,
texright, texbottom,
- texright, 0,
- 1, texbottom,
- 1, 0 };
+ 1, 1,
+ 1, texbottom };
glBindTexture(GL_TEXTURE_2D, d->_rectTexture.texture());
shader->setAttributeArray(SingleTextureShader::Vertices, vert1, 2);
shader->setAttributeArray(SingleTextureShader::TextureCoords, tex1, 2);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 8);
- shader->setAttributeArray(SingleTextureShader::Vertices, vert2, 2);
- shader->setAttributeArray(SingleTextureShader::TextureCoords, tex2, 2);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 8);
+ if (yMiddles) {
+ shader->setAttributeArray(SingleTextureShader::Vertices, vert2, 2);
+ shader->setAttributeArray(SingleTextureShader::TextureCoords, tex2, 2);
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 8);
+ }
shader->setAttributeArray(SingleTextureShader::Vertices, vert3, 2);
shader->setAttributeArray(SingleTextureShader::TextureCoords, tex3, 2);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 8);
@@ -761,9 +839,9 @@ void QFxRect::paintGLContents(GLPainter &p)
glColor4f(1, 1, 1, p.activeOpacity);
}
- float imgWidth = d->_rectTexture.width();
- float imgHeight = d->_rectTexture.height();
- if (!imgWidth || !imgHeight)
+ float texWidth = d->_rectTexture.width();
+ float texHeight = d->_rectTexture.height();
+ if (!texWidth || !texHeight)
return;
float widthV = width();
@@ -778,13 +856,13 @@ void QFxRect::paintGLContents(GLPainter &p)
float imgtop = 0;
float imgbottom = heightV;
- texleft = float(offset) / imgWidth;
+ texleft = float(offset) / texWidth;
imgleft = offset;
- texright = 1. - float(offset) / imgWidth;
+ texright = 1. - float(offset) / texWidth;
imgright = widthV - offset;
- textop = 1. - float(offset) / imgHeight;
+ textop = 1. - float(offset) / texHeight;
imgtop = offset;
- texbottom = float(offset) / imgHeight;
+ texbottom = float(offset) / texHeight;
imgbottom = heightV - offset;
float vert1[] = { 0, 0,
diff --git a/src/declarative/fx/qfxrect.h b/src/declarative/fx/qfxrect.h
index 42e7b2f..420ec44 100644
--- a/src/declarative/fx/qfxrect.h
+++ b/src/declarative/fx/qfxrect.h
@@ -42,7 +42,7 @@
#ifndef QFXRECT_H
#define QFXRECT_H
-#include <qfxitem.h>
+#include <QtDeclarative/qfxitem.h>
QT_BEGIN_HEADER
@@ -58,11 +58,11 @@ class Q_DECLARATIVE_EXPORT QFxPen : public QObject
Q_PROPERTY(QColor color READ color WRITE setColor)
public:
QFxPen(QObject *parent=0)
- : QObject(parent), _width(1), _color("#000000"), _valid(false)
+ : QObject(parent), _width(0), _color("#000000"), _valid(false)
{}
int width() const { return _width; }
- void setWidth(int w) { _width = w; emit updated(); _valid = (_width < 1) ? false : true; }
+ void setWidth(int w);
QColor color() const { return _color; }
void setColor(const QColor &c);
diff --git a/src/declarative/fx/qfxreflectionfilter.h b/src/declarative/fx/qfxreflectionfilter.h
index b0cc7b2..383e12f 100644
--- a/src/declarative/fx/qfxreflectionfilter.h
+++ b/src/declarative/fx/qfxreflectionfilter.h
@@ -42,8 +42,8 @@
#ifndef QFXREFLECTIONFILTER_H
#define QFXREFLECTIONFILTER_H
-#include <qsimplecanvasfilter.h>
-#include <qml.h>
+#include <QtDeclarative/qsimplecanvasfilter.h>
+#include <QtDeclarative/qml.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/fx/qfxrepeater.h b/src/declarative/fx/qfxrepeater.h
index 8efd281..362242b 100644
--- a/src/declarative/fx/qfxrepeater.h
+++ b/src/declarative/fx/qfxrepeater.h
@@ -42,7 +42,7 @@
#ifndef QFXREPEATER_H
#define QFXREPEATER_H
-#include <qfxitem.h>
+#include <QtDeclarative/qfxitem.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/fx/qfxscalegrid.h b/src/declarative/fx/qfxscalegrid.h
index 9010ce7..d0f735f 100644
--- a/src/declarative/fx/qfxscalegrid.h
+++ b/src/declarative/fx/qfxscalegrid.h
@@ -42,13 +42,13 @@
#ifndef QFXSCALEGRID_H
#define QFXSCALEGRID_H
-#include <qfxglobal.h>
-#include <QImage>
-#include <QString>
-#include <QObject>
-#include <qsimplecanvas.h>
-#include <qfxpixmap.h>
-#include <qml.h>
+#include <QtCore/QString>
+#include <QtCore/QObject>
+#include <QtGui/QImage>
+#include <QtDeclarative/qfxglobal.h>
+#include <QtDeclarative/qsimplecanvas.h>
+#include <QtDeclarative/qfxpixmap.h>
+#include <QtDeclarative/qml.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/fx/qfxshadowfilter.h b/src/declarative/fx/qfxshadowfilter.h
index 9ba3b7b..fc54e01 100644
--- a/src/declarative/fx/qfxshadowfilter.h
+++ b/src/declarative/fx/qfxshadowfilter.h
@@ -42,8 +42,8 @@
#ifndef QFXSHADOWFILTER_H
#define QFXSHADOWFILTER_H
-#include <qsimplecanvasfilter.h>
-#include <qml.h>
+#include <QtDeclarative/qsimplecanvasfilter.h>
+#include <QtDeclarative/qml.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/fx/qfxtext.cpp b/src/declarative/fx/qfxtext.cpp
index a43219d..e84255d 100644
--- a/src/declarative/fx/qfxtext.cpp
+++ b/src/declarative/fx/qfxtext.cpp
@@ -458,10 +458,11 @@ void QFxTextPrivate::updateSize()
singleline = !tmp.contains(QChar::LineSeparator);
if (singleline && elideMode != Qt::ElideNone && q->widthValid())
tmp = fm.elidedText(tmp,elideMode,q->width()); // XXX still worth layout...?
- QTextLayout layout;
+ layout.clearLayout();
layout.setFont(f);
layout.setText(tmp);
size = setupTextLayout(&layout);
+ cachedLayoutSize = size;
}
if (richText) {
singleline = false; // richtext can't elide or be optimized for single-line case
@@ -608,18 +609,11 @@ QImage QFxTextPrivate::wrappedTextImage(bool drawStyle)
//do layout
Q_Q(const QFxText);
QFont f; if (_font) f = _font->font();
- QString tmp = text;
- if (singleline && elideMode != Qt::ElideNone && q->widthValid()) {
- QFontMetrics fm(f);
- tmp = fm.elidedText(tmp,elideMode,q->width()); // XXX still worth layout...?
- }
- tmp.replace(QLatin1Char('\n'), QChar::LineSeparator);
- QTextLayout textLayout(tmp, f);
- QSize size = setupTextLayout(&textLayout);
+ QSize size = cachedLayoutSize;
int x = 0;
- for (int i = 0; i < textLayout.lineCount(); ++i) {
- QTextLine line = textLayout.lineAt(i);
+ for (int i = 0; i < layout.lineCount(); ++i) {
+ QTextLine line = layout.lineAt(i);
if (hAlign == QFxText::AlignLeft) {
x = 0;
} else if (hAlign == QFxText::AlignRight) {
@@ -640,7 +634,7 @@ QImage QFxTextPrivate::wrappedTextImage(bool drawStyle)
else
p.setPen(color);
p.setFont(f);
- textLayout.draw(&p, QPointF(0, 0));
+ layout.draw(&p, QPointF(0, 0));
return img;
}
@@ -749,7 +743,16 @@ void QFxText::paintContents(QPainter &p)
break;
}
+ bool needClip = !clip() && (d->imgCache.width() > width() ||
+ d->imgCache.height() > height());
+
+ if (needClip) {
+ p.save();
+ p.setClipRect(boundingRect());
+ }
p.drawImage(x, y, d->imgCache);
+ if (needClip)
+ p.restore();
}
#elif defined(QFX_RENDER_OPENGL2)
diff --git a/src/declarative/fx/qfxtext.h b/src/declarative/fx/qfxtext.h
index 0de884b..ee9082b 100644
--- a/src/declarative/fx/qfxtext.h
+++ b/src/declarative/fx/qfxtext.h
@@ -42,8 +42,8 @@
#ifndef QFXTEXT_H
#define QFXTEXT_H
-#include <qfxitem.h>
-#include <qmlfont.h>
+#include <QtDeclarative/qfxitem.h>
+#include <QtDeclarative/qmlfont.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/fx/qfxtext_p.h b/src/declarative/fx/qfxtext_p.h
index 4296891..8bb3142 100644
--- a/src/declarative/fx/qfxtext_p.h
+++ b/src/declarative/fx/qfxtext_p.h
@@ -56,6 +56,7 @@
#include "qfxitem.h"
#include "qfxitem_p.h"
#include "qml.h"
+#include <QtGui/qtextlayout.h>
#if defined(QFX_RENDER_OPENGL)
#include "gltexture.h"
@@ -72,7 +73,9 @@ class QFxTextPrivate : public QFxItemPrivate
Q_DECLARE_PUBLIC(QFxText)
public:
QFxTextPrivate()
- : _font(0), color((QRgb)0), style(QFxText::Normal), imgDirty(true), hAlign(QFxText::AlignLeft), vAlign(QFxText::AlignTop), elideMode(Qt::ElideNone), dirty(false), wrap(false), richText(false), singleline(false), control(0), doc(0)
+ : _font(0), color((QRgb)0), style(QFxText::Normal), imgDirty(true),
+ hAlign(QFxText::AlignLeft), vAlign(QFxText::AlignTop), elideMode(Qt::ElideNone),
+ dirty(false), wrap(false), richText(false), singleline(false), control(0), doc(0)
{
}
@@ -126,6 +129,8 @@ public:
bool singleline;
QTextControl *control;
QTextDocument *doc;
+ QTextLayout layout;
+ QSize cachedLayoutSize;
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp
index 35b1173..8667c9e 100644
--- a/src/declarative/fx/qfxtextedit.cpp
+++ b/src/declarative/fx/qfxtextedit.cpp
@@ -662,7 +662,6 @@ void QFxTextEdit::keyReleaseEvent(QKeyEvent *event)
*/
void QFxTextEdit::focusChanged(bool hasFocus)
{
- Q_D(QFxTextEdit);
setCursorVisible(hasFocus);
}
@@ -675,29 +674,6 @@ void QFxTextEdit::selectAll()
d->control->selectAll();
}
-static QMouseEvent *sceneMouseEventToMouseEvent(QGraphicsSceneMouseEvent *e)
-{
- QEvent::Type t;
- switch(e->type()) {
- default:
- case QEvent::GraphicsSceneMousePress:
- t = QEvent::MouseButtonPress;
- break;
- case QEvent::GraphicsSceneMouseRelease:
- t = QEvent::MouseButtonRelease;
- break;
- case QEvent::GraphicsSceneMouseMove:
- t = QEvent::MouseMove;
- break;
- case QGraphicsSceneEvent::GraphicsSceneMouseDoubleClick:
- t = QEvent::MouseButtonDblClick;
- break;
- }
-
- QMouseEvent *me = new QMouseEvent(t, e->pos().toPoint(), e->button(), e->buttons(), 0);
- return me;
-}
-
/*!
\overload
Handles the given mouse \a event.
@@ -707,10 +683,7 @@ void QFxTextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event)
Q_D(QFxTextEdit);
if (d->focusOnPress)
setFocus(true);
- QMouseEvent *me = sceneMouseEventToMouseEvent(event);
- d->control->processEvent(me, QPointF(0, 0));
- event->setAccepted(me->isAccepted());
- delete me;
+ d->control->processEvent(event, QPointF(0, 0));
if (!event->isAccepted())
QFxPaintedItem::mousePressEvent(event);
}
@@ -722,10 +695,7 @@ Handles the given mouse \a event.
void QFxTextEdit::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QFxTextEdit);
- QMouseEvent *me = sceneMouseEventToMouseEvent(event);
- d->control->processEvent(me, QPointF(0, 0));
- event->setAccepted(me->isAccepted());
- delete me;
+ d->control->processEvent(event, QPointF(0, 0));
if (!event->isAccepted())
QFxPaintedItem::mousePressEvent(event);
}
@@ -737,10 +707,7 @@ Handles the given mouse \a event.
void QFxTextEdit::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QFxTextEdit);
- QMouseEvent *me = sceneMouseEventToMouseEvent(event);
- d->control->processEvent(me, QPointF(0, 0));
- event->setAccepted(me->isAccepted());
- delete me;
+ d->control->processEvent(event, QPointF(0, 0));
if (!event->isAccepted())
QFxPaintedItem::mousePressEvent(event);
}
diff --git a/src/declarative/fx/qfxtextedit.h b/src/declarative/fx/qfxtextedit.h
index 0aaa17b..f702101 100644
--- a/src/declarative/fx/qfxtextedit.h
+++ b/src/declarative/fx/qfxtextedit.h
@@ -42,8 +42,8 @@
#ifndef QFXTEXTEDIT_H
#define QFXTEXTEDIT_H
-#include <qfxtext.h>
-#include <qfxpainteditem.h>
+#include <QtDeclarative/qfxtext.h>
+#include <QtDeclarative/qfxpainteditem.h>
#include <QtGui/qtextdocument.h>
#include <QtGui/qtextoption.h>
diff --git a/src/declarative/fx/qfxtransform.cpp b/src/declarative/fx/qfxtransform.cpp
index 7b76367..d99af27 100644
--- a/src/declarative/fx/qfxtransform.cpp
+++ b/src/declarative/fx/qfxtransform.cpp
@@ -179,6 +179,20 @@ void QFxAxis::setEndZ(qreal z)
emit updated();
}
+/*!
+ \qmlclass Rotation
+ \brief A Rotation object provides a way to rotate an Item around a point.
+
+ The following example rotates a Rect around its interior point 25, 25:
+ \qml
+ Rect {
+ width: 100; height: 100
+ color: "blue"
+ transform: Rotation { originX: 25; originY: 25; angle: 45}
+ }
+ \endqml
+*/
+
QFxRotation::QFxRotation(QObject *parent)
: QFxTransform(parent), _originX(0), _originY(0), _angle(0), _dirty(true)
{
@@ -188,6 +202,12 @@ QFxRotation::~QFxRotation()
{
}
+/*!
+ \qmlproperty real Rotation::originX
+ \qmlproperty real Rotation::originY
+
+ The point to rotate around.
+*/
qreal QFxRotation::originX() const
{
return _originX;
@@ -210,6 +230,11 @@ void QFxRotation::setOriginY(qreal oy)
update();
}
+/*!
+ \qmlproperty real Rotation::angle
+
+ The angle, in degrees, to rotate.
+*/
qreal QFxRotation::angle() const
{
return _angle;
@@ -217,8 +242,11 @@ qreal QFxRotation::angle() const
void QFxRotation::setAngle(qreal angle)
{
+ if (_angle == angle)
+ return;
_angle = angle;
update();
+ emit angleChanged();
}
bool QFxRotation::isIdentity() const
@@ -244,7 +272,9 @@ QMatrix4x4 QFxRotation::transform() const
if (_dirty) {
_transform = QMatrix4x4();
_dirty = false;
- _transform.rotate(_angle, _originX, _originY);
+ _transform.translate(_originX, _originY);
+ _transform.rotate(_angle, 0, 0, 1);
+ _transform.translate(-_originX, -_originY);
}
return _transform;
}
diff --git a/src/declarative/fx/qfxtransform.h b/src/declarative/fx/qfxtransform.h
index a3a1a83..31374df 100644
--- a/src/declarative/fx/qfxtransform.h
+++ b/src/declarative/fx/qfxtransform.h
@@ -42,12 +42,12 @@
#ifndef QFXTRANSFORM_H
#define QFXTRANSFORM_H
-#include <QObject>
-#include <QTransform>
+#include <QtCore/QObject>
+#include <QtGui/QTransform>
#if defined(QFX_RENDER_OPENGL)
#include <QtGui/qmatrix4x4.h>
#endif
-#include <qfxitem.h>
+#include <QtDeclarative/qfxitem.h>
QT_BEGIN_HEADER
@@ -115,7 +115,7 @@ class Q_DECLARATIVE_EXPORT QFxRotation : public QFxTransform
Q_PROPERTY(qreal originX READ originX WRITE setOriginX)
Q_PROPERTY(qreal originY READ originY WRITE setOriginY)
- Q_PROPERTY(qreal angle READ angle WRITE setAngle)
+ Q_PROPERTY(qreal angle READ angle WRITE setAngle NOTIFY angleChanged())
public:
QFxRotation(QObject *parent=0);
~QFxRotation();
@@ -132,6 +132,9 @@ public:
virtual bool isIdentity() const;
virtual QSimpleCanvas::Matrix transform() const;
+Q_SIGNALS:
+ void angleChanged();
+
private Q_SLOTS:
void update();
private:
diff --git a/src/declarative/fx/qfxvisualitemmodel.h b/src/declarative/fx/qfxvisualitemmodel.h
index 7156d70..622065c 100644
--- a/src/declarative/fx/qfxvisualitemmodel.h
+++ b/src/declarative/fx/qfxvisualitemmodel.h
@@ -44,7 +44,7 @@
#include <QtCore/qobject.h>
#include <QtCore/qabstractitemmodel.h>
-#include <qml.h>
+#include <QtDeclarative/qml.h>
QT_BEGIN_HEADER
@@ -62,7 +62,7 @@ class QFxItem;
class QmlComponent;
class QmlPackage;
class QFxVisualItemModelPrivate;
-class QFxVisualItemModel : public QObject
+class Q_DECLARATIVE_EXPORT QFxVisualItemModel : public QObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QFxVisualItemModel)
diff --git a/src/declarative/fx/qfxwebview.h b/src/declarative/fx/qfxwebview.h
index afd5b0f..6a3dad5 100644
--- a/src/declarative/fx/qfxwebview.h
+++ b/src/declarative/fx/qfxwebview.h
@@ -42,12 +42,12 @@
#ifndef QFXWEBVIEW_H
#define QFXWEBVIEW_H
-#include <QAction>
-#include <QUrl>
-#include <qfxglobal.h>
-#include <qfxpainteditem.h>
+#include <QtGui/QAction>
+#include <QtCore/QUrl>
+#include <QtDeclarative/qfxglobal.h>
+#include <QtDeclarative/qfxpainteditem.h>
#include <QtNetwork/qnetworkaccessmanager.h>
-#include <QWebPage>
+#include <QtWebKit/QWebPage>
QT_BEGIN_HEADER
diff --git a/src/declarative/fx/qfxwidgetcontainer.h b/src/declarative/fx/qfxwidgetcontainer.h
index 65e4352..3b1f016 100644
--- a/src/declarative/fx/qfxwidgetcontainer.h
+++ b/src/declarative/fx/qfxwidgetcontainer.h
@@ -48,6 +48,8 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
+QT_MODULE(Declarative)
+
class QGraphicsWidget;
class Q_DECLARATIVE_EXPORT QFxWidgetContainer : public QFxItem