From 1a75b369797c41d37f92950f7527c1eb989f1215 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Fri, 27 Aug 2010 18:23:37 +0200 Subject: Doc: More work on the QML documentation. --- .../graphicsitems/qdeclarativeborderimage.cpp | 21 +- .../graphicsitems/qdeclarativepositioners.cpp | 436 ++++++++++++--------- .../graphicsitems/qdeclarativerepeater.cpp | 10 +- 3 files changed, 263 insertions(+), 204 deletions(-) (limited to 'src') diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp index 5a9a18d687..832e1cddb4 100644 --- a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp @@ -169,7 +169,8 @@ QDeclarativeBorderImage::~QDeclarativeBorderImage() /*! \qmlproperty enumeration BorderImage::status - This property holds the status of image loading. It can be one of: + This property describes the status of image loading. It can be one of: + \list \o BorderImage.Null - no image has been set \o BorderImage.Ready - the image has been loaded @@ -201,18 +202,24 @@ QDeclarativeBorderImage::~QDeclarativeBorderImage() \note Generally scaling artifacts are only visible if the image is stationary on the screen. A common pattern when animating an image is to disable smooth - filtering at the beginning of the animation and reenable it at the conclusion. + filtering at the beginning of the animation and enable it at the conclusion. */ /*! \qmlproperty url BorderImage::source - BorderImage can handle any image format supported by Qt, loaded from any URL scheme supported by Qt. + This property holds the URL that refers to the source image. + + BorderImage can handle any image format supported by Qt, loaded from any + URL scheme supported by Qt. + + It can also handle .sci files, which are a QML-specific format. A .sci + file uses a simple text-based format that specifies the borders, the + image file and the tile rules. - It can also handle .sci files, which are a QML-specific format. A .sci file uses a simple text-based format that specifies - the borders, the image file and the tile rules. + The following .sci file sets the borders to 10 on each side for the + image \c picture.png: - The following .sci file sets the borders to 10 on each side for the image \c picture.png: \qml border.left: 10 border.top: 10 @@ -356,7 +363,7 @@ QDeclarativeScaleGrid *QDeclarativeBorderImage::border() This property describes how to repeat or stretch the middle parts of the border image. \list - \o BorderImage.Stretch - Scale the image to fit to the available area. + \o BorderImage.Stretch - Scales the image to fit to the available area. \o BorderImage.Repeat - Tile the image until there is no more space. May crop the last image. \o BorderImage.Round - Like Repeat, but scales the images down to ensure that the last image is not cropped. \endlist diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp index 4ceb5d9149..b653282cd0 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp +++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp @@ -330,58 +330,65 @@ static inline bool isInvisible(QGraphicsObject *child) /*! \qmlclass Column QDeclarativeColumn - \ingroup qml-positioning-elements - \since 4.7 + \ingroup qml-positioning-elements + \since 4.7 \brief The Column item arranges its children vertically. \inherits Item The Column item positions its child items so that they are vertically - aligned and not overlapping. Spacing between items can be added. + aligned and not overlapping. - The below example positions differently shaped rectangles using a Column. - \table - \row - \o \image verticalpositioner_example.png - \o - \qml -Column { - spacing: 2 - Rectangle { color: "red"; width: 50; height: 50 } - Rectangle { color: "green"; width: 20; height: 50 } - Rectangle { color: "blue"; width: 50; height: 20 } -} - \endqml - \endtable + Spacing between items can be added using the \l spacing property. + Transitions can be used for cases where items managed by a Column are + added or moved. These are stored in the \l add and \l move properties + respectively. + + See \l{Using QML Positioner and Repeater Items} for more details about this item and other + related items. + + \section1 Example Usage + + The following example positions differently shaped rectangles using a Column + item. + + \image verticalpositioner_example.png + + \snippet doc/src/snippets/declarative/column/vertical-positioner.qml document + + \section1 Using Transitions + + Transitions can be used to animate items that are added to, moved within, + or removed from a Column item. The \l add and \l move properties can be set to + the transitions that will be applied when items are added to, removed from, + or re-positioned within a Column item. + + The use of transitions with positioners is described in more detail in the + \l{Using QML Positioner and Repeater Items#Using Transitions}{Using QML + Positioner and Repeater Items} document. - Column 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. + \image verticalpositioner_transition.gif - \table - \row - \o \image verticalpositioner_transition.gif - \o \qml -Column { - spacing: 2 - add: ... - move: ... - ... -} + Column { + spacing: 2 + add: ... + move: ... + ... + } \endqml - \endtable + + \section1 Limitations Note that the positioner assumes that the x and y positions of its children will not change. If you manually change the x or y properties in script, bind the x or y properties, use anchors on a child of a positioner, or have the height of a child depend on the position of a child, then the - positioner may exhibit strange behaviour. If you need to perform any of these + positioner may exhibit strange behavior. If you need to perform any of these actions, consider positioning the items without the use of a Column. Items with a width or height of 0 will not be positioned. - \sa Row, {declarative/positioners}{Positioners example} + \sa Row, Grid, Flow, {declarative/positioners}{Positioners example} */ /*! \qmlproperty Transition Column::add @@ -389,55 +396,47 @@ Column { This property holds the transition to be applied when adding an item to the positioner. The transition will only be applied to the added item(s). Positioner transitions will only affect the - position (x,y) of items. - - 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. + position (x, y) of items. + For a positioner, adding an item 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. + \sa move */ /*! \qmlproperty Transition Column::move This property holds the transition to apply when moving an item within the positioner. Positioner transitions will only affect - the position (x,y) of items. + the position (x, y) of items. + + This transition can be performed when other items are added or removed + from the positioner, or when items resize themselves. - This can happen when other items are added or removed from the - positioner, or when items resize themselves. + \image positioner-move.gif - \table - \row - \o \image positioner-move.gif - \o \qml -Column { - move: Transition { - NumberAnimation { - properties: "y" - easing.type: Easing.OutBounce + Column { + move: Transition { + NumberAnimation { + properties: "y" + easing.type: Easing.OutBounce + } } } -} \endqml - \endtable + + \sa add, {declarative/positioners}{Positioners example} */ /*! \qmlproperty int Column::spacing - spacing is the amount in pixels left empty between each adjacent - item, and defaults to 0. - - The below example places a \l Grid 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 the default of no spacing, - and the bottom positioner has its spacing set to 2. - - \image spacing_a.png - \image spacing_b.png + The spacing is the amount in pixels left empty between adjacent + items. The default spacing is 0. + \sa Grid::spacing */ /*! \internal @@ -496,29 +495,38 @@ void QDeclarativeColumn::reportConflictingAnchors() /*! \qmlclass Row QDeclarativeRow - \ingroup qml-positioning-elements + \ingroup qml-positioning-elements \since 4.7 \brief The Row item arranges its children horizontally. \inherits Item - The Row item positions its child items so that they are - horizontally aligned and not overlapping. + The Row item positions its child items so that they are horizontally + aligned and not overlapping. Use \l spacing to set the spacing between items in a Row, and use the \l add and \l move properties to set the transitions that should be applied when items are added to, removed from, or re-positioned within the Row. - The below example lays out differently shaped rectangles using a Row. - \qml -Row { - spacing: 2 - Rectangle { color: "red"; width: 50; height: 50 } - Rectangle { color: "green"; width: 20; height: 50 } - Rectangle { color: "blue"; width: 50; height: 20 } -} - \endqml + See \l{Using QML Positioner and Repeater Items} for more details about this item and other + related items. + + \section1 Example Usage + + The following example lays out differently shaped rectangles using a Row. + \image horizontalpositioner_example.png + \snippet doc/src/snippets/declarative/row/row.qml document + + \section1 Using Transitions + + Transitions can be used to animate items that are added to, moved within, + or removed from a Grid item. The \l add and \l move properties can be set to + the transitions that will be applied when items are added to, removed from, + or re-positioned within a Row item. + + \section1 Limitations + Note that the positioner assumes that the x and y positions of its children will not change. If you manually change the x or y properties in script, bind the x or y properties, use anchors on a child of a positioner, or have the @@ -528,56 +536,54 @@ Row { Items with a width or height of 0 will not be positioned. - \sa Column, {declarative/positioners}{Positioners example} + \sa Column, Grid, Flow, {declarative/positioners}{Positioners example} */ /*! \qmlproperty Transition Row::add - This property holds the transition to apply when adding an item to the positioner. - The transition will only be applied to the added item(s). - Positioner transitions will only affect the position (x,y) of items. - - An object is considered to be added to the positioner if it has been - created or reparented and thus is now a child or the positioner, or if the - object has had its opacity increased from zero, and thus is now - visible. + + This property holds the transition to be applied when adding an + item to the positioner. The transition will only be applied to the + added item(s). Positioner transitions will only affect the + position (x, y) of items. + + For a positioner, adding an item 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. + + \sa move */ /*! \qmlproperty Transition Row::move - This property holds the transition to apply when moving an item - within the positioner. Positioner transitions will only affect - the position (x,y) of items. + This property holds the transition to be applied when moving an + item within the positioner. Positioner transitions will only affect + the position (x, y) of items. - This can happen when other items are added or removed from the - positioner, or when items resize themselves. + This transition can be performed when other items are added or removed + from the positioner, or when items resize themselves. \qml -Row { - id: positioner - move: Transition { - NumberAnimation { - properties: "x" - ease: "easeOutBounce" + Row { + id: positioner + move: Transition { + NumberAnimation { + properties: "x" + ease: "easeOutBounce" + } } } -} \endqml + \sa add, {declarative/positioners}{Positioners example} */ /*! \qmlproperty int Row::spacing - spacing is the amount in pixels left empty between each adjacent - item, and defaults to 0. - - The below example places a \l Grid 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 the default of no spacing, - and the bottom positioner has its spacing set to 2. - - \image spacing_a.png - \image spacing_b.png + The spacing is the amount in pixels left empty between adjacent + items. The default spacing is 0. + \sa Grid::spacing */ /*! \internal @@ -635,47 +641,45 @@ void QDeclarativeRow::reportConflictingAnchors() /*! \qmlclass Grid QDeclarativeGrid - \ingroup qml-positioning-elements + \ingroup qml-positioning-elements \since 4.7 \brief The Grid item positions its children in a grid. \inherits Item The Grid item positions its child items so that they are aligned in a grid and are not overlapping. - - Spacing can be added - between child items. 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. - - A Grid defaults to four columns, and as many rows as - are necessary to fit all child items. The number of rows - and/or the number of columns can be constrained by setting the \l rows - or \l 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 - example demonstrates this. - - \table - \row - \o \image gridLayout_example.png - \o - \qml -Grid { - columns: 3 - spacing: 2 - Rectangle { color: "red"; width: 50; height: 50 } - Rectangle { color: "green"; width: 20; height: 50 } - Rectangle { color: "blue"; width: 50; height: 20 } - Rectangle { color: "cyan"; width: 50; height: 50 } - Rectangle { color: "magenta"; width: 10; height: 10 } -} - \endqml - \endtable + + A Grid defaults to four columns, and as many rows as are necessary to + fit all child items. The number of rows and columns can be constrained + by setting the \l rows and \l columns properties. The grid positioner + calculates a grid of rectangular cells of sufficient size to hold all + items, placing the items in the cells, from left to right and top to + bottom. Each item is positioned in the top-left corner of its cell + with position (0, 0). + + Spacing can be added between child items by setting the \l spacing + property. The amount of spacing applied will be the same in the + horizontal and vertical directions. + + See \l{Using QML Positioner and Repeater Items} for more details about this item and other + related items. + + \section1 Example Usage + + The following example demonstrates this. + + \image gridLayout_example.png + + \snippet doc/src/snippets/declarative/grid/grid.qml document + + \section1 Using Transitions + + Transitions can be used to animate items that are added to, moved within, + or removed from a Grid item. The \l add and \l move properties can be set to + the transitions that will be applied when items are added to, removed from, + or re-positioned within a Grid item. + + \section1 Limitations Note that the positioner assumes that the x and y positions of its children will not change. If you manually change the x or y properties in script, bind @@ -686,55 +690,62 @@ Grid { Items with a width or height of 0 will not be positioned. - \sa Flow, {declarative/positioners}{Positioners example} + \sa Flow, Row, Column, {declarative/positioners}{Positioners example} */ /*! \qmlproperty Transition Grid::add - This property holds the transition to apply when adding an item to the positioner. - The transition is only applied to the added item(s). - Positioner transitions will only affect the position (x,y) of items, - as that is all the positioners affect. To animate other property change - you will have to do so based on how you have changed those properties. - - An object is considered to be added to the positioner if it has been - created or reparented and thus is now a child or the positioner, or if the - object has had its opacity increased from zero, and thus is now - visible. + + This property holds the transition to be applied when adding an + item to the positioner. The transition will only be applied to the + added item(s). Positioner transitions will only affect the + position (x, y) of items. + + For a positioner, adding an item 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. + + \sa move */ /*! \qmlproperty Transition Grid::move - This property holds the transition to apply when moving an item within the positioner. - Positioner transitions will only affect the position (x,y) of items. - This can happen when other items are added or removed from the positioner, or - when items resize themselves. + This property holds the transition to be applied when moving an + item within the positioner. Positioner transitions will only affect + the position (x, y) of items. + + This transition can be performed when other items are added or removed + from the positioner, or when items resize themselves. \qml -Grid { - move: Transition { - NumberAnimation { - properties: "x,y" - ease: "easeOutBounce" + Grid { + move: Transition { + NumberAnimation { + properties: "x,y" + ease: "easeOutBounce" + } } } -} \endqml + \sa add, {declarative/positioners}{Positioners example} */ /*! \qmlproperty int Grid::spacing - spacing is the amount in pixels left empty between each adjacent - item, and defaults to 0. + The spacing is the amount in pixels left empty between adjacent + items. The default spacing is 0. The below example places a Grid 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 the default of no spacing, - and the bottom positioner has its spacing set to 2. + occupies is colored white. The positioner on the left has the + no spacing (the default), and the positioner on the right has + a spacing of 6. - \image spacing_a.png - \image spacing_b.png + \inlineimage qml-grid-no-spacing.png + \inlineimage qml-grid-spacing.png + \sa rows, columns */ /*! \internal @@ -748,7 +759,9 @@ QDeclarativeGrid::QDeclarativeGrid(QDeclarativeItem *parent) : /*! \qmlproperty int Grid::columns - This property holds the number of columns in the grid. + + This property holds the number of columns in the grid. The default + number of columns is 4. If the grid does not have enough items to fill the specified number of columns, some columns will be of zero width. @@ -930,13 +943,43 @@ void QDeclarativeGrid::reportConflictingAnchors() /*! \qmlclass Flow QDeclarativeFlow - \ingroup qml-positioning-elements + \ingroup qml-positioning-elements \since 4.7 \brief The Flow item arranges its children side by side, wrapping as necessary. \inherits Item - The Flow item positions its child items so that they are side by side and are - not overlapping. + The Flow item positions its child items like words on a page, wrapping them + to create rows or columns of items that do not overlap. + + Spacing between items can be added using the \l spacing property. + Transitions can be used for cases where items managed by a Column are + added or moved. These are stored in the \l add and \l move properties + respectively. + + See \l{Using QML Positioner and Repeater Items} for more details about this item and other + related items. + + \section1 Example Usage + + The following example positions \l Text items within a parent item using + a Flow item. + + \image qml-flow-snippet.png + + \snippet doc/src/snippets/declarative/flow.qml flow item + + \section1 Using Transitions + + Transitions can be used to animate items that are added to, moved within, + or removed from a Flow item. The \l add and \l move properties can be set to + the transitions that will be applied when items are added to, removed from, + or re-positioned within a Flow item. + + The use of transitions with positioners is described in more detail in the + \l{Using QML Positioner and Repeater Items#Using Transitions}{Using QML + Positioner and Repeater Items} document. + + \section1 Limitations Note that the positioner assumes that the x and y positions of its children will not change. If you manually change the x or y properties in script, bind @@ -947,38 +990,46 @@ void QDeclarativeGrid::reportConflictingAnchors() Items with a width or height of 0 will not be positioned. - \sa Grid, {declarative/positioners}{Positioners example} + \sa Column, Row, Grid, {declarative/positioners}{Positioners example} */ /*! \qmlproperty Transition Flow::add - This property holds the transition to apply when adding an item to the positioner. - The transition will only be applied to the added item(s). - Positioner transitions will only affect the position (x,y) of items. - - An object is considered to be added to the positioner if it has been - created or reparented and thus is now a child or the positioner, or if the - object has had its opacity increased from zero, and thus is now - visible. + + This property holds the transition to be applied when adding an + item to the positioner. The transition will only be applied to the + added item(s). Positioner transitions will only affect the + position (x, y) of items. + + For a positioner, adding an item 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. + + \sa move */ /*! \qmlproperty Transition Flow::move - This property holds the transition to apply when moving an item within the positioner. - Positioner transitions will only affect the position (x,y) of items. - This can happen when other items are added or removed from the positioner, or when items resize themselves. + This property holds the transition to be applied when moving an + item within the positioner. Positioner transitions will only affect + the position (x, y) of items. + + This transition can be performed when other items are added or removed + from the positioner, or when items resize themselves. \qml -Flow { - id: positioner - move: Transition { - NumberAnimation { - properties: "x,y" - ease: "easeOutBounce" + Flow { + id: positioner + move: Transition { + NumberAnimation { + properties: "x,y" + ease: "easeOutBounce" + } } } -} \endqml + \sa add, {declarative/positioners}{Positioners example} */ /*! \qmlproperty int Flow::spacing @@ -986,6 +1037,7 @@ Flow { spacing is the amount in pixels left empty between each adjacent item, and defaults to 0. + \sa Grid::spacing */ class QDeclarativeFlowPrivate : public QDeclarativeBasePositionerPrivate diff --git a/src/declarative/graphicsitems/qdeclarativerepeater.cpp b/src/declarative/graphicsitems/qdeclarativerepeater.cpp index 4a951a281c..c4052bbaf7 100644 --- a/src/declarative/graphicsitems/qdeclarativerepeater.cpp +++ b/src/declarative/graphicsitems/qdeclarativerepeater.cpp @@ -78,9 +78,9 @@ QDeclarativeRepeaterPrivate::~QDeclarativeRepeaterPrivate() The following Repeater creates three instances of a \l Rectangle item within a \l Row: - \snippet doc/src/snippets/declarative/repeater.qml import + \snippet doc/src/snippets/declarative/repeaters/repeater.qml import \codeline - \snippet doc/src/snippets/declarative/repeater.qml simple + \snippet doc/src/snippets/declarative/repeaters/repeater.qml simple \image repeater-simple.png @@ -92,7 +92,7 @@ QDeclarativeRepeaterPrivate::~QDeclarativeRepeaterPrivate() a Repeater to be used inside a layout. For example, the following Repeater's items are stacked between a red rectangle and a blue rectangle: - \snippet doc/src/snippets/declarative/repeater.qml layout + \snippet doc/src/snippets/declarative/repeaters/repeater.qml layout \image repeater.png @@ -106,7 +106,7 @@ QDeclarativeRepeaterPrivate::~QDeclarativeRepeaterPrivate() \table \row - \o \snippet doc/src/snippets/declarative/repeater.qml index + \o \snippet doc/src/snippets/declarative/repeaters/repeater.qml index \o \image repeater-index.png \endtable @@ -115,7 +115,7 @@ QDeclarativeRepeaterPrivate::~QDeclarativeRepeaterPrivate() \table \row - \o \snippet doc/src/snippets/declarative/repeater.qml modeldata + \o \snippet doc/src/snippets/declarative/repeaters/repeater.qml modeldata \o \image repeater-modeldata.png \endtable -- cgit v1.2.1