mat3 skin prepared for smooth list view updates

This commit is contained in:
Uwe Rathmann 2023-08-07 08:35:37 +02:00
parent b014cc9958
commit 1a6a9f5941
4 changed files with 65 additions and 34 deletions

View File

@ -639,7 +639,7 @@ void Editor::setupListViewColors(
textColor = pal.fillColor.text.disabled;
indicatorColor = pal.fillColor.accent.disabled;
}
if ( state1 == Q::Pressed )
else if ( state1 == Q::Pressed )
{
textColor = pal.fillColor.text.secondary;
indicatorColor = pal.fillColor.accent.defaultColor;

View File

@ -1151,41 +1151,71 @@ void Editor::setupScrollView()
void Editor::setupListView()
{
using Q = QskListView;
using A = QskAspect;
setStrutSize( Q::Cell, { -1, 56_dp } );
setPadding( Q::Cell, { 16_dp, 8_dp, 24_dp, 8_dp } );
setBoxBorderColors( Q::Cell, m_pal.outline );
for ( const auto state1 : { A::NoState, Q::Hovered, Q::Focused, Q::Pressed, Q::Disabled } )
{
for ( const auto state2 : { A::NoState, Q::Selected } )
{
QRgb cellColor;
setGradient( Q::Cell, m_pal.surface );
setGradient( Q::Cell | Q::Disabled, m_pal.surface );
const auto hoveredColor = flattenedColor( m_pal.onSurface,
m_pal.surface, m_pal.hoverOpacity );
setGradient( Q::Cell | Q::Hovered, hoveredColor );
const auto pressedColor = flattenedColor( m_pal.onSurface,
m_pal.primary12, m_pal.pressedOpacity );
setGradient( Q::Cell | Q::Pressed, pressedColor );
setGradient( Q::Cell | Q::Selected, m_pal.primary12 );
const auto selectedHoveredColor = flattenedColor( m_pal.onSurface,
m_pal.primary12, m_pal.focusOpacity );
setGradient( Q::Cell | Q::Selected | Q::Hovered, selectedHoveredColor );
const auto selectedFocusedColor = flattenedColor( m_pal.onSurface,
m_pal.primary12, m_pal.focusOpacity );
setGradient( Q::Cell | Q::Selected | Q::Focused, selectedFocusedColor );
setGradient( Q::Cell | Q::Selected | Q::Disabled, m_pal.surfaceVariant );
if ( state2 == A::NoState )
{
if ( state1 == Q::Hovered )
{
cellColor = flattenedColor( m_pal.onSurface,
m_pal.surface, m_pal.hoverOpacity );
}
else if ( state1 == Q::Pressed )
{
cellColor = flattenedColor( m_pal.onSurface,
m_pal.primary12, m_pal.pressedOpacity );
}
else
{
cellColor = m_pal.surface;
}
}
else
{
if ( state1 == Q::Hovered )
{
cellColor = flattenedColor( m_pal.onSurface,
m_pal.primary12, m_pal.focusOpacity );
}
else if ( state1 == Q::Focused )
{
cellColor = flattenedColor( m_pal.onSurface,
m_pal.primary12, m_pal.focusOpacity );
}
else if ( state1 == Q::Disabled )
{
cellColor = m_pal.surfaceVariant;
}
else
{
cellColor = m_pal.primary12;
}
}
setGradient( Q::Cell | state1 | state2, cellColor );
}
}
setFontRole( Q::Text, QskMaterial3Skin::M3BodyMedium );
setColor( Q::Text, m_pal.onSurface );
setColor( Q::Text | Q::Disabled, m_pal.onSurface38 );
#if 1
setAnimation( Q::Cell | A::Color, 100 );
setAnimation( Q::Text | A::Color, 100 );
#endif
}
void Editor::setupSubWindow()

View File

@ -69,6 +69,7 @@ class QskListView::PrivateData
}
storedRow = row;
listView->update();
}
private:
@ -83,8 +84,6 @@ class QskListView::PrivateData
Q_UNUSED( row );
Q_UNUSED( oldStates );
Q_UNUSED( newStates );
listView->update();
}
public:

View File

@ -122,6 +122,16 @@ static inline T qskColor( const QskSkinnable* skinnable,
aspect | QskAspect::Color, status ).value< T >();
}
static inline constexpr QskAspect qskAnimatorAspect( const QskAspect aspect )
{
/*
We do not need the extra bits that would slow down resolving
the effective aspect in animatedHint.
*/
return aspect.type() | aspect.subControl() | aspect.primitive();
}
static inline void qskTriggerUpdates( QskAspect aspect, QQuickItem* item )
{
/*
@ -1296,15 +1306,7 @@ void QskSkinnable::startHintTransition( QskAspect aspect, int index,
v2.setValue( skin->graphicFilter( v2.toInt() ) );
}
/*
We do not need the extra bits that would slow down resolving
the effective aspect in animatedHint.
*/
aspect.clearStates();
aspect.setSection( QskAspect::Body );
aspect.setVariation( QskAspect::NoVariation );
aspect.setAnimator( false );
aspect = qskAnimatorAspect( aspect );
#if DEBUG_ANIMATOR
qDebug() << aspect << animationHint.duration;