summaryrefslogtreecommitdiff
path: root/modules/bar/components/workspaces/OccupiedBg.qml
blob: 7ffd436e732f91c006f1ee6531628e95fd4109c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import "root:/widgets"
import "root:/config"
import QtQuick
import QtQuick.Layouts

BoxLayout {
    id: root

    required property bool vertical
    required property list<StyledText> workspaces
    required property var occupied
    required property BoxLayout layout

    anchors.centerIn: parent
    spacing: 0
    z: -1

    Repeater {
        model: BarConfig.workspaces.shown

        Rectangle {
            required property int index
            readonly property int roundLeft: index === 0 || !root.occupied[index] ? Appearance.rounding.full : 0
            readonly property int roundRight: index === BarConfig.workspaces.shown - 1 || !root.occupied[index + 2] ? Appearance.rounding.full : 0

            color: Appearance.alpha(Appearance.colours.surface2, true)
            opacity: root.occupied[index + 1] ? 1 : 0
            topLeftRadius: roundLeft
            bottomLeftRadius: roundLeft
            topRightRadius: roundRight
            bottomRightRadius: roundRight

            // Ugh stupid size errors on reload
            Layout.preferredWidth: root.vertical ? BarConfig.sizes.innerHeight : root.workspaces[index]?.width ?? 1
            Layout.preferredHeight: root.vertical ? root.workspaces[index]?.height ?? 1 : BarConfig.sizes.innerHeight

            Behavior on opacity {
                NumberAnimation {
                    duration: Appearance.anim.durations.normal
                    easing.type: Easing.BezierSpline
                    easing.bezierCurve: Appearance.anim.curves.standard
                }
            }
        }
    }
}