diff --git a/playground/parrots/BlurredOverlay.cpp b/playground/parrots/BlurredOverlay.cpp index 32aa1f45..5e385344 100644 --- a/playground/parrots/BlurredOverlay.cpp +++ b/playground/parrots/BlurredOverlay.cpp @@ -13,10 +13,29 @@ #include -class BlurredOverlayPrivate : public QQuickItemPrivate, public QQuickItemChangeListener +namespace +{ + class TransformNode final : public QSGTransformNode + { + public: + bool isSubtreeBlocked() const override + { + return isBlocked || QSGTransformNode::isSubtreeBlocked(); + } + + bool isBlocked = false;; + }; +} + +class BlurredOverlayPrivate final : public QQuickItemPrivate, public QQuickItemChangeListener { public: + QSGTransformNode* createTransformNode() override + { + return new TransformNode(); + } + void itemGeometryChanged( QQuickItem*, QQuickGeometryChange change, const QRectF& ) { @@ -214,7 +233,22 @@ QSGNode* BlurredOverlay::updatePaintNode( QSGNode* oldNode, UpdatePaintNodeData* d->updateTexture( layer ); - layer->updateTexture(); + { + auto itemNode = static_cast< TransformNode* >( d->itemNode() ); + + /* + When we are a child of grabbedItem we end up in a recursion + that fails when initializing the texture twice. No problem + as we explicitly do not want to become part of it. + + Disabling our subtree avoids the problem with the initialization + - the texture contains some artifacts from our own children. TODO ... + */ + itemNode->isBlocked = true; + layer->updateTexture(); + itemNode->isBlocked = false; + } + node->setRect( QRectF( 0, 0, width(), height() ) ); return node; diff --git a/playground/parrots/main.cpp b/playground/parrots/main.cpp index 8999b6b7..b2e2dd30 100644 --- a/playground/parrots/main.cpp +++ b/playground/parrots/main.cpp @@ -26,11 +26,20 @@ class ButtonBox : public QskLinearBox { public: ButtonBox( QQuickItem* parent = nullptr ) - : QskLinearBox( parent ) + : QskLinearBox( Qt::Vertical, parent ) { - ( void ) new QskPushButton( "Button 1", this ); - ( void ) new QskPushButton( "Button 2", this ); - ( void ) new QskPushButton( "Button 3", this ); + setMargins( 20 ); + + auto label = new QskGraphicLabel( this ); + + const QImage image( ":/images/parrots.jpg" ); + label->setGraphic( QskGraphic::fromImage( image ) ); + label->setSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed ); + label->setLayoutAlignmentHint( Qt::AlignCenter ); + + + auto button = new QskPushButton( "Button", this ); + button->setLayoutAlignmentHint( Qt::AlignHCenter | Qt::AlignBottom ); } }; @@ -138,7 +147,12 @@ class MainView : public QskControl m_background = new BackgroundItem( this ); +#if 1 m_blurredBox = new BlurredBox( this ); +#else + // unsatisfying: see comment in BlurredOverlay::updatePaintNode TODO ... + m_blurredBox = new BlurredBox( m_background ); +#endif m_blurredBox->setGrabbedItem( m_background ); (void )new ButtonBox( m_blurredBox );