diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-04-28 19:28:30 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-04-28 19:28:30 +1000 |
| commit | e878949858610523175e24d4795780cc0806612a (patch) | |
| tree | baf419b4ebd4e7a0ebd021e8a63f436d3b4e3b27 /modules/bar | |
| parent | bar: workspaces events (diff) | |
| download | caelestia-shell-e878949858610523175e24d4795780cc0806612a.tar.gz caelestia-shell-e878949858610523175e24d4795780cc0806612a.tar.bz2 caelestia-shell-e878949858610523175e24d4795780cc0806612a.zip | |
bar: workspaces show occupied
Diffstat (limited to 'modules/bar')
| -rw-r--r-- | modules/bar/Workspaces.qml | 53 |
1 files changed, 48 insertions, 5 deletions
diff --git a/modules/bar/Workspaces.qml b/modules/bar/Workspaces.qml index 97a1934..d7dc2fb 100644 --- a/modules/bar/Workspaces.qml +++ b/modules/bar/Workspaces.qml @@ -12,6 +12,7 @@ Item { property alias vertical: layout.vertical readonly property color colour: Appearance.colours.mauve + readonly property list<Label> workspaces: layout.children.filter(c => c.isWorkspace) implicitWidth: layout.implicitWidth implicitHeight: layout.implicitHeight @@ -29,18 +30,60 @@ Item { Label { required property int index + readonly property bool isWorkspace: true text: index + 1 - color: root.colour + color: Appearance.colours.text horizontalAlignment: Label.AlignHCenter - Layout.alignment: Layout.Center Layout.preferredWidth: layout.homogenous && !layout.vertical ? layout.height : -1 Layout.preferredHeight: layout.homogenous && layout.vertical ? layout.width : -1 } } } + BoxLayout { + id: occupied + + readonly property var occupied: Hyprland.workspaces.values.reduce((acc, curr) => { + acc[curr.id] = curr.lastIpcObject.windows > 0; + return acc; + }, {}) + + anchors.centerIn: parent + spacing: 0 + z: -1 + + Repeater { + model: BarConfig.workspaces.shown + + Rectangle { + required property int index + readonly property int roundLeft: index === 0 || !occupied.occupied[index] ? Appearance.rounding.full : 0 + readonly property int roundRight: index === BarConfig.workspaces.shown - 1 || !occupied.occupied[index + 2] ? Appearance.rounding.full : 0 + + color: Appearance.alpha(Appearance.colours.surface2, true) + opacity: occupied.occupied[index + 1] ? 1 : 0 + topLeftRadius: roundLeft + bottomLeftRadius: roundLeft + topRightRadius: roundRight + bottomRightRadius: roundRight + + // Ugh stupid size errors on reload + Layout.preferredWidth: root.vertical ? layout.width : root.workspaces[index]?.width ?? 1 + Layout.preferredHeight: root.vertical ? root.workspaces[index]?.height ?? 1 : layout.height + + Behavior on opacity { + NumberAnimation { + duration: Appearance.anim.durations.normal + easing.type: Easing.BezierSpline + easing.bezierCurve: Appearance.anim.curves.standard + } + } + } + } + } + MouseArea { anchors.fill: parent @@ -58,9 +101,9 @@ Item { 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 leading: root.workspaces[currentIdx][root.vertical ? "y" : "x"] + property real trailing: root.workspaces[lastIdx][root.vertical ? "y" : "x"] + property real currentSize: root.workspaces[currentIdx][root.vertical ? "height" : "width"] property real size: Math.abs(leading - trailing) + currentSize property real offset: Math.min(leading, trailing) |