From a9621f19edf39b345de5e7ea45d2bc149ca22907 Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Thu, 26 Oct 2023 13:29:16 +0200 Subject: [PATCH] obsolete code removed --- playground/drawer/main.cpp | 5 ++ src/controls/QskQuick.cpp | 2 +- src/controls/QskQuick.h | 3 +- src/controls/QskSlideIn.cpp | 144 +++++++++++++++++------------------- src/controls/QskSlideIn.h | 3 - 5 files changed, 76 insertions(+), 81 deletions(-) diff --git a/playground/drawer/main.cpp b/playground/drawer/main.cpp index 3002310b..119e7066 100644 --- a/playground/drawer/main.cpp +++ b/playground/drawer/main.cpp @@ -27,6 +27,8 @@ namespace auto content = new QskControl( this ); content->setObjectName( "Content" ); + content->setAutoLayoutChildren( true ); + content->setMargins( 20 ); switch( edge ) { @@ -50,6 +52,9 @@ namespace content->setBackgroundColor( QskRgb::Wheat ); break; } + + auto button = new QskPushButton( "Push Me", content ); + button->setPreferredHeight( 100 ); } }; diff --git a/src/controls/QskQuick.cpp b/src/controls/QskQuick.cpp index 43967d29..6a8f045f 100644 --- a/src/controls/QskQuick.cpp +++ b/src/controls/QskQuick.cpp @@ -371,7 +371,7 @@ QList< QQuickItem* > qskPaintOrderChildItems( const QQuickItem* item ) return QList< QQuickItem* >(); } -const QSGNode* qskItemNode( const QQuickItem* item ) +const QSGTransformNode* qskItemNode( const QQuickItem* item ) { if ( item == nullptr ) return nullptr; diff --git a/src/controls/QskQuick.h b/src/controls/QskQuick.h index 458edf4f..6b2ae2df 100644 --- a/src/controls/QskQuick.h +++ b/src/controls/QskQuick.h @@ -16,6 +16,7 @@ class QskSizePolicy; class QQuickItem; class QSGNode; +class QSGTransformNode; class QRectF; template< typename T > class QList; @@ -67,7 +68,7 @@ QSK_EXPORT QList< QQuickItem* > qskPaintOrderChildItems( const QQuickItem* ); QSK_EXPORT void qskUpdateInputMethod( const QQuickItem*, Qt::InputMethodQueries ); QSK_EXPORT void qskInputMethodSetVisible( const QQuickItem*, bool ); -QSK_EXPORT const QSGNode* qskItemNode( const QQuickItem* ); +QSK_EXPORT const QSGTransformNode* qskItemNode( const QQuickItem* ); QSK_EXPORT const QSGNode* qskPaintNode( const QQuickItem* ); QSK_EXPORT void qskItemUpdateRecursive( QQuickItem* ); diff --git a/src/controls/QskSlideIn.cpp b/src/controls/QskSlideIn.cpp index cb49c292..d622d759 100644 --- a/src/controls/QskSlideIn.cpp +++ b/src/controls/QskSlideIn.cpp @@ -11,6 +11,71 @@ QSK_QT_PRIVATE_BEGIN #include QSK_QT_PRIVATE_END +static QPointF qskSlideInTranslation( const QskSlideIn* slideIn ) +{ + const auto ratio = 1.0 - slideIn->transitioningFactor(); + + auto dx = 0.0; + auto dy = 0.0; + + switch( slideIn->edge() ) + { + case Qt::LeftEdge: + dx = -ratio * slideIn->width(); + break; + + case Qt::RightEdge: + dx = ratio * slideIn->width(); + break; + + case Qt::TopEdge: + dy = -ratio * slideIn->height(); + break; + + case Qt::BottomEdge: + dy = ratio * slideIn->height(); + break; + } + + return QPointF( dx, dy ); +} + +static inline QRectF qskUnboundedClipRect( const QRectF& rect, Qt::Edge edge ) +{ + /* + When sliding we want to clip against the edge, where the drawer + slides in/out. However the size of the slidein is often smaller than the + one of the parent and we would clip the overlay node + and all content, that is located outside the drawer geometry. + + So we expand the clip rectangle to "unbounded" at the other edges. + */ + constexpr qreal d = 1e6; + + QRectF r( -d, -d, 2.0 * d, 2.0 * d ); + + switch( edge ) + { + case Qt::LeftEdge: + r.setLeft( rect.left() ); + break; + + case Qt::RightEdge: + r.setRight( rect.right() ); + break; + + case Qt::TopEdge: + r.setTop( rect.top() ); + break; + + case Qt::BottomEdge: + r.setBottom( rect.bottom() ); + break; + } + + return r; +} + namespace { // Using an eventFilter for QskEvent::GeometryChange instead ??? @@ -94,7 +159,7 @@ QskSlideIn::QskSlideIn( QQuickItem* parentItem ) setPlacementPolicy( QskPlacementPolicy::Ignore ); connect( this, &QskPopup::transitioningChanged, - this, &QskSlideIn::setIntermediate ); + this, &QskSlideIn::setClip ); } QskSlideIn::~QskSlideIn() @@ -132,90 +197,17 @@ void QskSlideIn::itemChange( QQuickItem::ItemChange change, } } -void QskSlideIn::setIntermediate( bool on ) -{ - setClip( on ); - Q_EMIT focusIndicatorRectChanged(); -} - -QRectF QskSlideIn::focusIndicatorRect() const -{ - if ( isTransitioning() ) - return QRectF(); - - return Inherited::focusIndicatorRect(); -} - QRectF QskSlideIn::clipRect() const { if ( !isTransitioning() ) return Inherited::clipRect(); - - /* - When sliding we want to clip against the edge, where the drawer - slides in/out. However the size of the slidein is often smaller than the - one of the parent and we would clip the overlay node - and all content, that is located outside the drawer geometry. - - So we expand the clip rectangle to "unbounded" at the other edges. - - Note, that clipping against "rounded" rectangles can't be done - properly by overloading clipRect. We would have to manipulate the clip node - manually - like it is done in QskScrollArea. TODO .. - */ - constexpr qreal d = std::numeric_limits< short >::max(); - - QRectF r( -d, -d, 2.0 * d, 2.0 * d ); - - switch( edge() ) - { - case Qt::LeftEdge: - r.setLeft( 0.0 ); - break; - - case Qt::RightEdge: - r.setRight( width() ); - break; - - case Qt::TopEdge: - r.setTop( 0.0 ); - break; - - case Qt::BottomEdge: - r.setBottom( height() ); - break; - } - return r; + return qskUnboundedClipRect( rect(), edge() ); } QRectF QskSlideIn::layoutRectForSize( const QSizeF& size ) const { - const auto ratio = 1.0 - transitioningFactor(); - - auto x = 0.0; - auto y = 0.0; - - switch( edge() ) - { - case Qt::LeftEdge: - x = -ratio * size.width(); - break; - - case Qt::RightEdge: - x = ratio * size.width(); - break; - - case Qt::TopEdge: - y = -ratio * size.height(); - break; - - case Qt::BottomEdge: - y = ratio * size.height(); - break; - } - - return QRectF( x, y, size.width(), size.height() ); + return QRectF( qskSlideInTranslation( this ), size ); } #include "moc_QskSlideIn.cpp" diff --git a/src/controls/QskSlideIn.h b/src/controls/QskSlideIn.h index 8c5d7fe1..37a72979 100644 --- a/src/controls/QskSlideIn.h +++ b/src/controls/QskSlideIn.h @@ -20,7 +20,6 @@ class QSK_EXPORT QskSlideIn : public QskPopup virtual Qt::Edge edge() const = 0; - QRectF focusIndicatorRect() const override; QRectF clipRect() const override; void setAdjustingToParentGeometry( bool on ); @@ -34,8 +33,6 @@ class QSK_EXPORT QskSlideIn : public QskPopup void itemChange( ItemChange, const ItemChangeData& ) override; private: - void setIntermediate( bool ); - class PrivateData; std::unique_ptr< PrivateData > m_data; };