import QtQuick import Weave.Templates as T import Weave.Controls T.ScrollBar { id: root implicitWidth: Math.max( implicitBackgroundWidth + leftInset + rightInset, implicitContentWidth + leftPadding + rightPadding) implicitHeight: Math.max( implicitBackgroundHeight + topInset + bottomInset, implicitContentHeight + topPadding + bottomPadding) leftPadding: leftInset + Theme.component.scrollbar.paddingLeft rightPadding: rightInset + Theme.component.scrollbar.paddingRight topPadding: topInset + Theme.component.scrollbar.paddingTop bottomPadding: bottomInset + Theme.component.scrollbar.paddingBottom visible: policy !== T.ScrollBar.AlwaysOff revealed: active minimumSize: orientation === Qt.Horizontal ? height / width : width / height hoverEnabled: root.enabled contentItem: Rectangle { id: scrollBar implicitWidth: root.orientation === Qt.Vertical ? Theme.component.scrollbar.width - Theme.component.scrollbar.paddingLeft - Theme.component.scrollbar.paddingRight : Theme.component.scrollbar.thumb.minHeight implicitHeight: root.orientation === Qt.Vertical ? Theme.component.scrollbar.thumb.minHeight : Theme.component.scrollbar.width - Theme.component.scrollbar.paddingLeft - Theme.component.scrollbar.paddingRight radius: root.orientation === Qt.Vertical ? width/2 : height/2 color: (root.pressed || root.hovered) ? Theme.component.scrollbar.thumb.backgroundColor.pressed : Theme.component.scrollbar.thumb.backgroundColor.default opacity: 0.0 Behavior on color { enabled: colorAnim.duration > 0 ColorAnimation { id: colorAnim duration: Theme.component.scrollbar.thumb.transitionDuration easing.type: Easing.OutQuad // TODO: Theme.component.scrollbar.thumb.transitionTimingFunction as Qt easing type } } states: State { name: "revealed" when: root.policy === T.ScrollBar.AlwaysOn || (root.revealed && root.size < 1.0) PropertyChanges { target: scrollBar; opacity: 1.0 } } transitions: Transition { enabled: thumbOpacityAnim.duration > 0 from: "revealed" SequentialAnimation { PauseAnimation { duration: Theme.component.scrollbar.thumb.transitionDuration } NumberAnimation { id: thumbOpacityAnim target: scrollBar property: "opacity" to: 0.0 duration: Theme.component.scrollbar.thumb.transitionDuration } } } } background: Rectangle { id: track implicitWidth: Theme.component.scrollbar.width implicitHeight: Theme.component.scrollbar.height visible: root.backgroundVisible color: root.backgroundVisible ? Theme.component.scrollbar.backgroundColor : Theme.component.scrollbar.emptyBackground.backgroundColor states: State { name: "revealed" when: root.policy === T.ScrollBar.AlwaysOn || (root.revealed && root.size < 1.0) PropertyChanges { target: track; opacity: 1.0 } } transitions: Transition { enabled: trackOpacityAnim.duration > 0 from: "revealed" SequentialAnimation { PauseAnimation { duration: Theme.component.scrollbar.thumb.transitionDuration } NumberAnimation { id: trackOpacityAnim target: track property: "opacity" to: 0.0 duration: Theme.component.scrollbar.thumb.transitionDuration } } } } }