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