From 1a6a9f5941fc9a8e6f32e825fc8030f71caf6d72 Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Mon, 7 Aug 2023 08:35:37 +0200 Subject: [PATCH] mat3 skin prepared for smooth list view updates --- skins/fluent2/QskFluent2Skin.cpp | 2 +- skins/material3/QskMaterial3Skin.cpp | 74 +++++++++++++++++++--------- src/controls/QskListView.cpp | 3 +- src/controls/QskSkinnable.cpp | 20 ++++---- 4 files changed, 65 insertions(+), 34 deletions(-) diff --git a/skins/fluent2/QskFluent2Skin.cpp b/skins/fluent2/QskFluent2Skin.cpp index 2c438d03..85227355 100644 --- a/skins/fluent2/QskFluent2Skin.cpp +++ b/skins/fluent2/QskFluent2Skin.cpp @@ -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; diff --git a/skins/material3/QskMaterial3Skin.cpp b/skins/material3/QskMaterial3Skin.cpp index 9f0a36de..564b0521 100644 --- a/skins/material3/QskMaterial3Skin.cpp +++ b/skins/material3/QskMaterial3Skin.cpp @@ -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() diff --git a/src/controls/QskListView.cpp b/src/controls/QskListView.cpp index dd97c20a..0218cccb 100644 --- a/src/controls/QskListView.cpp +++ b/src/controls/QskListView.cpp @@ -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: diff --git a/src/controls/QskSkinnable.cpp b/src/controls/QskSkinnable.cpp index 70b238a0..52430f34 100644 --- a/src/controls/QskSkinnable.cpp +++ b/src/controls/QskSkinnable.cpp @@ -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;