@@ -18,10 +18,38 @@ T.ScrollBar {
1818 policy: D .DTK .platformTheme .scrollBarPolicy
1919
2020 state: " hide"
21+ property int __currentState: 0
22+ function __calculateStateConditions () {
23+ var moving = control .active && ! control .pressed && ! control .hovered
24+ var shouldNormal = (control .policy === T .ScrollBar .AlwaysOn && ! control .hovered && ! control .pressed ) ||
25+ (moving && control .size < 1.0 )
26+
27+ var shouldHover = ((control .hovered && (control .contentItem .opacity > 0 && control .contentItem .opacity <= 1 )) && control .active && ! control .pressed && control .size < 1.0 )
28+
29+ var shouldActive = (control .pressed && control .size < 1.0 )
30+
31+ var shouldHide = ! shouldNormal && ! shouldHover && ! shouldActive
32+
33+ __currentState = shouldHide ? 0 : shouldNormal ? 1 : shouldHover ? 2 : 3
34+ }
35+
36+ onHoveredChanged: {
37+ Qt .callLater (() => { __calculateStateConditions () })
38+ }
39+ onPressedChanged: {
40+ Qt .callLater (() => { __calculateStateConditions () })
41+ }
42+ onActiveChanged: {
43+ Qt .callLater (() => { __calculateStateConditions () })
44+ }
45+ onSizeChanged: {
46+ Qt .callLater (() => { __calculateStateConditions () })
47+ }
48+
2149 states: [
2250 State {
2351 name: " hide"
24- when: control . policy === T . ScrollBar . AlwaysOff || ( control . policy !== T . ScrollBar . AlwaysOn && ( ! control . active || control . size >= 1.0 ))
52+ when: __currentState === 0
2553 PropertyChanges {
2654 target: control .contentItem
2755 implicitWidth: DS .Style .scrollBar .width
@@ -30,24 +58,23 @@ T.ScrollBar {
3058 },
3159 State {
3260 name: " normal"
33- property bool moving: control .active && ! control .pressed && ! control .hovered
34- when: (control .policy === T .ScrollBar .AlwaysOn && ! control .hovered && ! control .pressed ) || (moving && control .size < 1.0 )
61+ when: __currentState === 1
3562 PropertyChanges {
3663 target: control .contentItem
3764 implicitWidth: DS .Style .scrollBar .width
3865 }
3966 },
4067 State {
4168 name: " hover"
42- when: ( control . hovered && ! control . pressed && control . size < 1.0 )
69+ when: __currentState === 2
4370 PropertyChanges {
4471 target: control .contentItem
4572 implicitWidth: DS .Style .scrollBar .activeWidth
4673 }
4774 },
4875 State {
4976 name: " active"
50- when: ( control . pressed && control . size < 1.0 )
77+ when: __currentState === 3
5178 PropertyChanges {
5279 target: control .contentItem
5380 implicitWidth: DS .Style .scrollBar .activeWidth
@@ -58,8 +85,9 @@ T.ScrollBar {
5885 transitions: Transition {
5986 to: " hide"
6087 SequentialAnimation {
88+ NumberAnimation { target: control .contentItem ; duration: DS .Style .scrollBar .hideWidthDuration ; property: " implicitWidth" ;}
6189 PauseAnimation { duration: DS .Style .scrollBar .hidePauseDuration }
62- NumberAnimation { target: control .contentItem ; duration: DS .Style .scrollBar .hideDuration ; property: " opacity" ; to : DS . Style . scrollBar . hideOpacity }
90+ NumberAnimation { target: control .contentItem ; duration: DS .Style .scrollBar .hideDuration ; property: " opacity" ;}
6391 }
6492 }
6593
0 commit comments