QskListView::Selected state introduced
This commit is contained in:
parent
28024d80d9
commit
47f7737985
|
@ -38,7 +38,7 @@ namespace
|
||||||
|
|
||||||
QskSkinHintTableEditor ed( &newSkin->hintTable() );
|
QskSkinHintTableEditor ed( &newSkin->hintTable() );
|
||||||
|
|
||||||
ed.setColor( QskListView::CellSelected, m_accent.darker( 130 ) );
|
ed.setColor( QskListView::Cell | QskListView::Selected, m_accent.darker( 130 ) );
|
||||||
ed.setBoxBorderColors( QskFocusIndicator::Panel, m_accent.darker( 150 ) );
|
ed.setBoxBorderColors( QskFocusIndicator::Panel, m_accent.darker( 150 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -740,8 +740,8 @@ void Editor::setupListView()
|
||||||
setColor( Q::Cell, m_pal.baseColor );
|
setColor( Q::Cell, m_pal.baseColor );
|
||||||
setColor( Q::Text, m_pal.textColor );
|
setColor( Q::Text, m_pal.textColor );
|
||||||
|
|
||||||
setColor( Q::CellSelected, m_pal.accentColor );
|
setColor( Q::Cell | Q::Selected, m_pal.accentColor );
|
||||||
setColor( Q::TextSelected, m_pal.contrastColor );
|
setColor( Q::Text | Q::Selected, m_pal.contrastColor );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::setupSubWindow()
|
void Editor::setupSubWindow()
|
||||||
|
|
|
@ -804,8 +804,8 @@ void Editor::setupListView()
|
||||||
setColor( Q::Text, m_pal.themeForeground );
|
setColor( Q::Text, m_pal.themeForeground );
|
||||||
setColor( Q::Cell, m_pal.contrasted );
|
setColor( Q::Cell, m_pal.contrasted );
|
||||||
|
|
||||||
setColor( Q::CellSelected, m_pal.highlighted );
|
setColor( Q::Cell | Q::Selected, m_pal.highlighted );
|
||||||
setColor( Q::TextSelected, m_pal.highlightedText );
|
setColor( Q::Text | Q::Selected, m_pal.highlightedText );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::setupSubWindow()
|
void Editor::setupSubWindow()
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
|
|
||||||
QSK_SUBCONTROL( QskListView, Cell )
|
QSK_SUBCONTROL( QskListView, Cell )
|
||||||
QSK_SUBCONTROL( QskListView, Text )
|
QSK_SUBCONTROL( QskListView, Text )
|
||||||
QSK_SUBCONTROL( QskListView, CellSelected )
|
|
||||||
QSK_SUBCONTROL( QskListView, TextSelected )
|
QSK_STATE( QskListView, Selected, QskAspect::FirstUserState )
|
||||||
|
|
||||||
class QskListView::PrivateData
|
class QskListView::PrivateData
|
||||||
{
|
{
|
||||||
|
@ -147,12 +147,6 @@ QskColorFilter QskListView::graphicFilterAt( int row, int col ) const
|
||||||
return QskColorFilter();
|
return QskColorFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
QskAspect::Subcontrol QskListView::textSubControlAt( int row, int col ) const
|
|
||||||
{
|
|
||||||
Q_UNUSED( col );
|
|
||||||
return ( row == selectedRow() ) ? TextSelected : Text;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QskListView::keyPressEvent( QKeyEvent* event )
|
void QskListView::keyPressEvent( QKeyEvent* event )
|
||||||
{
|
{
|
||||||
if ( m_data->selectionMode == NoSelection )
|
if ( m_data->selectionMode == NoSelection )
|
||||||
|
|
|
@ -31,15 +31,8 @@ class QSK_EXPORT QskListView : public QskScrollView
|
||||||
using Inherited = QskScrollView;
|
using Inherited = QskScrollView;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*
|
QSK_SUBCONTROLS( Cell, Text )
|
||||||
Everything, that can have a skin state, needs to be a QskSkinnable.
|
QSK_STATES( Selected )
|
||||||
Of course this is no option for the cells considering that we might
|
|
||||||
have many, many of them.
|
|
||||||
So for the moment we simply use Cell/Text and CellSelected/TextSelected
|
|
||||||
as workaround until we found a solution that fits into the design.
|
|
||||||
TODO ...
|
|
||||||
*/
|
|
||||||
QSK_SUBCONTROLS( Cell, Text, CellSelected, TextSelected )
|
|
||||||
|
|
||||||
enum SelectionMode
|
enum SelectionMode
|
||||||
{
|
{
|
||||||
|
@ -76,7 +69,6 @@ class QSK_EXPORT QskListView : public QskScrollView
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
virtual QskColorFilter graphicFilterAt( int row, int col ) const;
|
virtual QskColorFilter graphicFilterAt( int row, int col ) const;
|
||||||
virtual QskAspect::Subcontrol textSubControlAt( int row, int col ) const;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
|
|
|
@ -15,13 +15,36 @@
|
||||||
#include <qsgsimplerectnode.h>
|
#include <qsgsimplerectnode.h>
|
||||||
#include <qtransform.h>
|
#include <qtransform.h>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
class StateChanger
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
StateChanger( const QskSkinnable* skinnable, QskAspect::States states )
|
||||||
|
: m_skinnable( const_cast< QskSkinnable* >( skinnable ) )
|
||||||
|
, m_oldStates( skinnable->skinStates() )
|
||||||
|
{
|
||||||
|
if ( states )
|
||||||
|
m_skinnable->replaceSkinStates( m_oldStates | states );
|
||||||
|
}
|
||||||
|
|
||||||
|
~StateChanger()
|
||||||
|
{
|
||||||
|
if ( m_oldStates != m_skinnable->skinStates() )
|
||||||
|
m_skinnable->replaceSkinStates( m_oldStates );
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QskSkinnable* m_skinnable;
|
||||||
|
QskAspect::States m_oldStates;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
class QskListViewNode final : public QSGTransformNode
|
class QskListViewNode final : public QSGTransformNode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
inline QskListViewNode( int columnCount )
|
inline QskListViewNode( int columnCount )
|
||||||
: m_columnCount( columnCount )
|
: m_columnCount( columnCount )
|
||||||
, m_rowMin( -1 )
|
|
||||||
, m_rowMax( -1 )
|
|
||||||
{
|
{
|
||||||
m_backgroundNode.setFlag( QSGNode::OwnedByParent, false );
|
m_backgroundNode.setFlag( QSGNode::OwnedByParent, false );
|
||||||
appendChildNode( &m_backgroundNode );
|
appendChildNode( &m_backgroundNode );
|
||||||
|
@ -78,8 +101,8 @@ class QskListViewNode final : public QSGTransformNode
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_columnCount;
|
int m_columnCount;
|
||||||
int m_rowMin;
|
int m_rowMin = -1;
|
||||||
int m_rowMax;
|
int m_rowMax = -1;
|
||||||
|
|
||||||
QSGNode m_backgroundNode;
|
QSGNode m_backgroundNode;
|
||||||
QSGNode m_foregroundNode;
|
QSGNode m_foregroundNode;
|
||||||
|
@ -97,7 +120,7 @@ QSGNode* QskListViewSkinlet::updateContentsNode(
|
||||||
{
|
{
|
||||||
const auto listView = static_cast< const QskListView* >( scrollView );
|
const auto listView = static_cast< const QskListView* >( scrollView );
|
||||||
|
|
||||||
auto* listViewNode = static_cast< QskListViewNode* >( node );
|
auto listViewNode = static_cast< QskListViewNode* >( node );
|
||||||
if ( listViewNode == nullptr )
|
if ( listViewNode == nullptr )
|
||||||
listViewNode = new QskListViewNode( listView->columnCount() );
|
listViewNode = new QskListViewNode( listView->columnCount() );
|
||||||
|
|
||||||
|
@ -162,7 +185,8 @@ void QskListViewSkinlet::updateBackgroundNodes(
|
||||||
|
|
||||||
if ( rowSelected >= rowMin && rowSelected <= rowMax )
|
if ( rowSelected >= rowMin && rowSelected <= rowMax )
|
||||||
{
|
{
|
||||||
const QColor color = listView->color( QskListView::CellSelected );
|
const StateChanger stateChanger( listView, QskListView::Selected );
|
||||||
|
const QColor color = listView->color( QskListView::Cell );
|
||||||
|
|
||||||
if ( rowNode == nullptr )
|
if ( rowNode == nullptr )
|
||||||
{
|
{
|
||||||
|
@ -434,6 +458,12 @@ QSGNode* QskListViewSkinlet::updateCellNode( const QskListView* listView,
|
||||||
{
|
{
|
||||||
using namespace QskSGNode;
|
using namespace QskSGNode;
|
||||||
|
|
||||||
|
QskAspect::States rowStates;
|
||||||
|
if ( row == listView->selectedRow() )
|
||||||
|
rowStates |= QskListView::Selected;
|
||||||
|
|
||||||
|
StateChanger stateChanger( listView, rowStates );
|
||||||
|
|
||||||
QSGNode* newNode = nullptr;
|
QSGNode* newNode = nullptr;
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
|
@ -466,10 +496,8 @@ QSGNode* QskListViewSkinlet::updateCellNode( const QskListView* listView,
|
||||||
if ( nodeRole( contentNode ) == TextRole )
|
if ( nodeRole( contentNode ) == TextRole )
|
||||||
newNode = contentNode;
|
newNode = contentNode;
|
||||||
|
|
||||||
auto subControl = listView->textSubControlAt( row, col );
|
|
||||||
|
|
||||||
newNode = updateTextNode( listView, newNode, rect, alignment,
|
newNode = updateTextNode( listView, newNode, rect, alignment,
|
||||||
value.toString(), listView->textOptions(), subControl );
|
value.toString(), listView->textOptions(), QskListView::Text );
|
||||||
|
|
||||||
if ( newNode )
|
if ( newNode )
|
||||||
setNodeRole( newNode, TextRole );
|
setNodeRole( newNode, TextRole );
|
||||||
|
|
Loading…
Reference in New Issue