summaryrefslogtreecommitdiff
path: root/modules/bar/Workspaces.qml
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-04-28 15:11:38 +1000
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-04-28 15:11:38 +1000
commit123676bd42b1ca6edec86688ab282ec9691b814c (patch)
tree606ac1cb4d6657e62d0a9127f1924af9eadd1383 /modules/bar/Workspaces.qml
parentfeat: bar workspaces (diff)
downloadcaelestia-shell-123676bd42b1ca6edec86688ab282ec9691b814c.tar.gz
caelestia-shell-123676bd42b1ca6edec86688ab282ec9691b814c.tar.bz2
caelestia-shell-123676bd42b1ca6edec86688ab282ec9691b814c.zip
bar: workspaces better anim
Also make it work for vertical
Diffstat (limited to 'modules/bar/Workspaces.qml')
-rw-r--r--modules/bar/Workspaces.qml67
1 files changed, 38 insertions, 29 deletions
diff --git a/modules/bar/Workspaces.qml b/modules/bar/Workspaces.qml
index a0b1470..699185a 100644
--- a/modules/bar/Workspaces.qml
+++ b/modules/bar/Workspaces.qml
@@ -19,7 +19,7 @@ Item {
BoxLayout {
id: layout
- padding: [Appearance.padding.smaller / 2, 0]
+ padding: vertical ? [0, Appearance.padding.smaller / 2] : [Appearance.padding.smaller / 2, 0]
anchors.centerIn: parent
homogenous: true
spacing: 0
@@ -32,10 +32,11 @@ Item {
text: index + 1
color: root.colour
- horizontalAlignment: Label.AlignCenter
+ horizontalAlignment: Label.AlignHCenter
Layout.alignment: Layout.Center
- Layout.preferredWidth: layout.homogenous ? layout.height : -1
+ Layout.preferredWidth: layout.homogenous && !layout.vertical ? layout.height : -1
+ Layout.preferredHeight: layout.homogenous && layout.vertical ? layout.width : -1
}
}
}
@@ -43,16 +44,13 @@ Item {
Rectangle {
id: active
- // property int lastIdx: 0
- property int currentIdx: (Hyprland.activeWorkspace?.id ?? 1) - 1
- readonly property real size: layout.children[currentIdx][root.vertical ? "height" : "width"]
- readonly property real offset: {
- const vertical = root.vertical;
- const child = layout.children[currentIdx];
- const size = child[vertical ? "height" : "width"];
- const implicitSize = child[vertical ? "implicitHeight" : "implicitWidth"];
- return child.x - (size - implicitSize) / 2;
- }
+ property int currentIdx: 0
+ property int lastIdx: 0
+ property real leading: layout.children[currentIdx][root.vertical ? "y" : "x"]
+ property real trailing: layout.children[lastIdx][root.vertical ? "y" : "x"]
+ property real currentSize: layout.children[currentIdx][root.vertical ? "height" : "width"]
+ property real size: Math.abs(leading - trailing) + currentSize
+ property real offset: Math.min(leading, trailing)
clip: true
x: root.vertical ? 0 : offset
@@ -62,6 +60,15 @@ Item {
color: Appearance.colours.mauve
radius: Appearance.rounding.full
+ Connections {
+ target: Hyprland
+
+ function onActiveWorkspaceChanged() {
+ active.currentIdx = (Hyprland.activeWorkspace?.id ?? 1) - 1;
+ active.lastIdx = active.currentIdx;
+ }
+ }
+
Rectangle {
id: base
@@ -78,28 +85,30 @@ Item {
y: root.vertical ? -parent.offset : 0
width: root.width
height: root.height
+ }
- Behavior on x {
- Anim {}
- }
-
- Behavior on y {
- Anim {}
+ Behavior on leading {
+ NumberAnimation {
+ duration: Appearance.anim.durations.normal
+ easing.type: Easing.BezierSpline
+ easing.bezierCurve: Appearance.anim.curves.emphasized
}
}
- Behavior on x {
- Anim {}
+ Behavior on trailing {
+ NumberAnimation {
+ duration: Appearance.anim.durations.normal * 2
+ easing.type: Easing.BezierSpline
+ easing.bezierCurve: Appearance.anim.curves.emphasized
+ }
}
- Behavior on y {
- Anim {}
+ Behavior on currentSize {
+ NumberAnimation {
+ duration: Appearance.anim.durations.normal
+ easing.type: Easing.BezierSpline
+ easing.bezierCurve: Appearance.anim.curves.emphasized
+ }
}
}
-
- component Anim: NumberAnimation {
- duration: Appearance.anim.durations.normal
- easing.type: Easing.BezierSpline
- easing.bezierCurve: Appearance.anim.curves.standard
- }
}