using QskBoxNode for the cell background
This commit is contained in:
parent
4a92bc7c12
commit
1634335a49
@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
#include <qmath.h>
|
#include <qmath.h>
|
||||||
#include <qsgnode.h>
|
#include <qsgnode.h>
|
||||||
#include <qsgsimplerectnode.h>
|
|
||||||
#include <qtransform.h>
|
#include <qtransform.h>
|
||||||
|
|
||||||
class QskListViewNode final : public QSGTransformNode
|
class QskListViewNode final : public QSGTransformNode
|
||||||
@ -113,10 +112,12 @@ QSGNode* QskListViewSkinlet::updateContentsNode(
|
|||||||
void QskListViewSkinlet::updateBackgroundNodes(
|
void QskListViewSkinlet::updateBackgroundNodes(
|
||||||
const QskListView* listView, QskListViewNode* listViewNode ) const
|
const QskListView* listView, QskListViewNode* listViewNode ) const
|
||||||
{
|
{
|
||||||
|
using Q = QskListView;
|
||||||
|
|
||||||
QSGNode* backgroundNode = listViewNode->backgroundNode();
|
QSGNode* backgroundNode = listViewNode->backgroundNode();
|
||||||
|
|
||||||
const qreal cellHeight = listView->rowHeight();
|
const qreal cellHeight = listView->rowHeight();
|
||||||
const QRectF viewRect = listView->viewContentsRect();
|
const auto viewRect = listView->viewContentsRect();
|
||||||
|
|
||||||
const QPointF scrolledPos = listView->scrollPos();
|
const QPointF scrolledPos = listView->scrollPos();
|
||||||
const int rowMin = qFloor( scrolledPos.y() / cellHeight );
|
const int rowMin = qFloor( scrolledPos.y() / cellHeight );
|
||||||
@ -129,32 +130,25 @@ void QskListViewSkinlet::updateBackgroundNodes(
|
|||||||
const double x0 = viewRect.left() + scrolledPos.x();
|
const double x0 = viewRect.left() + scrolledPos.x();
|
||||||
const double y0 = viewRect.top();
|
const double y0 = viewRect.top();
|
||||||
|
|
||||||
auto* rowNode = static_cast< QSGSimpleRectNode* >( backgroundNode->firstChild() );
|
auto rowNode = backgroundNode->firstChild();
|
||||||
|
|
||||||
if ( listView->alternatingRowColors() )
|
if ( listView->alternatingRowColors() )
|
||||||
{
|
{
|
||||||
#if 1
|
|
||||||
/*
|
|
||||||
Cell might be better for regular cells, while ( Cell | AlternateColor )
|
|
||||||
could be used for the alternate color TODO ...
|
|
||||||
*/
|
|
||||||
#endif
|
|
||||||
const auto color = listView->color( QskListView::Cell );
|
|
||||||
|
|
||||||
for ( int row = rowMin; row <= rowMax; row++ )
|
for ( int row = rowMin; row <= rowMax; row++ )
|
||||||
{
|
{
|
||||||
if ( row % 2 )
|
if ( row % 2 )
|
||||||
{
|
{
|
||||||
if ( rowNode == nullptr )
|
const QRectF rect( x0, y0 + row * cellHeight,
|
||||||
|
viewRect.width(), cellHeight );
|
||||||
|
|
||||||
|
auto newNode = updateBoxNode( listView, rowNode, rect, Q::Cell );
|
||||||
|
if ( newNode )
|
||||||
{
|
{
|
||||||
rowNode = new QSGSimpleRectNode();
|
if ( newNode->parent() != backgroundNode )
|
||||||
backgroundNode->appendChildNode( rowNode );
|
backgroundNode->appendChildNode( newNode );
|
||||||
|
else
|
||||||
|
rowNode = newNode->nextSibling();
|
||||||
}
|
}
|
||||||
|
|
||||||
rowNode->setRect( x0, y0 + row * cellHeight, viewRect.width(), cellHeight );
|
|
||||||
rowNode->setColor( color );
|
|
||||||
|
|
||||||
rowNode = static_cast< QSGSimpleRectNode* >( rowNode->nextSibling() );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -164,27 +158,15 @@ void QskListViewSkinlet::updateBackgroundNodes(
|
|||||||
QskSkinStateChanger stateChanger( listView );
|
QskSkinStateChanger stateChanger( listView );
|
||||||
stateChanger.setStates( listView->skinStates() | QskListView::Selected );
|
stateChanger.setStates( listView->skinStates() | QskListView::Selected );
|
||||||
|
|
||||||
const QColor color = listView->color( QskListView::Cell );
|
const QRectF rect( x0, y0 + rowSelected * cellHeight,
|
||||||
|
viewRect.width(), cellHeight );
|
||||||
|
|
||||||
if ( rowNode == nullptr )
|
rowNode = updateBoxNode( listView, rowNode, rect, Q::Cell );
|
||||||
{
|
if ( rowNode && rowNode->parent() != backgroundNode )
|
||||||
rowNode = new QSGSimpleRectNode();
|
|
||||||
backgroundNode->appendChildNode( rowNode );
|
backgroundNode->appendChildNode( rowNode );
|
||||||
}
|
}
|
||||||
|
|
||||||
rowNode->setRect( x0, y0 + rowSelected * cellHeight, viewRect.width(), cellHeight );
|
QskSGNode::removeAllChildNodesAfter( backgroundNode, rowNode );
|
||||||
rowNode->setColor( color );
|
|
||||||
|
|
||||||
rowNode = static_cast< QSGSimpleRectNode* >( rowNode->nextSibling() );
|
|
||||||
}
|
|
||||||
|
|
||||||
QSGNode* nextNode = rowNode;
|
|
||||||
while ( nextNode != nullptr )
|
|
||||||
{
|
|
||||||
QSGNode* tmpNode = nextNode;
|
|
||||||
nextNode = nextNode->nextSibling();
|
|
||||||
delete tmpNode;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskListViewSkinlet::updateForegroundNodes(
|
void QskListViewSkinlet::updateForegroundNodes(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user