diff options
Diffstat (limited to 'src/quickcontrols/basic/Tumbler.qml')
-rw-r--r-- | src/quickcontrols/basic/Tumbler.qml | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/quickcontrols/basic/Tumbler.qml b/src/quickcontrols/basic/Tumbler.qml new file mode 100644 index 0000000000..4bd5c5fed2 --- /dev/null +++ b/src/quickcontrols/basic/Tumbler.qml @@ -0,0 +1,48 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +import QtQuick +import QtQuick.Controls.impl +import QtQuick.Templates as T + +T.Tumbler { + id: control + + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, + implicitContentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + implicitContentHeight + topPadding + bottomPadding) + + readonly property real __delegateHeight: availableHeight / visibleItemCount + + delegate: Text { + text: modelData + color: control.visualFocus ? control.palette.highlight : control.palette.text + font: control.font + opacity: 1.0 - Math.abs(Tumbler.displacement) / (control.visibleItemCount / 2) + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + + // We use required property here to satisfy qmllint, but that means + // we also need to declare the index for the attached properties + // (see QQuickTumblerAttachedPrivate::init). + required property var modelData + required property int index + } + + contentItem: TumblerView { + implicitWidth: 60 + implicitHeight: 200 + model: control.model + delegate: control.delegate + path: Path { + startX: control.contentItem.width / 2 + startY: -control.__delegateHeight / 2 + + PathLine { + x: control.contentItem.width / 2 + y: (control.visibleItemCount + 1) * control.__delegateHeight - control.__delegateHeight / 2 + } + } + } +} |