summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/declarative/fx/qfxpositioners.cpp317
-rw-r--r--src/declarative/fx/qfxpositioners.h18
-rw-r--r--src/declarative/fx/qfxpositioners_p.h6
3 files changed, 121 insertions, 220 deletions
diff --git a/src/declarative/fx/qfxpositioners.cpp b/src/declarative/fx/qfxpositioners.cpp
index 270524d..c1e175b 100644
--- a/src/declarative/fx/qfxpositioners.cpp
+++ b/src/declarative/fx/qfxpositioners.cpp
@@ -55,17 +55,24 @@ QT_BEGIN_NAMESPACE
/*!
\internal
\class QFxBasePositioner
- \brief The QFxBasePositioner class provides a base for QFx layouts.
+ \brief The QFxBasePositioner class provides a base for Fx Positioners.
- To create a QFx Layout, simple subclass QFxBasePositioner and implement
- doLayout(), which is automatically called when the layout might need
+ Fx positioners are fluid UI positioners, which only position items and do not
+ resize them. In fluid UIs you can bind width and height to relative
+ expressions and/or use anchors to get dynamic sizing of items.
+
+ To create an Fx positioner, simply subclass QFxBasePositioner and implement
+ doPositioning(), which is automatically called when the positioner might need
updating.
- It is strongly recommended that in your implementation of doLayout()
+ It is strongly recommended that in your implementation of doPositioning()
that you use the move, remove and add transitions when those conditions
- arise.
+ arise (if a transition is set). Use them through the functions applyAdd,
+ applyMove and applyRemove.
- \ingroup group_layouts
+ TODO: Update every other doc comment in this file.
+
+ \ingroup group_positioners
*/
QFxBasePositioner::QFxBasePositioner(AutoUpdateType at, QFxItem *parent)
: QFxItem(*(new QFxBasePositionerPrivate), parent)
@@ -99,37 +106,16 @@ void QFxBasePositioner::setSpacing(int s)
if (s==d->_spacing)
return;
d->_spacing = s;
- preLayout();
-}
-
-/*!
- \property QFxBasePositioner::margin
- \brief the size of the margin around all items (in px)
-
-*/
-int QFxBasePositioner::margin() const
-{
- Q_D(const QFxBasePositioner);
- return d->_margin;
-}
-
-void QFxBasePositioner::setMargin(int s)
-{
- Q_D(QFxBasePositioner);
- if (s==d->_margin)
- return;
- d->_margin = s;
- preLayout();
+ prePositioning();
}
-
/*!
\property QFxBasePositioner::move
\brief the transition when moving an item.
\qml
-BaseLayout {
- id: layout
+Basepositioner {
+ id: positioner
y: 0
move: Transition {
NumberAnimation {
@@ -157,12 +143,12 @@ void QFxBasePositioner::setMove(QmlTransition *mt)
\brief the transition when adding an item.
\qml
-BaseLayout {
- id: layout
+Basepositioner {
+ id: positioner
y: 0
add: Transition {
NumberAnimation {
- target: layout.item
+ target: positioner.item
properties: "opacity"
from: 0
to: 1
@@ -192,12 +178,12 @@ void QFxBasePositioner::setAdd(QmlTransition *add)
Note that the item may be 'removed' because its opacity is zero. This can make certain
transitions difficult to see.
\qml
-BaseLayout {
- id: layout
+Basepositioner {
+ id: positioner
y: 0
remove: Transition {
NumberAnimation {
- target: layout.item
+ target: positioner.item
properties: "opacity"
from: 1
to: 0
@@ -219,38 +205,13 @@ void QFxBasePositioner::setRemove(QmlTransition *remove)
d->removeTransition = remove;
}
-/*!
- \property QFxBasePositioner::item
-
- The item that is currently being laid out. Used to target transitions that apply
- only to the item being laid out, such as in the add transition.
-*/
-
-QFxItem *QFxBasePositioner::layoutItem() const
-{
- Q_D(const QFxBasePositioner);
- return d->_layoutItem;
-}
-
-/*!
- \internal
-*/
-void QFxBasePositioner::setLayoutItem(QFxItem *li)
-{
- Q_D(QFxBasePositioner);
- if (li == d->_layoutItem)
- return;
- d->_layoutItem = li;
- emit layoutItemChanged();
-}
-
void QFxBasePositioner::componentComplete()
{
QFxItem::componentComplete();
#ifdef Q_ENABLE_PERFORMANCE_LOG
- QFxPerfTimer<QFxPerf::BaseLayoutComponentComplete> cc;
+ QFxPerfTimer<QFxPerf::BasepositionerComponentComplete> cc;
#endif
- preLayout();
+ prePositioning();
}
QVariant QFxBasePositioner::itemChange(GraphicsItemChange change,
@@ -258,7 +219,7 @@ QVariant QFxBasePositioner::itemChange(GraphicsItemChange change,
{
if (change == ItemChildAddedChange ||
change == ItemChildRemovedChange) {
- preLayout();
+ prePositioning();
}
return QFxItem::itemChange(change, value);
@@ -278,7 +239,7 @@ bool QFxBasePositioner::event(QEvent *e)
}
/*!
- Items that have just been added to the layout. This includes invisible items
+ Items that have just been added to the positioner. This includes invisible items
that have turned visible.
*/
QSet<QFxItem *>* QFxBasePositioner::newItems()
@@ -288,7 +249,7 @@ QSet<QFxItem *>* QFxBasePositioner::newItems()
}
/*!
- Items that are visible in the layout, not including ones that have just been added.
+ Items that are visible in the positioner, not including ones that have just been added.
*/
QSet<QFxItem *>* QFxBasePositioner::items()
{
@@ -297,7 +258,7 @@ QSet<QFxItem *>* QFxBasePositioner::items()
}
/*!
- Items that have just left the layout. This includes visible items
+ Items that have just left the positioner. This includes visible items
that have turned invisible.
*/
QSet<QFxItem *>* QFxBasePositioner::leavingItems()
@@ -306,7 +267,7 @@ QSet<QFxItem *>* QFxBasePositioner::leavingItems()
return &d->_leavingItems;
}
-void QFxBasePositioner::preLayout()
+void QFxBasePositioner::prePositioning()
{
Q_D(QFxBasePositioner);
if (!isComponentComplete() || d->_movingItem)
@@ -324,13 +285,13 @@ void QFxBasePositioner::preLayout()
continue;
if (!d->_items.contains(child)){
QObject::connect(child, SIGNAL(visibleChanged()),
- this, SLOT(preLayout()));
+ this, SLOT(prePositioning()));
QObject::connect(child, SIGNAL(opacityChanged()),
- this, SLOT(preLayout()));
+ this, SLOT(prePositioning()));
QObject::connect(child, SIGNAL(heightChanged()),
- this, SLOT(preLayout()));
+ this, SLOT(prePositioning()));
QObject::connect(child, SIGNAL(widthChanged()),
- this, SLOT(preLayout()));
+ this, SLOT(prePositioning()));
d->_items += child;
}
if (child->opacity() == 0.0){
@@ -348,59 +309,18 @@ void QFxBasePositioner::preLayout()
if (!allItems.contains(child)){
if (!deletedItems.contains(child)) {
QObject::disconnect(child, SIGNAL(opacityChanged()),
- this, SLOT(preLayout()));
+ this, SLOT(prePositioning()));
QObject::disconnect(child, SIGNAL(heightChanged()),
- this, SLOT(preLayout()));
+ this, SLOT(prePositioning()));
QObject::disconnect(child, SIGNAL(widthChanged()),
- this, SLOT(preLayout()));
+ this, SLOT(prePositioning()));
}
d->_items -= child;
}
}
d->_animated.clear();
- doLayout();
- //Set the layout's size to be the rect containing all children
- //d->aut determines whether a dimension is sum or max
- //Also sets the margin
- qreal width=0;
- qreal height=0;
- qreal maxWidth=0;
- qreal maxHeight=0;
- foreach(QFxItem *item, d->_items){
- if (item->opacity() != 0.0){
- if (!d->_animated.contains(item)){
- setMovingItem(item);
- QPointF p(item->x(), item->y());
- if(d->aut & Horizontal)
- p.setX(p.x() + d->_margin);
- if(d->aut & Vertical)
- p.setY(p.y() + d->_margin);
- item->setPos(p);
- setMovingItem(0);
- }
- maxWidth = qMax(maxWidth, item->width());
- maxHeight = qMax(maxHeight, item->height());
- width = qMax(width, item->x() + item->width());
- height = qMax(height, item->y() + item->height());
- }
- }
- width += d->_margin;
- height+= d->_margin;
-
- if(d->aut & Both){
- setImplicitHeight(int(height));
- setImplicitWidth(int(width));
- }else if (d->aut & Horizontal){
- setImplicitWidth(int(width));
- setImplicitHeight(int(maxHeight));
- } else if (d->aut & Vertical){
- setImplicitHeight(int(height));
- setImplicitWidth(int(maxWidth));
- }else{
- setImplicitHeight(int(maxHeight));
- setImplicitWidth(int(maxWidth));
- }
- setLayoutItem(0);
+ doPositioning();
+ finishApplyTransitions();
}
void QFxBasePositioner::applyTransition(const QList<QPair<QString, QVariant> >& changes, QFxItem* target, QmlStateOperation::ActionList &actions)
@@ -408,17 +328,10 @@ void QFxBasePositioner::applyTransition(const QList<QPair<QString, QVariant> >&
Q_D(QFxBasePositioner);
if (!target)
return;
- setLayoutItem(target);
for (int ii=0; ii<changes.size(); ++ii){
QVariant val = changes[ii].second;
- if (d->_margin &&
- (changes[ii].first == QLatin1String("x") ||
- changes[ii].first == QLatin1String("y"))) {
- val = QVariant(val.toInt() + d->_margin);
- }
-
actions << Action(target, changes[ii].first, val);
}
@@ -429,6 +342,9 @@ void QFxBasePositioner::applyTransition(const QList<QPair<QString, QVariant> >&
void QFxBasePositioner::finishApplyTransitions()
{
Q_D(QFxBasePositioner);
+ // Note that if a transition is not set the transition manager will
+ // apply the changes directly, in the case someone uses applyAdd/Move/Remove
+ // without testing add()/move()/remove().
d->addTransitionManager.transition(d->addActions, d->addTransition);
d->moveTransitionManager.transition(d->moveActions, d->moveTransition);
d->removeTransitionManager.transition(d->removeActions, d->removeTransition);
@@ -443,7 +359,7 @@ void QFxBasePositioner::setMovingItem(QFxItem *i)
}
/*!
- Applies the layout's add transition to the \a target item.\a changes is a list of property,value
+ Applies the positioner's add transition to the \a target item.\a changes is a list of property,value
pairs which will be changed on the target using the add transition.
*/
void QFxBasePositioner::applyAdd(const QList<QPair<QString, QVariant> >& changes, QFxItem* target)
@@ -453,7 +369,7 @@ void QFxBasePositioner::applyAdd(const QList<QPair<QString, QVariant> >& changes
}
/*!
- Applies the layout's move transition to the \a target.\a changes is a list of property,value pairs
+ Applies the positioner's move transition to the \a target.\a changes is a list of property,value pairs
which will be changed on the target using the move transition.
*/
void QFxBasePositioner::applyMove(const QList<QPair<QString, QVariant> >& changes, QFxItem* target)
@@ -463,7 +379,7 @@ void QFxBasePositioner::applyMove(const QList<QPair<QString, QVariant> >& change
}
/*!
- Applies the layout's remove transition to the \a target item.\a changes is a list of
+ Applies the positioner's remove transition to the \a target item.\a changes is a list of
property,value pairs which will be changed on the target using the remove transition.
*/
void QFxBasePositioner::applyRemove(const QList<QPair<QString, QVariant> >& changes, QFxItem* target)
@@ -475,16 +391,16 @@ void QFxBasePositioner::applyRemove(const QList<QPair<QString, QVariant> >& chan
QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,VerticalPositioner,QFxVerticalPositioner)
/*!
\qmlclass VerticalPositioner
- \brief The VerticalPositioner item arranges its children in a vertical layout.
+ \brief The VerticalPositioner item arranges its children in a vertical positioner.
\inherits Item
The VerticalPositioner item arranges its child items so that they are vertically
- aligned and not overlapping. Spacing between items can be added, as can a margin around all the items.
+ aligned and not overlapping. Spacing between items can be added.
The below example lays out differently shaped rectangles using a VerticalPositioner.
\table
\row
- \o \image verticalLayout_example.png
+ \o \image verticalpositioner_example.png
\o
\qml
VerticalPositioner {
@@ -497,13 +413,13 @@ VerticalPositioner {
\endtable
VerticalPositioner also provides for transitions to be set when items are added, moved,
- or removed in the layout. Adding and removing apply both to items which are deleted
- or have their position in the document changed so as to no longer be children of the layout,
+ or removed in the positioner. Adding and removing apply both to items which are deleted
+ or have their position in the document changed so as to no longer be children of the positioner,
as well as to items which have their opacity set to or from zero so as to appear or disappear.
\table
\row
- \o \image verticalLayout_transition.gif
+ \o \image verticalpositioner_transition.gif
\o
\qml
VerticalPositioner {
@@ -520,22 +436,22 @@ VerticalPositioner {
*/
/*!
\qmlproperty Transition VerticalPositioner::remove
- This property holds the transition to apply when removing an item from the layout.
+ This property holds the transition to apply when removing an item from the positioner.
- Removed can mean that either the object has been deleted or reparented, and thus is now longer a child of the layout, or that the object has had its opacity set to zero, and thus is no longer visible.
+ Removed can mean that either the object has been deleted or reparented, and thus is now longer a child of the positioner, or that the object has had its opacity set to zero, and thus is no longer visible.
Note that if the item counts as removed because its opacity is zero it will not be visible during the transition unless you set the opacity in the transition, like in the below example.
\table
\row
- \o \image layout-remove.gif
+ \o \image positioner-remove.gif
\o
\qml
VerticalPositioner {
- id: layout
+ id: positioner
remove: Transition {
NumberAnimation {
- target: layout.item
+ target: positioner.item
properties: "opacity"
from: 1
to: 0
@@ -549,20 +465,20 @@ VerticalPositioner {
*/
/*!
\qmlproperty Transition VerticalPositioner::add
- This property holds the transition to be applied when adding an item to the layout.
+ This property holds the transition to be applied when adding an item to the positioner.
- Added can mean that either the object has been created or reparented, and thus is now a child or the layout, or that the object has had its opacity increased from zero, and thus is now visible.
+ Added can mean that either the object has been created or reparented, and thus is now a child or the positioner, or that the object has had its opacity increased from zero, and thus is now visible.
\table
\row
- \o \image layout-add.gif
+ \o \image positioner-add.gif
\o
\qml
VerticalPositioner {
- id: layout
+ id: positioner
add: Transition {
NumberAnimation {
- target: layout.item
+ target: positioner.item
properties: "opacity"
from: 0
to: 1
@@ -576,17 +492,17 @@ VerticalPositioner {
*/
/*!
\qmlproperty Transition VerticalPositioner::move
- This property holds the transition to apply when moving an item within the layout.
+ This property holds the transition to apply when moving an item within the positioner.
- This can happen when other items are added or removed from the layout, or when items resize themselves.
+ This can happen when other items are added or removed from the positioner, or when items resize themselves.
\table
\row
- \o \image layout-move.gif
+ \o \image positioner-move.gif
\o
\qml
VerticalPositioner {
- id: layout
+ id: positioner
move: Transition {
NumberAnimation {
properties: "y"
@@ -609,16 +525,16 @@ VerticalPositioner {
\qmlproperty int VerticalPositioner::margin
spacing and margin allow you to control the empty space surrounding
- items in layouts.
+ items in positioners.
spacing is the amount in pixels left empty between each adjacent
item. margin is the amount in pixels which will be left empty
- around the inside edge of the layout. Both default to 0.
+ around the inside edge of the positioner. Both default to 0.
The below example places a GridPositioner containing a red, a blue and a
- green rectangle on a gray background. The area the grid layout
- occupies is colored white. The top layout has a spacing of 2 and a
- margin of 5, the bottom layout has the defaults of no margin or
+ green rectangle on a gray background. The area the grid positioner
+ occupies is colored white. The top positioner has a spacing of 2 and a
+ margin of 5, the bottom positioner has the defaults of no margin or
spacing.
\image spacing_a.png
@@ -629,14 +545,14 @@ VerticalPositioner {
\internal
\class QFxVerticalPositioner
\brief The QFxVerticalPositioner class lines up items vertically.
- \ingroup group_layouts
+ \ingroup group_positioners
*/
QFxVerticalPositioner::QFxVerticalPositioner(QFxItem *parent)
: QFxBasePositioner(Vertical, parent)
{
}
-void QFxVerticalPositioner::doLayout()
+void QFxVerticalPositioner::doPositioning()
{
int voffset = 0;
@@ -670,18 +586,15 @@ void QFxVerticalPositioner::doLayout()
voffset += child->height();
voffset += spacing();
}
- finishApplyTransitions();
- setMovingItem(this);
- setMovingItem(0);
}
QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,HorizontalPositioner,QFxHorizontalPositioner)
/*!
\qmlclass HorizontalPositioner
- \brief The HorizontalPositioner item arranges its children in a horizontal layout.
+ \brief The HorizontalPositioner item arranges its children in a horizontal positioner.
\inherits Item
- The HorizontalPositioner item arranges its child items so that they are horizontally aligned and not overlapping. Spacing can be added between the items, and a margin around all items can also be added. It also provides for transitions to be set when items are added, moved, or removed in the layout. Adding and removing apply both to items which are deleted or have their position in the document changed so as to no longer be children of the layout, as well as to items which have their opacity set to or from zero so as to appear or disappear.
+ The HorizontalPositioner item arranges its child items so that they are horizontally aligned and not overlapping. Spacing can be added between the items, and a margin around all items can also be added. It also provides for transitions to be set when items are added, moved, or removed in the positioner. Adding and removing apply both to items which are deleted or have their position in the document changed so as to no longer be children of the positioner, as well as to items which have their opacity set to or from zero so as to appear or disappear.
The below example lays out differently shaped rectangles using a HorizontalPositioner.
\qml
@@ -692,23 +605,23 @@ HorizontalPositioner {
Rect { color: "blue"; width: 50; height: 20 }
}
\endqml
- \image horizontalLayout_example.png
+ \image horizontalpositioner_example.png
*/
/*!
\qmlproperty Transition HorizontalPositioner::remove
- This property holds the transition to apply when removing an item from the layout.
+ This property holds the transition to apply when removing an item from the positioner.
- Removed can mean that either the object has been deleted or reparented, and thus is now longer a child of the layout, or that the object has had its opacity set to zero, and thus is no longer visible.
+ Removed can mean that either the object has been deleted or reparented, and thus is now longer a child of the positioner, or that the object has had its opacity set to zero, and thus is no longer visible.
Note that if the item counts as removed because its opacity is zero it will not be visible during the transition unless you set the opacity in the transition, like in the below example.
\qml
HorizontalPositioner {
- id: layout
+ id: positioner
remove: Transition {
NumberAnimation {
- target: layout.item
+ target: positioner.item
properties: "opacity"
from: 1
to: 0
@@ -721,16 +634,16 @@ HorizontalPositioner {
*/
/*!
\qmlproperty Transition HorizontalPositioner::add
- This property holds the transition to apply when adding an item to the layout.
+ This property holds the transition to apply when adding an item to the positioner.
- Added can mean that either the object has been created or reparented, and thus is now a child or the layout, or that the object has had its opacity increased from zero, and thus is now visible.
+ Added can mean that either the object has been created or reparented, and thus is now a child or the positioner, or that the object has had its opacity increased from zero, and thus is now visible.
\qml
HorizontalPositioner {
- id: layout
+ id: positioner
add: Transition {
NumberAnimation {
- target: layout.item
+ target: positioner.item
properties: "opacity"
from: 0
to: 1
@@ -743,13 +656,13 @@ HorizontalPositioner {
*/
/*!
\qmlproperty Transition HorizontalPositioner::move
- This property holds the transition to apply when moving an item within the layout.
+ This property holds the transition to apply when moving an item within the positioner.
- This can happen when other items are added or removed from the layout, or when items resize themselves.
+ This can happen when other items are added or removed from the positioner, or when items resize themselves.
\qml
HorizontalPositioner {
- id: layout
+ id: positioner
move: Transition {
NumberAnimation {
properties: "x"
@@ -775,19 +688,19 @@ HorizontalPositioner {
/*!
\qmlproperty int HorizontalPositioner::margin
- The margin size, in pixels, which will be left empty around the inside edge of the layout.
+ The margin size, in pixels, which will be left empty around the inside edge of the positioner.
*/
/*!
\qmlproperty int HorizontalPositioner::spacing
\qmlproperty int HorizontalPositioner::margin
- spacing and margin allow you to control the empty space surrounding items in layouts.
+ spacing and margin allow you to control the empty space surrounding items in positioners.
spacing is the amount in pixels left empty between each adjacent item.
- margin is the amount in pixels which will be left empty around the inside edge of the layout.
+ margin is the amount in pixels which will be left empty around the inside edge of the positioner.
Both default to 0.
- The below example places a GridPositioner containing a red, a blue and a green rectangle on a gray background. The area the grid layout occupies is colored white. The top layout has a spacing of 2 and a margin of 5, the bottom layout has the defaults of no margin or spacing.
+ The below example places a GridPositioner containing a red, a blue and a green rectangle on a gray background. The area the grid positioner occupies is colored white. The top positioner has a spacing of 2 and a margin of 5, the bottom positioner has the defaults of no margin or spacing.
\image spacing_a.png
\image spacing_b.png
@@ -797,14 +710,14 @@ HorizontalPositioner {
\internal
\class QFxHorizontalPositioner
\brief The QFxHorizontalPositioner class lines up items horizontally.
- \ingroup group_layouts
+ \ingroup group_positioners
*/
QFxHorizontalPositioner::QFxHorizontalPositioner(QFxItem *parent)
: QFxBasePositioner(Horizontal, parent)
{
}
-void QFxHorizontalPositioner::doLayout()
+void QFxHorizontalPositioner::doPositioning()
{
int hoffset = 0;
@@ -837,30 +750,29 @@ void QFxHorizontalPositioner::doLayout()
hoffset += child->width();
hoffset += spacing();
}
- finishApplyTransitions();
}
QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,GridPositioner,QFxGridPositioner)
/*!
\qmlclass GridPositioner QFxGridPositioner
- \brief The GridPositioner item arranges its children in a grid layout.
+ \brief The GridPositioner item arranges its children in a grid positioner.
\inherits Item
The GridPositioner item arranges its child items so that they are
aligned in a grid and are not overlapping. Spacing can be added
between the items, and a margin around all the items can also be
defined. It also provides for transitions to be set when items are
- added, moved, or removed in the layout. Adding and removing apply
+ added, moved, or removed in the positioner. Adding and removing apply
both to items which are deleted or have their position in the
- document changed so as to no longer be children of the layout, as
+ document changed so as to no longer be children of the positioner, as
well as to items which have their opacity set to or from zero so
as to appear or disappear.
The GridPositioner defaults to using four columns, and as many rows as
are necessary to fit all the child items. The number of rows
and/or the number of columns can be constrained by setting the rows
- or columns properties. The grid layout calculates a grid with
+ or columns properties. The grid positioner calculates a grid with
rectangular cells of sufficient size to hold all items, and then
places the items in the cells, going across then down, and
positioning each item at the (0,0) corner of the cell. The below
@@ -868,7 +780,7 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,GridPositioner,QFxGridPositioner
\table
\row
- \o \image gridLayout_example.png
+ \o \image gridlayout_example.png
\o
\qml
GridPositioner {
@@ -885,10 +797,10 @@ GridPositioner {
*/
/*!
\qmlproperty Transition GridPositioner::remove
- This property holds the transition to apply when removing an item from the layout.
+ This property holds the transition to apply when removing an item from the positioner.
Removed can mean that either the object has been deleted or
- reparented, and thus is now longer a child of the layout, or that
+ reparented, and thus is now longer a child of the positioner, or that
the object has had its opacity set to zero, and thus is no longer
visible.
@@ -898,10 +810,10 @@ GridPositioner {
\qml
GridPositioner {
- id: layout
+ id: positioner
remove: Transition {
NumberAnimation {
- target: layout.item
+ target: positioner.item
properties: "opacity"
from: 1
to: 0
@@ -914,19 +826,19 @@ GridPositioner {
*/
/*!
\qmlproperty Transition GridPositioner::add
- This property holds the transition to apply when adding an item to the layout.
+ This property holds the transition to apply when adding an item to the positioner.
Added can mean that either the object has been created or
- reparented, and thus is now a child or the layout, or that the
+ reparented, and thus is now a child or the positioner, or that the
object has had its opacity increased from zero, and thus is now
visible.
\qml
GridPositioner {
- id: layout
+ id: positioner
add: Transition {
NumberAnimation {
- target: layout.item
+ target: positioner.item
properties: "opacity"
from: 0
to: 1
@@ -939,14 +851,14 @@ GridPositioner {
*/
/*!
\qmlproperty Transition GridPositioner::move
- This property holds the transition to apply when moving an item within the layout.
+ This property holds the transition to apply when moving an item within the positioner.
- This can happen when other items are added or removed from the layout, or
+ This can happen when other items are added or removed from the positioner, or
when items resize themselves.
\qml
GridPositioner {
- id: layout
+ id: positioner
move: Transition {
NumberAnimation {
properties: "x,y"
@@ -970,16 +882,16 @@ GridPositioner {
\qmlproperty int GridPositioner::margin
spacing and margin allow you to control the empty space surrounding
- items in layouts.
+ items in positioners.
spacing is the amount in pixels left empty between each adjacent
item. margin is the amount in pixels which will be left empty
- around the inside edge of the layout. Both default to 0.
+ around the inside edge of the positioner. Both default to 0.
The below example places a GridPositioner containing a red, a blue and a
- green rectangle on a gray background. The area the grid layout
- occupies is colored white. The top layout has a spacing of 2 and a
- margin of 5, the bottom layout has the defaults of no margin or
+ green rectangle on a gray background. The area the grid positioner
+ occupies is colored white. The top positioner has a spacing of 2 and a
+ margin of 5, the bottom positioner has the defaults of no margin or
spacing.
\image spacing_a.png
@@ -1028,7 +940,7 @@ QFxGridPositioner::QFxGridPositioner(QFxItem *parent) :
\brief the number of rows in the grid.
*/
-void QFxGridPositioner::doLayout()
+void QFxGridPositioner::doPositioning()
{
int c=_columns,r=_rows;//Actual number of rows/columns
int numVisible = items()->size() + newItems()->size();
@@ -1101,10 +1013,9 @@ void QFxGridPositioner::doLayout()
xoffset=0;
curRow++;
if (curRow>=r)
- return;
+ break;
}
}
- finishApplyTransitions();
}
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxpositioners.h b/src/declarative/fx/qfxpositioners.h
index 6acb393..9560925 100644
--- a/src/declarative/fx/qfxpositioners.h
+++ b/src/declarative/fx/qfxpositioners.h
@@ -60,11 +60,9 @@ class Q_DECLARATIVE_EXPORT QFxBasePositioner : public QFxItem
Q_OBJECT
Q_PROPERTY(int spacing READ spacing WRITE setSpacing)
- Q_PROPERTY(int margin READ margin WRITE setMargin)
Q_PROPERTY(QmlTransition *move READ move WRITE setMove)
Q_PROPERTY(QmlTransition *add READ add WRITE setAdd)
Q_PROPERTY(QmlTransition *remove READ remove WRITE setRemove)
- Q_PROPERTY(QFxItem *item READ layoutItem NOTIFY layoutItemChanged)
public:
enum AutoUpdateType { None = 0x0, Horizontal = 0x1, Vertical = 0x2, Both = 0x3 };
QFxBasePositioner(AutoUpdateType, QFxItem *parent);
@@ -72,9 +70,6 @@ public:
int spacing() const;
void setSpacing(int);
- int margin() const;
- void setMargin(int);
-
QmlTransition *move() const;
void setMove(QmlTransition *);
@@ -84,8 +79,6 @@ public:
QmlTransition *remove() const;
void setRemove(QmlTransition *);
- QFxItem *layoutItem() const;
-
protected:
virtual void componentComplete();
virtual QVariant itemChange(GraphicsItemChange, const QVariant &);
@@ -102,11 +95,10 @@ Q_SIGNALS:
void layoutItemChanged();
protected Q_SLOTS:
- virtual void doLayout()=0;
- void setLayoutItem(QFxItem *);
+ virtual void doPositioning()=0;
private Q_SLOTS:
- void preLayout();
+ void prePositioning();
protected:
QFxBasePositioner(QFxBasePositionerPrivate &dd, AutoUpdateType at, QFxItem *parent);
@@ -125,7 +117,7 @@ class Q_DECLARATIVE_EXPORT QFxVerticalPositioner : public QFxBasePositioner
public:
QFxVerticalPositioner(QFxItem *parent=0);
protected Q_SLOTS:
- virtual void doLayout();
+ virtual void doPositioning();
private:
Q_DISABLE_COPY(QFxVerticalPositioner)
};
@@ -136,7 +128,7 @@ class Q_DECLARATIVE_EXPORT QFxHorizontalPositioner: public QFxBasePositioner
public:
QFxHorizontalPositioner(QFxItem *parent=0);
protected Q_SLOTS:
- virtual void doLayout();
+ virtual void doPositioning();
private:
Q_DISABLE_COPY(QFxHorizontalPositioner)
};
@@ -155,7 +147,7 @@ public:
int columns() const {return _columns;}
void setcolumns(const int columns){_columns = columns;}
protected Q_SLOTS:
- virtual void doLayout();
+ virtual void doPositioning();
private:
int _rows;
diff --git a/src/declarative/fx/qfxpositioners_p.h b/src/declarative/fx/qfxpositioners_p.h
index 53f5dcd..8960952 100644
--- a/src/declarative/fx/qfxpositioners_p.h
+++ b/src/declarative/fx/qfxpositioners_p.h
@@ -69,8 +69,8 @@ class QFxBasePositionerPrivate : public QFxItemPrivate
public:
QFxBasePositionerPrivate()
: _ep(false), _componentComplete(false), _spacing(0),
- _margin(0), aut(QFxBasePositioner::None), moveTransition(0), addTransition(0),
- removeTransition(0), _layoutItem(0), _movingItem(0)
+ aut(QFxBasePositioner::None), moveTransition(0), addTransition(0),
+ removeTransition(0), _movingItem(0)
{
}
@@ -82,7 +82,6 @@ public:
bool _ep;
bool _componentComplete;
int _spacing;
- int _margin;
QFxBasePositioner::AutoUpdateType aut;
QmlTransition *moveTransition;
QmlTransition *addTransition;
@@ -92,7 +91,6 @@ public:
QSet<QFxItem *> _stableItems;
QSet<QFxItem *> _newItems;
QSet<QFxItem *> _animated;
- QFxItem *_layoutItem;
QmlStateOperation::ActionList addActions;
QmlStateOperation::ActionList moveActions;
QmlStateOperation::ActionList removeActions;