summary refs log tree commit diff
path: root/resources/qml/ui/NhekoSlider.qml
blob: 6cf1fd2d71d098239095d6272541fe43afa796cf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// SPDX-FileCopyrightText: 2021 Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later

import QtQuick 2.15
import QtQuick.Controls 2.15
import im.nheko 1.0

Slider {
    id: control
		value: 0

		property color progressColor: Nheko.colors.highlight
    property bool alwaysShowSlider: true
    property int sliderRadius: 16
    implicitHeight: sliderRadius

		padding: 0

    background: Rectangle {
        x: control.leftPadding + handle.width/2
        y: control.topPadding + control.availableHeight / 2 - height / 2
        implicitWidth: 200
        implicitHeight: control.sliderRadius/4
        width: control.availableWidth - handle.width
        height: implicitHeight
        radius: height/2
        color: Nheko.colors.buttonText

        Rectangle {
            width: control.visualPosition * parent.width
            height: parent.height
            color: control.progressColor
            radius: 2
        }
    }

    handle: Rectangle {
        x: control.leftPadding + control.visualPosition * background.width
        y: control.topPadding + control.availableHeight / 2 - height / 2
        implicitWidth: control.sliderRadius
        implicitHeight: control.sliderRadius
        radius: control.sliderRadius/2
				color: control.progressColor
        visible:  Settings.mobileMode || control.alwaysShowSlider || control.hovered || control.pressed
        border.color: control.progressColor
    }
}