C

Qt Quick Ultralite swipe_game Demo

/****************************************************************************** ** ** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Quick Ultralite module. ** ** $QT_BEGIN_LICENSE:COMM$ ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see http://www.qt.io/terms-conditions. For further ** information use the contact form at http://www.qt.io/contact-us. ** ** $QT_END_LICENSE$ ** ******************************************************************************/
import QtQuick 2.0 import StyleModule 1.0 /* This component displays visual feedback about the content height and the scroll position of an assigned flickable. */ Rectangle { id: root // NOTE: overwrite the Style value assignments if you want to use the component outside of this project // the indicator is sized in relation to the height ratio of the flickable. The minimum height makes sure // that the indicator remains visible if it would be otherwise unrecognizable small. property int indicatorMinimumHeight: Style.buttonHeight property color indicatorColor: Style.colorHighlight property alias showIndicator: indicator.visible // assign a flickable to the ScrollIndicator so it can read its properties for positioning and sizing property Flickable flickable implicitHeight: Style.lineSize implicitWidth: Style.lineSize color: Style.colorLines QtObject { id: internal // relation of flickable height to flickable content height property real flickableHeightRatio: flickable ? flickable.visibleArea.heightRatio : 1 } Rectangle { id: indicator y: flickable ? Math.max(0, Math.min(root.height - height, (flickable.visibleArea.yPosition / (1.0 - internal.flickableHeightRatio)) * (root.height - height))) : 0 width: root.width height: Math.max(root.indicatorMinimumHeight, root.height * internal.flickableHeightRatio) color: root.indicatorColor } }