diff options
Diffstat (limited to 'modules/background/Visualiser.qml')
| -rw-r--r-- | modules/background/Visualiser.qml | 85 |
1 files changed, 58 insertions, 27 deletions
diff --git a/modules/background/Visualiser.qml b/modules/background/Visualiser.qml index e5a8a9b..f6020da 100644 --- a/modules/background/Visualiser.qml +++ b/modules/background/Visualiser.qml @@ -15,19 +15,24 @@ Item { required property ShellScreen screen required property Wallpaper wallpaper - ServiceRef { - service: Audio.cava - } + readonly property bool shouldBeActive: Config.background.visualiser.enabled && (!Config.background.visualiser.autoHide || Hypr.monitorFor(screen).activeWorkspace.toplevels.values.every(t => t.lastIpcObject.floating)) + property real offset: shouldBeActive ? 0 : screen.height * 0.2 + + opacity: shouldBeActive ? 1 : 0 - MultiEffect { + Loader { anchors.fill: parent - source: root.wallpaper - maskSource: wrapper - maskEnabled: true - blurEnabled: true - blur: 1 - blurMax: 32 - autoPaddingEnabled: false + active: root.opacity > 0 && Config.background.visualiser.blur + + sourceComponent: MultiEffect { + source: root.wallpaper + maskSource: wrapper + maskEnabled: true + blurEnabled: true + blur: 1 + blurMax: 32 + autoPaddingEnabled: false + } } Item { @@ -36,27 +41,53 @@ Item { anchors.fill: parent layer.enabled: true - Item { - id: content - + Loader { anchors.fill: parent - anchors.margins: Config.border.thickness - anchors.leftMargin: Visibilities.bars.get(root.screen).exclusiveZone + Appearance.spacing.small * Config.background.visualiser.spacing + anchors.topMargin: root.offset + anchors.bottomMargin: -root.offset - Side {} - Side { - isRight: true - } + active: root.opacity > 0 + + sourceComponent: Item { + ServiceRef { + service: Audio.cava + } + + Item { + id: content + + anchors.fill: parent + anchors.margins: Config.border.thickness + anchors.leftMargin: Visibilities.bars.get(root.screen).exclusiveZone + Appearance.spacing.small * Config.background.visualiser.spacing - Behavior on anchors.leftMargin { - Anim {} + Side { + content: content + } + Side { + content: content + isRight: true + } + + Behavior on anchors.leftMargin { + Anim {} + } + } } } } + Behavior on offset { + Anim {} + } + + Behavior on opacity { + Anim {} + } + component Side: Repeater { id: side + required property Item content property bool isRight model: Config.services.visualiserBars @@ -69,11 +100,11 @@ Item { clip: true - x: modelData * ((content.width * 0.4) / Config.services.visualiserBars) + (side.isRight ? content.width * 0.6 : 0) - implicitWidth: (content.width * 0.4) / Config.services.visualiserBars - Appearance.spacing.small * Config.background.visualiser.spacing + x: modelData * ((side.content.width * 0.4) / Config.services.visualiserBars) + (side.isRight ? side.content.width * 0.6 : 0) + implicitWidth: (side.content.width * 0.4) / Config.services.visualiserBars - Appearance.spacing.small * Config.background.visualiser.spacing - y: content.height - height - implicitHeight: bar.value * content.height * 0.4 + y: side.content.height - height + implicitHeight: bar.value * side.content.height * 0.4 color: "transparent" topLeftRadius: Appearance.rounding.small * Config.background.visualiser.rounding @@ -107,7 +138,7 @@ Item { anchors.left: parent.left anchors.right: parent.right y: parent.height - height - implicitHeight: content.height * 0.4 + implicitHeight: side.content.height * 0.4 } Behavior on value { |