qskinny/doc/classes/QskLinearBox.dox

319 lines
9.0 KiB
Plaintext
Raw Normal View History

2020-12-08 11:02:57 +01:00
/*!
2021-01-25 11:06:01 +01:00
\class QskLinearBox QskLinearBox.h
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\brief Layout stringing items in rows and columns
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
QskLinearBox organizes layout items in vertical or horizontal order
( \ref orientation ). When the number of items for a row/column has
reached an upper limit ( \ref dimension ) the following items will be
added to a new row/column.
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
When having the \ref dimension being set to unlimited ( or 1 with the
inverted \ref orientation ) the string layout behaves similar to
QBoxLayout, RowLayout/ColumnLayout ( QML ) or what is
sometimes called a linear layout.
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
When not restricting the layout to one row/column only the layout can
be used to set up simple grid formations.
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
Layout items may be QQuickItem *s or spacers - both having a stretch factor
in the range of [0..10];
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\note All available Qsk layouts are thin layers on top of the same grid
based workhorse ( = QGridLayoutEngine ). QskLinearBox offers
a reasonable subset of features, tailored for an index based
point of view.
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\sa QskGridBox, QskStackBox
2020-12-08 11:02:57 +01:00
*/
2020-12-12 14:05:09 +01:00
/*!
2021-01-25 11:06:01 +01:00
\property Qt::Orientation QskLinearBox::orientation
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\brief Direction of flow for laying out the items
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
In case of Qt::Horizontal the elements are organized horizontally
increasing the column index, when appending an item. When the
number of columns exceeds the \ref dimension the next item will be
in the first column of the next row ( v.v for Qt::Vertical ).
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
The horizontal layout direction is affected by its state
of QskControl::layoutMirroring(), what might depend on the
QskControl::locale().
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\sa transpose(), dimension
\accessors orientation(), setOrientation(), orientationChanged()
2020-12-12 14:05:09 +01:00
*/
2020-12-08 11:02:57 +01:00
2020-12-12 14:05:09 +01:00
/*!
2021-01-25 11:06:01 +01:00
\property uint QskLinearBox::dimension
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\brief Upper limit for the number of elements in a row or column
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
According to the orientation the layout is organized in
rows or columns. The dimension is an upper limit for the number
of elements in a row/column.
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
When the number of elements exceeds the dimension the following element
will be inserted in the following row/column.
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\sa orientation
\accessors dimension(), setDimension(), dimensionChanged()
2020-12-12 14:05:09 +01:00
*/
2020-12-08 11:02:57 +01:00
2020-12-12 14:05:09 +01:00
/*!
2021-01-25 11:06:01 +01:00
\property qreal QskLinearBox::spacing
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\brief Global layout spacing
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
The spacing is the distance between each cell and row
of the layout. Its initial value depend on the current theme.
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
Beside setting the global spacing it is also possible to add
individual spacings at the end of each row and column.
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\note In opposite to a spacer, the global spacing does not insert elements.
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\sa setRowSpacing(), setColumnSpacing(), insertSpacer(), QskControl::setMargins()
\accessors spacing(), setSpacing(), spacingChanged()
2020-12-12 14:05:09 +01:00
*/
2020-12-08 11:02:57 +01:00
2020-12-12 14:05:09 +01:00
/*!
2021-01-25 11:06:01 +01:00
\fn QskLinearBox::QskLinearBox( QQuickItem* );
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\brief Create a row layout
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
The \ref orientation is set to Qt::Horizontal orientation having
an unlimited \ref dimension.
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\param parent Parent item
\sa orientation, dimension
2020-12-12 14:05:09 +01:00
*/
2020-12-08 11:02:57 +01:00
2020-12-12 14:05:09 +01:00
/*!
2021-01-25 11:06:01 +01:00
\fn QskLinearBox::QskLinearBox( Qt::Orientation orientation, QQuickItem * parent );
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\brief Create a row or column layout
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
The \ref dimension is unlimited.
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\param orientation Qt::Horizontal or Qt::Vertical
\param parent Parent item
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\sa orientation, dimension
2020-12-12 14:05:09 +01:00
*/
2020-12-08 11:02:57 +01:00
2020-12-12 14:05:09 +01:00
/*!
2021-01-25 11:06:01 +01:00
\fn QskLinearBox::QskLinearBox( Qt::Orientation, uint, QQuickItem* );
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\brief Constructor
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\param orientation Qt::Horizontal or Qt::Vertical
\param dimension Upper limit for the number of elements
in a row or column
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\param parent Parent item
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\sa orientation, dimension
2020-12-12 14:05:09 +01:00
*/
2020-12-08 11:02:57 +01:00
2020-12-12 14:05:09 +01:00
/*!
2021-01-25 11:06:01 +01:00
\fn QskLinearBox::~QskLinearBox();
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
Destructor
2020-12-12 14:05:09 +01:00
*/
2020-12-08 11:02:57 +01:00
2020-12-12 14:05:09 +01:00
/*!
2021-01-25 11:06:01 +01:00
\fn void QskLinearBox::setOrientation( Qt::Orientation orientation );
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\brief Set the orientation of the layout
\param orientation Qt::Vertical or Qt::Horizontal
\sa orientation
2020-12-12 14:05:09 +01:00
*/
2020-12-08 11:02:57 +01:00
2020-12-12 14:05:09 +01:00
/*!
2021-01-25 11:06:01 +01:00
\fn Qt::Orientation QskLinearBox::orientation() const;
\return Value of the \ref orientation property
2020-12-12 14:05:09 +01:00
*/
2020-12-08 11:02:57 +01:00
2020-12-12 14:05:09 +01:00
/*!
2021-01-25 11:06:01 +01:00
\fn void QskLinearBox::transpose()
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\brief Invert the orientation of the layout
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
Qt::Horizontal becomes to Qt::Vertical and v.v.
\sa setOrientation(), orientation(), orientationChanged()
2020-12-12 14:05:09 +01:00
*/
2020-12-08 11:02:57 +01:00
2020-12-12 14:05:09 +01:00
/*!
2021-01-25 11:06:01 +01:00
\fn void QskLinearBox::orientationChanged()
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
The orientation of the layout has changed
\sa orientation
2020-12-12 14:05:09 +01:00
*/
2020-12-08 11:02:57 +01:00
2020-12-12 14:05:09 +01:00
/*!
2021-01-25 11:06:01 +01:00
\fn void QskLinearBox::setDimension( uint dimension );
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\brief Set the dimension of the layout
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\param dimension Upper limit for the number of elements in a row or column
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\warning A value of 0 is invalid and will be set to 1
\sa dimension
2020-12-12 14:05:09 +01:00
*/
2020-12-08 11:02:57 +01:00
2020-12-12 14:05:09 +01:00
/*!
2021-01-25 11:06:01 +01:00
\fn uint QskLinearBox::dimension(void);
\return Value of the \ref dimension property const
2020-12-12 14:05:09 +01:00
*/
2020-12-08 11:02:57 +01:00
2020-12-12 14:05:09 +01:00
/*!
2021-01-25 11:06:01 +01:00
\fn void QskLinearBox::dimensionChanged()
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
The dimension of the layout has changed
\sa setDimension(), dimension()
2020-12-12 14:05:09 +01:00
*/
2020-12-08 11:02:57 +01:00
2020-12-12 14:05:09 +01:00
/*!
2021-01-25 11:06:01 +01:00
\fn void QskLinearBox::spacingChanged()
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
The spacing of the layout has changed
\sa setSpacing(), spacing(), setRowSpacing(), setColumnSpacing()
2020-12-12 14:05:09 +01:00
*/
2020-12-08 11:02:57 +01:00
2020-12-12 14:05:09 +01:00
/*!
2021-01-25 11:06:01 +01:00
\fn void QskLinearBox::setSpacing( qreal spacing )
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\brief Set the global spacing of the layout
\param spacing Distance between each cell and row
\sa spacing
2020-12-12 14:05:09 +01:00
*/
2020-12-08 11:02:57 +01:00
2020-12-12 14:05:09 +01:00
/*!
2021-01-25 11:06:01 +01:00
\fn void QskLinearBox::resetSpacing()
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\brief Reset the global spacing to its initial value
\sa spacing
2020-12-12 14:05:09 +01:00
*/
2020-12-08 11:02:57 +01:00
2020-12-12 14:05:09 +01:00
/*!
2021-01-25 11:06:01 +01:00
\fn qreal QskLinearBox::spacing(void) const
\return Value of the \ref spacing property
2020-12-08 11:02:57 +01:00
2020-12-12 14:05:09 +01:00
*/
2020-12-08 11:02:57 +01:00
2020-12-12 14:05:09 +01:00
/*!
2021-01-25 11:06:01 +01:00
\fn void QskLinearBox::addSpacer( qreal spacing, int stretchFactor )
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\brief Append a spacer to the layout
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
The same as \ref insertSpacer( -1, spacing, stretchFactor );
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\param spacing Spacing
\param stretchFactor A value between [0..10].
The ratio of the stretch factors of expandable
candidates decides about how to distribute extra space.
\sa insertSpacer()
2020-12-12 14:05:09 +01:00
*/
2020-12-08 11:02:57 +01:00
2020-12-12 14:05:09 +01:00
/*!
2021-01-25 11:06:01 +01:00
\fn void QskLinearBox::insertSpacer( int index, qreal spacing, int stretchFactor )
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\brief Insert a spacer at a specific position
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
Spacers being inserted to the layout are elements having
an index - like regular QQuickItem *s and participate in the
calculation of the geometries.
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
A spacer is treated like being an item with a preferred
width/height of spacing. In case of having a stretchFactor > 0
the width/height might exceed spacing.
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\param index Position, where to insert the spacer. If index is < 0
or beyond QskLayout::itemCount() the spacer will be appended.
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\param spacing Spacing Minimum for width/height
\param stretchFactor A value between [0..10].
The ratio of the stretch factors of expandable
candidates decides about how to distribute extra space.
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\note Calling QskLayout::itemAtIndex( index ) will return a nullptr.
\sa insertItem(), QskLayout::itemAtIndex()
2020-12-12 14:05:09 +01:00
*/
2020-12-08 11:02:57 +01:00
2020-12-12 14:05:09 +01:00
/*!
2021-01-25 11:06:01 +01:00
\fn void QskLinearBox::addStretch( int stretchFactor )
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\brief Append a stretch to the layout
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
The same as \ref insertStretch( -1, stretchFactor );
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\param stretchFactor A value between [0..10].
The ratio of the stretch factors of expandable
candidates decides about how to distribute extra space.
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\sa insertStretch(), addSpacer()
2020-12-12 14:05:09 +01:00
*/
2020-12-08 11:02:57 +01:00
2020-12-12 14:05:09 +01:00
/*!
2021-01-25 11:06:01 +01:00
\fn void QskLinearBox::insertStretch( int index, int stretchFactor )
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\brief Insert a stretch at a specific position
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
A stretch is simply a spacer with a spacing of 0
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\param index Position, where to insert the stretch. If index is < 0
or beyond QskLayout::itemCount() the stretch will be appended.
\param stretchFactor A value between [0..10].
The ratio of the stretch factors of expandable
candidates decides about how to distribute extra space.
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\note Calling QskLayout::itemAtIndex( index ) will return a nullptr.
\sa insertSpacer(), QskLayout::itemAtIndex()
2020-12-12 14:05:09 +01:00
*/
2020-12-08 11:02:57 +01:00
2020-12-12 14:05:09 +01:00
/*!
2021-01-25 11:06:01 +01:00
\fn void QskLinearBox::setStretchFactor( int index, int stretchFactor )
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\brief Modify the stretch factor of a layout element
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\param index Position of the element
\param stretchFactor A value between [0..10].
The ratio of the stretch factors of expandable
candidates decides about how to distribute extra space.
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\sa stretchFactor()
2020-12-12 14:05:09 +01:00
*/
2020-12-08 11:02:57 +01:00
2020-12-12 14:05:09 +01:00
/*!
2021-01-25 11:06:01 +01:00
\fn int QskLinearBox::stretchFactor( int index ) const
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\param index Position of the inserted element
\return Stretch factor of a layout element
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\sa setStretchFactor()
2020-12-12 14:05:09 +01:00
*/
2020-12-08 11:02:57 +01:00
2020-12-12 14:05:09 +01:00
/*!
2021-01-25 11:06:01 +01:00
\fn void QskLinearBox::setStretchFactor( const QQuickItem * item, int stretchFactor )
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\brief Modify the stretch factor of an inserted item
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\param item Inserted item
\param stretchFactor A value between [0..10].
The ratio of the stretch factors of expandable
candidates decides about how to distribute extra space.
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\sa stretchFactor()
2020-12-12 14:05:09 +01:00
*/
2020-12-08 11:02:57 +01:00
2020-12-12 14:05:09 +01:00
/*!
2021-01-25 11:06:01 +01:00
\fn int QskLinearBox::stretchFactor( const QQuickItem * item ) const
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\param item Inserted item
\return Stretch factor of a layout element
2020-12-08 11:02:57 +01:00
2021-01-25 11:06:01 +01:00
\sa setStretchFactor()
2020-12-12 14:05:09 +01:00
*/