summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-07-23 18:57:49 +1000
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-07-23 18:57:49 +1000
commit1835271c2829180bc7ba9a3629e474b9464c6c16 (patch)
tree6ee56f4c9ec6f9df5347ce7ca854b7f90994c56d
parentinternal: fix damn lsp overshadowing (diff)
downloadcaelestia-shell-1835271c2829180bc7ba9a3629e474b9464c6c16.tar.gz
caelestia-shell-1835271c2829180bc7ba9a3629e474b9464c6c16.tar.bz2
caelestia-shell-1835271c2829180bc7ba9a3629e474b9464c6c16.zip
internal: better styled switch
Add state layer + cursor change
-rw-r--r--widgets/StyledSwitch.qml48
1 files changed, 32 insertions, 16 deletions
diff --git a/widgets/StyledSwitch.qml b/widgets/StyledSwitch.qml
index 90957c0..e38040c 100644
--- a/widgets/StyledSwitch.qml
+++ b/widgets/StyledSwitch.qml
@@ -28,6 +28,18 @@ Switch {
implicitHeight: parent.implicitHeight - Appearance.padding.small
anchors.verticalCenter: parent.verticalCenter
+ StyledRect {
+ anchors.fill: parent
+ radius: parent.radius
+
+ color: root.checked ? Colours.palette.m3primary : Colours.palette.m3onSurface
+ opacity: root.pressed ? 0.1 : root.hovered ? 0.08 : 0
+
+ Behavior on opacity {
+ NumberAnim {}
+ }
+ }
+
Shape {
id: icon
@@ -73,7 +85,7 @@ Switch {
ShapePath {
strokeWidth: Appearance.font.size.larger * 0.15
- strokeColor: root.checked ? Colours.palette.m3onPrimaryContainer : Colours.palette.m3surfaceContainerHighest
+ strokeColor: root.checked ? Colours.palette.m3primary : Colours.palette.m3surfaceContainerHighest
fillColor: "transparent"
capStyle: ShapePath.RoundCap
@@ -103,38 +115,42 @@ Switch {
}
Behavior on start1 {
- Anim {}
+ PropAnim {}
}
Behavior on end1 {
- Anim {}
+ PropAnim {}
}
Behavior on start2 {
- Anim {}
+ PropAnim {}
}
Behavior on end2 {
- Anim {}
+ PropAnim {}
}
}
Behavior on x {
- NumberAnimation {
- duration: Appearance.anim.durations.normal
- easing.type: Easing.BezierSpline
- easing.bezierCurve: Appearance.anim.curves.standard
- }
+ NumberAnim {}
}
Behavior on implicitWidth {
- NumberAnimation {
- duration: Appearance.anim.durations.normal
- easing.type: Easing.BezierSpline
- easing.bezierCurve: Appearance.anim.curves.standard
- }
+ NumberAnim {}
}
}
}
- component Anim: PropertyAnimation {
+ MouseArea {
+ anchors.fill: parent
+ cursorShape: Qt.PointingHandCursor
+ enabled: false
+ }
+
+ component NumberAnim: NumberAnimation {
+ duration: Appearance.anim.durations.normal
+ easing.type: Easing.BezierSpline
+ easing.bezierCurve: Appearance.anim.curves.standard
+ }
+
+ component PropAnim: PropertyAnimation {
duration: Appearance.anim.durations.normal
easing.type: Easing.BezierSpline
easing.bezierCurve: Appearance.anim.curves.standard