summaryrefslogtreecommitdiff
path: root/modules/bar/components/workspaces/OccupiedBg.qml
blob: e831558e3e3d220bfe01ba897e699d8aab0db288 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
pragma ComponentBehavior: Bound

import "root:/widgets"
import "root:/config"
import QtQuick
import QtQuick.Layouts

BoxLayout {
    id: root

    required property bool vertical
    required property list<Workspace> workspaces
    required property var occupied
    required property int groupOffset

    anchors.centerIn: parent
    opacity: BarConfig.workspaces.occupiedBg ? 1 : 0
    spacing: 0
    z: -1

    Repeater {
        model: BarConfig.workspaces.shown

        Rectangle {
            id: rect

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

            property int ws: root.groupOffset + index + 1

            color: Appearance.alpha(Appearance.colours.surface2, true)
            opacity: 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

            states: [
                State {
                    name: "occupied"
                    when: root.occupied[rect.ws] ?? false

                    PropertyChanges {
                        rect.opacity: 1
                    }
                }
            ]

            transitions: [
                Transition {
                    from: ""
                    to: "occupied"

                    SequentialAnimation {
                        PropertyAction {
                            target: rect
                            properties: "roundLeft,roundRight"
                            value: Appearance.rounding.full
                        }
                        Anim {
                            easing.bezierCurve: Appearance.anim.curves.standardDecel
                        }
                    }
                },
                Transition {
                    from: "occupied"
                    to: ""

                    Anim {
                        easing.bezierCurve: Appearance.anim.curves.standardAccel
                    }
                }
            ]

            Behavior on roundLeft {
                SequentialAnimation {
                    PropertyAction {
                        exclude: rect.roundLeft ? [] : [rect]
                    }
                    Anim {}
                }
            }

            Behavior on roundRight {
                SequentialAnimation {
                    PropertyAction {
                        exclude: rect.roundRight ? [] : [rect]
                    }
                    Anim {}
                }
            }
        }
    }

    Behavior on opacity {
        Anim {}
    }

    component Anim: NumberAnimation {
        duration: Appearance.anim.durations.normal
        easing.type: Easing.BezierSpline
        easing.bezierCurve: Appearance.anim.curves.standard
    }
}