From 82139e9c2d04bae0d40fa5702751d6bf7edfce05 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Tue, 29 Apr 2025 12:07:44 +1000 Subject: refactor: workspaces use inner bar height Also simplify boxpadding --- modules/bar/components/workspaces/Workspaces.qml | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'modules/bar/components/workspaces/Workspaces.qml') diff --git a/modules/bar/components/workspaces/Workspaces.qml b/modules/bar/components/workspaces/Workspaces.qml index 26dc23a..b95497c 100644 --- a/modules/bar/components/workspaces/Workspaces.qml +++ b/modules/bar/components/workspaces/Workspaces.qml @@ -28,8 +28,7 @@ Item { BoxLayout { id: layout - padding: vertical ? [0, Appearance.padding.smaller / 2] : [Appearance.padding.smaller / 2, 0] - anchors.centerIn: parent + anchors.fill: parent homogenous: true spacing: 0 @@ -72,8 +71,8 @@ Item { Rectangle { id: active - property int currentIdx: 0 - property int lastIdx: 0 + property int currentIdx: (Hyprland.activeWorkspace?.id ?? 1) - 1 + property int lastIdx: currentIdx 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"] @@ -83,19 +82,13 @@ Item { clip: true x: root.vertical ? 0 : offset y: root.vertical ? offset : 0 - width: root.vertical ? layout.width : size - height: root.vertical ? size : layout.height + width: root.vertical ? BarConfig.sizes.innerHeight : size + height: root.vertical ? size : BarConfig.sizes.innerHeight color: Appearance.colours.mauve radius: Appearance.rounding.full - Connections { - target: Hyprland - - function onActiveWorkspaceChanged() { - active.currentIdx = (Hyprland.activeWorkspace?.id ?? 1) - 1; - active.lastIdx = active.currentIdx; - } - } + anchors.horizontalCenter: root.vertical ? parent.horizontalCenter : undefined + anchors.verticalCenter: root.vertical ? undefined : parent.verticalCenter Rectangle { id: base @@ -113,6 +106,9 @@ Item { y: root.vertical ? -parent.offset : 0 width: root.width height: root.height + + anchors.horizontalCenter: root.vertical ? parent.horizontalCenter : undefined + anchors.verticalCenter: root.vertical ? undefined : parent.verticalCenter } Behavior on leading { -- cgit v1.2.3-freya