base -> settled

This commit is contained in:
Uwe Rathmann 2024-10-14 08:33:28 +02:00
parent aae2ebad96
commit 0cdff58c93
2 changed files with 13 additions and 16 deletions

View File

@ -186,7 +186,7 @@ qreal QskItemAnchors::centerOffset( Qt::Orientation orientation )
return 0.0; return 0.0;
} }
QQuickItem* QskItemAnchors::baseItem( Qt::AnchorPoint edge ) const QQuickItem* QskItemAnchors::settledItem( Qt::AnchorPoint edge ) const
{ {
const auto anchors = qskGetAnchors( m_attachedItem ); const auto anchors = qskGetAnchors( m_attachedItem );
if ( anchors == nullptr ) if ( anchors == nullptr )
@ -364,7 +364,7 @@ void QskItemAnchors::setCenterAnchors( QQuickItem* baseItem, Qt::Orientations or
} }
} }
Qt::AnchorPoint QskItemAnchors::basePosition( Qt::AnchorPoint edge ) const Qt::AnchorPoint QskItemAnchors::settledItemAnchorPoint( Qt::AnchorPoint edge ) const
{ {
if ( const auto anchors = qskGetAnchors( m_attachedItem ) ) if ( const auto anchors = qskGetAnchors( m_attachedItem ) )
{ {

View File

@ -14,22 +14,19 @@ class QMarginsF;
class QQuickItem; class QQuickItem;
/* /*
QskItemAnchors is a C++ API to access the Qt/Quick anchoring, QskItemAnchors is a C++ API to access the Qt/Quick anchoring.
that has been designed to be used from QML.
Qt/Quick anchoring is a simple concept, that allows to attach Qt/Quick anchoring is a simple concept, that allows to attach
borders ( Qt::AnchorPoint ) of attachedItem to a border of borders ( Qt::AnchorPoint ) of one item ( attachedItem ) to borders of
other items. It is up to the user to avoid cycles or conflicting other items ( settledItem ).
anchor chains.
Note that Qt/Quick ( in opposite to Qt/GraphicsView ) anchoring In opposite to anchoring layouts ( f.e QGraphicsAnchorLayout, QskAnchorLayout )
is not capable of handling typical layout scenarios, like distributing the positions of the anchors are provided - not calculated. That makes
the space of a bounding rectangle to a chain of anchored children. Qt/Quick anchoring unsuitable for scenarios, where the space of
For those you can use QskAnchorLayout/QskAnchorBox. a bounding rectangle has to be distributed.
The Qt/Quick implementation supports attaching to the parent or The implementation supports attaching to the parent or the siblings
the siblings of attachedItem only ( conceptually this limitation of attachedItem only ( conceptually this limitation would not be necessary ).
would not be necessary ).
Note that what is known in QML as "fill" or "centerIn" can be done Note that what is known in QML as "fill" or "centerIn" can be done
using setBorderAnchors or setCenterAnchors. using setBorderAnchors or setCenterAnchors.
@ -46,8 +43,8 @@ class QSK_EXPORT QskItemAnchors
QQuickItem* attachedItem() const; QQuickItem* attachedItem() const;
QQuickItem* baseItem( Qt::AnchorPoint ) const; QQuickItem* settledItem( Qt::AnchorPoint ) const;
Qt::AnchorPoint basePosition( Qt::AnchorPoint ) const; Qt::AnchorPoint settledItemAnchorPoint( Qt::AnchorPoint ) const;
bool operator==( const QskItemAnchors& ) const noexcept; bool operator==( const QskItemAnchors& ) const noexcept;
bool operator!=( const QskItemAnchors& ) const noexcept; bool operator!=( const QskItemAnchors& ) const noexcept;