summaryrefslogtreecommitdiff
path: root/modules/bar/components/workspaces/ActiveIndicator.qml
blob: cd5ce35f6cf1b3dbfcd143354667ab31cdc30563 (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
import qs.components
import qs.components.effects
import qs.services
import qs.config
import QtQuick

StyledRect {
    id: root

    required property int activeWsId
    required property Repeater workspaces
    required property Item mask

    readonly property int currentWsIdx: {
        let wss = Hypr.workspaces.values;
        for (let i = 0; i < wss.length; i++) {
            let ws = wss[i];
            if (ws.id == activeWsId)
                return i;
        }
    }

    property real currentSize: workspaces.itemAt(currentWsIdx)?.size ?? 0
    property real offset: workspaces.itemAt(currentWsIdx)?.y ?? 0
    property real size: Config.bar.sizes.innerWidth - Appearance.padding.small * 2

    property int cWs
    property int lastWs

    onCurrentWsIdxChanged: {
        lastWs = cWs;
        cWs = currentWsIdx;
    }

    clip: true
    y: offset + mask.y
    implicitWidth: size
    implicitHeight: size
    radius: Appearance.rounding.full
    color: Colours.palette.m3primary

    Colouriser {
        source: root.mask
        sourceColor: Colours.palette.m3onSurface
        colorizationColor: Colours.palette.m3onPrimary

        x: 0
        y: -parent.offset
        implicitWidth: root.mask.implicitWidth
        implicitHeight: root.mask.implicitHeight

        anchors.horizontalCenter: parent.horizontalCenter
    }

    Behavior on offset {
        EAnim {}
    }

    component EAnim: Anim {
        easing.bezierCurve: Appearance.anim.curves.emphasized
    }
}