moving ClipItem to namespace
This commit is contained in:
parent
1228518e6a
commit
571f532307
|
@ -175,14 +175,16 @@ namespace
|
|||
};
|
||||
}
|
||||
|
||||
class QskScrollAreaClipItem final : public QskControl, public QQuickItemChangeListener
|
||||
namespace
|
||||
{
|
||||
class ClipItem final : public QskControl, public QQuickItemChangeListener
|
||||
{
|
||||
// when inheriting from QskControl we participate in node cleanups
|
||||
using Inherited = QskControl;
|
||||
|
||||
public:
|
||||
QskScrollAreaClipItem( QskScrollArea* );
|
||||
virtual ~QskScrollAreaClipItem();
|
||||
ClipItem( QskScrollArea* );
|
||||
virtual ~ClipItem();
|
||||
|
||||
void enableGeometryListener( bool on );
|
||||
|
||||
|
@ -213,7 +215,7 @@ class QskScrollAreaClipItem final : public QskControl, public QQuickItemChangeLi
|
|||
void itemChange( ItemChange, const ItemChangeData& ) override;
|
||||
void geometryChanged( const QRectF&, const QRectF& ) override;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 5, 8, 0 )
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 5, 8, 0 )
|
||||
void itemGeometryChanged( QQuickItem*,
|
||||
QQuickGeometryChange change, const QRectF& ) override
|
||||
{
|
||||
|
@ -221,14 +223,14 @@ class QskScrollAreaClipItem final : public QskControl, public QQuickItemChangeLi
|
|||
scrollArea()->polish();
|
||||
}
|
||||
|
||||
#else
|
||||
#else
|
||||
void itemGeometryChanged( QQuickItem*,
|
||||
const QRectF& newRect, const QRectF& oldRect ) override
|
||||
{
|
||||
if ( m_isSizeChangedEnabled && ( oldRect.size() != newRect.size() ) )
|
||||
scrollArea()->polish();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void updateNode( QSGNode* ) override;
|
||||
|
||||
|
@ -246,22 +248,22 @@ class QskScrollAreaClipItem final : public QskControl, public QQuickItemChangeLi
|
|||
const QSGClipNode* viewPortClipNode() const;
|
||||
|
||||
bool m_isSizeChangedEnabled = true;
|
||||
};
|
||||
};
|
||||
|
||||
QskScrollAreaClipItem::QskScrollAreaClipItem( QskScrollArea* scrollArea )
|
||||
ClipItem::ClipItem( QskScrollArea* scrollArea )
|
||||
: Inherited( scrollArea )
|
||||
{
|
||||
{
|
||||
setObjectName( QStringLiteral( "QskScrollAreaClipItem" ) );
|
||||
setClip( true );
|
||||
}
|
||||
}
|
||||
|
||||
QskScrollAreaClipItem::~QskScrollAreaClipItem()
|
||||
{
|
||||
ClipItem::~ClipItem()
|
||||
{
|
||||
enableGeometryListener( false );
|
||||
}
|
||||
}
|
||||
|
||||
void QskScrollAreaClipItem::updateNode( QSGNode* )
|
||||
{
|
||||
void ClipItem::updateNode( QSGNode* )
|
||||
{
|
||||
auto* d = QQuickItemPrivate::get( this );
|
||||
|
||||
if ( QQuickItemPrivate::get( scrollArea() )->dirtyAttributes &
|
||||
|
@ -315,10 +317,10 @@ void QskScrollAreaClipItem::updateNode( QSGNode* )
|
|||
auto viewClipNode = static_cast< ViewportClipNode* >( clipNode );
|
||||
viewClipNode->copyFrom( viewPortClipNode() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const QSGClipNode* QskScrollAreaClipItem::viewPortClipNode() const
|
||||
{
|
||||
const QSGClipNode* ClipItem::viewPortClipNode() const
|
||||
{
|
||||
auto node = const_cast< QSGNode* >( qskPaintNode( scrollArea() ) );
|
||||
if ( node )
|
||||
node = QskSkinlet::findNodeByRole( node, QskScrollViewSkinlet::ContentsRootRole );
|
||||
|
@ -327,11 +329,11 @@ const QSGClipNode* QskScrollAreaClipItem::viewPortClipNode() const
|
|||
return static_cast< QSGClipNode* >( node );
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void QskScrollAreaClipItem::geometryChanged(
|
||||
void ClipItem::geometryChanged(
|
||||
const QRectF& newRect, const QRectF& oldRect )
|
||||
{
|
||||
{
|
||||
Inherited::geometryChanged( newRect, oldRect );
|
||||
|
||||
if ( newRect.size() != oldRect.size() )
|
||||
|
@ -339,11 +341,11 @@ void QskScrollAreaClipItem::geometryChanged(
|
|||
// we need to restore the clip node
|
||||
update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QskScrollAreaClipItem::itemChange(
|
||||
void ClipItem::itemChange(
|
||||
QQuickItem::ItemChange change, const QQuickItem::ItemChangeData& value )
|
||||
{
|
||||
{
|
||||
if ( change == QQuickItem::ItemChildAddedChange )
|
||||
{
|
||||
enableGeometryListener( true );
|
||||
|
@ -354,10 +356,10 @@ void QskScrollAreaClipItem::itemChange(
|
|||
}
|
||||
|
||||
Inherited::itemChange( change, value );
|
||||
}
|
||||
}
|
||||
|
||||
void QskScrollAreaClipItem::enableGeometryListener( bool on )
|
||||
{
|
||||
void ClipItem::enableGeometryListener( bool on )
|
||||
{
|
||||
auto item = scrolledItem();
|
||||
if ( item )
|
||||
{
|
||||
|
@ -370,10 +372,10 @@ void QskScrollAreaClipItem::enableGeometryListener( bool on )
|
|||
else
|
||||
p->removeItemChangeListener( this, types );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool QskScrollAreaClipItem::event( QEvent* event )
|
||||
{
|
||||
bool ClipItem::event( QEvent* event )
|
||||
{
|
||||
if ( event->type() == QEvent::LayoutRequest )
|
||||
{
|
||||
if ( scrollArea()->isItemResizable() )
|
||||
|
@ -381,6 +383,7 @@ bool QskScrollAreaClipItem::event( QEvent* event )
|
|||
}
|
||||
|
||||
return Inherited::event( event );
|
||||
}
|
||||
}
|
||||
|
||||
class QskScrollArea::PrivateData
|
||||
|
@ -405,7 +408,7 @@ class QskScrollArea::PrivateData
|
|||
}
|
||||
}
|
||||
|
||||
QskScrollAreaClipItem* clipItem = nullptr;
|
||||
ClipItem* clipItem = nullptr;
|
||||
|
||||
bool isItemResizable : 1;
|
||||
};
|
||||
|
@ -430,7 +433,7 @@ QskScrollArea::QskScrollArea( QQuickItem* parentItem )
|
|||
{
|
||||
setPolishOnResize( true );
|
||||
|
||||
m_data->clipItem = new QskScrollAreaClipItem( this );
|
||||
m_data->clipItem = new ClipItem( this );
|
||||
m_data->enableAutoTranslation( this, true );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue