From 4e2a069c140d11494c4d52912cad46330eedac4e Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Wed, 19 Jul 2023 17:43:51 +0200 Subject: [PATCH] Fluent2 scrollbar updates --- skins/fluent2/QskFluent2Skin.cpp | 35 ++++++++++++++++++++++---------- src/controls/QskScrollView.cpp | 18 ++++++++++++---- 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/skins/fluent2/QskFluent2Skin.cpp b/skins/fluent2/QskFluent2Skin.cpp index e8e2be85..51db94c3 100644 --- a/skins/fluent2/QskFluent2Skin.cpp +++ b/skins/fluent2/QskFluent2Skin.cpp @@ -1102,11 +1102,31 @@ void Editor::setupScrollViewMetrics() using Q = QskScrollView; for ( auto subControl : { Q::HorizontalScrollBar, Q::VerticalScrollBar } ) - setMetric( subControl | A::Size, 2 ); + { + const auto aspect = subControl | A::Size; + + setMetric( aspect, 2 ); + setMetric( aspect | Q::Hovered, 6 ); + setMetric( aspect | Q::Pressed, 6 ); + } + + /* + The scroll bars are actually above the viewport, what is not + supported by the skinlet. Do we want to have this. TODO ... + */ + + setAlignment( Q::VerticalScrollBar, Qt::AlignHCenter ); + setAlignment( Q::HorizontalScrollBar, Qt::AlignVCenter ); + + setBoxShape( Q::HorizontalScrollHandle, 100, Qt::RelativeSize ); + setBoxShape( Q::VerticalScrollHandle, 100, Qt::RelativeSize ); const auto handleExtent = 40.0; setStrutSize( Q::HorizontalScrollHandle, handleExtent, 0.0 ); setStrutSize( Q::VerticalScrollHandle, 0.0, handleExtent ); + + for ( auto subControl : { Q::HorizontalScrollBar, Q::VerticalScrollBar } ) + setAnimation( subControl | A::Metric, 100 ); } void Editor::setupScrollViewColors( @@ -1114,17 +1134,10 @@ void Editor::setupScrollViewColors( { using Q = QskScrollView; - const auto& pal = theme.palette; + const auto fillColor = theme.palette.fillColor.controlStrong.defaultColor; -#if 1 - setGradient( Q::Panel, QColor() ); - setGradient( Q::Viewport, QColor() ); -#endif - - for ( auto subControl : { Q::HorizontalScrollHandle, Q::VerticalScrollHandle } ) - { - setGradient( subControl | section, pal.fillColor.controlStrong.defaultColor ); - } + setGradient( Q::HorizontalScrollHandle | section, fillColor ); + setGradient( Q::VerticalScrollHandle | section, fillColor ); } void Editor::setupSegmentedBarMetrics() diff --git a/src/controls/QskScrollView.cpp b/src/controls/QskScrollView.cpp index ecfcc3fc..828b2d40 100644 --- a/src/controls/QskScrollView.cpp +++ b/src/controls/QskScrollView.cpp @@ -30,11 +30,12 @@ class QskScrollView::PrivateData if ( isScrolling == scrolling ) return; - QskAspect::Subcontrol subControl; + Qt::Orientation orientation; + if ( ( isScrolling == Qt::Horizontal ) || ( scrolling == Qt::Horizontal ) ) - subControl = HorizontalScrollHandle; + orientation = Qt::Horizontal; else - subControl = VerticalScrollHandle; + orientation = Qt::Vertical; this->isScrolling = scrolling; this->scrollPressPos = pos; @@ -47,7 +48,16 @@ class QskScrollView::PrivateData if ( scrolling == 0 ) qSwap( oldStates, newStates ); - scrollView->startHintTransitions( { subControl }, oldStates, newStates ); + if ( orientation == Qt::Horizontal ) + { + scrollView->startHintTransitions( { HorizontalScrollHandle }, oldStates, newStates ); + scrollView->startHintTransitions( { HorizontalScrollBar }, oldStates, newStates ); + } + else + { + scrollView->startHintTransitions( { VerticalScrollHandle }, oldStates, newStates ); + scrollView->startHintTransitions( { VerticalScrollBar }, oldStates, newStates ); + } } Qt::ScrollBarPolicy horizontalScrollBarPolicy = Qt::ScrollBarAsNeeded;