From ae67fcb0538c0f47c77eef0ed39955e33671343e Mon Sep 17 00:00:00 2001 From: Artur Duque de Souza Date: Wed, 12 Aug 2009 11:33:14 -0300 Subject: Update Anchor Layout API More user friendly API for anchor layouts. Changed method names and also provided more methods to receive spacing. Signed-off-by: Artur Duque de Souza Reviewed-by: Caio Marcelo de Oliveira Filho --- src/gui/graphicsview/qgraphicsanchorlayout.cpp | 16 +++--- src/gui/graphicsview/qgraphicsanchorlayout.h | 70 +++++++++++++++++++------- 2 files changed, 59 insertions(+), 27 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.cpp b/src/gui/graphicsview/qgraphicsanchorlayout.cpp index 6360e75..902f0b2 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout.cpp @@ -131,10 +131,10 @@ void QGraphicsAnchorLayout::anchor(QGraphicsLayoutItem *firstItem, * \a firstItem and \a secondItem are automatically added to the layout if they are not part * of the layout. This means that count() can increase with up to 2. */ -void QGraphicsAnchorLayout::anchor(QGraphicsLayoutItem *firstItem, - Qt::Corner firstCorner, - QGraphicsLayoutItem *secondItem, - Qt::Corner secondCorner) +void QGraphicsAnchorLayout::anchorCorner(QGraphicsLayoutItem *firstItem, + Qt::Corner firstCorner, + QGraphicsLayoutItem *secondItem, + Qt::Corner secondCorner) { Q_D(QGraphicsAnchorLayout); @@ -157,10 +157,10 @@ void QGraphicsAnchorLayout::anchor(QGraphicsLayoutItem *firstItem, * By calling this function the caller can specify the magnitude of the anchor with \a spacing. * */ -void QGraphicsAnchorLayout::anchor(QGraphicsLayoutItem *firstItem, - Qt::Corner firstCorner, - QGraphicsLayoutItem *secondItem, - Qt::Corner secondCorner, qreal spacing) +void QGraphicsAnchorLayout::anchorCorner(QGraphicsLayoutItem *firstItem, + Qt::Corner firstCorner, + QGraphicsLayoutItem *secondItem, + Qt::Corner secondCorner, qreal spacing) { Q_D(QGraphicsAnchorLayout); diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.h b/src/gui/graphicsview/qgraphicsanchorlayout.h index 1f622eb..249996e 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout.h @@ -78,22 +78,30 @@ public: QGraphicsLayoutItem *secondItem, Edge secondEdge, qreal spacing); - void anchor(QGraphicsLayoutItem *firstItem, Qt::Corner firstCorner, - QGraphicsLayoutItem *secondItem, Qt::Corner secondCorner); + void anchorCorner(QGraphicsLayoutItem *firstItem, Qt::Corner firstCorner, + QGraphicsLayoutItem *secondItem, Qt::Corner secondCorner); - void anchor(QGraphicsLayoutItem *firstItem, Qt::Corner firstCorner, - QGraphicsLayoutItem *secondItem, Qt::Corner secondCorner, - qreal spacing); + void anchorCorner(QGraphicsLayoutItem *firstItem, Qt::Corner firstCorner, + QGraphicsLayoutItem *secondItem, Qt::Corner secondCorner, + qreal spacing); void removeAnchor(QGraphicsLayoutItem *firstItem, Edge firstEdge, QGraphicsLayoutItem *secondItem, Edge secondEdge); - inline void fillWidth(QGraphicsLayoutItem *item, - QGraphicsLayoutItem *relativeTo = 0); - inline void fillHeight(QGraphicsLayoutItem *item, - QGraphicsLayoutItem *relativeTo = 0); - inline void fill(QGraphicsLayoutItem *item, - QGraphicsLayoutItem *relativeTo = 0); + inline void anchorWidth(QGraphicsLayoutItem *item, + QGraphicsLayoutItem *relativeTo = 0); + inline void anchorWidth(QGraphicsLayoutItem *item, + QGraphicsLayoutItem *relativeTo, qreal spacing); + + inline void anchorHeight(QGraphicsLayoutItem *item, + QGraphicsLayoutItem *relativeTo = 0); + inline void anchorHeight(QGraphicsLayoutItem *item, + QGraphicsLayoutItem *relativeTo, qreal spacing); + + inline void anchorGeometry(QGraphicsLayoutItem *item, + QGraphicsLayoutItem *relativeTo = 0); + inline void anchorGeometry(QGraphicsLayoutItem *item, + QGraphicsLayoutItem *relativeTo, qreal spacing); void setSpacing(qreal spacing, Qt::Orientations orientations = Qt::Horizontal|Qt::Vertical); qreal spacing(Qt::Orientation) const; @@ -115,8 +123,8 @@ private: Q_DECLARE_PRIVATE(QGraphicsAnchorLayout) }; -void QGraphicsAnchorLayout::fillWidth(QGraphicsLayoutItem *item, - QGraphicsLayoutItem *relativeTo) +void QGraphicsAnchorLayout::anchorWidth(QGraphicsLayoutItem *item, + QGraphicsLayoutItem *relativeTo) { if (!relativeTo) relativeTo = this; @@ -125,8 +133,16 @@ void QGraphicsAnchorLayout::fillWidth(QGraphicsLayoutItem *item, anchor(item, Right, relativeTo, Right); } -void QGraphicsAnchorLayout::fillHeight(QGraphicsLayoutItem *item, - QGraphicsLayoutItem *relativeTo) +void QGraphicsAnchorLayout::anchorWidth(QGraphicsLayoutItem *item, + QGraphicsLayoutItem *relativeTo, + qreal spacing) +{ + anchor(relativeTo, Left, item, Left, spacing); + anchor(item, Right, relativeTo, Right, spacing); +} + +void QGraphicsAnchorLayout::anchorHeight(QGraphicsLayoutItem *item, + QGraphicsLayoutItem *relativeTo) { if (!relativeTo) relativeTo = this; @@ -135,14 +151,30 @@ void QGraphicsAnchorLayout::fillHeight(QGraphicsLayoutItem *item, anchor(item, Bottom, relativeTo, Bottom); } -void QGraphicsAnchorLayout::fill(QGraphicsLayoutItem *item, - QGraphicsLayoutItem *relativeTo) +void QGraphicsAnchorLayout::anchorHeight(QGraphicsLayoutItem *item, + QGraphicsLayoutItem *relativeTo, + qreal spacing) +{ + anchor(relativeTo, Top, item, Top, spacing); + anchor(item, Bottom, relativeTo, Bottom, spacing); +} + +void QGraphicsAnchorLayout::anchorGeometry(QGraphicsLayoutItem *item, + QGraphicsLayoutItem *relativeTo) { if (!relativeTo) relativeTo = this; - fillWidth(item, relativeTo); - fillHeight(item, relativeTo); + anchorWidth(item, relativeTo); + anchorHeight(item, relativeTo); +} + +void QGraphicsAnchorLayout::anchorGeometry(QGraphicsLayoutItem *item, + QGraphicsLayoutItem *relativeTo, + qreal spacing) +{ + anchorWidth(item, relativeTo, spacing); + anchorHeight(item, relativeTo, spacing); } #endif -- cgit v0.12