Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

quickshell/nuguland/AuroraBackdrop.qml

Raw
pragma ComponentBehavior: Bound
import QtQuick
import Quickshell
import Quickshell.Wayland
import "features/system"

PanelWindow {
    id: root

    required property Resources resourceService
    required property Theme theme
    property real targetX: 0.5
    property real targetY: 0.5
    property real smoothX: 0.5
    property real smoothY: 0.5
    property int activeTicks: 0
    property bool lowPowerMode: false
    property real firestormMix: 0
    property real auroraTime: 0

    function targetFirestormMix() {
        return root.resourceService ? Number(root.resourceService.firestormTarget || 0) : 0;
    }

    visible: true
    // Dark keeps its near-black wallpaper; light sits on the content backdrop, so the
    // transparent Bar's text reads in both modes.
    color: theme.mode === "light" ? theme.content.backdrop : "#101010"
    exclusionMode: ExclusionMode.Ignore
    implicitWidth: 1
    implicitHeight: 1
    WlrLayershell.layer: WlrLayer.Background
    WlrLayershell.namespace: "nuguland-backdrop"
    WlrLayershell.keyboardFocus: WlrKeyboardFocus.None

    anchors {
        top: true
        bottom: true
        left: true
        right: true
    }

    AuroraShader {
        id: aurora

        anchors.fill: parent
        active: !root.lowPowerMode
        time: root.auroraTime
        mouse: Qt.vector2d(root.smoothX, root.smoothY)
        firestormMix: root.firestormMix
    }

    MouseArea {
        anchors.fill: parent
        hoverEnabled: true
        acceptedButtons: Qt.NoButton
        onPositionChanged: mouse => {
            root.targetX = mouse.x / Math.max(1, width);
            root.targetY = mouse.y / Math.max(1, height);
            root.activeTicks = root.lowPowerMode ? 0 : 45;
        }
    }

    Timer {
        interval: 67
        running: (root.activeTicks > 0 || Math.abs(root.firestormMix - root.targetFirestormMix()) > 0.001) && !root.lowPowerMode
        repeat: true
        onTriggered: {
            root.activeTicks = Math.max(0, root.activeTicks - 1);
            if (aurora.rendering)
                root.auroraTime += 0.04;

            root.smoothX += (root.targetX - root.smoothX) * 0.035;
            root.smoothY += (root.targetY - root.smoothY) * 0.035;
            root.firestormMix += (root.targetFirestormMix() - root.firestormMix) * 0.0035;
        }
    }
}