diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-05-04 20:45:34 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-05-04 20:45:34 +1000 |
| commit | fb471f1023ab4991c124d0bc432028d95d7b7300 (patch) | |
| tree | 6e46278fabc8f4b584cd668703bfe28e3d78ec8d /widgets | |
| parent | appearance: better on colours (diff) | |
| download | caelestia-shell-fb471f1023ab4991c124d0bc432028d95d7b7300.tar.gz caelestia-shell-fb471f1023ab4991c124d0bc432028d95d7b7300.tar.bz2 caelestia-shell-fb471f1023ab4991c124d0bc432028d95d7b7300.zip | |
feat: audio osd
Diffstat (limited to 'widgets')
| -rw-r--r-- | widgets/VerticalSlider.qml | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/widgets/VerticalSlider.qml b/widgets/VerticalSlider.qml new file mode 100644 index 0000000..1dc9ac4 --- /dev/null +++ b/widgets/VerticalSlider.qml @@ -0,0 +1,130 @@ +import "root:/widgets" +import "root:/config" +import QtQuick +import QtQuick.Controls +import QtQuick.Effects + +Slider { + id: root + + required property string icon + + orientation: Qt.Vertical + + background: StyledRect { + color: Appearance.alpha(Appearance.colours.m3surfaceContainerHigh, true) + radius: Appearance.rounding.full + + StyledRect { + anchors.left: parent.left + anchors.right: parent.right + + y: root.handle.y + implicitHeight: parent.height - y + + color: Appearance.alpha(Appearance.colours.m3secondary, true) + radius: Appearance.rounding.full + } + } + + handle: Item { + id: handle + + property bool moving + + y: root.visualPosition * (root.availableHeight - height) + implicitWidth: root.width + implicitHeight: root.width + + RectangularShadow { + anchors.fill: parent + radius: rect.radius + color: Appearance.colours.m3shadow + blur: 5 + spread: 0 + } + + StyledRect { + id: rect + + anchors.fill: parent + + color: Appearance.alpha(Appearance.colours.m3inverseSurface, true) + radius: Appearance.rounding.full + + MaterialIcon { + id: icon + + animate: true + text: root.icon + color: Appearance.colours.m3onPrimary + anchors.centerIn: parent + + states: State { + name: "value" + when: handle.moving + + PropertyChanges { + icon.animate: false + icon.text: Math.round(root.value * 100) + icon.font.pointSize: Appearance.font.size.small + icon.font.family: Appearance.font.family.sans + } + } + + transitions: Transition { + from: "*" + to: "*" + + NumberAnimation { + target: icon + property: "scale" + from: 1 + to: 0 + duration: Appearance.anim.durations.normal + easing.type: Easing.BezierSpline + easing.bezierCurve: Appearance.anim.curves.standardAccel + } + PropertyAction { + target: icon + properties: "animate,text,font.pointSize,font.family" + } + NumberAnimation { + target: icon + property: "scale" + from: 0 + to: 1 + duration: Appearance.anim.durations.normal + easing.type: Easing.BezierSpline + easing.bezierCurve: Appearance.anim.curves.standardDecel + } + } + } + } + } + + onPressedChanged: handle.moving = pressed + + onValueChanged: { + handle.moving = true; + stateChangeDelay.restart(); + } + + Timer { + id: stateChangeDelay + + interval: 500 + onTriggered: { + if (!root.pressed) + handle.moving = false; + } + } + + Behavior on value { + NumberAnimation { + duration: Appearance.anim.durations.large + easing.type: Easing.BezierSpline + easing.bezierCurve: Appearance.anim.curves.standard + } + } +} |