Fluid 1.3.0
Material Design for QtQuick and Qml
Loading...
Searching...
No Matches
ScrollBar.qml
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2// SPDX-License-Identifier: MPL-2.0
3
4import QtQuick
5import QtQuick.Templates as T
6import Fluid as MD
7
18T.ScrollBar {
19 id: control
20
21 readonly property bool _visuallyExpanded: hovered || pressed || visualFocus
22
23 implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, implicitContentWidth + leftPadding + rightPadding)
24 implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, implicitContentHeight + topPadding + bottomPadding)
25
26 padding: control._visuallyExpanded ? 1 : 2
27
28 minimumSize: orientation === Qt.Horizontal ? height / width : width / height
29
30 interactive: true
31 focusPolicy: Qt.StrongFocus
32
33 visible: control.policy !== T.ScrollBar.AlwaysOff
34
35 contentItem: Rectangle {
36 implicitWidth: control._visuallyExpanded ? 6 : 2
37 implicitHeight: control._visuallyExpanded ? 6 : 2
38
39 color: MD.Utils.transparent(control.MD.Style.onSurfaceColor, control.pressed ? 0.8 : 0.38)
40 radius: control.orientation === Qt.Horizontal ? height / 2.0 : width / 2.0
41 opacity: 0.0
42 }
43
44 background: Rectangle {
45 implicitWidth: control._visuallyExpanded ? 4 : 2
46 implicitHeight: control._visuallyExpanded ? 4 : 2
47
48 color: MD.Utils.transparent(control.MD.Style.onSurfaceColor, 0.12)
49 radius: control.orientation === Qt.Horizontal ? height / 2.0 : width / 2.0
50 opacity: 0.0
51 visible: control._visuallyExpanded
52 }
53
54 states: [
55 State {
56 name: "active"
57 when: control.policy === T.ScrollBar.AlwaysOn || (control.active && control.size < 1.0)
58 }
59 ]
60
61 transitions: [
62 Transition {
63 to: "active"
64
65 NumberAnimation {
66 targets: [control.contentItem, control.background]
67 property: "opacity"
68 to: 1.0
69 }
70 },
71 Transition {
72 from: "active"
73
74 SequentialAnimation {
75 PropertyAction {
76 targets: [control.contentItem, control.background]
77 property: "opacity"
78 value: 1.0
79 }
80 PauseAnimation {
81 duration: 2450
82 }
83 NumberAnimation {
84 targets: [control.contentItem, control.background]
85 property: "opacity"
86 to: 0.0
87 }
88 }
89 }
90 ]
91}