some improvement for Overlays being the child of the grabbed item - not
finaly solved
This commit is contained in:
parent
7f6e77d53d
commit
725500fdaf
|
@ -13,9 +13,28 @@
|
||||||
|
|
||||||
#include <qpointer.h>
|
#include <qpointer.h>
|
||||||
|
|
||||||
class BlurredOverlayPrivate : public QQuickItemPrivate, public QQuickItemChangeListener
|
namespace
|
||||||
|
{
|
||||||
|
class TransformNode final : public QSGTransformNode
|
||||||
{
|
{
|
||||||
public:
|
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*,
|
void itemGeometryChanged( QQuickItem*,
|
||||||
QQuickGeometryChange change, const QRectF& )
|
QQuickGeometryChange change, const QRectF& )
|
||||||
|
@ -214,7 +233,22 @@ QSGNode* BlurredOverlay::updatePaintNode( QSGNode* oldNode, UpdatePaintNodeData*
|
||||||
|
|
||||||
d->updateTexture( layer );
|
d->updateTexture( layer );
|
||||||
|
|
||||||
|
{
|
||||||
|
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();
|
layer->updateTexture();
|
||||||
|
itemNode->isBlocked = false;
|
||||||
|
}
|
||||||
|
|
||||||
node->setRect( QRectF( 0, 0, width(), height() ) );
|
node->setRect( QRectF( 0, 0, width(), height() ) );
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
|
|
|
@ -26,11 +26,20 @@ class ButtonBox : public QskLinearBox
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ButtonBox( QQuickItem* parent = nullptr )
|
ButtonBox( QQuickItem* parent = nullptr )
|
||||||
: QskLinearBox( parent )
|
: QskLinearBox( Qt::Vertical, parent )
|
||||||
{
|
{
|
||||||
( void ) new QskPushButton( "Button 1", this );
|
setMargins( 20 );
|
||||||
( void ) new QskPushButton( "Button 2", this );
|
|
||||||
( void ) new QskPushButton( "Button 3", this );
|
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 );
|
m_background = new BackgroundItem( this );
|
||||||
|
|
||||||
|
#if 1
|
||||||
m_blurredBox = new BlurredBox( this );
|
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 );
|
m_blurredBox->setGrabbedItem( m_background );
|
||||||
|
|
||||||
(void )new ButtonBox( m_blurredBox );
|
(void )new ButtonBox( m_blurredBox );
|
||||||
|
|
Loading…
Reference in New Issue